public override void Calculate(Player player, int dx, int dy, int speed, PlayerControlManager pcm, Unit[] units) { int multiplier = 1; int[,] edges = pcm.getEdges(new int[] { player.x, player.y }); int x = (dx * speed) / multiplier; int y = (dy * speed) / multiplier; for (int i = 0; i < 4; i++) { edges[i, 0] += x; edges[i, 1] += y; } if (pcm.isOccupiedSquared(edges, units)) { player.x += x; player.y += y; } else { next.Calculate(player, dx, dy, speed, pcm, units); } return; }
public override void Calculate(Player player, int dx, int dy, int speed, PlayerControlManager pcm, Unit[] units) { int[,] edges = pcm.getEdges(new int[] { player.x, player.y }); for (int i = 0; i < 4; i++) { edges[i, 0] += dx; edges[i, 1] += dy; } if (pcm.isOccupiedSquared(edges, units)) { player.x += dx; player.y += dy; } else { return; } }
public override void UseBoost(Player player, Unit[,] units) { PlayerControlManager pcm = new PlayerControlManager(0, 0, null, null); int[] playerCenter = pcm.getCenterPlayer(new int[] { player.x, player.y }); int[] playerTile = pcm.getTile(playerCenter[0], playerCenter[1]); Teleporter t = new Teleporter(playerTile[0], playerTile[1]); TeleporterChangeVisitor visitor = new TeleporterChangeVisitor(t); for (int x = 0; x < units.GetLength(0); x++) { for (int y = 0; y < units.GetLength(1); y++) { if (units[x, y] != null) { units[x, y].Accept(visitor); } } } }
public MapFacade(int xSize, int ySize, Unit[,] units, Explosive[,] explosions) { pcm = new PlayerControlManager(xSize, ySize, units, explosions); em = new ExplosionManager(xSize, ySize, units, explosions); }
public abstract void Calculate(Player player, int dx, int dy, int speed, PlayerControlManager pcm, Unit[] units);