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); }; }
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); }; }
static void InitLevel4() { Rogue.level_target = "找到正真的公主"; Rogue.AddMonster(13, 0, 1); Rogue.AddMonster(8, 5, 3); Rogue.AddMonster(21, 5, 12, 100); Rogue.AddMonster(8, 10, 80, 100); //Rogue.AddMonster(21, 10, 13); Rogue.AddMonster(21, 8, 1000); Rogue.AddMonster(8, 8, 90); for (int i = 0; i < 9; i++) { Walls wall = new Walls(); wall.SetPos(i, 6); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 0; i < 5; i++) { Walls wall = new Walls(); wall.SetPos(8, i); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 0; i < 9; i++) { Walls wall = new Walls(); wall.SetPos(i, 9); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 11; i < 15; i++) { Walls wall = new Walls(); wall.SetPos(8, i); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 21; i < 27; i++) { Walls wall = new Walls(); wall.SetPos(i, 6); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 28; i < 30; i++) { Walls wall = new Walls(); wall.SetPos(i, 6); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 21; i < 30; i++) { Walls wall = new Walls(); wall.SetPos(i, 9); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 0; i < 5; i++) { Walls wall = new Walls(); wall.SetPos(21, i); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } for (int i = 11; i < 15; i++) { Walls wall = new Walls(); wall.SetPos(21, i); Rogue.walls[MapPos(wall.x, wall.y)] = wall; } Walls walls = new Walls(); walls.SetPos(21, 7); Rogue.walls[MapPos(walls.x, walls.y)] = walls; Walls walls2 = new Walls(); walls2.SetPos(8, 7); Rogue.walls[MapPos(walls2.x, walls.y)] = walls2; OldMan oldman = new OldMan("传说中的人物", 101); oldman.SetPos(0, 0); Rogue.npcs[MapPos(oldman.x, oldman.y)] = oldman; Merchant merchant = new Merchant("奇怪的东西", 201); merchant.SetPos(21, 10);//21 Rogue.npcs[MapPos(merchant.x, merchant.y)] = merchant; Merchant merchant2 = new Merchant("商人", 200); merchant2.SetPos(Rogue.map_width - 1, 0); Rogue.npcs[MapPos(merchant2.x, merchant2.y)] = merchant2; Princess gongzhu = new Princess("美丽善良的公主", 300); gongzhu.SetPos(Rogue.map_width - 1, 7); Rogue.princess[MapPos(gongzhu.x, gongzhu.y)] = gongzhu; Princess2 gongzhu2 = new Princess2("邪恶的公主", 300); gongzhu2.SetPos(0, 7); Rogue.princess[MapPos(gongzhu2.x, gongzhu2.y)] = gongzhu2; Dabaojian equipment = new Dabaojian("宝剑", 300); equipment.SetPos(Rogue.map_width - 1, Rogue.map_height - 1); Rogue.equipments[MapPos(equipment.x, equipment.y)] = equipment; Monster boss1 = Rogue.AddMonster(0, Rogue.map_height - 1, 140); boss1.attack = 50; Rogue.onMonsterDead = (Monster monster) => { if (Rogue.monsters.Count() <= 1) { Rogue.OnStageClear(); } if (monster == boss1) { merchant.SetState(2); return(true); } MonsterDropMoney(monster); int pos = Rogue.RandPos2(); int x, y; MapXY(pos, out x, out y); if (Rogue.player.level < 2) { Rogue.AddMonster(x, y, Rogue.player.level + 1); } return(true); }; }
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);*/ }