public void addWalls(int x, int y) { gridData wall = new gridData(x, y, 1, 1, this.width, this.height); int pos = x + y * this.width; this.grids[pos] = wall; return; }
public void addRunners(int x, int y) { gridData runner = new gridData(x, y, 2, 0, this.width, this.height); int pos = x + y * this.width; this.grids[pos] = runner; this.runners.Add(runner); }
public void addChaser(int x, int y) { gridData chaser = new gridData(x, y, 3, 0, this.width, this.height); int pos = x + y * this.width; this.grids[pos] = chaser; this.chasers.Add(chaser); }
public map(int width, int height) { this.width = width; this.height = height; for (int j = 0; j < width; j++) { for (int i = 0; i < height; i++) { gridData empty = new gridData(i, j); this.grids.Add(empty); } } this.addRunners(9, 0); this.addChaser(9, 1); }
public void runnerMove(int serialNumber, string direction) { int pos = this.runners[serialNumber].y * this.width + this.runners[serialNumber].x; gridData empty = new gridData(this.runners[serialNumber].x, this.runners[serialNumber].y); this.grids[pos] = empty; int pseudo_pos = this.runners[serialNumber].pseudoMove(direction); //如果移动后的结果是chaser,那么就要死亡了 if (this.grids[pseudo_pos].type != 3 && this.grids[pseudo_pos].type == 0) { this.runners[serialNumber].move(direction); pos = this.runners[serialNumber].y * this.width + this.runners[serialNumber].x; this.grids[pos] = this.runners[serialNumber]; } else { this.runners[serialNumber].die(); } return; }