using System;
using System.Threading;
namespace @new
{
class Program
{
/*常量初始化*/
#region
//昵称
static string name = "";
//生命
static int hp;
//当前生命
static int c_hp;
//成长生命
static int g_hp;
//攻击力
static int atk;
//成长攻击力
static int g_atk;
//防御
static int def;
//成长防御
static int g_def;
//速度
static int speed;
//成长速度
static int g_speed;
//等级
static int level = 1;
//当前经验
static int exp = 0;
//升级所需经验
static int g_exp = 1000;
//金钱
static int money = 100;
//查看面板
#endregion
//武器 衣服 鞋子
static Equip wuqi;
static int wuqi_atk;
static Equip yifu;
static int yifu_hp;
static Equip xiezi;
static int xiezi_speed;
//装备中转站
static string q1 = null;
static string q2 = null;
static string q3 = null;
//装备道具
enum EquipType
{
wuqi,
yifu,
xiezi
}
struct Equip
{
public EquipType type;
public string name;
public string des;
public int hp;
public int atk;
public int speed;
public Equip(EquipType type, string name, string des, int hp, int atk, int speed)
{
this.type = type;
this.name = name;
this.des = des;
this.hp = hp;
this.atk = atk;
this.speed = speed;
}
}
static void EquipItem(Equip a)
{
switch (a.type)
{
case EquipType.wuqi:
Log("你装备了武器:" + a.name + " 它" + a.des + " 攻击力+" + a.atk);
//装备穿戴
wuqi_atk = a.atk;
//装备中转站内装备放入背包数组
BeiBao(q1);
//新的装备再次放入装备中转站
q1 = a.name;
wuqi = a;
break;
case EquipType.yifu:
Log("你装备了衣服:" + a.name + " 它" + a.des + " 生命+" + a.hp);
yifu_hp = a.hp;
BeiBao(q2);
q2 = a.name;
yifu = a;
break;
case EquipType.xiezi:
Log("你装备了鞋子:" + a.name + " 它" + a.des + " 速度+" + a.speed);
xiezi_speed = a.speed;
BeiBao(q3);
q3 = a.name;
xiezi = a;
break;
}
}
//背包
static string[] a = new string[20];
static void BeiBao(string str)
{
for (int n = 0; n < 10; n++)
{
if (a[n] == null)
{
a[n] = str;
break;
}
}
Console.WriteLine("当前你的背包里有:");
for (int m = 0; m <= 9; m++)
{
if (a[m] == null)
{
break;
}
Console.Write(a[m] + " ");
}
Console.WriteLine();
}
//面板提示
static void ShowInfo()
{
Console.WriteLine("你现在状态:生命为:{0}/{1}+{2},攻击力为:{3}+{4},防御为:{5},速度为:{6}+{7},金钱为:{8},等级为:{9},经验为:{10}/{11}", c_hp, hp, yifu.hp, atk, wuqi.atk, def, speed, xiezi_speed, money, level, exp, g_exp);
Log("武器:" + wuqi.name + " 衣服:" + yifu.name + " 鞋子:" + xiezi.name);
Thread.Sleep(1000);
BeiBao(null);
}
//延迟输出函数
static void Log(string text)
{
Console.WriteLine(text);
Thread.Sleep(1000);
}
//战前准备以及战斗过程
static void Battle(string e_name, int e_hp, int e_atk, int e_speed, int e_satk, int e_miss, int e_money, int e_exp)
{
Log("你遇到了" + e_name + "!是否在战斗前消耗10银两回满生命?");
ShowInfo();
Console.WriteLine(e_name + "现在的状态:生命为:{0},攻击力为:{1},速度为:{2},暴击为:{3},闪避为:{4},金钱为:{5},经验为:{6}", e_hp, e_atk, e_speed, e_satk, e_miss, e_money, e_exp);
Thread.Sleep(1000);
Log("1,回满 2,跳过");
string str = Console.ReadLine();
if (str == "1" && money >= 10)
{
c_hp = hp+yifu_hp ;
money -= 10;
Log("血量已回满!");
ShowInfo();
}
//判断先手
bool playerAtk = speed + xiezi_speed > e_speed;
while (true)
{
//如果是玩家攻击
if (playerAtk)
{
//下一次攻击轮到敌人
playerAtk = false;
//判定闪避
if (new Random().Next(0, 100) < e_miss)
{
Log("你向" + e_name + "砍出一刀,却被" + e_name + "轻松地躲了过去!");
continue;
}
//敌人掉血
int num = new Random().Next(atk + wuqi_atk - 5, atk + wuqi_atk + 5)
C#第七课文字游戏2.0版本
最新推荐文章于 2023-01-10 19:42:31 发布