using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace wanjia
{
class Program
{
static void Main(string[] args)
{
Player wanjia = new Player("玩家",123456);
wanjia._name = "和C#抗争到底";
Console.WriteLine("名字:" + wanjia._name);
Console.WriteLine("血条:" + wanjia.hp);
Console.WriteLine("魔法值:" + wanjia.mp);
Console.WriteLine("攻击力:" + wanjia.atp);
Console.WriteLine("攻击的方法:" + wanjia.AttackDamage);
Console.WriteLine("受攻击的方法:" + wanjia.TakeDamage);
Console.WriteLine(" ");
Enemy diren = new Enemy("敌人",123456);
diren._name = "C#真难学";
Console.WriteLine("名字:" + diren._name);
Console.WriteLine("血条:" + diren.hp);
Console.WriteLine("魔法值:" + diren.mp);
Console.WriteLine("攻击力:" + diren.atp);
Console.WriteLine("攻击的方法:" + diren.AttackDamage);
Console.WriteLine("受攻击的方法:" + diren.TakeDamage);
while (diren.Health > 0)
{
wanjia.Attack(diren);
Console.WriteLine("玩家:" + "‘" + wanjia._name + "’" + "会心一击!");
Console.WriteLine("敌人:" + "‘" + diren._name + "’" + "受到:" + wanjia.atp + "伤害");
Console.WriteLine("敌人:" + "‘" + diren._name + "’" + "剩余生命值:" + diren.Health);
Console.WriteLine(" ");
}
Console.WriteLine("敌人“C#真难学”死亡,游戏结束");
}
}
public class Player : Person
{
public Player(string name,int health) : base(name,health)
{
_name = name;
Health = health;
}
public string _name = "lulin";
public int hp = 1000000;
public bool isAlive = true;
public float money = 88888;
public int atp = 99999;
public int mp = 66666;
public string TakeDamage = "击打";
public string AttackDamage = "冲刺";
public void Attack(Person person)
{
person.ReceiveDamage(54321);
}
}
public class Enemy : Person
{
public Enemy(string name,int health) : base(name,health)
{
_name = name;
Health = health;
}
public string _name = "敌人";
public int hp = 10000000;
public bool isAlive = true;
public float money = 8888;
public int atp = 9999;
public int mp = 666;
public string TakeDamage = "击打";
public string AttackDamage = "冲刺";
}
public class Person
{
public string Name { get; set; }
public int Health { get; set; }
public Person(string name, int health)
{
Name = name;
Health = health;
}
public void ReceiveDamage(int damage)
{
Health -= damage;
if (Health < 0) Health = 0; //防止生命为负
}
}
}