private int[,] ResetBoard(out Stack <int[]> start) { int[,] dungeon = new int[board.Width, board.Height]; start = new Stack <int[]>(); for (int i = 0; i < board.Width; i++) { for (int j = 0; j < board.Height; j++) { // A start point might be impassable. // 1) NPC's start point is PC's current position. // 2) PC's start points are unexplored positions in the map. if (GetComponent <IAutoExplore>().IsStartPoint(i, j)) { dungeon[i, j] = startPoint; start.Push(new int[] { i, j }); } else if (terrain.IsPassable(i, j)) { dungeon[i, j] = notChecked; } else { dungeon[i, j] = impassable; } } } return(dungeon); }
public bool IsStartPoint(int x, int y) { bool fov = GetComponent <FieldOfView>().CheckFOV(FOVStatus.Unknown, new int[] { x, y }); bool passable = terrain.IsPassable(x, y); return(fov && passable); }
public void MoveGameObject(int targetX, int targetY) { int[] start = coord.Convert(transform.position); if (!GetComponent <Energy>().HasEnoughEnergy()) { return; } if (!terrain.IsPassable(targetX, targetY)) { // Auto-explore does not work sometimes and will let the actor // bump into wall. This is a workaround to prevent printing an // error message for NPC. if (GetComponent <MetaInfo>().IsPC) { modeline.PrintStaticText( text.GetStringData("Combat", "Blocked")); } return; } terrain.ChangeStatus(true, start[0], start[1]); terrain.ChangeStatus(false, targetX, targetY); actor.RemoveActor(start[0], start[1]); actor.AddActor(gameObject, targetX, targetY); transform.position = coord.Convert(targetX, targetY); int moveEnergy = GetComponent <Energy>().GetMoveEnergy( start, new int[2] { targetX, targetY }); GetComponent <Energy>().LoseEnergy(moveEnergy); }