예제 #1
0
        static void InitLevel6()
        {
            FileStream   fs   = new FileStream("../../map.txt", FileMode.Open, FileAccess.Read);
            StreamReader read = new StreamReader(fs, Encoding.Default);
            string       strReadline;
            int          y = 0;

            while ((strReadline = read.ReadLine()) != null)
            {
                Console.WriteLine(strReadline);
                for (int x = 0; x < strReadline.Length; ++x)
                {
                    if (strReadline[x] == '#')
                    {
                        Walls wall = new Walls();
                        wall.SetPos(x, y);
                        Rogue.walls[MapPos(wall.x, wall.y)] = wall;
                    }
                    if (strReadline[x] == '!')
                    {
                        Rogue.AddMonster(x, y, 1, 1);
                    }
                    if (strReadline[x] == '%')
                    {
                        Yaoshi yaoshi = new Yaoshi();
                        yaoshi.SetPos(x, y);
                        Rogue.yaoshis[MapPos(yaoshi.x, yaoshi.y)] = yaoshi;
                    }
                    if (strReadline[x] == '=')
                    {
                        Door door = new Door();
                        door.SetPos(x, y);
                        Rogue.doors[MapPos(door.x, door.y)] = door;
                    }
                    if (strReadline[x] == '^')
                    {
                        Trap trap = new Trap();
                        trap.SetPos(x, y);
                        Rogue.traps[MapPos(trap.x, trap.y)] = trap;
                    }
                    if (strReadline[x] == '↓')
                    {
                        Loutidowm loutidown = new Loutidowm();
                        loutidown.SetPos(x, y);
                        Rogue.loutis_d [MapPos(loutidown.x, loutidown.y)] = loutidown;
                    }
                    if (strReadline[x] == '*')
                    {
                        Trap trap = new Trap();
                        trap.SetPos(x, y);
                        Rogue.trap2s[MapPos(trap.x, trap.y)] = trap;
                    }
                    if (strReadline[x] == '剑')
                    {
                        Equipment baojian = new Equipment("宝剑", 100);
                        baojian.SetPos(x, y);
                        Rogue.equipments[MapPos(baojian.x, baojian.y)] = baojian;
                    }
                }
                y += 1;
                // strReadline即为按照行读取的字符串
            }
            Rogue.onMonsterDead = (Monster monster) =>
            {
                if (Rogue.doors.Count() <= 1)
                {
                    Rogue.OnStageClear();
                }
                return(true);
            };
        }
예제 #2
0
        static void InitLevel3()
        {
            Rogue.level_target = "目标:消灭大魔王,救出公主。";

            BuildWall();

            Rogue.AddMonster(5, 4, 21, 50);
            Rogue.AddMonster(24, 4, 37);
            Rogue.AddMonster(24, 10, 120);
            Rogue.AddMonster(5, 10, 21, 50);
            Rogue.AddMonster(5, 7, 21, 50);
            Rogue.AddMonster(24, 7, 121);
            Rogue.AddMonster(27, 7, 150);
            for (int i = 0; i < 15; i++)
            {
                Rogue.AddMonster(10, i, 34, 10);
            }
            for (int i = 0; i < 15; i++)
            {
                Rogue.AddMonster(15, i, 34, 10);
            }
            for (int i = 0; i < 15; i++)
            {
                Rogue.AddMonster(20, i, 34, 10);
            }

            Equipment equipment = new Equipment("利刃", 20);

            equipment.SetPos(3, 7);
            Rogue.equipments[MapPos(equipment.x, equipment.y)] = equipment;

            Equipment equipment1 = new Equipment("屠魔剑", 8);

            equipment1.SetPos(26, 6);
            Rogue.equipments[MapPos(equipment1.x, equipment1.y)] = equipment1;

            Prop prop = new Prop("人参", 96);

            prop.SetPos(29, 14);
            Rogue.props[MapPos(prop.x, prop.y)] = prop;

            Businessman1 businessman1 = new Businessman1("被关在地牢中的冒险家", 1);

            businessman1.SetPos(0, 0);
            Rogue.npcs[MapPos(businessman1.x, businessman1.y)] = businessman1;

            Businessman2 businessman2 = new Businessman2("商人", 2);

            businessman2.SetPos(0, 14);
            Rogue.npcs[MapPos(businessman2.x, businessman2.y)] = businessman2;

            Pangolin pangolin = new Pangolin("盗贼", 3);

            pangolin.SetPos(29, 0);
            Rogue.npcs[MapPos(pangolin.x, pangolin.y)] = pangolin;

            Princess princess = new Princess("公主", 10);

            princess.SetPos(29, 7);
            Rogue.npcs[MapPos(princess.x, princess.y)] = princess;

            Rogue.onMonsterDead = (Monster monster) =>
            {
                MonsterDropMoney(monster);
                return(true);
            };
            //// 匿名函数还可以像下面这样写:

            //Rogue.onMonsterDead = delegate (Monster monster)
            //{
            //    if (Rogue.monsters.Count() <= 1)
            //    {
            //        Rogue.OnStageClear();
            //    }
            //    return true;
            //};
        }