C#控制台简单魔塔小游戏

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using System.Collections.Generic;
using System.Threading;

namespace 简单程序__20180817__1
{
#region 创建宠物
//限定宠物性别
public enum sex
{
公, 母
}

//狗狗种类
public enum DogBreed
{
    藏獒, 西伯利亚雪橇犬, 卷毛比雄犬, 边境牧羊犬, 吉娃娃, 斗牛犬,
    北京狮子狗, 西施犬, 哈叭狗, 冠毛狗, 西藏狮子犬, 小曼彻斯特犬, 猎狐犬,
    威尔斯柯基犬, 可卡犬, 格备犬, 拉萨狮子狗, 法国玩具贵宾犬, 博美犬, 腊肠犬, 马耳他犬,
    中华田园犬, 结束
}
//猫猫品种
public enum CatBreed
{
    挪威森林猫, 安哥拉猫, 金吉拉猫, 英国短毛猫, 美国短毛猫, 欧洲短毛猫, 东方短毛猫, 暹罗猫, 卷毛猫,
    哈瓦那猫, 新加坡猫, 曼岛猫, 埃及猫, 孟加拉猫, 苏格兰折耳猫, 美国卷耳猫, 加州闪亮猫, 加拿大无毛猫,
    日本短尾猫, 呵叻猫, 阿比西尼亚猫, 孟买猫, 俄罗斯蓝猫,
    中华大花猫, 结束
}

//乌龟品种
public enum TortoiseBreed
{
    水龟, 泥龟, 箱龟, 巴西龟, 象龟, 乌龟, 地龟, 星点水龟, 星龟, 蛛网陆龟,
    安布闭壳龟, 饼干龟, 鳄鱼龟, 黄喉拟水龟, 黄缘盒龟, 金头龟, 猪鼻龟,
    中华花龟, 结束
}

//熊猫种类
public enum PandeBreed
{
    中华熊猫, 功夫熊猫, 结束
}

//派生类 狗
public class Dog : CreatPet
{

    public DogBreed _dogBreed;//狗狗种类

    public Dog()
    {

    }

}

//派生类 猫
public class Cat : CreatPet
{
    public CatBreed _catBreed;//猫猫种类
    public Cat()
    {

    }
}

//宠物
public class CreatPet
{
    private bool bo = false;

    private string _petName;//宠物名字
    private sex _petSex;//宠物性别
    private int _hierarchy;//等级
    private int _EXP;//经验值
    private int _ATK;//攻击力
    private int _DEF;//防御力
    private int _HP;//血量值
    //品种
    private int _appetite;//食量
    private int _PetPrice;//宠物价格

    //后台管理验证
    public void backstaGeverify()
    {
        Console.WriteLine("请输入后台管理密码");
        string possword = Console.ReadLine();
        if (possword == "zsq520")
        {
            Function();
        }
        else
        {
            Quit();
        }
    }

    //功能
    private void Function()
    {


        Console.WriteLine("****************");
        Console.WriteLine("*  请选择操作  *");
        Console.WriteLine("*  1.创建宠物  *");
        Console.WriteLine("*  2.删除宠物  *");
        Console.WriteLine("*  3.创建怪物  *");
        Console.WriteLine("*  4.删除怪物  *");
        Console.WriteLine("*  5.创建宝箱  *");
        Console.WriteLine("*  6.删除宝箱  *");
        Console.WriteLine("*  0.退出      *");
        Console.WriteLine("****************");
        while (true)
        {
            int n = new CreateID().InputDigit();
            switch (n)
            {
                case 1: PetKing(); break;
                case 2: DeleteKing(); break;
                case 3: CreatMonster(); break;
                case 4: RemoveMonster(); break;
                case 5: CreatGift(); break;
                case 6: RemoveGift(); break;
                case 0: Quit(); break;
                default:
                    Console.WriteLine("输入有误,请重新输入");
                    break;
            }

        }


    }

    //选择宠物种类
    private void PetKing()
    {
        Console.WriteLine("************************");
        Console.WriteLine("*    请选择宠物种类    *");
        Console.WriteLine("*       1.小狗         *");
        Console.WriteLine("*       2.小猫         *");
        Console.WriteLine("*       3.熊猫         *");
        Console.WriteLine("*       4.乌龟         *");
        Console.WriteLine("*       5.返回         *");
        Console.WriteLine("************************");
        int n = int.Parse(Console.ReadLine());
        switch (n)
        {
            case 1:
                CreatePets(n, "dog"); break;
            case 2:
                CreatePets(n, "cat"); break;
            case 3:
                CreatePets(n, "pande"); break;
            case 4:
                CreatePets(n, "tortoise"); break;
            case 5:
                Function(); break;
            default:
                Console.WriteLine("输入错误,请重新输入");
                PetKing();
                break;
        }
    }

    //删除宠物种类
    private void DeleteKing()
    {
        Console.WriteLine("************************");
        Console.WriteLine("*    请选择宠物种类    *");
        Console.WriteLine("*       1.小狗         *");
        Console.WriteLine("*       2.小猫         *");
        Console.WriteLine("*       3.熊猫         *");
        Console.WriteLine("*       4.乌龟         *");
        Console.WriteLine("*       5.返回         *");
        Console.WriteLine("************************");
        int n = int.Parse(Console.ReadLine());
        switch (n)
        {
            case 1:
                RemovePet("dog"); break;
            case 2:
                RemovePet("cat"); break;
            case 3:
                RemovePet("pande"); break;
            case 4:
                RemovePet("tortoise"); break;
            case 5:
                Function(); break;
            default:
                Console.WriteLine("输入错误,请重新输入");
                PetKing();
                break;
        }
    }

    /// <summary>
    /// 创建宠物
    /// </summary>

    //创建宠物
    private void CreatePets(int num, string petStr)
    {

        bo = File.Exists(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt");
        if (bo == false)
        {
            FileStream file = File.Create(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt");
            file.Dispose();
        }

        string[] str1 = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt");
        //姓名:{1}  年龄:{2}岁  性别:{3}  体重:{4}kg  身高:{5}cm   品种:{6}  价格:{7}金"

        CreatPet pet = new CreatPet();//实例化宠物对象
        Console.WriteLine("创建{0}宠物", petStr);

        //输入宠物名字
        Console.WriteLine("请输入宠物姓名:");
        pet._petName = Console.ReadLine();
        if (str1.Length == 0)
        {
            File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", pet._petName);//在原有文本文件上添加
        }
        else
        {
            File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._petName);//在原有文本文件上添加
        }

        //选择宠物性别
        Console.WriteLine("选择宠物性别:");
        CreateSex(petStr);

        //输入宠物等级
        Console.WriteLine("请输入宠物等级:(1-5)");
        pet._hierarchy = int.Parse(Console.ReadLine());
        File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._hierarchy.ToString());//在原有文本文件上添加

        //宠物经验值
        Console.WriteLine("宠物经验值:");
        pet._EXP = 0;
        File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._EXP.ToString());//在原有文本文件上添加

        //输入宠物攻击力
        Console.WriteLine("输入宠物攻击力:(1-100)");
        pet._ATK = int.Parse(Console.ReadLine());
        File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._ATK.ToString());//在原有文本文件上添加

        //输入宠物防御力
        Console.WriteLine("输入宠物防御力:(1-100)");
        pet._DEF = int.Parse(Console.ReadLine());
        File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._DEF.ToString());//在原有文本文件上添加

        //输入宠物血量值
        Console.WriteLine("输入宠物血量值:(10-500)");
        pet._HP = int.Parse(Console.ReadLine());
        File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._HP.ToString());//在原有文本文件上添加

        //选择宠物品种
        Console.WriteLine("选择宠物品种");
        switch (num)
        {
            case 1:
                dogKing(petStr); break;
            case 2:
                catKing(petStr); break;
            case 3:
                pandeKing(petStr); break;
            case 4:
                tortoiseKing(petStr); break;
        }

        //输入宠物食量
        pet._appetite = pet._hierarchy;
        Console.WriteLine("宠物食量为:{0}", pet._appetite);
        File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._appetite.ToString());//在原有文本文件上添加

        //输入宠物价格           
        pet._PetPrice = pet._hierarchy * pet._HP;
        Console.WriteLine("宠物金额w为:{0}", pet._PetPrice);
        File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + pet._PetPrice);//在原有文本文件上添加

        ChooseOperation();//每创建一只宠物成功之后进入选择           

    }

    //创建完成后选择操作
    private void ChooseOperation()
    {
        Console.WriteLine("********************");
        Console.WriteLine("*     选择操作     *");
        Console.WriteLine("*     1.继续创建   *");
        Console.WriteLine("*     2.退出       *");
        Console.WriteLine("********************");
        for (int i = 0; true; i++)
        {
            int n = int.Parse(Console.ReadLine());
            switch (n)
            {
                case 1: PetKing(); bo = true; break;
                case 2: Quit(); bo = true; break;
                default:
                    Console.WriteLine("输入错误,请重新输入");
                    break;
            }

            if (bo == true)
            {
                break;
            }
        }
    }

    //选择宠物性别
    private void CreateSex(string petStr)
    {
        Console.WriteLine("************");
        Console.WriteLine("*   1.公   *");
        Console.WriteLine("*   2.母   *");
        Console.WriteLine("************");
        for (int i = 0; true; i++)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 1 || n == 2)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + (sex)(n - 1));//在原有文本文件上添加
                bo = true;
            }
            if (bo == true)
            {
                break;
            }
        }
    }

    //狗狗种类
    private void dogKing(string petStr)
    {
        int num = 0;
        Console.WriteLine("--------------------");
        for (int i = 0; true; i++)
        {
            if (((DogBreed)i) == DogBreed.结束)
            {
                break;
            }
            num++;
            Console.WriteLine("{0}.{1}", i + 1, (DogBreed)i);

        }
        Console.WriteLine("--------------------");
        Console.WriteLine("请输入对应数字");
        for (int i = 0; true; i++)
        {
            int n = int.Parse(Console.ReadLine());
            if (n > 0 && n <= num)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + (DogBreed)(n - 1));//在原有文本文件上添加
                bo = true;
            }
            else
            {
                Console.WriteLine("输入错误,请重新输入");
            }

            if (bo == true)
            {
                break;
            }
        }


    }

    //小猫种类
    private void catKing(string petStr)
    {
        int num = 0;
        Console.WriteLine("--------------------");
        for (int i = 0; true; i++)
        {
            if (((CatBreed)i) == CatBreed.结束)
            {
                break;
            }
            num++;
            Console.WriteLine("{0}.{1}", i + 1, (CatBreed)i);
        }
        Console.WriteLine("--------------------");
        Console.WriteLine("请输入对应数字");
        for (int i = 0; true; i++)
        {
            int n = int.Parse(Console.ReadLine());
            if (n > 0 && n <= num)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + (CatBreed)(n - 1));//在原有文本文件上添加
                bo = true;
            }
            else
            {
                Console.WriteLine("输入错误,请重新输入");
            }
            if (bo == true)
            {
                break;
            }
        }
    }

    //熊猫种类
    private void pandeKing(string petStr)
    {
        int num = 0;
        Console.WriteLine("--------------------");
        for (int i = 0; true; i++)
        {
            if (((PandeBreed)i) == PandeBreed.结束)
            {
                break;
            }
            num++;
            Console.WriteLine("{0}.{1}", i + 1, (PandeBreed)i);
        }
        Console.WriteLine("--------------------");
        Console.WriteLine("请输入对应数字");
        for (int i = 0; true; i++)
        {
            int n = int.Parse(Console.ReadLine());
            if (n > 0 && n <= num)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + (PandeBreed)(n - 1));//在原有文本文件上添加
                bo = true;
            }
            else
            {
                Console.WriteLine("输入错误,请重新输入");
            }
            if (bo == true)
            {
                break;
            }
        }
    }

    //乌龟种类
    private void tortoiseKing(string petStr)
    {
        int num = 0;
        Console.WriteLine("--------------------");
        for (int i = 0; true; i++)
        {
            if (((TortoiseBreed)i) == TortoiseBreed.结束)
            {
                break;
            }
            num++;
            Console.WriteLine("{0}.{1}", i + 1, (TortoiseBreed)i);
        }
        Console.WriteLine("--------------------");
        Console.WriteLine("请输入对应数字");
        for (int i = 0; true; i++)
        {
            int n = int.Parse(Console.ReadLine());
            if (n > 0 && n <= num)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt", "\n" + (TortoiseBreed)(n - 1));//在原有文本文件上添加
                bo = true;
            }
            else
            {
                Console.WriteLine("输入错误,请重新输入");
            }
            if (bo == true)
            {
                break;
            }
        }
    }

    /// <summary>
    /// 修改宠物
    /// </summary>
    //删除宠物
    public void RemovePet(string petName)
    {
        string[] PetStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petName + ".txt");
        PetList(petName);
        Console.WriteLine("请选择要删除的宠物序号");
        while (true)
        {
            int n = new CreateID().InputDigit();
            if (n <= petName.Length && n > 0)
            {
                for (int i = n * 10; i < PetStr.Length; i++)
                {
                    PetStr[i - 10] = PetStr[i];
                }
                PetRefresh(PetStr, petName);
                Console.WriteLine("删除成功");
                Function();
            }
            else
            {
                Console.WriteLine("输入错误");
            }

        }

    }

    //宠物列表
    public void PetList(string petName)
    {
        string[] PetStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petName + ".txt");

        int n = 0;
        for (int i = 0; i < PetStr.Length; i += 10)
        {
            n++;
            Console.WriteLine("{0}:姓名;{1}  性别:{2}  等级:{3}  经验值:{4}  攻击力:{5}  防御力:{6}  血量值:{7}  品种:{8}   食量;{9}   价格:{10}", n, PetStr[i], PetStr[i + 1], PetStr[i + 2], PetStr[i + 3], PetStr[i + 4], PetStr[i + 5], PetStr[i + 6], PetStr[i + 7], PetStr[i + 8], PetStr[i + 9]);
        }

    }

    //宠物刷新
    public void PetRefresh(string[] PetStr, string petName)
    {
        for (int i = 0; i < PetStr.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petName + ".txt", PetStr[i]);
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petName + ".txt", "\n" + PetStr[i]);
            }

        }

    }


    //创建怪物
    public void CreatMonster()
    {
        bool bo1 = File.Exists(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt");
        if (bo1 == false)
        {
            FileStream file = File.Create(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt");
            file.Dispose();
        }
        string[] Str = new string[5];
        Console.WriteLine("请输入怪物名称:");
        Str[0] = Console.ReadLine();
        Console.WriteLine("请输入怪物等级(1--10):");
        Str[1] = Console.ReadLine();
        Console.WriteLine("请输入怪物攻击力(10--500):");
        Str[2] = Console.ReadLine();
        Console.WriteLine("请输入怪物防御力(1--500):");
        Str[3] = Console.ReadLine();
        Console.WriteLine("请输入怪物血量值(100--1000):");
        Str[4] = Console.ReadLine();
        Console.WriteLine("是否创建(是或者否):");
        bool bo = new CreateID().IsAffirm();
        if (bo)
        {
            for (int i = 0; i < Str.Length; i++)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt", "\n" + Str[i]);
            }
            Console.WriteLine("创建成功!");
            MonsterSort();//创建后排序
            Function();
        }
    }

    //删除怪物
    public void RemoveMonster()
    {
        string[] Monster = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt");
        int n = 0;
        for (int i = 0; i < Monster.Length; i += 5)
        {
            n++;
            Console.WriteLine("{0}: 姓名;{1}  等级:{2}  攻击力:{3}  防御力:{4}  血量值:{5}", n, Monster[i], Monster[i + 1], Monster[i + 2], Monster[i + 3], Monster[i + 4]);
            Console.WriteLine();
        }
        while (true)
        {
            int num = new CreateID().InputDigit();
            if (num > 0 && num <= Monster.Length)
            {
                for (int i = n * 10; i < Monster.Length; i++)
                {
                    Monster[i - 10] = Monster[i];
                }
                MonsterRefresh(Monster);
                Console.WriteLine("删除成功!!!");
                Function();
            }

        }

    }

    //怪物排序sort
    public void MonsterSort()
    {
        string[] Monster = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt");

        for (int i = 0; i < Monster.Length; i += 5)
        {
            for (int j = i; j < Monster.Length; j += 5)
            {

                if (int.Parse(Monster[i + 1]) > int.Parse(Monster[j + 1]))
                {
                    string[] Str = new string[5];
                    for (int k = 0; k < 5; k++)
                    {
                        Str[k] = Monster[i + k];
                    }
                    for (int k = 0; k < 5; k++)
                    {
                        Monster[i + k] = Monster[j + k];
                    }
                    for (int k = 0; k < 5; k++)
                    {
                        Monster[j + k] = Str[k];
                    }
                }
                else if (int.Parse(Monster[i + 1]) == int.Parse(Monster[j + 1]))
                {
                    if (int.Parse(Monster[i + 2]) > int.Parse(Monster[j + 2]))
                    {
                        string[] Str = new string[5];
                        for (int k = 0; k < 5; k++)
                        {
                            Str[k] = Monster[i + k];
                        }
                        for (int k = 0; k < 5; k++)
                        {
                            Monster[i + k] = Monster[j + k];
                        }
                        for (int k = 0; k < 5; k++)
                        {
                            Monster[j + k] = Str[k];
                        }
                    }

                }


            }

        }
        MonsterRefresh(Monster);
    }

    //怪物刷新
    public void MonsterRefresh(string[] Monster)
    {
        for (int i = 0; i < Monster.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt", Monster[i]);
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt", "\n" + Monster[i]);
            }

        }

    }

    //创建宝物
    public void CreatGift()
    {
        bool bo1 = File.Exists(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt");
        if (bo1 == false)
        {
            FileStream file = File.Create(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt");
            file.Dispose();
        }
        string[] Str = new string[2];
        Console.WriteLine("请输入宠爱药丸数量:(1--10)");
        Str[0] = Console.ReadLine();
        Console.WriteLine("请输入金币数量:(10--100)");
        Str[1] = Console.ReadLine();
        bool bo = new CreateID().IsAffirm();
        if (bo)
        {
            for (int i = 0; i < 2; i++)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt", "\n" + Str[i]);
            }

            GiftSort();
            Console.WriteLine("创建成功!!!");
            Function();

        }


    }

    //删除宝物
    public void RemoveGift()
    {
        string[] GiftStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt");
        int n1 = 0;
        for (int i = 1; i < GiftStr.Length; i += 2)
        {
            n1++;
            Console.WriteLine("{0}: 药丸:{1}  金币:{2}", n1, GiftStr[i], GiftStr[i + 1]);
            Console.WriteLine();
        }
        Console.WriteLine("请输入所要删除宝物序号");
        while (true)
        {
            int n = new CreateID().InputDigit();
            if (n > 0 && n <= GiftStr.Length)
            {
                for (int i = n * 2; i < GiftStr.Length; i++)
                {
                    GiftStr[i - 2] = GiftStr[i];
                }

                GiftRefresh(GiftStr);
                Console.WriteLine("删除成功!!");
                Function();
            }


        }

    }

    //宝物排序
    public void GiftSort()
    {
        string[] GiftStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt");

        for (int i = 1; i < GiftStr.Length; i += 2)
        {
            for (int j = i; j < GiftStr.Length; j += 2)
            {
                if (int.Parse(GiftStr[i]) > int.Parse(GiftStr[j]))
                {
                    string[] strss = new string[2];
                    for (int k = 0; k < 2; k++)
                    {
                        strss[k] = GiftStr[i + k];
                    }
                    for (int k = 0; k < 2; k++)
                    {
                        GiftStr[i + k] = GiftStr[j + k];
                    }
                    for (int k = 0; k < 2; k++)
                    {
                        GiftStr[j + k] = strss[k];
                    }
                }
                else if (int.Parse(GiftStr[i]) == int.Parse(GiftStr[j]))
                {
                    if (int.Parse(GiftStr[i + 1]) > int.Parse(GiftStr[j + 1]))
                    {
                        string[] strss = new string[2];
                        for (int k = 0; k < 2; k++)
                        {
                            strss[k] = GiftStr[i + k];
                        }
                        for (int k = 0; k < 2; k++)
                        {
                            GiftStr[i + k] = GiftStr[j + k];
                        }
                        for (int k = 0; k < 2; k++)
                        {
                            GiftStr[j + k] = strss[k];
                        }
                    }

                }
            }
        }
        GiftRefresh(GiftStr);//排序完刷新
    }

    //刷新宝物
    public void GiftRefresh(string[] GiftStr)
    {
        for (int i = 0; i < GiftStr.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt", GiftStr[i]);
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt", "\n" + GiftStr[i]);
            }

        }
    }

    //退出
    private void Quit()
    {
        Console.WriteLine("退出成功");
        Environment.Exit(0);
    }
}

//修改宠物


#endregion


public class Vection2
{
    public int x;
    public int y;
}

public class World
{

}

//创建身份
public class CreateID
{
    public bool bo = false;

    //界面
    public void Inter()
    {

        Console.WriteLine("*********************************");
        Console.WriteLine("*        欢迎来到本系统         *");
        Console.WriteLine("*          请选择操作           *");
        Console.WriteLine("*          1.登录账户           *");
        Console.WriteLine("*          2.注册账户           *");
        Console.WriteLine("*          3.找回密码           *");
        Console.WriteLine("*          4.账户解锁           *");
        Console.WriteLine("*          5.退出               *");
        Console.WriteLine("*********************************");
        for (int i = 0; true; i++)
        {
            int n = InputDigit();
            switch (n)
            {
                case 1: Register(); break;
                case 2: Console.Clear(); RegisteredAaccount(); break;
                case 3: Console.Clear(); ForgotPassword(); break;
                case 4: Console.Clear(); Unlock(); break;
                case 5: Quit(); break;
                case 10086: new CreatPet().backstaGeverify(); break;
                default:
                    Console.WriteLine("输入错误");
                    break;
            }
        }

    }

    //登录成功后选择
    public void RegisterInter(string account)
    {
        Console.WriteLine("*********************************");
        Console.WriteLine("*          请选择操作           *");
        Console.WriteLine("*          1.修改密码           *");
        Console.WriteLine("*          2.开始历程           *");
        Console.WriteLine("*          3.返回登录           *");
        Console.WriteLine("*          4.注销账户           *");
        Console.WriteLine("*          5.退出               *");
        Console.WriteLine("*********************************");
        int n = int.Parse(Console.ReadLine());
        switch (n)
        {
            case 1: Console.Clear(); ChangePassword(account); break;
            case 2: Console.Clear(); new School().SchoolMap(account); ; break;
            case 3: Console.Clear(); Register(); break;
            case 4: Console.Clear(); CancelUser(account); break;
            case 5: Console.Clear(); Quit(); break;
            default:
                Console.WriteLine("输入错误");
                break;
        }
    }

    //修改密码后选择
    public void changePasswordInter()
    {
        Console.WriteLine("*********************************");
        Console.WriteLine("*         修改密码成功           *");
        Console.WriteLine("*          请选择操作           *");
        Console.WriteLine("*          1.返回主界面         *");
        Console.WriteLine("*          2.重新登录           *");
        Console.WriteLine("*          3.退出               *");
        Console.WriteLine("*********************************");
        for (int i = 0; true; i++)
        {
            int n = int.Parse(Console.ReadLine());
            switch (n)
            {
                case 1: Console.Clear(); Inter(); break;
                case 2: Console.Clear(); Register(); break;
                case 3: Console.Clear(); Quit(); break;
                default:
                    Console.WriteLine("输入错误,请重新输入");
                    break;
            }
        }

    }


    //登录失败
    public void LogonFailed()
    {
        Console.WriteLine("*********************************");
        Console.WriteLine("*          请选择操作           *");
        Console.WriteLine("*          1.重新登录           *");
        Console.WriteLine("*          2.注册账户           *");
        Console.WriteLine("*          3.找回密码           *");
        Console.WriteLine("*          4.退出               *");
        Console.WriteLine("*********************************");
        for (int i = 0; i < 3; i++)
        {
            int n = int.Parse(Console.ReadLine());
            switch (n)
            {
                case 1: Console.Clear(); Register(); break;
                case 2: Console.Clear(); RegisteredAaccount(); break;
                case 3: Console.Clear(); ForgotPassword(); break;
                case 4: Console.Clear(); Quit(); break;
                default:
                    Console.WriteLine("输入错误,请重新输入");
                    break;
            }
            if (2 - i == 0)
            {
                Quit();
            }
            Console.WriteLine("您还有{0}次机会", 2 - i);
        }

    }

    //登录
    public void Register()
    {

        string account;//1.账号
        string password = "";//2.密码
        string sex;//3.性别
        string encrypted;//4.密保问题
        string result;//5.密保答案
        string photo;//6.手机号码
                     //7.待定
                     //8.待定
                     //9.注册时间
                     //10.账号锁 true

        List<string> list = PlayerFilename();

        Console.WriteLine("请输入账号");
        for (int k = 0; k < 3; k++)
        {
            account = Console.ReadLine();
            for (int i = 0; i < list.Count; i++)
            {
                if (account == list[i])
                {
                    string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
                    if (Convert.ToBoolean(AccountStr[9]) == true)
                    {
                        for (int j = 0; j < 3; j++)
                        {

                            Console.WriteLine("请输入密码");
                            password = Console.ReadLine();
                            if (AccountStr[1] == password)
                            {
                                Console.WriteLine("登录成功!");
                                Console.Clear();
                                RegisterInter(account);

                            }
                            if (2 - j == 0)
                            {
                                AccountStr[9] = "false";
                                DeleteAndReinsertMessage(AccountStr, account);
                                Console.WriteLine("输入错误超过三次,账号已被锁定,自动退出登录");
                                LogonFailed();
                            }
                            else
                            {
                                Console.WriteLine("密码输入错误,请重新输入,还有{0}次机会", 2 - j);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("该账号已被锁定,请前往解锁");
                        Inter();
                    }

                }
                if (i == list.Count - 1)
                {
                    break;
                }
            }
            if (2 - k == 0)
            {
                Console.WriteLine("输入错误超过三次,自动退出登录");
                LogonFailed();
            }
            else
            {
                Console.WriteLine("密码输入错误,请重新输入,还有{0}次机会", 2 - k);
            }
        }


    }

    //注册账户
    public void RegisteredAaccount()
    {
        List<string> playList = PlayerFilename();

        if (Directory.Exists(@"D:\AllMyLife\DataCenter\PlayerData"))
        {

        }
        foreach (string content in Directory.GetFileSystemEntries(@"D:\AllMyLife\DataCenter\PlayerData"))//遍历玩家信息文件夹,找到文件夹所对应的子文件名
        {
            playList.Add(Path.GetFileNameWithoutExtension(content));
        }

        string account;//1.账号
        string password = "";//2.密码
        string sex;//3.性别
        string encrypted;//4.密保问题
        string result;//5.密保答案
        string photo;//6.手机号码
        string screeName;///7.网名
        //8.待定
        //9.注册时间
        //10.账号锁 true
        string[] playInformation = new string[10];

        //1.生成随机账号           
        //account = RandomAccount(playList);
        playInformation[0] = RandomAccount(playList);
        Console.WriteLine("账号生成成功:{0}", playInformation[0]);

        //2.输入密码
        //password = CreatePassword();
        playInformation[1] = CreatePassword();
        Console.WriteLine("密码创建成功!");

        //3.选择性别
        //sex = ChangSex();
        playInformation[2] = ChangSex();
        Console.WriteLine("性别选择完成!");

        //4.选择密保问题
        //encrypted = Encrypted();
        playInformation[3] = Encrypted();
        Console.WriteLine("密保问题选择完成!");

        //5.输入密保答案
        Console.WriteLine("请输入密保问题答案");
        //result = Console.ReadLine();
        playInformation[4] = Console.ReadLine();
        Console.WriteLine("密保创建成功");

        //6.验证手机号
        //photo = VerifyPhone();
        playInformation[5] = VerifyPhone();

        //7.网名
        playInformation[6] = Screenname();

        //8.待定
        playInformation[7] = "待定";

        //9.注册时间
        playInformation[8] = DateTime.Now.ToLongDateString().ToString();

        //10.账户锁
        playInformation[9] = "true";


        Console.WriteLine("是否注册");
        bo = IsAffirm();
        if (bo)
        {
            File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerData\" + playInformation[0] + ".txt", playInformation[0]);
            for (int i = 1; i < playInformation.Length; i++)
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerData\" + playInformation[0] + ".txt", "\n" + playInformation[i]);

            }
            Directory.CreateDirectory(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + playInformation[0]);//qwe为文件夹名称
            File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + playInformation[0] + @"\attribute.txt", "VIP0" + "\n" + "1" + "\n" + "20" + "\n" + "20" + "\n" + "20" + "\n" + "20" + "\n" + "20" + "\n" + "20" + "\n" + "20" + "\n" + "20");//人物属性
            File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + playInformation[0] + @"\backpack.txt", "1000" + "\n" + "1000" + "\n" + "500" + "\n" + "5" + "\n" + "500" + "\n" + "0" + "\n" + "0" + "\n" + "0" + "\n" + "0" + "\n" + "false");//人物背包
            File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + playInformation[0] + @"\RPGVection2.txt", "5" + "\n" + "19");//人物坐标
            Console.Clear();
            Console.WriteLine("注册成功!");
            Inter();
        }
        else
        {
            Console.Clear();
            Console.WriteLine("自动返回主界面");
            Inter();
        }
    }

    //修改密码
    public void ChangePassword(string account)
    {
        string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        Console.WriteLine("请输入旧密码");
        for (int i = 0; i < 3; i++)
        {
            string oldPassworld = Console.ReadLine();
            if (oldPassworld == AccountStr[1])
            {
                Console.WriteLine("请输入新密码");
                for (int j = 0; j < 3; j++)
                {
                    string newPassword = Console.ReadLine();
                    Console.WriteLine("再次确认新密码");
                    string newPassword1 = Console.ReadLine();
                    if (newPassword == newPassword1)
                    {
                        AccountStr[1] = newPassword;
                        DeleteAndReinsertMessage(AccountStr, account);
                        Console.Clear();
                        Console.WriteLine("密码修改成功,请重新登陆");
                        changePasswordInter();
                    }
                    if (2 - j == 0)
                    {
                        Console.WriteLine("输入错误超过三次,自动退出");
                        RegisterInter(account);
                    }
                    else
                    {
                        Console.WriteLine("两次输入不相同,请重新输入,还有{0}次机会", 2 - j);
                    }
                }



            }
            if (2 - i == 0)
            {
                Console.Clear();
                Console.WriteLine("输入错误超过三次,自动退出");
                RegisterInter(account);

            }
            else
            {
                Console.WriteLine("旧密码输入错误,请重新输入,还有{0}次机会", 2 - i);
            }
        }

    }

    //注销账户
    public void CancelUser(string account)
    {
        string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        Console.WriteLine("请输入密保:“{0}” 的答案", AccountStr[3]);
        for (int i = 0; i < 3; i++)
        {
            string result = Console.ReadLine();
            if (result == AccountStr[4])
            {
                for (int j = 0; j < 3; j++)
                {
                    int num = AuthorizedCode();
                    Console.WriteLine("手机授权码{0}以发送至手机,请输入授权码", num);
                    int num1 = 0;
                    string num2 = Console.ReadLine();
                    if (int.TryParse(num2, out num1) && num == int.Parse(num2))
                    {
                        bool bo = IsAffirm();
                        if (bo)
                        {
                            string HowSex = "";
                            //注销宿舍床铺
                            if (AccountStr[2] == "男")
                            {
                                HowSex = "DormitoryMan";
                            }

                            if (AccountStr[2] == "女")
                            {
                                HowSex = "DormitoryWoman";
                            }

                            string[] DormitoryStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\" + HowSex + @"\Vection2.txt");

                            for (int k = 0; k < DormitoryStr.Length; k += 10)
                            {
                                if (int.Parse(DormitoryStr[i + 2]) > 0)
                                {
                                    for (int m = 3 + i; m < 7 + m; j++)
                                    {
                                        if (DormitoryStr[j] == AccountStr[6])
                                        {
                                            DormitoryStr[j] = "0";
                                            DormitoryStr[i + 2] = (float.Parse(DormitoryStr[i + 2]) - 1).ToString();
                                            new Dormitory().DormitoryVection2Refresh(account, DormitoryStr);

                                            break;
                                        }
                                    }
                                    break;
                                }

                            }

                            File.Delete(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
                            Directory.Delete(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account, true);


                            Console.Clear();
                            Console.WriteLine("注销成功!自动返回主界面!");
                            Inter();
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("已经取消注销");
                            Inter();
                        }
                    }
                    if (2 - j == 0)
                    {
                        Console.Clear();
                        Console.WriteLine("输入错误超过三次,自动退出");
                        RegisterInter(account);
                    }
                    else
                    {
                        Console.WriteLine("授权码输入错误,请重新输入,还有{0}次机会", 2 - j);
                    }
                }



            }
            if (2 - i == 0)
            {
                Console.Clear();
                Console.WriteLine("输入错误超过三次,自动退出");
                RegisterInter(account);
            }
            else
            {
                Console.WriteLine("密保答案输入错误,请重新输入,还有{0}次机会", 2 - i);
            }
        }


    }

    //找回密码
    public void ForgotPassword()
    {
        List<string> list = PlayerFilename();
        Console.WriteLine("请输入账号");

        for (int i = 0; i < 3; i++)
        {
            string account = Console.ReadLine();
            for (int j = 0; j < list.Count; j++)
            {
                if (list[j] == account)
                {
                    Console.WriteLine("*********************************");
                    Console.WriteLine("*          请选择操作           *");
                    Console.WriteLine("*          1.密保找回           *");
                    Console.WriteLine("*          2.手机号找回         *");
                    Console.WriteLine("*          3.返回登录           *");
                    Console.WriteLine("*          4.主界面             *");
                    Console.WriteLine("*          5.退出               *");
                    Console.WriteLine("*********************************");
                    while (true)
                    {
                        int n = InputDigit();
                        switch (n)
                        {
                            case 1: Console.Clear(); EncryptedBackPassword(account); break;
                            case 2: Console.Clear(); PhotoBackPassword(account); break;
                            case 3: Console.Clear(); Register(); break;
                            case 4: Console.Clear(); Inter(); break;
                            case 5: Console.Clear(); Quit(); break;
                            default:
                                Console.WriteLine("输入错误");
                                break;
                        }
                    }


                }
            }
            if (2 - i == 0)
            {
                Console.WriteLine("账号输入错误超过三次,返回主界面");
                Inter();
            }
            else
            {
                Console.WriteLine("账号输入错误,请重新输入,还有{0}次机会", 2 - i);
            }
        }

    }

    //密保找回
    public void EncryptedBackPassword(string account)
    {
        string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        Console.WriteLine("密保问题:{0}", AccountStr[3]);
        Console.WriteLine("请输入密保答案:");
        for (int i = 0; i < 3; i++)
        {
            string result = Console.ReadLine();
            if (result == AccountStr[4])
            {
                Console.WriteLine("请输入新密码");
                for (int j = 0; j < 3; j++)
                {
                    string newPassword = Console.ReadLine();
                    Console.WriteLine("再次确认新密码");
                    string newPassword1 = Console.ReadLine();
                    if (newPassword == newPassword1)
                    {
                        AccountStr[1] = newPassword;
                        DeleteAndReinsertMessage(AccountStr, account);
                        Console.Clear();
                        Console.WriteLine("密码修改成功,请从新登陆");
                        changePasswordInter();
                    }
                    if (2 - j == 0)
                    {
                        Console.Clear();
                        Console.WriteLine("输入错误超过三次,自动退出");
                        RegisterInter(account);
                    }
                    else
                    {
                        Console.WriteLine("两次输入不相同,请重新输入,还有{0}次机会", 2 - j);
                    }
                }

            }
            if (2 - i == 0)
            {
                Console.Clear();
                Console.WriteLine("输入次数超过三次,自动返回主界面");
                Inter();
            }
            else
            {
                Console.WriteLine("密保答案输入错误,请重新输入,还有{0}次机会", 2 - i);
            }


        }


    }

    //手机号找回
    public void PhotoBackPassword(string account)
    {
        string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        Console.WriteLine("请输入绑定手机号");

        for (int i = 0; i < 3; i++)
        {
            string photoStr = Console.ReadLine();
            if (photoStr == AccountStr[5])
            {
                for (int k = 0; k < 3; k++)
                {
                    int num = AuthorizedCode();
                    Console.WriteLine("授权码{0}已经发送至你的手机,请输入授权码", num);
                    string num1 = Console.ReadLine();
                    int num2 = 0;
                    if (int.TryParse(num1, out num2) && int.Parse(num1) == num)
                    {
                        Console.WriteLine("请输入新密码");
                        for (int j = 0; j < 3; j++)
                        {
                            string newPassword = Console.ReadLine();
                            Console.WriteLine("再次确认新密码");
                            string newPassword1 = Console.ReadLine();
                            if (newPassword == newPassword1)
                            {
                                AccountStr[1] = newPassword;
                                DeleteAndReinsertMessage(AccountStr, account);
                                Console.Clear();
                                Console.WriteLine("密码修改成功,请重新登陆");
                                changePasswordInter();
                            }
                            if (2 - j == 0)
                            {
                                Console.Clear();
                                Console.WriteLine("输入错误超过三次,自动退出");
                                RegisterInter(account);
                            }
                            else
                            {
                                Console.WriteLine("两次输入不相同,请重新输入,还有{0}次机会", 2 - j);
                            }
                        }
                    }
                    if (2 - k == 0)
                    {
                        Console.WriteLine("输入错误超过三次,自动返回主界面");
                        Inter();
                    }
                    else
                    {
                        Console.WriteLine("授权码输入错误,请重新输入,还有{0}次机会", 2 - k);
                    }
                }
            }
            if (2 - i == 0)
            {
                Console.Clear();
                Console.WriteLine("输入次数超过三次,自动返回主界面");
                Inter();
            }
            else
            {
                Console.WriteLine("手机号错误,请重新输入,还有{0}次机会", 2 - i);
            }
        }
    }

    //随机账号
    public string RandomAccount(List<string> playList)
    {
        string account;
        while (true)
        {
            Random rd = new Random();
            int n = rd.Next(8, 10);

            if (n == 8)
            {
                account = (n.ToString()) + (rd.Next(10000000, 100000000).ToString());
            }
            else
            {
                account = (rd.Next(1, 4).ToString()) + (rd.Next(1, 6).ToString()) + (rd.Next(10000000, 100000000).ToString());
            }
            if (playList.Count == 0)
            {
                return account;
            }
            else
            {
                for (int i = 0; i < playList.Count; i++)
                {
                    string[] str = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + playList[i] + ".txt");//每行读取
                    if (account == str[0])
                    {
                        break;
                    }
                    if (i == playList.Count - 1)
                    {
                        return account;
                        break;
                    }
                }
            }
        }

    }

    //创建密码
    public string CreatePassword()
    {
        string password;
        Console.WriteLine("创建密码,长度为8为,不能为纯数字");
        Console.WriteLine("请输入密码");
        while (true)
        {
            password = Console.ReadLine();
            Console.WriteLine("请再次确认密码");
            string password1 = Console.ReadLine();
            if (password == password1)
            {
                if (password.Length >= 8)
                {
                    int n = 0;
                    int num;
                    for (int i = 0; i < password.Length; i++)
                    {
                        if (int.TryParse(password[i].ToString(), out num))
                        {
                            n++;
                        }
                        if (i == password.Length - 1 && n != password.Length)
                        {
                            return password;
                        }
                        if (i == password.Length - 1 && n == password.Length)
                        {
                            Console.WriteLine("密码不能用纯数字");
                            break;
                        }
                    }

                }
                else
                {
                    Console.WriteLine("密码长度小于8位");
                }

            }
            else
            {
                Console.WriteLine("两次密码不相同,请重新输入!");
            }


        }



    }

    //选择性别
    public string ChangSex()
    {
        Console.WriteLine("********");
        Console.WriteLine("* 1.男 *");
        Console.WriteLine("* 2.女 *");
        Console.WriteLine("********");
        Console.WriteLine("请选择性别");
        while (true)
        {
            int n = InputDigit();
            switch (n)
            {
                case 1: return "男"; break;
                case 2: return "女"; break;
                default:
                    Console.WriteLine("输入错误,请重新选择");
                    break;
            }

        }
    }

    //验证手机号
    public string VerifyPhone()
    {
        List<string> playList = PlayerFilename();
        Console.WriteLine("请输入手机号");
        //13 15 18
        while (true)
        {
            string photoStr = Console.ReadLine();
            if (photoStr.Length == 11)
            {
                if (int.Parse(photoStr[0].ToString()) == 1 && (int.Parse(photoStr[1].ToString()) == 3 || int.Parse(photoStr[1].ToString()) == 5 || int.Parse(photoStr[1].ToString()) == 8))
                {
                    if (playList.Count == 0)
                    {
                        return photoStr;
                    }
                    else
                    {
                        for (int i = 0; i < playList.Count; i++)
                        {
                            string[] playerStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + playList[i] + ".txt");
                            if (playerStr[5] == photoStr)
                            {
                                break;
                            }
                            if (i == playList.Count - 1)
                            {
                                return photoStr;
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("没有该形式手机号码,请重新输入!");
                }
            }
            else
            {
                Console.WriteLine("输入手机号码不正确,请重新输入");
            }




        }

    }

    //创建网名
    public string Screenname()
    {
        List<string> playList = PlayerFilename();

        Console.WriteLine("请输入网名:");
        while (true)
        {
            string name = Console.ReadLine();
            if (playList.Count == 0)
            {
                return name;
            }
            else
            {
                for (int i = 0; i < playList.Count; i++)
                {
                    string[] playerStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + playList[0] + ".txt");
                    if (name == playerStr[6])
                    {
                        break;
                    }
                    if (i == playList.Count - 1)
                    {
                        return name;
                    }
                }
                Console.WriteLine("该网名已被注册,请重新输入");
            }

        }
    }


    //解锁
    public void Unlock()
    {
        List<string> list = PlayerFilename();
        Console.WriteLine("请输入已经被锁定账号");
        for (int m = 0; m < 3; m++)
        {
            string account = Console.ReadLine();
            for (int k = 0; k < list.Count; k++)
            {
                if (account == list[k])
                {
                    string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");

                    if (Convert.ToBoolean(AccountStr[9]) == false)
                    {
                        Console.WriteLine("请输入密保:“{0}” 的答案", AccountStr[3]);
                        for (int i = 0; i < 3; i++)
                        {
                            string result = Console.ReadLine();
                            if (result == AccountStr[4])
                            {
                                for (int j = 0; j < 3; j++)
                                {
                                    int num = AuthorizedCode();
                                    Console.WriteLine("手机授权码{0}以发送至手机,请输入授权码", num);
                                    int num1 = 0;
                                    string num2 = Console.ReadLine();
                                    if (int.TryParse(num2, out num1) && num == int.Parse(num2))
                                    {
                                        AccountStr[9] = "true";
                                        DeleteAndReinsertMessage(AccountStr, account);
                                        Console.WriteLine("解锁成功");
                                        Inter();
                                    }
                                    if (2 - j == 0)
                                    {
                                        Console.WriteLine("输入错误超过三次,自动退出");
                                        RegisterInter(account);
                                    }
                                    else
                                    {
                                        Console.WriteLine("授权码输入错误,请重新输入,还有{0}次机会", 2 - j);
                                    }
                                }



                            }
                            if (2 - i == 0)
                            {
                                Console.WriteLine("输入错误超过三次,自动退出");
                                RegisterInter(account);
                            }
                            else
                            {
                                Console.WriteLine("密保答案输入错误,请重新输入,还有{0}次机会", 2 - i);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("该账号未被锁定");
                        Inter();
                    }

                }
                if (k == list.Count - 1)
                {
                    break;
                }
            }
            if (2 - m == 0)
            {
                Console.WriteLine("输入次数超过三次,自动返回到主界面");
            }
            else
            {
                Console.WriteLine("账号输入错误,请重新输入,还有{0}次机会", 2 - m);
            }
        }


    }

    //退出
    public void Quit()
    {
        Console.WriteLine("退出成功");
        Environment.Exit(0);
    }

    //验证码
    public int AuthCode()
    {
        Random rand1 = new Random();
        int a = rand1.Next(1000, 9000);
        return a;
    }

    //密保问题
    public string Encrypted()
    {
        Console.WriteLine("*********************************");
        Console.WriteLine("*        请选择密保问题         *");
        Console.WriteLine("*         1.最崇拜的人          *");
        Console.WriteLine("*         2.最喜欢数字          *");
        Console.WriteLine("*         3.女友姓名            *");
        Console.WriteLine("*         4.初恋对象            *");
        Console.WriteLine("*********************************");
        string[] str = new string[] { "最崇拜的人", "最喜欢数字", "女友姓名", "初恋对象" };
        while (true)
        {
            int n = InputDigit();
            if (n <= 4 && n >= 1)
            {
                return str[n - 1];
            }
            else
            {
                Console.WriteLine("输入错误,请重新输入");
            }
        }


    }

    //产品授权码
    public int AuthorizedCode()
    {
        Random rand1 = new Random();
        return rand1.Next(100000, 999999);
    }

    //删除并重新插入(账号)
    public void DeleteAndReinsertMessage(string[] accountStr, string account)
    {
        for (int i = 0; i < accountStr.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt", accountStr[i]);//在原有文本文件替换
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt", "\n" + accountStr[i]);//在原有文本文件上替换
            }
        }
    }

    //键盘输入数字
    public int InputDigit()
    {
        while (true)
        {
            string str = Console.ReadLine();
            int n = 0;
            if (int.TryParse(str, out n))
            {
                return n;
                Console.WriteLine(n);
            }
            else
            {
                Console.WriteLine("请输入数字");
            }
        }
    }

    //获取玩家文件名
    public List<string> PlayerFilename()
    {
        List<string> playList = new List<string>();
        foreach (string content in Directory.GetFileSystemEntries(@"D:\AllMyLife\DataCenter\PlayerData"))//遍历玩家信息文件夹,找到文件夹所对应的子文件名
        {
            playList.Add(Path.GetFileNameWithoutExtension(content));
        }
        return playList;
    }

    //确认方法
    public bool IsAffirm()
    {
        Console.WriteLine("**********");
        Console.WriteLine("*  1.是  *");
        Console.WriteLine("*  2.否  *");
        Console.WriteLine("**********");
        Console.WriteLine("请输入:");
        while (true)
        {
            int n = InputDigit();
            switch (n)
            {
                case 1: return true; break;
                case 2: return false; break;
                default:
                    Console.WriteLine("输入错误,请重新输入");
                    break;
            }
        }
    }

    //玩家属性,背包,坐标刷新

    //玩家背包刷新
    public void backpackRefresh(string[] backpackStr, string account)
    {
        for (int i = 0; i < backpackStr.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", backpackStr[i]);//在原有文本文件替换
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", "\n" + backpackStr[i]);//在原有文本文件上替换
            }
        }
    }

    //玩家属性刷新
    public void attributeRefresh(string[] attributeStr, string account)
    {
        string[] playerBackpack = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//获取玩家背包,用来刷新背包容量
        attributeStr[6] = (int.Parse(attributeStr[7]) - ((playerBackpack.Length - 10) / 10) - (int.Parse(playerBackpack[2]) / 100) - int.Parse(playerBackpack[3]) - (int.Parse(playerBackpack[4]) / 120)).ToString();//刷新背包容量

        for (int i = 0; i < attributeStr.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt", attributeStr[i]);//在原有文本文件替换
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt", "\n" + attributeStr[i]);//在原有文本文件上替换
            }
        }
    }

    //玩家坐标刷新
    public void Vection2Refresh(string[] Vection2Str, string account)
    {
        for (int i = 0; i < Vection2Str.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\RPGVection2.txt", Vection2Str[i]);//在原有文本文件替换
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\RPGVection2.txt", "\n" + Vection2Str[i]);//在原有文本文件上替换
            }
        }
    }

    //判断耐久力是否为0
    public void DurabilityVerdict(string[] DurabilityStr, string account)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        if (backpackStr[9] == "true")
        {
            if (float.Parse(DurabilityStr[4]) <= 1)
            {
                Console.WriteLine("需要休息了");
                Console.WriteLine("自动返回宿舍");
                string[] accountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");

                string HowSex = "";
                if (accountStr[2] == "男")
                {
                    HowSex = "DormitoryMan";
                }

                if (accountStr[2] == "女")
                {
                    HowSex = "DormitoryWoman";
                }
                string[] dormStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\" + HowSex + @"\Vection2.txt");

                for (int i = 0; i < dormStr.Length; i += 10)
                {
                    int bedWhile = 0;
                    for (int j = i + 3; j < i + 7; j++)
                    {
                        bedWhile++;
                        if (dormStr[j] == accountStr[6])
                        {
                            Console.Write("休息中:");
                            for (int k = 0; k < 5; k++)
                            {
                                Thread.Sleep(800);
                                Console.Write(">");
                            }
                            Console.WriteLine();
                            DurabilityStr[4] = DurabilityStr[5];
                            attributeRefresh(DurabilityStr, account);
                            string[] Vection2Str = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\RPGVection2.txt");

                            if (accountStr[2] == "男")
                            {
                                Vection2Str[0] = "3";
                                Vection2Str[1] = "10";
                            }

                            if (accountStr[2] == "女")
                            {
                                Vection2Str[0] = "7";
                                Vection2Str[1] = "10";
                            }
                            Vection2Refresh(Vection2Str, account);


                            int BedX = 0;
                            int BedY = 0;
                            if (bedWhile == 1)
                            {
                                BedX = 2;
                                BedY = 2;
                            }

                            if (bedWhile == 2)
                            {
                                BedX = 2;
                                BedY = 4;
                            }

                            if (bedWhile == 3)
                            {
                                BedX = 6;
                                BedY = 2;
                            }

                            if (bedWhile == 4)
                            {
                                BedX = 2;
                                BedY = 4;
                            }
                            new DormitoryRoom().DormitoryRoomMap(account, BedX, BedY);
                            //if (accountStr[2] == "男")
                            //{

                            //    //new Dormitory().DormitoryMap(account, int.Parse(dormStr[i]), int.Parse(dormStr[i + 1]));
                            //}

                            //if (accountStr[2] == "女")
                            //{
                            //    new Dormitory().DormitoryWomanMap(account, int.Parse(dormStr[i]), int.Parse(dormStr[i + 1]));
                            //}

                        }
                    }
                }
            }

        }
        else
        {
            Console.WriteLine("你还不是该学校学生,没有办法回到宿舍补充耐力");
        }



    }

    //等级判断
    public void HierarchyVerdict(string[] attributeStr, string account)
    {
        float num1 = 0;
        int length = (attributeStr.Length - 2) / 2;
        float[] num = new float[length];
        int n = 0;
        for (int i = 3; i < attributeStr.Length; i += 2)
        {
            num[n] = float.Parse(attributeStr[i]);
            num1 += float.Parse(attributeStr[i]);
            n++;
        }

        //等级值集合
        int[] Hierarchy = new int[] { 100, 300, 600, 1000 };
        int tmp = 0;
        for (int i = 0; i < Hierarchy.Length; i++)
        {
            if (float.Parse(attributeStr[1]) == i + 1)
            {
                tmp = Hierarchy[i];
                break;
            }
        }

        if (num1 > tmp)
        {
            for (int i = 0; i < num.Length; i++)
            {
                if (num[i] <= (tmp / length))
                {
                    break;
                }
                if (i == num.Length - 1)
                {
                    attributeStr[1] = "2";
                    //更新完等级后刷新背包
                    new CreateID().attributeRefresh(attributeStr, account);
                }
            }
        }
    }

    //宠物等级判断
    public void PetVerdict(string[] backpackStr, string account)
    {
        backpackRefresh(backpackStr, account);
        int[] PetGrade = new int[] { 0, 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500 };//经验值达到,某个值升级
        for (int i = 10; i < backpackStr.Length; i += 10)
        {

            if (float.Parse(backpackStr[i + 3]) > PetGrade[int.Parse(backpackStr[i + 2])])
            {
                backpackStr[i + 2] = (int.Parse(backpackStr[i + 2]) + 1).ToString();
                backpackStr[i + 4] = (int.Parse(backpackStr[i + 4]) * 100 / 85).ToString();
                backpackStr[i + 5] = (int.Parse(backpackStr[i + 5]) * 100 / 85).ToString();
                backpackStr[i + 6] = (int.Parse(backpackStr[i + 6]) * 100 / 85).ToString();
                backpackStr[i + 8] = backpackStr[2];
                backpackStr[i + 9] = (int.Parse(backpackStr[i + 6]) * int.Parse(backpackStr[i + 2])).ToString();//宠物价格等于血量*等级
            }
        }
        backpackRefresh(backpackStr, account);
    }

    //查看所有属性信息
    public void AllInformation(string account, int a, int b)
    {
        string[] playerID = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + @".txt");
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//背包
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt"); //属性

        Console.WriteLine("用户名称:{0}\n\n用户金额:{1}\n用户食物:{2}\n用户药品:{3}\n宠物食物:{4} ", playerID[6], backpackStr[0], backpackStr[2], backpackStr[3], backpackStr[4]);
        Console.WriteLine("VIP等级:{0}\n人物等级:{1}\n智力:{2}\n耐久力:{3}\n剩余耐久力:{4}\n负重:{5}\n剩余负重:{6}\n幸运值:{7}\n", attributeStr[0], attributeStr[1], attributeStr[2], attributeStr[5], attributeStr[4], attributeStr[7], attributeStr[6], attributeStr[8]);

        string petStr = "姓名性别等级经验攻击防御血量品种食量价格";
        int n = 0;
        Console.WriteLine("宠物信息:");
        for (int i = 10; i < backpackStr.Length; i++)
        {
            Console.Write(petStr[n]);
            n++;
            Console.Write(petStr[n] + ":");
            n++;
            Console.WriteLine(backpackStr[i]);
            if ((i + 1) % 10 == 0)
            {
                n = 0;
                Console.WriteLine("-------------------");
            }
        }
        new DormitoryRoom().RoomChange(account, a, b);

    }

    //玩家没走一步,耐久减一和宠物食物相应实物量
    public void Consume(string account)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//背包
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt"); //属性

        attributeStr[4] = (int.Parse(attributeStr[4]) - 1).ToString();//没走一步耐久力下降一
        backpackStr[2] = (int.Parse(backpackStr[2]) - 1).ToString();//没走一步玩家食物下降一
        for (int i = 10; i < backpackStr.Length; i += 10)//没走一步减少相应的宠物食物
        {
            backpackStr[4] = (int.Parse(backpackStr[4]) - int.Parse(backpackStr[i + 8])).ToString();
        }

        backpackRefresh(backpackStr, account);
        attributeRefresh(attributeStr, account);


    }

    //判断食物是否充足
    public void Adequatefood(string account)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//背包
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt"); //属性

        if (int.Parse(backpackStr[2]) < int.Parse(attributeStr[5]))
        {
            Console.WriteLine("玩家食物不足,请到商店购买");
        }
        int petFood = 0;
        for (int i = 10; i < backpackStr.Length; i += 10)
        {
            petFood += int.Parse(backpackStr[i + 8]);
        }
        float moneyPet=0;
        for (int i = 10; i < backpackStr.Length; i+=10)
        {
            moneyPet += float.Parse(backpackStr[i + 9]);
        }

        if (int.Parse(backpackStr[4])<= petFood)
        {
            Console.WriteLine("宠物被活活饿死,是否花{0}金救活宠物", (moneyPet/4));
            if (float.Parse(backpackStr[0]) > (moneyPet / 4))
            {
                bool bo = new CreateID().IsAffirm();
                if (bo)
                {
                    Console.WriteLine("宠物已被救活");
                    backpackStr[0] = (float.Parse(backpackStr[0]) - (moneyPet / 4)).ToString();
                    backpackStr[4] = "500";
                    new CreateID().backpackRefresh(backpackStr, account);
                }
                else
                {
                    Console.WriteLine("金钱不足,宠物死亡");
                    string[] backpack = new string[10];
                    for (int i = 0; i < 10; i++)
                    {
                        backpack[i] = backpackStr[i];
                    }
                    new CreateID().backpackRefresh(backpack, account);
                }

            }
            else
            {
                Console.WriteLine("金钱不足,宠物死亡");
                string[] backpack = new string[10];
                for (int i = 0; i < 10; i++)
                {
                    backpack[i] = backpackStr[i];
                }
                new CreateID().backpackRefresh(backpack,account);
            }
           

        }

        if (int.Parse(backpackStr[4]) < petFood * int.Parse(attributeStr[5]))
        {
            Console.WriteLine("宠物食物不足,请到商店购买");
        }


    }


}

//学校
public class School
{
    //生成学校地图
    public void SchoolMap(string account)
    {

        //File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", "暂无");//人物背包
        string[] rpgVection2 = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\RPGVection2.txt");//获取人物初始坐标

        int a = 0;
        int b = 0;
        int[,] schoolMapStr = new int[,]
        {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
            {1,0,0,0,0,0,0,0,2,2,9,2,2,0,2,2,2,2,2,1 },
            {1,0,2,2,2,2,2,0,2,9,2,9,2,0,2,9,9,9,2,1 },
            {1,0,2,2,9,2,2,0,2,2,0,2,2,0,2,2,0,2,2,1 },
            {1,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,2,1 },
            {1,0,2,2,9,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
            {1,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,2,1 },
            {1,0,2,2,9,2,2,0,2,2,0,2,2,0,2,2,0,2,2,1 },
            {1,0,2,2,2,2,2,0,2,9,2,9,2,0,2,9,9,9,2,1 },
            {1,0,0,0,0,0,0,0,2,2,9,2,2,0,2,2,2,2,2,1 },
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }

        };
        schoolMapStr[int.Parse(rpgVection2[0]), int.Parse(rpgVection2[1])] = 3;
        string phraseStr = "男宿舍冒险岛教学楼宿舍宠物店女";
        int n = 0;
        for (int i = 0; i < schoolMapStr.GetLength(0); i++)
        {
            for (int j = 0; j < schoolMapStr.GetLength(1); j++)
            {
                if (schoolMapStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (schoolMapStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (schoolMapStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (schoolMapStr[i, j] == 3)
                {

                    Console.Write("★");
                }
                if (schoolMapStr[i, j] == 9)
                {
                    Console.Write(phraseStr[n]);
                    n++;
                }
            }
            Console.WriteLine();
        }

        SchoolRpgRemove(account, schoolMapStr);
    }

    //人物在学校移动
    public void SchoolRpgRemove(string account, int[,] schoolMapStr)
    {
        string phraseStr = "男宿舍冒险岛教学楼宿舍宠物店女";
        string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        string[] rpgVection2 = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\RPGVection2.txt");//获取人物坐标
        int x = int.Parse(rpgVection2[0]);
        int y = int.Parse(rpgVection2[1]);
        while (true)
        {

            new CreateID().Adequatefood(account);//判断玩家食物以及宠物食物是否充足

            //没运动一次刷新玩家背包
            string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
            //玩家属性
            string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
            //玩家耐久力判断,一旦达到某个值就会自动休息
            new CreateID().DurabilityVerdict(attributeStr, account);
            //等级判断
            new CreateID().HierarchyVerdict(attributeStr, account);


            bool bo = false;
            int rpgX = 0;//控制人物上下
            int rpgY = 0;//控制人物左右

            char ch = Console.ReadKey().KeyChar;
            Console.WriteLine();

            #region 判断移动方向
            if (ch == 'w' || ch == 'W')
            {
                rpgX = -1;
            }
            if (ch == 's' || ch == 'S')
            {
                rpgX = 1;
            }
            if (ch == 'a' || ch == 'A')
            {
                rpgY = -1;
            }
            if (ch == 'd' || ch == 'D')
            {
                rpgY = 1;
            }
            #endregion

            if (x + rpgX >= schoolMapStr.GetLength(0) || y + rpgY >= schoolMapStr.GetLength(1))
            {
                continue;
            }

            if (schoolMapStr[x + rpgX, y + rpgY] == 1 && x + rpgX == 5 && y + rpgY == 0)
            {
                Console.WriteLine("隐藏上网任务,增加属性");
                new SecretMissions().surfTheInternet(account);

            }
            else if (schoolMapStr[x + rpgX, y + rpgY] == 2 && x + rpgX == 9 && y + rpgY == 12)
            {
                if (AccountStr[2] == "男")
                {
                    Console.WriteLine("愉快的进入女生宿舍撩妹纸(^_^)");
                    Console.WriteLine("撩妹纸中勿扰");
                    new SecretMissions().IsomerismRoom(account);
                }
                Console.WriteLine("撩完赶紧跑");
                continue;
            }
            else if (schoolMapStr[x + rpgX, y + rpgY] == 2 && x + rpgX == 1 && y + rpgY == 12)
            {
                if (AccountStr[2] == "女")
                {
                    Console.WriteLine("老娘愉快的进入男生宿舍撩汉纸(^_^)哈哈哈~~~");
                    Console.WriteLine("撩汉纸中:");
                    new SecretMissions().IsomerismRoom(account);
                }

                Console.WriteLine("撩完赶紧跑");
                continue;
            }
            else if (schoolMapStr[x + rpgX, y + rpgY] == 1 || schoolMapStr[x + rpgX, y + rpgY] == 2 || schoolMapStr[x + rpgX, y + rpgY] == 9)
            {
                continue;
            }
            else
            {
                schoolMapStr[x + rpgX, y + rpgY] = 3;
                schoolMapStr[x, y] = 0;
                SchoolMapRefresh(schoolMapStr, phraseStr);
                Console.Clear();
                SchoolMapRefresh(schoolMapStr, phraseStr);

                if (x + rpgX == 5 && y + rpgY == 18)//判断是否缴费
                {
                    if (Convert.ToBoolean(backpackStr[9]) == true)
                    {
                        Console.WriteLine("欢迎{0}同学回校!", AccountStr[6]);
                    }
                    else
                    {
                        Console.WriteLine("欢迎{0}新同学,请缴纳学费100金,是否缴纳", AccountStr[6]);
                        string HowSex = "";
                        if (AccountStr[2] == "男")
                        {
                            HowSex = "DormitoryMan";
                        }

                        if (AccountStr[2] == "女")
                        {
                            HowSex = "DormitoryWoman";
                        }

                        bool bo1 = new CreateID().IsAffirm();
                        if (bo1 == true)
                        {
                            backpackStr[0] = (float.Parse(backpackStr[0]) - 100).ToString();
                            backpackStr[9] = "true";
                            new CreateID().backpackRefresh(backpackStr, account);

                            //获取宿舍情况
                            string[] DormitoryStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\" + HowSex + @"\Vection2.txt");

                            for (int i = 0; i < DormitoryStr.Length; i += 10)
                            {
                                if (int.Parse(DormitoryStr[i + 2]) < 4)
                                {
                                    for (int j = 3 + i; j < 7 + i; j++)
                                    {
                                        if (DormitoryStr[j] == "0")
                                        {
                                            DormitoryStr[j] = AccountStr[6];
                                            DormitoryStr[i + 2] = (float.Parse(DormitoryStr[i + 2]) + 1).ToString();
                                            new Dormitory().DormitoryVection2Refresh(account, DormitoryStr);
                                            Console.WriteLine("宿舍已经分好{0}生宿舍为{1}号寝", AccountStr[2], DormitoryStr[i + 9]);
                                            break;
                                        }
                                    }
                                    break;
                                }

                            }



                            Console.WriteLine("缴费成功,欢迎新同学!");
                        }
                        else
                        {
                            Console.WriteLine("您未缴费,可以进入学校但不能进入学校相关区域");
                        }
                    }

                }


                if (x + rpgX == 3 && y + rpgY == 10)
                {
                    if (backpackStr[9] == "true")
                    {
                        if (AccountStr[2] == "男")
                        {
                            Console.WriteLine("进入男生宿舍");
                            new Dormitory().DormitoryMap(account, 6, 9);
                        }
                        else
                        {
                            Console.WriteLine("男生宿舍,女生止步!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("由于你不是本校学生,不能进入该建筑,请缴费成为本校学生");
                    }
                }
                if (x + rpgX == 7 && y + rpgY == 10)
                {
                    if (backpackStr[9] == "true")
                    {
                        if (AccountStr[2] == "女")
                        {
                            Console.WriteLine("进入女生宿舍");
                            new Dormitory().DormitoryWomanMap(account, 0, 9);
                        }
                        else
                        {
                            Console.WriteLine("女生宿舍,男生止步!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("由于你不是本校学生,不能进入该建筑,请缴费成为本校学生");
                    }
                }
                if (x + rpgX == 3 && y + rpgY == 16)
                {
                    if (backpackStr[9] == "true")
                    {
                        Console.WriteLine("进入冒险岛");
                        new Adventure().AdventureMap(account, 10, 8);
                    }
                    else
                    {
                        Console.WriteLine("由于你不是本校学生,不能进入该建筑,请缴费成为本校学生");
                    }
                }
                if (x + rpgX == 7 && y + rpgY == 16)
                {
                    if (backpackStr[9] == "true")
                    {
                        Console.WriteLine("进入商店");
                        new Shop().ShopMap(account, 0, 5);
                    }
                    else
                    {
                        Console.WriteLine("由于你不是本校学生,不能进入该建筑,请缴费成为本校学生");
                    }
                }
                if (x + rpgX == 5 && y + rpgY == 6)
                {
                    if (backpackStr[9] == "true")
                    {
                        Console.WriteLine("进入教学楼");
                        new TeachingBuild().TeachingBuildMap(account);
                    }
                    else
                    {
                        Console.WriteLine("由于你不是本校学生,不能进入该建筑,请缴费成为本校学生");
                    }

                }


                bo = true;

            }
            if (bo == true)
            {
                x += rpgX;
                y += rpgY;
                //刷新玩家坐标   
                File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\RPGVection2.txt", x.ToString() + "\n" + y.ToString());//移动后更新人物坐标
                //刷新玩家耐久力
                attributeStr[4] = (float.Parse(attributeStr[4]) - 1).ToString();

                new CreateID().attributeRefresh(attributeStr, account);

                new CreateID().Consume(account);//减少玩家耐久以及食物
            }

        }


    }

    //地图刷新
    public void SchoolMapRefresh(int[,] MapStr, string str)
    {
        int n = 0;
        for (int i = 0; i < MapStr.GetLength(0); i++)
        {
            for (int j = 0; j < MapStr.GetLength(1); j++)
            {
                if (MapStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (MapStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (MapStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (MapStr[i, j] == 3)
                {
                    Console.Write("★");
                }
                if (MapStr[i, j] == 4)
                {
                    Console.Write("●");
                }
                if (MapStr[i, j] == 9)
                {
                    Console.Write(str[n]);
                    n++;
                }
            }
            Console.WriteLine();
        }
    }

}

//商店
public class Shop
{
    //商店地图
    public void ShopMap(string account, int a, int b)
    {
        int[,] ShopMapStr = new int[,]
        {
            {1,1,1,1,1,0,1,1,1,1,1 },
            {1,9,2,0,0,0,0,0,2,9,1 },
            {1,9,2,0,0,0,0,0,2,9,1 },
            {1,9,0,0,0,0,0,0,0,9,1 },
            {1,9,2,0,0,0,0,0,2,9,1 },
            {1,2,2,0,2,2,2,0,2,2,1 },
            {1,9,9,9,9,2,9,9,9,9,1 },
            {1,1,1,1,1,1,1,1,1,1,1 }
        };
        ShopMapStr[a, b] = 3;
        string shopStr = "购出买售商商品品充值中心商品转赠";
        int n = 0;
        for (int i = 0; i < ShopMapStr.GetLength(0); i++)
        {
            for (int j = 0; j < ShopMapStr.GetLength(1); j++)
            {
                if (ShopMapStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (ShopMapStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (ShopMapStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (ShopMapStr[i, j] == 3)
                {
                    Console.Write("★");
                }
                if (ShopMapStr[i, j] == 9)
                {
                    Console.Write(shopStr[n]);
                    n++;
                }
            }
            Console.WriteLine();
        }
        ShopMapRemove(account, ShopMapStr, a, b);

    }

    //商店里面移动
    public void ShopMapRemove(string account, int[,] ShopMapStr, int a, int b)
    {
        string shopStr = "购出买售商商品品充值中心商品转赠";
        //string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        int x = a;
        int y = b;
        while (true)
        {

            new CreateID().Adequatefood(account);//判断玩家食物以及宠物食物是否充足

            //获取玩家属性
            string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
            //玩家耐久力判断,一旦达到某个值就会自动休息
            new CreateID().DurabilityVerdict(attributeStr, account);
            bool bo = false;
            int rpgX = 0;//控制人物上下
            int rpgY = 0;//控制人物左右

            char ch = Console.ReadKey().KeyChar;

            #region 判断移动方向
            if (ch == 'w' || ch == 'W')
            {
                rpgX = -1;
            }
            if (ch == 's' || ch == 'S')
            {
                rpgX = 1;
            }
            if (ch == 'a' || ch == 'A')
            {
                rpgY = -1;
            }
            if (ch == 'd' || ch == 'D')
            {
                rpgY = 1;
            }
            #endregion

            if (x + rpgX < 0 && y + rpgY == 5)
            {
                continue;
            }
            if (ShopMapStr[x + rpgX, y + rpgY] == 1 || ShopMapStr[x + rpgX, y + rpgY] == 2 || ShopMapStr[x + rpgX, y + rpgY] == 9)
            {
                continue;
            }
            else
            {
                ShopMapStr[x + rpgX, y + rpgY] = 3;
                ShopMapStr[x, y] = 0;
                new School().SchoolMapRefresh(ShopMapStr, shopStr);
                Console.Clear();
                new School().SchoolMapRefresh(ShopMapStr, shopStr);

                if (x + rpgX == 0 && y + rpgY == 5)
                {
                    Console.WriteLine("退出商店");
                    new School().SchoolMap(account);
                }

                if (x + rpgX == 3 && y + rpgY == 2)
                {
                    Console.WriteLine("购买商品");
                    Commodity(account, "buy");
                }
                if (x + rpgX == 3 && y + rpgY == 8)
                {
                    Console.WriteLine("出售商品");
                    Commodity(account, "sell");
                }
                if (x + rpgX == 5 && y + rpgY == 3)
                {
                    Console.WriteLine("充值中心");
                    rechargeInter(account);
                }
                if (x + rpgX == 5 && y + rpgY == 7)
                {
                    Console.WriteLine("商品转赠");
                    GiveInter(account);
                }

                bo = true;
            }
            if (bo == true)
            {
                x += rpgX;
                y += rpgY;
                new CreateID().attributeRefresh(attributeStr, account);
                new CreateID().Consume(account);//减少玩家耐久以及食物
            }

        }



    }

    //商品界面
    public void Commodity(string account, string fromWhile)
    {
        Console.WriteLine("************************");
        Console.WriteLine("*  请选择购买商品种类  *");
        Console.WriteLine("*        1.食物        *");
        Console.WriteLine("*        2.药品        *");
        Console.WriteLine("*        3.宠物        *");
        Console.WriteLine("*        4.宠物食物    *");
        Console.WriteLine("*        5.玩家背包    *");
        Console.WriteLine("*        6.退出        *");
        Console.WriteLine("************************");
        while (true)
        {
            int n = new CreateID().InputDigit();
            switch (n)
            {
                case 1: Aliment(account, fromWhile); break;
                case 2: Drug(account, fromWhile); break;
                case 3:
                    if (fromWhile == "buy")
                    {
                        PetKing(account);
                    }
                    if (fromWhile == "sell")
                    {
                        sellPet(account);
                    }
                    break;
                case 4: petFood(account, fromWhile); break;
                case 5: accounterPacksack(account, "buy"); break;
                case 6:
                    if (fromWhile == "buy")
                    {
                        ShopMap(account, 3, 2);
                    }
                    if (fromWhile == "sell")
                    {
                        ShopMap(account, 3, 8);
                    }
                    break;
                default:
                    Console.WriteLine("输入错误");
                    break;
            }

        }

    }

    //宠物种类
    public void PetKing(string account)
    {
        string[] str = new string[Directory.GetFileSystemEntries(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop").Length];//声明一个数组,用来装D:\AllMyLife\DataCenter\SystemMessage\PetShop中文件名,
        int n = 0;                                                                          //Directory.GetFileSystemEntries(@"D:\PetShop\Pet").Length 表示文件中含有子文件个数

        Console.WriteLine("************************");
        Console.WriteLine("   请选择查看宠物种类  ");
        foreach (string content in Directory.GetFileSystemEntries(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop"))
        {
            Console.WriteLine("       {0}.{1}          ", (n + 1), Path.GetFileNameWithoutExtension(content));
            str[n] = Path.GetFileNameWithoutExtension(content);
            n++;
        }
        Console.WriteLine("************************");
        Console.WriteLine("请输入对应序号");
        for (int i = 0; true; i++)
        {
            n = new CreateID().InputDigit();
            if (n > Directory.GetFileSystemEntries(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop").Length)
            {
                Console.WriteLine("输入错误,请重新输入!!!");
            }
            else
            {
                petShow(account, str[n - 1]); break;
            }
        }
    }

    //看完宠物之后选择
    public void petInterLast(string account, string petStr)
    {
        Console.WriteLine("**********************");
        Console.WriteLine("*     请选择操作     *");
        Console.WriteLine("*     1.购买宠物     *");
        Console.WriteLine("*     2.退出         *");
        Console.WriteLine("**********************");
        for (int i = 0; true; i++)
        {
            int n = new CreateID().InputDigit();
            switch (n)
            {
                case 1: changeDogPet(account, petStr); break;
                case 2: ShopMap(account, 3, 2); ; break;
                default:
                    Console.WriteLine("输入错误,请重新输入 ");
                    break;
            }
        }
    }

    //宠物列表
    public void petShow(string account, string petStr)
    {
        int num = 0;
        string[] str = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt");//每行读取
        Console.WriteLine("{0}宠物目录如下:", petStr);
        for (int i = 0; i < str.Length; i += 10)
        {
            num++;
            Console.WriteLine("{0}.  姓名:{1}  性别:{2}  等级:{3}  经验值:{4}  攻击力:{5}   防御力:{6}  血量值:{7}   品种:{8}  食量:{9}  价格:{10}  ", num, str[i], str[i + 1], str[i + 2], str[i + 3], str[i + 4], str[i + 5], str[i + 6], str[i + 7], str[i + 8], str[i + 9]);
        }

        petInterLast(account, petStr);//跳转选择界面
    }

    //购买宠物,并且加入到背包
    public void changeDogPet(string account, string petStr)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//每行读取玩家背包
        string[] str = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\PetShop\" + petStr + ".txt");//每行读取宠物列表
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        if (int.Parse(attributeStr[6]) < 1)
        {
            Console.WriteLine("背包空间不足,请扩充背包空间");
            Commodity(account, "buy");
        }

        Console.WriteLine("*请输入序号*");
        for (int i1 = 0; true; i1++)
        {

            int n = new CreateID().InputDigit();
            int num = n - 1;

            for (int i2 = 0; i2 < backpackStr.Length; i2 += 10)
            {
                if (backpackStr.Length != 10 && backpackStr[i2] == str[num * 10])
                {
                    Console.WriteLine("用户已经存在该宠物,请重新选择");
                    petInterLast(account, petStr);//跳转选择界面
                    break;
                }
                if (i2 == backpackStr.Length - 10 || backpackStr.Length == 10)
                {
                    if (float.Parse(backpackStr[0]) < float.Parse(str[num * 10 + 9]))
                    {
                        Console.WriteLine("余额不足,请充值!");
                        Commodity(account, "buy");
                        break;
                    }
                    else
                    {
                        backpackStr[0] = (float.Parse(backpackStr[0]) - float.Parse(str[num * 10 + 9])).ToString();
                        new CreateID().backpackRefresh(backpackStr, account);//背包刷新
                        new CreateID().attributeRefresh(attributeStr, account);//属性刷新,这里刷新背包空间
                        for (int i = 0; i < 10; i++)
                        {
                            File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", "\n" + str[num * 10 + i]);//在原有文本文件上添加
                        }

                        Console.WriteLine("购买成功");
                        Commodity(account, "buy");
                    }

                }
            }
        }
    }

    //观看背包列表
    public void accounterPacksack(string account, string fromWhile)
    {
        string[] playerID = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + @".txt");
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//每行读取背包
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");//每行玩家属性

        Console.WriteLine("用户名称:{0}\n会员等级:{1}\n用户等级:{2}\n用户金额:{3}\n用户食物:{4}\n用户药品:{5}\n宠物食物:{6}\n背包剩余空间:{7} ", playerID[6], attributeStr[0], attributeStr[1], backpackStr[0], backpackStr[2], backpackStr[3], backpackStr[4], attributeStr[6]);
        string petStr = "姓名性别等级经验攻击防御血量品种食量价格";
        int n = 0;
        Console.WriteLine("宠物信息:");
        for (int i = 10; i < backpackStr.Length; i++)
        {
            Console.Write(petStr[n]);
            n++;
            Console.Write(petStr[n] + ":");
            n++;
            Console.WriteLine(backpackStr[i]);
            if ((i + 1) % 10 == 0)
            {
                n = 0;
                Console.WriteLine("-------------------");
            }
        }

        returnWhile(account, fromWhile);
    }

    //卖掉宠物
    public void sellPet(string account)
    {
        string[] accountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//每行读取背包
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");//每行读取属性

        Console.WriteLine("宠物信息:");
        string petStr = "姓名性别等级经验攻击防御血量品种食量价格";
        int n = 0;
        Console.WriteLine("宠物信息:");
        for (int i = 10; i < accountStr.Length; i++)
        {
            Console.Write(petStr[n]);
            n++;
            Console.Write(petStr[n] + ":");
            n++;
            Console.WriteLine(accountStr[i]);
            if ((i + 1) % 10 == 0)
            {
                n = 0;
                Console.WriteLine("-------------------");
            }
        }
        Console.WriteLine("卖掉宠物将会以原来价格六折折现");
        Console.WriteLine("请输入宠物姓名:");
        for (int k = 0; k < 3; k++)
        {
            string name = Console.ReadLine();
            for (int i = 10; i < accountStr.Length; i += 10)
            {
                if (accountStr[i] == name)
                {
                    Console.WriteLine("再次确认是否卖掉,请输入“是”或者“否”");
                    string notarize = Console.ReadLine();
                    if (notarize == "是")
                    {
                        accountStr[0] = (float.Parse(accountStr[0]) + (0.6 * float.Parse(accountStr[i + 9]))).ToString();
                        for (int m = 0; m < i; m++)
                        {
                            if (m == 0)
                            {

                                File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", accountStr[m]);//在原有文本文件替换
                            }
                            else
                            {
                                File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", "\n" + accountStr[m]);//在原有文本文件上替换
                            }
                        }
                        for (int m = i + 10; m < accountStr.Length; m++)
                        {
                            File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", "\n" + accountStr[m]);//在原有文本文件上替换
                        }
                        Console.WriteLine("删除成功");
                        new CreateID().attributeRefresh(attributeStr, account);//在这里是为了刷新背包
                        Commodity(account, "sell");
                        break;
                    }
                    else
                    {
                        Console.WriteLine("返回宠物界面");
                        Commodity(account, "sell");
                        break;
                    }
                }
            }
            if (2 - k == 0)
            {
                Console.WriteLine("输入次数超过三次,自动退出");
                Commodity(account, "sell");
                break;
            }
            Console.WriteLine("还有{0}次机会,请重新输入宠物名字:", 2 - k);

        }
    }

    //充值界面
    public void rechargeInter(string account)
    {

        string[] accountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");//每行读取背包
        Console.WriteLine("**********************");
        Console.WriteLine("*   请选择充值金额   *");
        Console.WriteLine("*    1.10元1000金    *");
        Console.WriteLine("*    2.30元5000金    *");
        Console.WriteLine("*    3.50元12000金   *");
        Console.WriteLine("*    4.100元30000金  *");
        Console.WriteLine("*    5.退出          *");
        Console.WriteLine("**********************");

        int n = new CreateID().InputDigit();
        float num = 0;
        switch (n)
        {
            case 1: num = 1000; break;
            case 2: num = 5000; break;
            case 3: num = 12000; break;
            case 4: num = 30000; break;
            case 5: ShopMap(account, 5, 3); break;
            default:
                Console.WriteLine("输入错误,请重新输入,返回宠物商店界面");
                break;
        }
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");//每行玩家属性
        float money = float.Parse(accountStr[1]) + num;

        if (money >= 5000 && money < 150000)
        {
            attributeStr[0] = "VIP黑铁";//替换等级
        }
        else if (money >= 15000 && money < 50000)
        {
            attributeStr[0] = "VIP青铜";//替换等级
        }
        else if (money >= 50000 && money < 100000)
        {
            attributeStr[0] = "VIP白银";//替换等级
        }
        else if (money >= 100000)
        {
            attributeStr[0] = "VIP黄金";//替换等级
        }
        else
        {
            attributeStr[0] = "VIP0";//替换等级
        }

        accountStr[0] = (float.Parse(accountStr[0]) + num).ToString();//增加金钱
        accountStr[1] = (float.Parse(accountStr[1]) + num).ToString();//增加金钱
        //背包刷新
        new CreateID().backpackRefresh(accountStr, account);

        //刷新属性
        new CreateID().attributeRefresh(attributeStr, account);

        Console.WriteLine("充值成功!");
        rechargeInter(account);
    }

    //事物
    public void Thing(string account, string fromWhile, int _num)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        Console.WriteLine("当前剩余{0}单位粮食", backpackStr[2]);
        //购买食品
        if (fromWhile == "buy")
        {
            Console.WriteLine("1金等于100单位粮食 \n请输入购买金额:");
            int amount = new CreateID().InputDigit();
            if (float.Parse(attributeStr[6]) > amount)//判断背包空间
            {
                bool bo = new CreateID().IsAffirm();
                Console.WriteLine("是否确认购买{0}金{1}单位的粮食", amount, amount * 100);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) - amount).ToString();//金钱
                    backpackStr[2] = (float.Parse(backpackStr[2]) + (amount * 100)).ToString();//人的事物
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("购买成功!!!");

                }
                else
                {
                    Console.WriteLine("退出购买!!!");
                }
            }
            else
            {
                Console.WriteLine("背包空间不足,退出购买!");
            }

        }

        //卖出食品
        if (fromWhile == "sell")
        {
            Console.WriteLine("100单位粮食等于0.8金 \n请输入卖出粮食数量:");
            int amount = new CreateID().InputDigit();
            bool bo = new CreateID().IsAffirm();
            if (int.Parse(backpackStr[2]) > amount)
            {
                Console.WriteLine("是否确认卖出{0}单位粮食", amount);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) + amount * 0.008f).ToString();//金钱
                    backpackStr[2] = (float.Parse(backpackStr[2]) - amount).ToString();//人的背包--粮食
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("卖出成功!!!");

                }
                else
                {
                    Console.WriteLine("退出卖出!!!");
                }
            }
            else
            {
                Console.WriteLine("粮食不足,退出卖出");
            }

        }
        returnWhile(account, fromWhile);
    }

    //人食品
    public void Aliment(string account, string fromWhile)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        Console.WriteLine("当前剩余{0}单位粮食", backpackStr[2]);
        //购买食品
        if (fromWhile == "buy")
        {
            Console.WriteLine("1金等于100单位粮食 \n请输入购买金额:");
            int amount = new CreateID().InputDigit();
            if (float.Parse(attributeStr[6]) > amount)//判断背包空间
            {
                bool bo = new CreateID().IsAffirm();
                Console.WriteLine("是否确认购买{0}金{1}单位的粮食", amount, amount * 100);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) - amount).ToString();//金钱
                    backpackStr[2] = (float.Parse(backpackStr[2]) + (amount * 100)).ToString();//人的事物
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("购买成功!!!");

                }
                else
                {
                    Console.WriteLine("退出购买!!!");
                }
            }
            else
            {
                Console.WriteLine("背包空间不足,退出购买!");
            }

        }

        //卖出食品
        if (fromWhile == "sell")
        {
            Console.WriteLine("100单位粮食等于0.8金 \n请输入卖出粮食数量:");
            int amount = new CreateID().InputDigit();
            bool bo = new CreateID().IsAffirm();
            if (int.Parse(backpackStr[2]) > amount)
            {
                Console.WriteLine("是否确认卖出{0}单位粮食", amount);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) + amount * 0.008f).ToString();//金钱
                    backpackStr[2] = (float.Parse(backpackStr[2]) - amount).ToString();//人的背包--粮食
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("卖出成功!!!");

                }
                else
                {
                    Console.WriteLine("退出卖出!!!");
                }
            }
            else
            {
                Console.WriteLine("粮食不足,退出卖出");
            }

        }
        returnWhile(account, fromWhile);
    }

    //药品
    public void Drug(string account, string fromWhile)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        Console.WriteLine("当前剩余{0}粒药品", backpackStr[3]);
        //购买食品
        if (fromWhile == "buy")
        {
            Console.WriteLine("5金等于1粒药品 \n请输入购买药品数目:");
            int amount = new CreateID().InputDigit();
            if (float.Parse(attributeStr[6]) > amount)//判断背包空间
            {
                bool bo = new CreateID().IsAffirm();
                Console.WriteLine("是否确认购买{0}金{1}单位的粮食", amount * 5, amount);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) - amount * 5).ToString();//金钱
                    backpackStr[3] = (float.Parse(backpackStr[3]) + amount).ToString();//人的背包--药品
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("购买成功!!!");

                }
                else
                {
                    Console.WriteLine("退出购买!!!");
                }
            }
            else
            {
                Console.WriteLine("背包空间不足,退出购买!");
            }

        }

        //卖出食品
        if (fromWhile == "sell")
        {
            Console.WriteLine("1粒药品等于3金 \n请输入出售药品数目:");
            int amount = new CreateID().InputDigit();
            bool bo = new CreateID().IsAffirm();
            if (int.Parse(backpackStr[3]) > amount)
            {
                Console.WriteLine("是否确认卖出{0}粒药品", amount);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) + amount * 3).ToString();//金钱
                    backpackStr[3] = (float.Parse(backpackStr[3]) - amount).ToString();//人的背包--药品
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("购买成功!!!");

                }
                else
                {
                    Console.WriteLine("退出卖出!!!");
                }
            }
            else
            {
                Console.WriteLine("药品不足,退出卖出");
            }

        }



        returnWhile(account, fromWhile);

    }

    //宠物食物
    public void petFood(string account, string fromWhile)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        Console.WriteLine("当前剩余{0}单位宠物粮食", backpackStr[3]);
        //购买食品
        if (fromWhile == "buy")
        {
            Console.WriteLine("1金等于120单位宠物粮食 \n请输入购买金额:");
            int amount = new CreateID().InputDigit();
            if (float.Parse(attributeStr[6]) > amount)//判断背包空间
            {
                bool bo = new CreateID().IsAffirm();
                Console.WriteLine("是否确认购买{0}金{1}单位的宠物粮食", amount, amount * 120);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) - amount).ToString();//金钱
                    backpackStr[4] = (float.Parse(backpackStr[4]) + (amount * 120)).ToString();//人的背包--宠物食物
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("购买成功!!!");

                }
                else
                {
                    Console.WriteLine("退出购买!!!");
                }
            }
            else
            {
                Console.WriteLine("背包空间不足,退出购买!");
            }

        }

        //卖出食品
        if (fromWhile == "sell")
        {
            Console.WriteLine("100单位粮食等于0.6金 \n请输入卖出数量:");
            int amount = new CreateID().InputDigit();
            bool bo = new CreateID().IsAffirm();
            if (int.Parse(backpackStr[4]) > amount)
            {
                Console.WriteLine("是否确认卖出{0}单位宠物粮食", amount);
                if (bo)
                {
                    backpackStr[0] = (float.Parse(backpackStr[0]) + amount * 0.006f).ToString();//金钱
                    backpackStr[4] = (float.Parse(backpackStr[4]) - amount).ToString();//人的背包--宠物食物
                    new CreateID().backpackRefresh(backpackStr, account);
                    new CreateID().attributeRefresh(attributeStr, account);
                    Console.WriteLine("卖出成功!!!");

                }
                else
                {
                    Console.WriteLine("退出卖出!!!");
                }
            }
            else
            {
                Console.WriteLine("事物不足,退出赠送");
            }

        }



        returnWhile(account, fromWhile);

    }

    //判断返回到哪里
    public void returnWhile(string account, string fromWhile)
    {
        if (fromWhile == "buy")
        {
            Commodity(account, "buy");
        }
        if (fromWhile == "sell")
        {
            Commodity(account, "sell");
        }
        if (fromWhile == "give")
        {
            GiveInter(account);
        }
    }

    //赠送界面
    public void GiveInter(string account)
    {
        Console.WriteLine("************************");
        Console.WriteLine("*  请选择购买商品种类  *");
        Console.WriteLine("*        1.赠送对象    *");
        Console.WriteLine("*        2.玩家背包    *");
        Console.WriteLine("*        3.返回        *");
        Console.WriteLine("************************");
        while (true)
        {
            int n = new CreateID().InputDigit();
            switch (n)
            {
                case 1: GivingFriend(account); break;
                case 2: accounterPacksack(account, "give"); break;
                case 3: ShopMap(account, 5, 7); break;
                default:
                    Console.WriteLine("输入错误");
                    break;
            }

        }
    }

    //赠送商品
    public void GiveCommodity(string account, string friendAccount)
    {
        Console.WriteLine("************************");
        Console.WriteLine("*  请选择赠送商品种类  *");
        Console.WriteLine("*        1.食物        *");
        Console.WriteLine("*        2.药品        *");
        Console.WriteLine("*        3.宠物        *");
        Console.WriteLine("*        4.宠物食物    *");
        Console.WriteLine("*        5.退出        *");
        Console.WriteLine("************************");
        while (true)
        {
            int n = new CreateID().InputDigit();
            switch (n)
            {
                case 1: Console.Write("食物"); GivingThing(account, friendAccount, 2); break;
                case 2: Console.Write("药品"); GivingThing(account, friendAccount, 3); break;
                case 3: GivingPet(account, friendAccount); break;
                case 4: Console.Write("宠物食物"); GivingThing(account, friendAccount, 4); break;
                case 5: GiveInter(account); break;
                default:
                    Console.WriteLine("输入错误");
                    break;
            }

        }

    }

    //赠送宠物
    public void GivingPet(string account, string friendAccount)
    {
        string[] accountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        string[] friendStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + friendAccount + @"\backpack.txt");
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        string petStr = "姓名性别等级经验攻击防御血量品种食量价格";
        int n = 0;
        Console.WriteLine("宠物信息:");
        Console.WriteLine("宠物1.");
        for (int i = 10; i < accountStr.Length; i++)
        {

            Console.Write(petStr[n]);
            n++;
            Console.Write(petStr[n] + ":");
            n++;
            Console.WriteLine(accountStr[i]);
            if ((i + 1) % 10 == 0)
            {
                n = 0;
                Console.WriteLine("-------------------");
                Console.WriteLine("宠物{0}: ", ((i + 1) / 10) - 1);
            }
        }
        Console.WriteLine("请输入赠送宠物序号");
        while (true)
        {
            int num = new CreateID().InputDigit();
            if ((accountStr.Length / 10) > num)
            {
                for (int i = 10; i <= friendStr.Length; i += 10)
                {
                    if (friendStr.Length != 10 && accountStr[10 * num] == friendStr[i])
                    {
                        Console.WriteLine("您的朋友已有该宠物,请重新");
                        GiveCommodity(account, friendAccount);
                    }
                    if (friendStr.Length == 10 || i == friendStr.Length - 10)
                    {
                        int tmp = num * 10;
                        //好友背包刷新
                        for (int m = 0; m < 10; m++)
                        {
                            File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + friendAccount + @"\backpack.txt", "\n" + accountStr[tmp + m]);//在原有文本文件上增加
                        }

                        //玩家自己刷新背包
                        for (int m = 0; m < tmp; m++)
                        {
                            if (m == 0)
                            {

                                File.WriteAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", accountStr[m]);//在原有文本文件替换
                            }
                            else
                            {
                                File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", "\n" + accountStr[m]);//在原有文本文件上增加
                            }
                        }
                        for (int m = tmp + 10; m < accountStr.Length; m++)
                        {
                            File.AppendAllText(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt", "\n" + accountStr[m]);//在原有文本文件上增加
                        }
                        new CreateID().attributeRefresh(attributeStr, account);//刷新玩家背包空间
                        Console.WriteLine("赠送成功");
                        GiveCommodity(account, friendAccount);


                    }
                }

            }
            else
            {
                Console.WriteLine("请重新输入");
            }

        }


    }

    //赠送食品
    public void GivingThing(string account, string friendAccount, int _num)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        string[] friendStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + friendAccount + @"\backpack.txt");
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        Console.WriteLine("当前剩余量为{0}", backpackStr[_num]);
        Console.WriteLine("请输入赠送数量");
        int amount = new CreateID().InputDigit();
        if (int.Parse(backpackStr[_num]) >= amount)
        {
            bool bo = new CreateID().IsAffirm();
            Console.WriteLine("是否确认赠送");
            if (bo)
            {
                if (_num == 2)
                {
                    backpackStr[2] = (float.Parse(backpackStr[2]) - amount).ToString();//人的背包--食物
                }
                if (_num == 3)
                {
                    backpackStr[3] = (float.Parse(backpackStr[3]) - amount).ToString();//人的背包--药品
                }
                if (_num == 4)
                {
                    backpackStr[4] = (float.Parse(backpackStr[4]) - amount).ToString();//人的背包--食物
                }
                new CreateID().backpackRefresh(backpackStr, account);
                new CreateID().attributeRefresh(attributeStr, account);
                Console.WriteLine("赠送成功!!!");

            }
            else
            {
                Console.WriteLine("退出赠送!!!");
            }
        }
        else
        {
            Console.WriteLine("数量不足,请重新选择");
        }

        GiveCommodity(account, friendAccount);

    }

    //判断玩家是否存在
    public void GivingFriend(string account)
    {
        List<string> list = new CreateID().PlayerFilename();//获取所有玩家账号           
        Console.WriteLine("请输入对方网名");
        string friendAccount = Console.ReadLine();
        for (int i = 0; i < list.Count; i++)
        {
            string[] playerID = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + list[i] + @".txt");
            if (friendAccount == playerID[6])
            {
                GiveCommodity(account, list[i]);
            }
            if (list.Count == i - 1)
            {
                Console.WriteLine("没有该玩家");
                GiveInter(account);
            }
        }

    }

}

//教学楼
public class TeachingBuild
{
    //生成教学楼地图
    public void TeachingBuildMap(string account)
    {
        int a = 0;
        int b = 0;
        int[,] TeachingBuildStr = new int[,]
         {
            {1,1,1,1,1,1,1,1,1,1,1,1 },
            {1,2,2,2,2,0,0,2,2,2,2,1 },
            {1,9,2,9,2,0,0,2,9,2,9,1 },
            {1,2,2,2,2,0,0,2,2,2,2,1 },
            {1,9,2,9,2,0,0,2,9,2,9,1 },
            {1,2,2,2,0,0,0,0,2,2,2,1 },
            {1,2,2,2,2,0,0,2,2,2,2,1 },
            {1,0,0,0,0,0,0,0,0,0,3,0 },
            {1,2,2,2,2,0,0,2,2,2,2,1 },
            {1,2,2,2,0,0,0,0,2,2,2,1 },
            {1,9,2,9,2,0,0,2,9,2,9,1 },
            {1,2,2,2,2,0,0,2,2,2,2,1 },
            {1,9,2,9,2,0,0,2,9,2,9,1 },
            {1,2,2,2,2,0,0,2,2,2,2,1 },
            {1,1,1,1,1,1,1,1,1,1,1,1}
         };
        string phraseStr = "学堂耐久教室教室负重幸运教室教室";
        int n = 0;

        for (int i = 0; i < TeachingBuildStr.GetLength(0); i++)
        {
            for (int j = 0; j < TeachingBuildStr.GetLength(1); j++)
            {
                if (TeachingBuildStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (TeachingBuildStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (TeachingBuildStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (TeachingBuildStr[i, j] == 3)
                {
                    a = i;
                    b = j;
                    Console.Write("★");
                }
                if (TeachingBuildStr[i, j] == 9)
                {
                    Console.Write(phraseStr[n]);
                    n++;
                }
            }
            Console.WriteLine();
        }
        TeachingBuildRemove(account, TeachingBuildStr, a, b);

    }

    //人物在教学楼移动
    public void TeachingBuildRemove(string account, int[,] TeachingBuildStr, int a, int b)
    {
        string phraseStr = "学堂耐久教室教室负重幸运教室教室";
        //string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        int x = a;
        int y = b;
        while (true)
        {
            new CreateID().Adequatefood(account);//判断玩家食物以及宠物食物是否充足
            //获取玩家属性
            string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
            //玩家耐久力判断,一旦达到某个值就会自动休息
            new CreateID().DurabilityVerdict(attributeStr, account);
            bool bo = false;
            int rpgX = 0;//控制人物上下
            int rpgY = 0;//控制人物左右

            char ch = Console.ReadKey().KeyChar;

            #region 判断移动方向
            if (ch == 'w' || ch == 'W')
            {
                rpgX = -1;
            }
            if (ch == 's' || ch == 'S')
            {
                rpgX = 1;
            }
            if (ch == 'a' || ch == 'A')
            {
                rpgY = -1;
            }
            if (ch == 'd' || ch == 'D')
            {
                rpgY = 1;
            }
            #endregion

            if (x + rpgX >= TeachingBuildStr.GetLength(0) || y + rpgY >= TeachingBuildStr.GetLength(1))
            {
                continue;
            }
            else if (TeachingBuildStr[x + rpgX, y + rpgY] == 1 || TeachingBuildStr[x + rpgX, y + rpgY] == 2 || TeachingBuildStr[x + rpgX, y + rpgY] == 9)
            {
                continue;
            }
            else
            {
                TeachingBuildStr[x + rpgX, y + rpgY] = 3;
                TeachingBuildStr[x, y] = 0;
                new School().SchoolMapRefresh(TeachingBuildStr, phraseStr);
                //TeachingBuildMapRefresh(TeachingBuildStr);
                Console.Clear();
                new School().SchoolMapRefresh(TeachingBuildStr, phraseStr);
                //TeachingBuildMapRefresh(TeachingBuildStr);

                if (x + rpgX == 7 && y + rpgY == 11)
                {
                    Console.WriteLine("退出教学楼");
                    new School().SchoolMap(account);
                }
                if (x + rpgX == 5 && y + rpgY == 4)
                {
                    Console.WriteLine("进入学堂教室");
                    Console.WriteLine("正在提高智力,请稍后");
                    for (int i = 0; i < 4; i++)
                    {
                        Thread.Sleep(800);
                        Console.Write(">");
                    }
                    attributeStr[2] = (float.Parse(attributeStr[2]) + 4).ToString();
                    attributeStr[3] = (float.Parse(attributeStr[3]) + 4).ToString();
                    Console.WriteLine("提高完成!");
                }
                if (x + rpgX == 5 && y + rpgY == 7)
                {
                    Console.WriteLine("进入耐久教室");
                    Console.WriteLine("正在提高耐久力,请稍后");
                    for (int i = 0; i < 5; i++)
                    {
                        Thread.Sleep(800);
                        Console.Write(">");
                    }
                    attributeStr[4] = (float.Parse(attributeStr[4]) + 5).ToString();
                    attributeStr[5] = (float.Parse(attributeStr[5]) + 5).ToString();
                    Console.WriteLine("提高完成!");
                }
                if (x + rpgX == 9 && y + rpgY == 4)
                {
                    Console.WriteLine("进入负重教室");
                    Console.WriteLine("正在提高负重,请稍后");
                    for (int i = 0; i < 4; i++)
                    {
                        Thread.Sleep(800);
                        Console.Write(">");
                    }
                    attributeStr[6] = (float.Parse(attributeStr[6]) + 4).ToString();
                    attributeStr[7] = (float.Parse(attributeStr[7]) + 4).ToString();
                    Console.WriteLine("提高完成!");
                }
                if (x + rpgX == 9 && y + rpgY == 7)
                {
                    Console.WriteLine("进入魅力教室");
                    Console.WriteLine("正在提高魅力,请稍后");
                    for (int i = 0; i < 2; i++)
                    {
                        Thread.Sleep(800);
                        Console.Write(">");
                    }
                    attributeStr[8] = (float.Parse(attributeStr[8]) + 2).ToString();
                    attributeStr[9] = (float.Parse(attributeStr[9]) + 2).ToString();
                    Console.WriteLine("提高完成!");
                }

                bo = true;
            }
            if (bo == true)
            {
                x += rpgX;
                y += rpgY;

                new CreateID().attributeRefresh(attributeStr, account);
                new CreateID().Consume(account);//减少玩家耐久以及食物
            }

        }

    }

}

//宿舍
public class Dormitory
{
    //宿舍地图
    public void DormitoryMap(string account, int a, int b)
    {

        int[,] DormitoryMapStr = new int[,]
        {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
            {1,9,9,9,2,9,9,9,2,0,2,9,9,9,2,9,9,9,1 },
            {1,2,0,2,2,2,0,2,2,0,2,2,0,2,2,2,0,2,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,2,0,2,2,2,0,2,2,0,2,2,0,2,2,2,0,2,1 },
            {1,9,9,9,2,9,9,9,2,0,2,9,9,9,2,9,9,9,1 },
            {1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1 }
        };
        DormitoryMapStr[a, b] = 3;
        string DormitoryStr = "一号寝三号寝五号寝七号寝二号寝四号寝六号寝四号寝";
        int n = 0;
        for (int i = 0; i < DormitoryMapStr.GetLength(0); i++)
        {
            for (int j = 0; j < DormitoryMapStr.GetLength(1); j++)
            {
                if (DormitoryMapStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (DormitoryMapStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (DormitoryMapStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (DormitoryMapStr[i, j] == 3)
                {

                    Console.Write("★");
                }
                if (DormitoryMapStr[i, j] == 9)
                {
                    Console.Write(DormitoryStr[n]);
                    n++;
                }
            }
            Console.WriteLine();
        }
        BedNo(account);
        DormitoryRpgRemove(account, DormitoryMapStr, a, b);
    }

    //女生宿舍
    public void DormitoryWomanMap(string account, int a, int b)
    {

        int[,] DormitoryMapStr = new int[,]
        {
            {1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1 },
            {1,9,9,9,2,9,9,9,2,0,2,9,9,9,2,9,9,9,1 },
            {1,2,0,2,2,2,0,2,2,0,2,2,0,2,2,2,0,2,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,2,0,2,2,2,0,2,2,0,2,2,0,2,2,2,0,2,1 },
            {1,9,9,9,2,9,9,9,2,0,2,9,9,9,2,9,9,9,1 },
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }
        };
        DormitoryMapStr[a, b] = 3;
        string DormitoryStr = "一号寝三号寝五号寝七号寝二号寝四号寝六号寝四号寝";
        int n = 0;
        for (int i = 0; i < DormitoryMapStr.GetLength(0); i++)
        {
            for (int j = 0; j < DormitoryMapStr.GetLength(1); j++)
            {
                if (DormitoryMapStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (DormitoryMapStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (DormitoryMapStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (DormitoryMapStr[i, j] == 3)
                {

                    Console.Write("★");
                }
                if (DormitoryMapStr[i, j] == 9)
                {
                    Console.Write(DormitoryStr[n]);
                    n++;
                }
            }
            Console.WriteLine();
        }
        BedNo(account);
        DormitoryRpgRemove(account, DormitoryMapStr, a, b);
    }

    //人物在宿舍移动
    public void DormitoryRpgRemove(string account, int[,] DormitoryMapStr, int a, int b)
    {
        string DormitoryStr = "一号寝三号寝五号寝七号寝二号寝四号寝六号寝四号寝";
        //string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        int x = a;
        int y = b;
        while (true)
        {
            new CreateID().Adequatefood(account);//判断玩家食物以及宠物食物是否充足

            //获取玩家属性
            string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
            //玩家耐久力判断,一旦达到某个值就会自动休息
            new CreateID().DurabilityVerdict(attributeStr, account);
            bool bo = false;
            int rpgX = 0;//控制人物上下
            int rpgY = 0;//控制人物左右

            char ch = Console.ReadKey().KeyChar;

            #region 判断移动方向
            if (ch == 'w' || ch == 'W')
            {
                rpgX = -1;
            }
            if (ch == 's' || ch == 'S')
            {
                rpgX = 1;
            }
            if (ch == 'a' || ch == 'A')
            {
                rpgY = -1;
            }
            if (ch == 'd' || ch == 'D')
            {
                rpgY = 1;
            }
            #endregion

            if (x + rpgX >= DormitoryMapStr.GetLength(0) || y + rpgY >= DormitoryMapStr.GetLength(1))
            {
                continue;
            }
            if (x + rpgX < 0 || x + rpgX >= DormitoryMapStr.Length)
            {
                continue;
            }
            else if (DormitoryMapStr[x + rpgX, y + rpgY] == 1 || DormitoryMapStr[x + rpgX, y + rpgY] == 2 || DormitoryMapStr[x + rpgX, y + rpgY] == 9)
            {
                continue;
            }
            else
            {
                DormitoryMapStr[x + rpgX, y + rpgY] = 3;
                DormitoryMapStr[x, y] = 0;
                new School().SchoolMapRefresh(DormitoryMapStr, DormitoryStr);
                //DormitoryMapRefresh(DormitoryMapStr);
                Console.Clear();
                new School().SchoolMapRefresh(DormitoryMapStr, DormitoryStr);
                //DormitoryMapRefresh(DormitoryMapStr);

                if ((x + rpgX == 6 && y + rpgY == 9) || (x + rpgX == 0 && y + rpgY == 9))
                {
                    Console.WriteLine("退出宿舍");
                    new School().SchoolMap(account);
                }
                if (x + rpgX == 2 && y + rpgY == 2)
                {
                    Console.WriteLine("进入宿舍房间");
                    new DormitoryRoom().DormitoryRoomMap(account, 8, 3);
                }


                bo = true;
            }
            if (bo == true)
            {
                x += rpgX;
                y += rpgY;
                //刷新玩家属性
                attributeStr[4] = (float.Parse(attributeStr[4]) - 1).ToString();
                new CreateID().attributeRefresh(attributeStr, account);
                new CreateID().Consume(account);//减少玩家耐久以及食物
            }

        }
    }

    //宿舍坐标以及成员更新
    public void DormitoryVection2Refresh(string account, string[] DormitoryStr)
    {
        string[] accountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");

        string HowSex = "";
        if (accountStr[2] == "男")
        {
            HowSex = "DormitoryMan";
        }

        if (accountStr[2] == "女")
        {
            HowSex = "DormitoryWoman";
        }

        for (int i = 0; i < DormitoryStr.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\SystemMessage\" + HowSex + @"\Vection2.txt", DormitoryStr[i]);//在原有文本文件替换
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\" + HowSex + @"\Vection2.txt", "\n" + DormitoryStr[i]);//在原有文本文件上替换
            }
        }

    }

    //判断床铺号
    public void BedNo(string account)
    {
        bool bo = false;
        int n = 0;

        string[] accountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");

        string HowSex = "";
        if (accountStr[2] == "男")
        {
            HowSex = "DormitoryMan";
        }

        if (accountStr[2] == "女")
        {
            HowSex = "DormitoryWoman";
        }

        //获取宿舍情况
        string[] DormitoryStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\" + HowSex + @"\Vection2.txt");

        //获取玩家网名
        string[] PlayerStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");

        for (int i = 0; i < DormitoryStr.Length; i += 10)
        {
            for (int j = i + 3; j < i + 7; j++)
            {
                if (DormitoryStr[j] == PlayerStr[6])
                {
                    Console.WriteLine("{0}同学的宿舍位置是{1}号寝{2}号铺", PlayerStr[6], DormitoryStr[i + 9], n + 1);
                    bo = true;
                    break;
                }
                n++;
            }
            if (bo == true)
            {
                break;
            }
        }

    }


}

//宿舍房间
public class DormitoryRoom
{
    //宿舍地图
    public void DormitoryRoomMap(string account, int a, int b)
    {
        //获取宿舍情况
        string[] DormitoryStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\DormitoryMan\Vection2.txt");

        int[,] DormitoryRoomStr = new int[,]
        {
            {1,1,1,1,1,1,1},
            {1,9,2,0,2,9,1},
            {1,9,0,0,0,9,1},
            {1,9,2,0,2,9,1},
            {1,2,2,0,2,2,1},
            {1,9,2,0,2,9,1},
            {1,9,0,0,0,9,1},
            {1,9,2,0,2,9,1},
            {1,1,1,0,1,1,1}

        };
        DormitoryRoomStr[a, b] = 3;
        string RoomStr = "一二号号铺铺三四号号铺铺";
        int n = 0;
        for (int i = 0; i < DormitoryRoomStr.GetLength(0); i++)
        {
            for (int j = 0; j < DormitoryRoomStr.GetLength(1); j++)
            {
                if (DormitoryRoomStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (DormitoryRoomStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (DormitoryRoomStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (DormitoryRoomStr[i, j] == 3)
                {
                    Console.Write("★");
                }
                if (DormitoryRoomStr[i, j] == 9)
                {
                    Console.Write(RoomStr[n]);
                    n++;
                }
            }
            Console.WriteLine();
        }


        DormitoryRoomRemove(account, DormitoryRoomStr, a, b);
    }

    //在宿舍房间里移动
    public void DormitoryRoomRemove(string account, int[,] DormitoryRoomStr, int a, int b)
    {
        string RoomStr = "一二号号铺铺三四号号铺铺";
        string[] AccountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
        int x = a;
        int y = b;
        while (true)
        {
            new CreateID().Adequatefood(account);//判断玩家食物以及宠物食物是否充足
            //获取玩家属性
            string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
            //玩家耐久力判断,一旦达到某个值就会自动休息
            new CreateID().DurabilityVerdict(attributeStr, account);
            bool bo = false;
            int rpgX = 0;//控制人物上下
            int rpgY = 0;//控制人物左右

            char ch = Console.ReadKey().KeyChar;

            #region 判断移动方向
            if (ch == 'w' || ch == 'W')
            {
                rpgX = -1;
            }
            if (ch == 's' || ch == 'S')
            {
                rpgX = 1;
            }
            if (ch == 'a' || ch == 'A')
            {
                rpgY = -1;
            }
            if (ch == 'd' || ch == 'D')
            {
                rpgY = 1;
            }
            #endregion
            if (x + rpgX >= DormitoryRoomStr.GetLength(0) || y + rpgY >= DormitoryRoomStr.GetLength(1))
            {
                continue;
            }
            if (DormitoryRoomStr[x + rpgX, y + rpgY] == 1 || DormitoryRoomStr[x + rpgX, y + rpgY] == 2 || DormitoryRoomStr[x + rpgX, y + rpgY] == 9)
            {
                continue;
            }
            else
            {
                DormitoryRoomStr[x + rpgX, y + rpgY] = 3;
                DormitoryRoomStr[x, y] = 0;
                new School().SchoolMapRefresh(DormitoryRoomStr, RoomStr);
                //DormitoryMapRefresh(DormitoryMapStr);
                Console.Clear();
                new School().SchoolMapRefresh(DormitoryRoomStr, RoomStr);
                //DormitoryMapRefresh(DormitoryMapStr);


                bool bo1 = false;
                int n = 0;
                string[] accountStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");
                string HowSex = "";
                if (accountStr[2] == "男")
                {
                    HowSex = "DormitoryMan";
                }
                if (accountStr[2] == "女")
                {
                    HowSex = "DormitoryWoman";
                }
                //获取宿舍情况
                string[] DormitoryStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\" + HowSex + @"\Vection2.txt");
                //获取玩家网名
                string[] PlayerStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerData\" + account + ".txt");



                if (x + rpgX == 8 && y + rpgY == 3)
                {

                    for (int i = 0; i < DormitoryStr.Length; i += 10)
                    {
                        for (int j = i + 3; j < i + 7; j++)
                        {
                            if (DormitoryStr[j] == PlayerStr[6])
                            {

                                if (accountStr[2] == "男")
                                {

                                    new Dormitory().DormitoryMap(account, int.Parse(DormitoryStr[0]), int.Parse(DormitoryStr[1]));
                                }

                                if (accountStr[2] == "女")
                                {

                                    new Dormitory().DormitoryWomanMap(account, int.Parse(DormitoryStr[0]), int.Parse(DormitoryStr[1]));
                                }
                                break;
                            }
                        }
                    }


                }

                int bedWhile = 0;
                bool bolBed = false;
                for (int i = 0; i < DormitoryStr.Length; i += 10)
                {
                    int numBed = 0;
                    for (int j = i + 3; j < i + 7; j++)
                    {
                        numBed++;
                        if (DormitoryStr[j] == PlayerStr[6])
                        {
                            bedWhile = numBed;
                            bolBed = true;
                            break;
                        }
                    }
                    if (bolBed == true)
                    {
                        break;
                    }
                }

                if (bedWhile == 1 && x + rpgX == 2 && y + rpgY == 2)
                {
                    RoomChange(account, x + rpgX, y + rpgY);
                }

                if (bedWhile == 2 && x + rpgX == 2 && y + rpgY == 4)
                {
                    RoomChange(account, x + rpgX, y + rpgY);
                }

                if (bedWhile == 3 && x + rpgX == 6 && y + rpgY == 2)
                {
                    RoomChange(account, x + rpgX, y + rpgY);
                }

                if (bedWhile == 4 && x + rpgX == 6 && y + rpgY == 4)
                {
                    RoomChange(account, x + rpgX, y + rpgY);
                }

                bo = true;
            }
            if (bo == true)
            {
                x += rpgX;
                y += rpgY;

                new CreateID().attributeRefresh(attributeStr, account);
                new CreateID().Consume(account);//减少玩家耐久以及食物
            }

        }
    }

    //进入床铺后选项
    public void RoomChange(string account, int a, int b)
    {
        Console.WriteLine("****************");
        Console.WriteLine("*  请选择操作  *");
        Console.WriteLine("*   1.休息     *");
        Console.WriteLine("*   2.贪吃蛇   *");
        Console.WriteLine("*   3.推箱子   *");
        Console.WriteLine("*   4.玩家属性 *");
        Console.WriteLine("*   5.退出     *");
        Console.WriteLine("****************");
        while (true)
        {
            int n = new CreateID().InputDigit();
            switch (n)
            {
                case 1: RecoverEndurance(account, a, b); break;
                case 2: new SnakeCoordinate().Inter(account, a, b); break;
                case 3: new Sokoban().Inter(account, a, b); break;
                case 4: new CreateID().AllInformation(account, a, b); break;
                case 5: DormitoryRoomMap(account, a, b); break;
                default:
                    Console.WriteLine("输入错误");
                    break;
            }


        }



    }

    //恢复耐力
    public void RecoverEndurance(string account, int a, int b)
    {
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        attributeStr[4] = attributeStr[5];
        new CreateID().attributeRefresh(attributeStr, account);
        Console.WriteLine("休息中:");
        for (int i = 0; i < 10; i++)
        {
            Thread.Sleep(800);
            Console.Write(">");
        }
        Console.WriteLine();
        Console.WriteLine("休息一下真好!!!");
        RoomChange(account, a, b);
    }

}

//冒险岛
public class Adventure
{
    //冒险岛地图
    public void AdventureMap(string account, int a, int b)
    {
        int[,] AdventureMapStr = new int[,]
        {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
            {1,2,0,1,0,0,0,0,0,0,0,0,0,0,0,2,1 },
            {1,1,0,1,0,1,0,1,1,0,1,1,1,1,1,1,1 },
            {1,2,0,0,0,1,0,0,1,0,1,2,1,0,0,2,1 },
            {1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1 },
            {1,2,0,0,0,0,0,0,1,0,0,0,0,0,1,2,1 },
            {1,1,1,1,0,1,1,1,1,0,1,1,1,0,1,0,1 },
            {1,0,0,0,0,0,0,2,1,2,1,2,0,0,1,0,1 },
            {1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1 },
            {1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1 },
            {1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1 }
        };
        AdventureMapStr[a, b] = 3;
        for (int i = 0; i < AdventureMapStr.GetLength(0); i++)
        {
            for (int j = 0; j < AdventureMapStr.GetLength(1); j++)
            {
                if (AdventureMapStr[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (AdventureMapStr[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (AdventureMapStr[i, j] == 2)
                {
                    Console.Write("※");
                }
                if (AdventureMapStr[i, j] == 3)
                {
                    Console.Write("★");
                }

            }
            Console.WriteLine();
        }
        AdventureRemove(account, AdventureMapStr, a, b);
    }

    //人物移动
    public void AdventureRemove(string account, int[,] AdventureMapStr, int a, int b)
    {
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");//获取玩家属性里面的幸运值
        int LickValue = int.Parse(attributeStr[8]) / 20;

        int x = a;
        int y = b;
        while (true)
        {

            new CreateID().Adequatefood(account);//判断玩家食物以及宠物食物是否充足
            //玩家耐久力判断,一旦达到某个值就会自动休息
            new CreateID().DurabilityVerdict(attributeStr, account);

            bool boBad1 = false;
            bool boBad2 = false;
            for (int i = 0; i < AdventureMapStr.GetLength(0); i++)
            {
                for (int j = 0; j < AdventureMapStr.GetLength(1); j++)
                {
                    if (AdventureMapStr[i, j] == 4)
                    {
                        boBad1 = true;
                        boBad2 = true;
                        break;
                    }
                    if (i == AdventureMapStr.GetLength(0) - 1 && j == AdventureMapStr.GetLength(1) - 1)
                    {
                        boBad1 = false;
                        boBad2 = true;
                        break;
                    }
                }
                if (boBad2 == true)
                {
                    break;
                }
            }

            if (boBad1 == false)
            {
                Vection2 GiftBad = RandomGiftBad(AdventureMapStr);//随机生成礼包
                AdventureMapStr[GiftBad.x, GiftBad.y] = 4;
            }






            没运动一次刷新玩家背包
            //string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
            玩家属性
            //string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
            玩家耐久力判断,一旦达到某个值就会自动休息
            //new CreateID().DurabilityVerdict(attributeStr, account);
            等级判断
            //new CreateID().HierarchyVerdict(attributeStr, account);


            bool bo = false;
            int rpgX = 0;//控制人物上下
            int rpgY = 0;//控制人物左右

            char ch = Console.ReadKey().KeyChar;

            #region 判断移动方向
            if (ch == 'w' || ch == 'W')
            {
                rpgX = -1;
            }
            if (ch == 's' || ch == 'S')
            {
                rpgX = 1;
            }
            if (ch == 'a' || ch == 'A')
            {
                rpgY = -1;
            }
            if (ch == 'd' || ch == 'D')
            {
                rpgY = 1;
            }
            #endregion

            if (AdventureMapStr[x + rpgX, y + rpgY] == 1)
            {
                continue;
            }
            else
            {
                if (x + rpgX == 10 && y + rpgY == 8 || x + rpgX == 10 && y + rpgY == 10)
                {
                    Console.WriteLine("冒险返回");
                    new School().SchoolMap(account);
                }
                //遇到宝物
                bool boGift = false;
                if (AdventureMapStr[x + rpgX, y + rpgY] == 4)
                {
                    boGift = true;
                }


                AdventureMapStr[x + rpgX, y + rpgY] = 3;
                AdventureMapStr[x, y] = 0;
                new School().SchoolMapRefresh(AdventureMapStr, "  ");
                Console.Clear();
                new School().SchoolMapRefresh(AdventureMapStr, "  ");

                if (boGift)
                {
                    string[] TreasureStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt");
                    Console.WriteLine("遇到宝物");
                    Random LickRdom = new Random();
                    GetTreasure(account, (LickRdom.Next(LickValue, TreasureStr.Length + 1)) / 2);

                }

                if (x + rpgX == 2 && y + rpgY == 9)
                {
                    Console.WriteLine("怪物等级偏高,请慎入!!!");
                }
                if (x + rpgX == 8 && y + rpgY == 15)
                {
                    Console.WriteLine("即将遇到最终大boos");
                }
                Random radMonster = new Random();
                //怪物1                            //怪物2                         //怪物3                            //怪物4                            //怪物5                                
                if (x + rpgX == 7 && y + rpgY == 7 || x + rpgX == 5 && y + rpgY == 1 || x + rpgX == 1 && y + rpgY == 1 || x + rpgX == 3 && y + rpgY == 1 || x + rpgX == 7 && y + rpgY == 7)
                {
                    Console.WriteLine("遭遇怪物");
                    EncounterMonster(account, radMonster.Next(1, 6), x + rpgX, y + rpgY, rpgX, rpgY);
                }

                //怪物6--9
                if (x + rpgX == 1 && y + rpgY == 15 || x + rpgX == 3 && y + rpgY == 11 || x + rpgX == 3 && y + rpgY == 15 || x + rpgX == 7 && y + rpgY == 11)
                {
                    Console.WriteLine("遭遇怪物");
                    EncounterMonster(account, radMonster.Next(6, 10), x + rpgX, y + rpgY, rpgX, rpgY);
                }
                //怪物10
                if (x + rpgX == 5 && y + rpgY == 15)
                {
                    Console.WriteLine("遭遇怪物");
                    EncounterMonster(account, 10, x + rpgX, y + rpgY, rpgX, rpgY);
                }


                bo = true;

            }
            if (bo == true)
            {
                x += rpgX;
                y += rpgY;
                new CreateID().Consume(account);//减少玩家耐久以及食物
            }

        }


    }

    //遭遇怪物
    public void EncounterMonster(string account, int MonNum, int x, int y, int RpgX, int RpgY)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");

        Console.WriteLine("是否战斗");
        bool bo = new CreateID().IsAffirm();
        if (bo)
        {
            PetList(account);
            Console.WriteLine("请选择出战宠物,输入序号:");
            while (true)
            {
                int n = new CreateID().InputDigit();
                if (n < (backpackStr.Length / 10) && n > 0)
                {
                    Random rd = new Random();
                    int num = rd.Next(1, 3);
                    //backpackStr[i+0],backpackStr[i + 2],backpackStr[i + 3],backpackStr[i + 4],backpackStr[i + 5]
                    File.WriteAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\PlayerPet.txt", backpackStr[n * 10 + 0]);
                    File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\PlayerPet.txt", "\n" + backpackStr[n * 10 + 2]);
                    File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\PlayerPet.txt", "\n" + backpackStr[n * 10 + 4]);
                    File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\PlayerPet.txt", "\n" + backpackStr[n * 10 + 5]);
                    File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\PlayerPet.txt", "\n" + backpackStr[n * 10 + 6]);

                    string[] MonsterStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\Monster.txt");
                    for (int i = 0; i < 5; i++)
                    {
                        if (i == 0)
                        {
                            File.WriteAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\HitOut.txt", MonsterStr[(MonNum - 1) * 5 + i]);
                        }
                        else
                        {
                            File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\HitOut.txt", "\n" + MonsterStr[(MonNum - 1) * 5 + i]);
                        }

                    }


                    Autofight(account, n, x, y);//自动战斗
                }
                else
                {
                    Console.WriteLine("输入错误,请重新输入");
                }

            }

        }
        else
        {
            AdventureMap(account, x - RpgX, y - RpgY);
        }
    }

    //自动战斗
    public void Autofight(string account, int n, int x, int y)
    {
        while (true)
        {
            string[] playerPetStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\PlayerPet.txt");
            string[] enemyStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\HitOut.txt");
            string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
            string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");//获取玩家属性里面的幸运值

            if (float.Parse(playerPetStr[4]) <= 0)
            {
                Console.WriteLine("宠物死亡,任务失败");
                Quit(account, n, x, y);
            }

            if (float.Parse(enemyStr[4]) <= 0)
            {
                Console.WriteLine("宠物胜利,过关");
                PetWin(account, n, x, y);
            }

            Thread.Sleep(500);
            //玩家宠物攻击
            Console.WriteLine("我方宠物开始攻击-->");
            Random pet = new Random();
            int petNum = pet.Next(2, 6);
            if (petNum >= 4)
            {
                Console.WriteLine("怪物轻飘飘闪避我方宠物攻击!");
            }
            else
            {
                if (petNum == 2)
                {
                    Console.WriteLine("怪物竟然反击也发起攻击");
                    if (float.Parse(playerPetStr[2]) > float.Parse(enemyStr[2]))
                    {
                        Console.WriteLine("我方宠物攻击力大于怪物攻击力,怪物受到{0}点伤害", (float.Parse(playerPetStr[2]) - float.Parse(enemyStr[2])));
                        enemyStr[4] = (float.Parse(enemyStr[4]) - float.Parse(playerPetStr[2]) + float.Parse(enemyStr[2])).ToString();
                    }
                    else
                    {
                        Console.WriteLine("怪物宠物反击见效,我方宠物受到{0}点伤害", (float.Parse(enemyStr[2]) - float.Parse(playerPetStr[2])));
                        playerPetStr[4] = (float.Parse(playerPetStr[4]) - float.Parse(enemyStr[2]) + float.Parse(playerPetStr[2])).ToString();
                    }
                }

                if (petNum == 3)
                {
                    Console.WriteLine("怪物进行防御>>>");
                    if (float.Parse(playerPetStr[2]) > float.Parse(enemyStr[3]))
                    {
                        Console.WriteLine("我方宠物攻破怪物防御,怪物受到{0}点伤害", (float.Parse(playerPetStr[2]) - float.Parse(enemyStr[3])));
                        enemyStr[4] = (float.Parse(enemyStr[4]) - float.Parse(playerPetStr[2]) + float.Parse(enemyStr[3])).ToString();
                    }
                    else
                    {
                        Console.WriteLine("怪物皮糙肉厚,我方宠物未攻破怪物防御!!!(*_*)");
                    }
                }

            }

            Thread.Sleep(500);
            //怪物攻击
            Console.WriteLine("怪物发动攻击-->");
            int NumStr = int.Parse(attributeStr[2]) / 50;//智力值来让玩家宠物躲避攻击
            Random enemy = new Random();
            int enenyNum = enemy.Next(2, 5 + NumStr);
            if (enenyNum >= 4)
            {
                Console.WriteLine("我方宠物麻溜地躲避了攻击!!!");
            }
            else
            {
                if (enenyNum == 2)
                {
                    Console.WriteLine("再怪物发动攻击之际,我方宠物奋起反击,也发动攻击-->");
                    if (float.Parse(enemyStr[2]) > float.Parse(playerPetStr[2]))
                    {
                        Console.WriteLine("我方宠物反击无效,受到了{0}点伤害", (float.Parse(enemyStr[2]) - float.Parse(playerPetStr[2])));
                        playerPetStr[4] = (float.Parse(playerPetStr[4]) - float.Parse(enemyStr[2]) + float.Parse(playerPetStr[2])).ToString();
                    }
                    else
                    {
                        Console.WriteLine("我方宠物反击有见效,使得怪物受到{0}点伤害", (float.Parse(playerPetStr[2]) - float.Parse(enemyStr[2])));
                        enemyStr[4] = (float.Parse(enemyStr[4]) - float.Parse(playerPetStr[2]) + float.Parse(enemyStr[2])).ToString();
                    }

                }

                if (enenyNum == 3)
                {
                    Console.WriteLine("我方宠物进行防御抗揍>>>");
                    if (float.Parse(enemyStr[2]) > float.Parse(playerPetStr[3]))
                    {
                        Console.WriteLine("皮薄防御未见成效,受到了{0}点伤害", (float.Parse(enemyStr[2]) - float.Parse(playerPetStr[3])));
                        playerPetStr[4] = (float.Parse(playerPetStr[4]) - float.Parse(enemyStr[2]) + float.Parse(playerPetStr[3])).ToString();
                    }
                    else
                    {
                        Console.WriteLine("我方宠物拼命护住脸,保住了脸面,未受到伤害!!!(^_^)");
                    }

                }


            }


            Console.WriteLine("按F键加血,按T撤退");
            Thread.Sleep(1000);
            Console.WriteLine(">");

            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo info = Console.ReadKey(true);
                if (info.Key == ConsoleKey.F)
                {
                    playerPetStr[4] = (float.Parse(playerPetStr[4]) + 50).ToString();
                    backpackStr[3] = (int.Parse(backpackStr[3]) - 1).ToString(); ;
                    new CreateID().backpackRefresh(backpackStr, account);
                }
                if (info.Key == ConsoleKey.T)
                {
                    Console.WriteLine("战略撤退!!!");
                    AdventureMap(account, x, y);
                }
            }


            Refresh(playerPetStr, "PlayerPet");
            Refresh(enemyStr, "HitOut");

        }


    }

    //宠物列表
    public void PetList(string account)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        int n = 0;
        for (int i = 10; i < backpackStr.Length; i += 10)
        {
            n++;
            Console.WriteLine("{0}: 姓名:{1}  等级:{2}  攻击:{3}  防御:{4}  血量:{5}", n, backpackStr[i + 0], backpackStr[i + 2], backpackStr[i + 4], backpackStr[i + 5], backpackStr[i + 6]);
        }
    }

    //怪物信息刷新
    public void Refresh(string[] _str, string _name)
    {
        for (int i = 0; i < _str.Length; i++)
        {
            if (i == 0)
            {
                File.WriteAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\" + _name + ".txt", _str[i]);
            }
            else
            {
                File.AppendAllText(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\" + _name + ".txt", "\n" + _str[i]);
            }
        }
        Console.WriteLine("姓名:{0}  等级:{1}  攻击:{2}  防御:{3}  血量:{4}", _str[0], _str[1], _str[2], _str[3], _str[4]);
    }

    //失败
    public void Quit(string account, int n, int x, int y)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");

        Console.WriteLine("宠物死亡,是否复活宠物,需要{0}金", (int.Parse(backpackStr[n * 10 + 9]) * 6 / 10));
        bool bo = new CreateID().IsAffirm();
        if (bo && int.Parse(backpackStr[0]) > (int.Parse(backpackStr[n * 10 + 9]) * 6 / 10))
        {
            backpackStr[0] = (int.Parse(backpackStr[0]) - (int.Parse(backpackStr[n * 10 + 9]) * 6 / 10)).ToString(); ;
            Console.WriteLine("{0}已经被复活", backpackStr[n * 10]);
        }
        else
        {
            if (int.Parse(backpackStr[0]) < (int.Parse(backpackStr[n * 10 + 9]) * 6 / 10))
            {
                Console.WriteLine("金钱不足,宠物死亡");
            }
            Console.WriteLine("{0}死亡", backpackStr[n * 10]);
            string[] backpack = new string[backpackStr.Length - 10];
            for (int i = 0; i < n * 10; i++)
            {
                backpack[i] = backpackStr[i];
            }
            for (int i = n * 10 + 10; i < backpackStr.Length; i++)
            {
                backpack[i - 10] = backpackStr[i];
            }
            new CreateID().PetVerdict(backpack, account);//刷新等级以及背包

        }
        AdventureMap(account, x, y);
        //Thread.Sleep(2000);
        //Environment.Exit(0);
    }

    //宠物胜利
    public void PetWin(string account, int n, int x, int y)
    {
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        string[] enemyStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\HitOut.txt");

        Console.WriteLine("获得金币:{0}金,药丸:{1}粒", enemyStr[3], enemyStr[1]);

        backpackStr[0] = (float.Parse(backpackStr[0]) + float.Parse(enemyStr[3])).ToString(); //怪物的防御作为金币
        backpackStr[3] = (int.Parse(backpackStr[3]) + int.Parse(enemyStr[1])).ToString(); ;//怪物等级作为药丸量
        backpackStr[n * 10 + 3] = (int.Parse(backpackStr[n * 10 + 3]) + int.Parse(enemyStr[2])).ToString(); ;//怪物的攻击作经验值

        new CreateID().PetVerdict(backpackStr, account);//等级判断并且刷新背包
        new CreateID().attributeRefresh(attributeStr, account);
        AdventureMap(account, x, y);
    }

    //随机宝物
    public Vection2 RandomGiftBad(int[,] AdventureMapStr)
    {
        while (true)
        {
            Random rd = new Random();
            int x = rd.Next(0, AdventureMapStr.GetLength(0));
            int y = rd.Next(0, AdventureMapStr.GetLength(1));
            if (AdventureMapStr[x, y] == 1 || AdventureMapStr[x, y] == 3 || AdventureMapStr[x, y] == 2 || (x == 10 && y == 8) || (x == 10 && y == 10))
            {
                continue;
            }
            else
            {
                return new Vection2() { x = x, y = y };
            }
        }


    }

    //获得宝物
    public void GetTreasure(string account, int lickNum)
    {
        string[] TreasureStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\SystemMessage\Adventure\LuckyValue.txt");
        string[] backpackStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\backpack.txt");
        Console.WriteLine("获得宝物:\n{0}粒药丸\n{1}金", TreasureStr[lickNum * 2 - 1], TreasureStr[lickNum * 2]);
        backpackStr[0] = (float.Parse(backpackStr[0]) + float.Parse(TreasureStr[lickNum * 2])).ToString();
        backpackStr[3] = (float.Parse(backpackStr[3]) + float.Parse(TreasureStr[lickNum * 2 - 1])).ToString();
        new CreateID().backpackRefresh(backpackStr, account);


    }
}


//游戏
//
//贪吃蛇游戏
public class SnakeCoordinate
{
    public int x;
    public int y;
    public SnakeCoordinate()
    {

    }
    //贪吃蛇首界面
    public void Inter(string account, int a, int b)
    {
        Console.WriteLine("**************");
        Console.WriteLine("*   请选择   *");
        Console.WriteLine("* 1.开始游戏 *");
        Console.WriteLine("* 2.退出     *");
        Console.WriteLine("**************");
        for (int i = 0; true; i++)
        {
            string str = Console.ReadLine();
            int n = 0;
            if (int.TryParse(str, out n))
            {
                switch (n)
                {
                    case 1: Remove(account, a, b); break;
                    case 2: Quit(account, a, b); break;
                    default:
                        Console.WriteLine("输入不正确,请重新输入");
                        break;
                }
            }
            else
            {
                Console.WriteLine("输入不正确,请重新输入");
            }
        }
    }

    //游戏失败后选择
    public void RemoveAgain(string account, int a, int b)
    {
        Console.WriteLine("**************");
        Console.WriteLine("*   请选择   *");
        Console.WriteLine("* 1.重新开始 *");
        Console.WriteLine("* 2.退出     *");
        Console.WriteLine("**************");
        for (int i = 0; true; i++)
        {
            string str = Console.ReadLine();
            int n = 0;
            if (int.TryParse(str, out n))
            {
                switch (n)
                {
                    case 1: Remove(account, a, b); break;
                    case 2: new DormitoryRoom().RoomChange(account, a, b); break;
                    default:
                        Console.WriteLine("输入不正确,请重新输入");
                        break;
                }
            }
            else
            {
                Console.WriteLine("输入不正确,请重新输入");
            }
        }
    }

    //退出
    public void Quit(string account, int a, int b)
    {
        Console.WriteLine("游戏失败!自动返回宿舍房间");
        new DormitoryRoom().RoomChange(account, a, b);
        //Environment.Exit(0);

    }

    //游戏通关
    public void GameVictory(string account, int a, int b)
    {
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        attributeStr[4] = (float.Parse(attributeStr[4]) + 10).ToString();
        attributeStr[5] = (float.Parse(attributeStr[5]) + 10).ToString();
        new CreateID().attributeRefresh(attributeStr, account);
        Console.WriteLine("游戏通关,耐久力加10!自动返回宿舍房间");
        new DormitoryRoom().RoomChange(account, a, b);

    }

    //刷新界面
    public void Labyrinth(int[,] num, List<SnakeCoordinate> list)
    {

        for (int i = 0; i < num.GetLength(0); i++)
        {
            for (int j = 0; j < num.GetLength(1); j++)
            {
                if (num[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (num[i, j] == 0)
                {
                    Console.Write("  ");
                }

                if (num[i, j] == 3)
                {
                    Console.Write("◆");
                }
                if (i == list[list.Count - 1].x && j == list[list.Count - 1].y)
                {
                    Console.Write("♀");
                }
                else if (num[i, j] == 2)
                {
                    Console.Write("●");
                }
            }
            Console.WriteLine();
        }
    }

    //随机生成方块
    public SnakeCoordinate RandeDiamonds(int[,] num, List<SnakeCoordinate> list)
    {
        Random tmp = new Random();
        Random tmps = new Random();
        bool bo = false;
        int tmp1 = 0;
        int tmp2 = 0;
        while (true)
        {

            tmp1 = tmp.Next(0, num.GetLength(0));
            tmp2 = tmps.Next(0, num.GetLength(1));
            if (num[tmp1, tmp2] == 1)
            {
                continue;
            }
            else
            {
                for (int k = 0; k < list.Count; k++)
                {
                    if (list[k].x == tmp1 && list[k].y == tmp2)
                    {
                        break;

                    }
                    if (k == list.Count - 1)
                    {

                        return new SnakeCoordinate() { x = tmp1, y = tmp2 };
                        bo = true;

                    }
                }
            }
            if (bo == true)
            {
                break;
            }


        }
        return new SnakeCoordinate() { x = tmp1, y = tmp2 };


    }

    //是否包含方块
    public bool IsContains(int[,] num)
    {

        for (int i = 0; i < num.GetLength(0); i++)
        {
            for (int j = 0; j < num.GetLength(1); j++)
            {
                if (num[i, j] == 3)
                {
                    return false;
                    break;
                }
                if (i == num.GetLength(0) - 1 && j == num.GetLength(1) - 1)
                {

                    return true;
                    break;
                }
            }
        }
        return true;
    }

    //是否包含蛇自己
    public bool IsIsContainsSelf(List<SnakeCoordinate> list, SnakeCoordinate snake)
    {
        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].x == snake.x && list[i].y == snake.y)
            {
                return false;

            }
            if (i == list.Count - 1)
            {
                return true;

            }
        }
        return true;

    }

    //是否包含墙壁
    public bool ISContainsCube(int[,] num, SnakeCoordinate snake)
    {
        if (num[snake.x, snake.y] == 1)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    //移动
    public void Remove(string account, int x, int y)
    {


        List<SnakeCoordinate> list = new List<SnakeCoordinate>();
        int a = 0;
        int b = 0;
        bool bo;
        int[,] num = new int[,]
        {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }

        };
        for (int i = 0; i < num.GetLength(0); i++)
        {
            for (int j = 0; j < num.GetLength(1); j++)
            {
                if (num[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (num[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (num[i, j] == 2)
                {
                    list.Add(new SnakeCoordinate() { x = i, y = j });
                    a = i;
                    b = j;

                    Console.Write("♀");
                }
                if (num[i, j] == 3)
                {
                    Console.Write("◆");
                }
            }
            Console.WriteLine();
        }

        while (true)
        {

            if (list.Count == 10)
            {
                Console.WriteLine("game over,player victory");
                GameVictory(account, x, y);
            }
            bo = false;

            if (new SnakeCoordinate().IsContains(num))
            {
                //SnakeCoordinate sna = new SnakeCoordinate().RandeDiamonds(num, list);
                num[new SnakeCoordinate().RandeDiamonds(num, list).x, new SnakeCoordinate().RandeDiamonds(num, list).y] = 3;
            }


            int aa = 0;
            int bb = 0;
            Console.WriteLine("按英文格式下w,s,a,d控制♀移动吃掉◆!");
            Console.WriteLine("    现在:{0}分", list.Count - 1);
            char str = Console.ReadKey().KeyChar;
            Console.WriteLine();

            if (str == 'w')
            {
                aa = -1;
            }
            if (str == 's')
            {
                aa = 1;
            }
            if (str == 'a')
            {
                bb = -1;
            }
            if (str == 'd')
            {
                bb = 1;
            }

            if (num[a + aa, b + bb] == 1)
            {
                Console.WriteLine("game over,player death");
                RemoveAgain(account, x, y);
                break;

            }
            else
            {
                if (num[a + aa, b + bb] == 3)
                {
                    list.Add(new SnakeCoordinate() { x = a + aa, y = b + bb });
                    num[a + aa, b + bb] = 2;
                    new SnakeCoordinate().Labyrinth(num, list);
                    Console.Clear();
                    new SnakeCoordinate().Labyrinth(num, list);
                    bo = true;
                }
                else
                {
                    if (new SnakeCoordinate().IsIsContainsSelf(list, new SnakeCoordinate() { x = a + aa, y = b + bb }) == true)
                    {

                        list.Add(new SnakeCoordinate() { x = a + aa, y = b + bb });
                        num[a + aa, b + bb] = 2;
                        SnakeCoordinate snake = list[0];
                        num[snake.x, snake.y] = 0;
                        list.RemoveAt(0);

                        new SnakeCoordinate().Labyrinth(num, list);
                        Console.Clear();
                        new SnakeCoordinate().Labyrinth(num, list);
                        bo = true;
                    }
                    else
                    {
                        Console.WriteLine("game over,player death");
                        RemoveAgain(account, x, y);
                        break;
                    }

                }
                if (bo == true)
                {
                    a += aa;
                    b += bb;
                }



            }
        }
    }
}

//推箱子游戏
public class Sokoban
{
    public int x;
    public int y;

    //贪吃蛇首界面
    public void Inter(string account, int x, int y)
    {
        Console.WriteLine("**************");
        Console.WriteLine("*   请选择   *");
        Console.WriteLine("* 1.开始游戏 *");
        Console.WriteLine("* 2.退出     *");
        Console.WriteLine("**************");
        for (int i = 0; true; i++)
        {
            string str = Console.ReadLine();
            int n = 0;
            if (int.TryParse(str, out n))
            {
                switch (n)
                {
                    case 1: SokobanMap(account, x, y); break;
                    case 2: Quit(account, x, y); break;
                    default:
                        Console.WriteLine("输入不正确,请重新输入");
                        break;
                }
            }
            else
            {
                Console.WriteLine("输入不正确,请重新输入");
            }
        }
    }

    //游戏失败后选择
    public void RemoveAgain(string account, int x, int y)
    {
        Console.WriteLine("**************");
        Console.WriteLine("*   请选择   *");
        Console.WriteLine("* 1.重新开始 *");
        Console.WriteLine("* 2.退出     *");
        Console.WriteLine("**************");
        for (int i = 0; true; i++)
        {
            string str = Console.ReadLine();
            int n = 0;
            if (int.TryParse(str, out n))
            {
                switch (n)
                {
                    case 1: SokobanMap(account, x, y); break;
                    case 2: new DormitoryRoom().RoomChange(account, x, y); break;
                    default:
                        Console.WriteLine("输入不正确,请重新输入");
                        break;
                }
            }
            else
            {
                Console.WriteLine("输入不正确,请重新输入");
            }
        }
    }

    //退出
    public void Quit(string account, int x, int y)
    {
        Console.WriteLine("游戏失败!自动返回宿舍房间");
        new DormitoryRoom().RoomChange(account, x, y);
        //Environment.Exit(0);

    }

    //游戏通关
    public void GameVictory(string account, int a, int b)
    {
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        attributeStr[6] = (float.Parse(attributeStr[6]) + 6).ToString();
        attributeStr[7] = (float.Parse(attributeStr[7]) + 6).ToString();
        new CreateID().attributeRefresh(attributeStr, account);
        Console.WriteLine("游戏通关,负重加6!自动返回宿舍房间");
        new DormitoryRoom().RoomChange(account, a, b);

    }

    //推箱子地图
    public void SokobanMap(string account, int x, int y)
    {
        int a = 0;
        int b = 0;
        int[,] num = new int[10, 10]//制作地图
        {
            {1,1,1,1,1,1,1,1,1,1 },
            {1,2,1,1,4,1,1,4,1,1 },
            {1,0,3,0,0,3,0,0,4,1 },
            {1,1,1,0,0,1,1,3,1,1 },
            {1,4,3,0,1,0,0,0,0,1 },
            {1,1,0,0,0,0,0,1,0,1 },
            {1,4,1,0,0,1,0,3,0,1 },
            {1,0,3,3,1,1,1,1,0,1 },
            {1,0,0,0,0,0,4,1,4,1 },
            {1,1,1,1,1,1,1,1,1,1 }

        };
        for (int i = 0; i < num.GetLength(0); i++)
        {
            for (int j = 0; j < num.GetLength(1); j++)
            {
                if (num[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (num[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (num[i, j] == 2)
                {
                    a = i;
                    b = j;

                    Console.Write("♀");
                }
                if (num[i, j] == 3)
                {
                    Console.Write("◆");
                }
                if (num[i, j] == 4)
                {
                    Console.Write("○");
                }
            }
            Console.WriteLine();
        }

        Stater(num, a, b, account, x, y);
    }

    //开始控制人物移动
    public void Stater(int[,] num, int a, int b, string account, int x, int y)
    {
        int n = 0;

        while (true)
        {

            bool bo = false;
            if (IsContains4(num) == false)
            {
                Console.WriteLine("Game Over,Player Victory");
                GameVictory(account, x, y);
            }
            if (n == 55)
            {
                Console.WriteLine("游戏结束");
                RemoveAgain(account, x, y);
            }

            Console.WriteLine("按英文格式下w,s,a,d控制♀推◆到○处!");
            Console.WriteLine("还剩{0}步", 55 - n);
            char str = Console.ReadKey().KeyChar;//从键盘上输入键
            int aa = 0;
            int bb = 0;
            if (str == 'w')
            {
                aa = -1;
            }
            if (str == 's')
            {
                aa = 1;
            }
            if (str == 'a')
            {
                bb = -1;
            }
            if (str == 'd')
            {
                bb = 1;
            }
            if (num[a + aa, b + bb] == 1 || num[a + aa, b + bb] == 4)//判断任务移动坐标是否包含1和4
            {
                continue;
            }
            if (num[a + aa, b + bb] == 0)
            {
                num[a + aa, b + bb] = 2;
                num[a, b] = 0;
                Remove(num);
                Console.Clear();
                Remove(num);

                bo = true;
            }
            if (num[a + aa, b + bb] == 3 && num[a + aa + aa, b + bb + bb] != 1 && num[a + aa + aa, b + bb + bb] != 3)//判断箱子移动坐标是否包含3和不能包含1
            {
                num[a + aa + aa, b + bb + bb] = 3;
                num[a + aa, b + bb] = 2;
                num[a, b] = 0;
                Remove(num);
                Console.Clear();
                Remove(num);

                bo = true;
            }

            if (bo == true)
            {
                a += aa;
                b += bb;
                n++;
            }





        }
    }

    //刷新物体坐标
    public void Remove(int[,] num)
    {
        for (int i = 0; i < num.GetLength(0); i++)
        {
            for (int j = 0; j < num.GetLength(1); j++)
            {
                if (num[i, j] == 0)
                {
                    Console.Write("  ");
                }
                if (num[i, j] == 1)
                {
                    Console.Write("■");
                }
                if (num[i, j] == 2)
                {
                    Console.Write("♀");
                }
                if (num[i, j] == 3)
                {
                    Console.Write("◆");
                }
                if (num[i, j] == 4)
                {
                    Console.Write("○");
                }
            }
            Console.WriteLine();
        }
    }

    //判断是否还有空地○
    public bool IsContains4(int[,] num)
    {
        for (int i = 0; i < num.GetLength(0); i++)
        {
            for (int j = 0; j < num.GetLength(1); j++)
            {
                if (num[i, j] == 4)
                {
                    return true;
                }
                if (i == num.GetLength(0) - 1 && j == num.GetLength(1))
                {
                    return false;
                }
            }

        }
        return false;
    }

    //获取箱子对应的点
    public List<Sokoban> Is(int[,] num)
    {
        List<Sokoban> list = new List<Sokoban>();
        for (int i = 0; i < num.GetLength(0); i++)
        {
            for (int j = 0; j < num.GetLength(1); j++)
            {
                if (num[i, j] == 4)
                {
                    list.Add(new Sokoban() { x = i, y = j });
                }
            }
        }
        return list;


    }



}

//隐藏任务
public class SecretMissions
{
    //上网
    public void surfTheInternet(string account)
    {
        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");
        Console.WriteLine("愉快的逃出学校上网中(^_^)");
        for (int i = 0; i < 10; i++)
        {
            Thread.Sleep(800);
            Console.WriteLine(">");
        }
        attributeStr[2] = (int.Parse(attributeStr[2]) + 10).ToString();
        attributeStr[3] = (int.Parse(attributeStr[3]) + 10).ToString();
        new CreateID().attributeRefresh(attributeStr, account);
    }

    //进入异性宿舍
    public void IsomerismRoom(string account)
    {

        string[] attributeStr = File.ReadAllLines(@"D:\AllMyLife\DataCenter\PlayerBackpack\" + account + @"\attribute.txt");

        for (int i = 0; i < 10; i++)
        {
            Thread.Sleep(800);
            Console.WriteLine(">");
        }
        attributeStr[8] = (int.Parse(attributeStr[8]) + 5).ToString();//幸运值
        attributeStr[9] = (int.Parse(attributeStr[9]) + 5).ToString();
        new CreateID().attributeRefresh(attributeStr, account);
    }
}



class Program
{
    static void Main(string[] args)
    {
        new CreateID().Inter();

        // new Adventure().AdventureMap("1369276274", 10,8);

        Console.ReadKey();
    }
}

}

//在D盘创建一个文件夹,做数据库,如下图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 9
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
好的,下面是一个简单控制台魔塔游戏的示例代码: ```delphi program ConsoleMota; {$APPTYPE CONSOLE} uses SysUtils; type TMap = array[1..10, 1..10] of Char; var Map: TMap; PlayerX, PlayerY: Integer; Level: Integer; procedure InitializeMap; var X, Y: Integer; begin for Y := 1 to 10 do for X := 1 to 10 do Map[X, Y] := ' '; Map[1, 1] := 'S'; // Start point Map[10, 10] := 'E'; // End point Map[3, 4] := 'W'; // Wall Map[4, 4] := 'W'; // Wall Map[5, 4] := 'W'; // Wall Map[6, 4] := 'W'; // Wall Map[7, 4] := 'W'; // Wall Map[8, 4] := 'W'; // Wall Map[9, 4] := 'W'; // Wall Map[4, 7] := 'W'; // Wall Map[5, 7] := 'W'; // Wall Map[6, 7] := 'W'; // Wall end; procedure PrintMap; var X, Y: Integer; begin for Y := 1 to 10 do begin for X := 1 to 10 do begin if (X = PlayerX) and (Y = PlayerY) then Write('@') else Write(Map[X, Y]); end; Writeln; end; end; function CanMoveTo(X, Y: Integer): Boolean; begin Result := False; if (X >= 1) and (X <= 10) and (Y >= 1) and (Y <= 10) then Result := Map[X, Y] <> 'W'; end; procedure MovePlayer(DX, DY: Integer); begin if CanMoveTo(PlayerX + DX, PlayerY + DY) then begin PlayerX := PlayerX + DX; PlayerY := PlayerY + DY; end; end; procedure PlayGame; var Input: Char; begin while True do begin PrintMap; Write('> '); Readln(Input); case Input of 'w': MovePlayer(0, -1); 'a': MovePlayer(-1, 0); 's': MovePlayer(0, 1); 'd': MovePlayer(1, 0); end; if (PlayerX = 10) and (PlayerY = 10) then begin Writeln('Congratulations, you have completed level ', Level, '!'); Inc(Level); InitializeMap; PlayerX := 1; PlayerY := 1; end; end; end; begin Randomize; Level := 1; InitializeMap; PlayerX := 1; PlayerY := 1; PlayGame; end. ``` 这个示例代码实现了一个简单控制台魔塔游戏,玩家通过控制台输入 w, a, s, d 来移动人物,通过到达终点来完成关卡。每次完成关卡后,会重新初始化地图并进入下一关。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值