public Game() { var lines = File.ReadAllLines("Map.txt"); for (int k = 0; k < lines.Length; k++) { var data = lines[k].Split(' '); if (k == 0) { MapHeight = int.Parse(data[1]); MapWidth = int.Parse(data[0]); Map = new ICreature[MapWidth, MapHeight]; for (var i = 0; i < MapWidth; i++) { for (var j = 0; j < MapHeight; j++) { Map[i, j] = new Terrain(); } } } if (char.IsLetter(data[0][0])) { if (data[0] == "Digger") { digger = new Digger(this); var coord = lines[k + 1].Split(' '); k++; Map[int.Parse(coord[0]), int.Parse(coord[1])] = digger; } if (data[0] == "SackOfGold") { var coord = lines[k + 1].Split(' '); k++; Map[int.Parse(coord[0]), int.Parse(coord[1])] = new SackOfGold(int.Parse(coord[1]), this); } if (data[0] == "TNT") { var coord = lines[k + 1].Split(' '); k++; Map[int.Parse(coord[0]), int.Parse(coord[1])] = new TNT(int.Parse(coord[1]), this, int.Parse(coord[0])); } } } //MapHeight = 20; //MapWidth = 30; //Map = new ICreature[MapWidth, MapHeight]; //for (var i = 0; i < MapWidth; i++) // for (var j = 0; j < MapHeight; j++) // Map[i, j] = new Terrain(); //digger = new Digger(this); //Map[15, 16] = digger; //Map[6, 6] = new SackOfGold(6, this); //Map[24, 6] = new SackOfGold(6, this); //Map[6, 9] = new SackOfGold(9, this); //Map[15, 10] = new TNT(10, this); }
public Game(ITimer timer) { bags = new Bags(this); digger = new Digger(this); sound = new Sound(this); monster = new Monster(this); scores = new Scores(this); sprite = new Sprite(this); drawing = new Drawing(this); input = new Input(this); video = new Video(); recorder = new Recorder(this); level = new Level(this); this.timer = timer; }
public Game(string[] map) { //TODO: Инициализируйте здесь //map = File.ReadAllLines("Maps//Map" + Program.lvl.ToString() + ".txt"); MapWidth = map[0].Length - 1; MapHeight = map.Length - 1; var rnd = new Random(); IsOver = false; Map = new ICreature[MapWidth, MapHeight]; for (int i = 0; i < MapHeight; i++) { for (int j = 0; j < MapWidth; j++) { switch (map[i][j]) { case '#': { Map[j, i] = new Terrain(); break; } case '$': { Map[j, i] = new Sack(this); break; } case '@': { Map[j, i] = new Monster(this); break; } case '%': { Map[j, i] = new Digger(this); DigX = j; DigY = i; break; } } } } Scores = 0; }
public static void CreateMap() { //TODO: Инициализируйте здесь карту MapWidth = 20; MapHeight = 20; Map = new ICreature[MapWidth, MapHeight]; for (int i = 0; i < MapHeight; ++i) { for (int j = 0; j < MapWidth; ++j) { Map[i, j] = new Terrain(); } } for (int i = 0; i < 20; i++) { Map[i, 10] = null; } Map[9, 9] = new Monster(); Map[5, 5] = new Sack(); Map[5, 4] = new Sack(); Map[0, 0] = new Digger(); Map[7, 18] = new Sack(); Map[6, 9] = null; Map[6, 10] = new Monster(); // Map[7, 10] = null; //Map[8, 10] = null; Map[7, 14] = new Monster(); Map[7, 15] = null; Map[7, 16] = null; Map[8, 16] = new Monster(); Map[10, 18] = new Monster(); Map[9, 1] = new Monster(); Map[7, 10] = null; Map[8, 10] = null; Map[9, 10] = null; Map[10, 10] = new Monster(); }
public void Blast(Level l) { if (Death) { return; } Position p = l.GetSpritePosition(this); for (int y = p.y - 1; y <= p.y + 1; y++) { for (int x = p.x - 1; x <= p.x + 1; x++) { if ((x > 0) && (x < 19) && (y > 0) && (y < 13)) { if (l.GetSprite(x, y).GetType() == typeof(Digger)) { Digger d = (Digger)l.GetSprite(x, y); l.Digger.Die(); } else { if (l.GetSprite(x, y).GetType().BaseType == typeof(Ghost)) { Ghost g = (Ghost)l.GetSprite(x, y); g.Die(); l.Score += 99; } l.SetSprite(x, y, new Nothing()); } } } } Die(); }
void CreateMap(string fileName) { string[] lines = File.ReadAllLines(fileName); var sizes = lines[0].Split(' '); MapWidth = int.Parse(sizes[1]); MapHeight = int.Parse(sizes[0]); WinCondition = int.Parse(sizes[2]); Map = new ICreature[MapWidth, MapHeight]; for (int i = 0; i < MapWidth; i++) { for (int j = 0; j < MapHeight; j++) { if (lines[j + 1][i] == '*') { Map[i, j] = new Terrain(); } if (lines[j + 1][i] == 'D') { Map[i, j] = new Digger(); } if (lines[j + 1][i] == 'S') { Map[i, j] = new Sack(); } if (lines[j + 1][i] == 'M') { Map[i, j] = new Monster(); } if (lines[j + 1][i] == 'G') { Map[i, j] = new Gold(); } } } }
public void Load() { Byte[] level = new Byte[156]; for (int i = 0; i < 156; i++) { level[i] = data[Number * 156 + i]; } for (int y = 0; y < 14; y++) { for (int x = 0; x < 10; x++) { CreateSprite(x * 2, y, (byte)(level[y * 10 + x] >> 4)); CreateSprite(x * 2 + 1, y, (byte)(level[y * 10 + x] & 0x0F)); } } Digger = (Digger)map[level[145], level[146] - 2]; for (int g = 0; g < 16; g++) { ghosts[g] = null; } int Ghost = 0; for (int y = 0; y < 14; y++) { for (int x = 0; x < 20; x++) { if (GetSprite(x, y).GetType().BaseType == typeof(Ghost)) { Ghost g = (Ghost)GetSprite(x, y); ghosts[Ghost] = g; int GhostInfo = level[0x94 + (Ghost >> 1)]; if ((Ghost & 1) != 0) { GhostInfo = GhostInfo & 0x0F; if (g.GetType() == typeof(Ghost90LR)) { ((Ghost90LR)g).Lastturn = Directions.Right; } } else { GhostInfo = GhostInfo >> 4; if (g.GetType() == typeof(Ghost90LR)) { ((Ghost90LR)g).Lastturn = Directions.Left; } } Directions[] d = { Directions.Down, Directions.Up, Directions.Right, Directions.Left }; g.Direction = d[GhostInfo]; Ghost++; } } } Diamonds = (level[147] / 0x10) * 10 + (level[147] % 0x10); Collected = 0; Time = 5000; }