c#第十三课面向对象的文字游戏2.0

本文档详细介绍了使用C#进行面向对象编程来构建一款文字游戏的过程,涉及类的设计如Player、NPC、Enemy、Skills等,以及场景(Scene)的交互和战斗(BeforeFight)机制。通过Game类作为核心控制器,整合各类对象,实现游戏流程。
摘要由CSDN通过智能技术生成

A.cs

namespace _7._24
{
   
    class A:Player
    {
   
        public A()
        {
   
            name = "A";
            maxHp = 100;
            g_Hp = 20;
            atk = 50;
            g_Atk = 10;
            speed = 100;
            g_Speed = 20;
            sAtk = 80;
            miss = 10;
        }
    }
}

A1.cs

namespace _7._24
{
   
    class A1:Enemy
    {
   
        public A1()
        {
   
            Go("A1", 700, 10, 50, 10, 10, 10, 100);
        }
    }
}

B.cs

namespace _7._24
{
   
    class B : Player
    {
   
        public B()
        {
   
            name = "B";
            maxHp = 100;
            g_Hp = 20;
            atk = 50;
            g_Atk = 10;
            speed = 100;
            g_Speed = 20;
            sAtk = 80;
            miss = 10;
        }
    }
}

B1.cs

namespace _7._24
{
   
    class B1: Enemy
    {
   
        public B1()
        {
   
            Go("B1", 800, 10, 50, 10, 10, 10, 100);
        }
    }
}

BeforeFight.cs

using System;
namespace _7._24
{
   
    class BeforeFight
    {
   
        public void Run()
        {
   
            Game.player.ShowInfo();           
            Debug.Log("是否消耗20金币回满血量?",ConsoleColor.Cyan);
            Debug.Log("1,是 2,跳过", ConsoleColor.Cyan);
            string str = Console.ReadLine();
            if (str == "1" && Game.player.money >= 20)
            {
   
                Game.player.money -= 20;
                Game.player.currentHp = Game.player.maxHp;
                Game.player.ShowInfo();
            }
        }
    }
}

Debug.cs

using System;
using System.Threading;
namespace _7._24
{
   
    class Debug
    {
   
        public static void Log(int a)
        {
   
            Console.WriteLine(a);
            Thread.Sleep(1000);
        }
        public static void Log(string text)
        {
   
            Console.WriteLine(text);
            Thread.Sleep(1000);
        }
        public static void Log()
        {
   
            for(int i = 0; i < 12; i++)
            {
   
                Console.WriteLine("·");
                Thread.Sleep(200);
            }
            Console.WriteLine();
        }
        public static void Log(string text,ConsoleColor color)
        {
   
            Console.ForegroundColor = color;
            Console.WriteLine(text);
            Thread.Sleep(1000);
            Console.ForegroundColor = ConsoleColor.White;
        }
        public static void Log(string text,int time)
        {
   
            Console.WriteLine(text);
            Thread.Sleep(time);
        }
        public static void Log(string text,int time,ConsoleColor color)
        {
   
            Console.ForegroundColor = color;
            Console.WriteLine(text);
            Thread.Sleep(time);
            Console.ForegroundColor = ConsoleColor.White;
        }
    }
}

Enemy.cs

using System;
namespace _7._24
{
   
    enum EnemyType
    {
   
        A1,
        B1
    }
    class Enemy
    {
   
        SkillType[] skillTypes = {
    SkillType.晴天霹雳, SkillType.火舞炫风 };
        int[] skillP = {
    30, 100 };
        public string name;
        public int hp;
        public int atk;
        public int speed;
        public int satk;
        public int miss;
        public int money;
        public int exp;
        public void Go(string name, int hp, int atk, int speed
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

葬月飘零

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值