using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RPG小游戏
{
class BOSS //BOSS
{
public string Name = "大大王";
//private int hp = 10000;
public int HP { set; get; }
}
class Role //角色
{
public int HP { set; get; } //HP属性
public int MP { set; get; } //MP属性
public int AP { set; get; } //AP属性
}
class Fighter : Role //战士
{
public string Name { set; get; } //名字
public int Fight() //普通攻击
{
//Console.WriteLine("普通攻击造成30点伤害\t");
int x = 30;
return x;
}
}
class Magic : Role //法师
{
public string Name { set; get; } //名字
public int Fight() //普通攻击
{
//Console.WriteLine("普通攻击造成25点伤害\t");
int x = 25;
return x;
}
}
class Program
{
static void Main(string[] args)
{
BOSS boss = new BOSS(); //实例化BOSS
boss.HP = 1000; //BOSS的HP为1000
Console.WriteLine("欢迎来到RPG小游戏,BOSS: {0},HP {1}\t", boss.Name, boss.HP);
Console.WriteLine("请问您要创建哪种职业,战士请选“1”、法师请选“2”\n");
id: //设置标签
string str = Console.ReadLine(); //选择职业
int i1;
if (int.TryParse(str, out i1)) //判断输入是否合法
{
switch (i1)
{
case 1:
Fighter fighter = new Fighter(); //实例化Fighter
Console.WriteLine("给你的战士取个名字吧!");
fighter.Name = Console.ReadLine(); //为Name赋值
fighter.HP = 250; //为HP赋值
fighter.MP = 80; //为MP赋值
fighter.AP = 150; //为AP赋值
Console.WriteLine("{0}: {1} HP {2} MP {3} AP {4}",fighter.Name,fighter.Name, fighter.HP, fighter.MP, fighter.AP);
Console.WriteLine();
while (boss.HP > 0) //判断BOSS的HP时候大于0
{
Console.WriteLine("请选择攻击方式:1、普通攻击 2、技能一 3、技能二 4、怒气技能 ");
int i2 = Convert.ToInt32(Console.ReadLine());
switch (i2) //选择攻击方式
{
case 1: //普通攻击
Console.WriteLine("普通攻击造成30点伤害\t");
boss.HP = boss.HP - fighter.Fight();
Console.Write("BOSS的HP剩下 {0}\n", boss.HP);
break;
case 2: //技能,待定
break;
default: break;
}
}
break;
case 2:
Magic magic = new Magic();
Console.WriteLine("给你的法师取个名字吧!");
magic.Name = Console.ReadLine();
magic.HP = 80;
magic.MP = 250;
magic.AP = 100;
Console.WriteLine("{0}: {1} HP {2} MP {3} AP {4}", magic.Name, magic.Name, magic.HP, magic.MP, magic.AP);
Console.WriteLine();
while (boss.HP > 0)
{
Console.WriteLine("请选择攻击方式:1、普通攻击 2、技能一 3、技能二 4、怒气技能 ");
int i2 = Convert.ToInt32(Console.ReadLine());
switch (i2)
{
case 1:
Console.WriteLine("普通攻击造成25点伤害\t");
boss.HP = boss.HP - magic.Fight();
Console.Write("BOSS的HP剩下 {0}\n", boss.HP);
break;
case 2:
break;
}
}
break;
default: Console.WriteLine("您的选择无效!"); break;
}
}
else
{
Console.WriteLine("请重新选择。\n");
goto id; //跳转到id位置