Пример #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 InitLevel7()
        {
            Rogue.monsters.Clear();
            Rogue.walls.Clear();
            Rogue.yaoshis.Clear();
            Rogue.doors.Clear();
            Rogue.trap2s.Clear();
            Rogue.traps.Clear();

            FileStream   fs   = new FileStream("C:\\Users\\meta42games\\Desktop\\Map地图游戏\\Map地图游戏\\Map地图游戏\\map2.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] == '*')
                    {
                        Trap trap = new Trap();
                        trap.SetPos(x, y);
                        Rogue.trap2s[MapPos(trap.x, trap.y)] = trap;
                    }
                }
                y += 1;
                // strReadline即为按照行读取的字符串
            }
            Rogue.onMonsterDead = (Monster monster) =>
            {
                if (Rogue.monsters.Count() <= 1)
                {
                    Rogue.OnStageClear();
                }
                return(true);
            };
        }
Пример #3
0
        static void Map_save()
        {
            FileStream   fs   = new FileStream("../../map2.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] == '$')
                    {
                        Money monry = new Money(100);
                        monry.SetPos(x, y);
                        Rogue.moneys [MapPos(monry.x, monry.y)] = monry;
                    }
                    if (strReadline[x] == '!')
                    {
                        Rogue.AddMonster(x, y, 1);
                    }
                    if (strReadline[x] == '8')
                    {
                        Rogue.AddMonster(x, y, 160, 100);
                    }
                    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] == '*')
                    {
                        Trap trap = new Trap();
                        trap.SetPos(x, y);
                        Rogue.trap2s[MapPos(trap.x, trap.y)] = trap;
                    }
                    if (strReadline[x] == '@')
                    {
                        OldMan oldman = new OldMan("公主", 101);
                        oldman.SetPos(x, y);
                        Rogue.npcs[MapPos(oldman.x, oldman.y)] = oldman;
                    }
                    if (strReadline[x] == '&')
                    {
                        Merchant merchant2 = new Merchant("商人", 200);
                        merchant2.SetPos(x, y);
                        Rogue.npcs[MapPos(merchant2.x, merchant2.y)] = merchant2;
                    }
                }
                y += 1;
                // strReadline即为按照行读取的字符串
            }

            /*Guanka guanka1 = new Guanka(Rogue.monsters, Rogue.npcs, Rogue.walls, Rogue.equipments, Rogue.princess, Rogue.traps, Rogue.doors, Rogue.yaoshis
             * , Rogue.trap2s, Rogue.loutis_d, Rogue.loutis_u);*/
        }