public Plate findFutureTargetPlate(int stepsAhead) { Plate resPlate = Player.CurrentPlate; int numberToLookAhead = stepsAhead; Direction resDirection = Player.Direction; for (int i = 0; i < numberToLookAhead; i++) { if (resPlate.Xpos == 0 || resPlate.Xpos == 27) { return(Maze1.maze[13, 13]); } if (resPlate.diretions[(int)Player.NextDirection].Passable) { resPlate = resPlate.diretions[(int)Player.NextDirection]; resDirection = Player.NextDirection; } else { for (int j = 0; j < 4; j++) { if (resPlate.diretions[j] != null && resPlate.diretions[j].Passable && j != ((int)resDirection + 2) % 4) { resPlate = resPlate.diretions[j]; resDirection = (Direction)j; } } } } return(resPlate); }
public override void Spawn(int x, int y) { Xpos = y; Ypos = x; Radius = 0.1f; Game.Maze1.maze[x, y].ObjOnPlate.Add(this); currentPlate = Game.Maze1.maze[x, y]; IsActive = true; }
char getSymb(Plate pl) { if (pl.ObjOnPlate.Count == 0) { if (pl.Passable) { return(' '); } else { return('#'); } } else { switch (pl.ObjOnPlate[pl.ObjOnPlate.Count - 1].GetType().ToString()) { case "Pacman.Player": return('0'); case "Pacman.Monsters.Bashfull": return('0'); case "Pacman.Shadow": return('0'); case "Pacman.Monsters.Speedy": return('0'); case "Pacman.Monsters.Pokey": return('0'); case "Pacman.Coin": return('.'); case "Pacman.Cherry": return('o'); default: return('?'); } } }
public Shadow(GameEngine game) : base(game) { patrolCorner = game.Maze1.maze[2, 26]; RespawnPos = game.Maze1.maze[game.Maze1.Width / 2 - 2, game.Maze1.Length / 2];; }
public void getToPosition(Plate destination) { Mechanics.BreadthSearch aStar = new Mechanics.BreadthSearch(Game); Path = aStar.getPath(CurrentPlate, destination); }
public void fillMaze(int[,] matrixMaze) { Width = matrixMaze.GetUpperBound(0) - matrixMaze.GetLowerBound(0) + 1; Length = matrixMaze.GetUpperBound(1) - matrixMaze.GetLowerBound(1) + 1; maze = new Plate[Width, Length]; coins = new bool[Width, Length]; for (int i = 0; i < Width; i++) { for (int j = 0; j < Length; j++) { maze[i, j] = new Plate(); } } for (int i = 0; i < Width; i++) { for (int j = 0; j < Length; j++) { maze[i, j].Xpos = j; maze[i, j].Ypos = i; if (matrixMaze[i, j] == 0) { maze[i, j].Passable = true; coins[i, j] = true; if (maze[i, j].ObjOnPlate.Count == 0) { maze[i, j].ObjOnPlate.Add(new Coin(i, j, Game)); } CoinsCount++; } else { maze[i, j].Passable = false; } if (i != 0) {//downPlate = 2 maze[i - 1, j].diretions[2] = maze[i, j]; } if (i != Width - 1) {//upperPlate = 0 maze[i + 1, j].diretions[0] = maze[i, j]; } if (j != Length - 1) {//leftPlate = 1 maze[i, j + 1].diretions[1] = maze[i, j]; } if (j != 0) {//rightPlate = 3 maze[i, j - 1].diretions[3] = maze[i, j]; } } int tunl = Game.Map.TunnelY; maze[tunl, 0].diretions[1] = maze[tunl, 27]; maze[tunl, 0].diretions[0] = maze[tunl - 1, 27]; maze[tunl, 0].diretions[2] = maze[tunl + 1, 27]; maze[tunl, 0].diretions[3] = maze[tunl, 1]; maze[tunl, 27].diretions[3] = maze[tunl, 0]; maze[tunl, 27].diretions[1] = maze[tunl, 26]; maze[tunl, 27].diretions[2] = maze[tunl + 1, 27]; maze[tunl, 27].diretions[0] = maze[tunl - 1, 27]; } }
public Player(GameEngine game) : base(game) { Game.PlayerInput = new Mechanics.PlayerMoveInput(this); respawnPos = Game.Maze1.maze[Game.Maze1.Width / 2 + 2, Game.Maze1.Length / 2]; }