public void DownGrade() { switch (Kind) { case Tile_Manager.Cover_Kind.Debris: View = View_Kind.None; Kind = Tile_Manager.Cover_Kind.Default; _Tile.TileMap[X][Y] = Tile_Manager.Cover_Kind.Default; Destroy(_Obstacle); break; case Tile_Manager.Cover_Kind.HalfCover: View = View_Kind.Low; Kind = Tile_Manager.Cover_Kind.Debris; _Tile.TileMap[X][Y] = Tile_Manager.Cover_Kind.Debris; Destroy(_Obstacle); _Obstacle = Instantiate(Obstacle_Manager.Obstacles[0],transform); Prev_Highlighted = orginal_color; break; case Tile_Manager.Cover_Kind.HighCover: View = View_Kind.Half; Kind = Tile_Manager.Cover_Kind.HalfCover; _Tile.TileMap[X][Y] = Tile_Manager.Cover_Kind.HalfCover; Destroy(_Obstacle); _Obstacle = Instantiate(Obstacle_Manager.Obstacles[1], transform); break; default: break; } if (_Obstacle != null) _obstacle = _Obstacle.GetComponent<Obstacle>(); else _obstacle = null; }
public bool CanMove(int ActionPoint, int[] Prev,int cost) { Tile_Manager.Cover_Kind Kind; Kind = _Tile.TileMap[X][Y]; if (Kind == Tile_Manager.Cover_Kind.HighCover || StartPoint) return false; if (RealCost != -1 && RealCost <= cost) return false; if (Kind == Tile_Manager.Cover_Kind.HalfCover) { cost++; ActionPoint--; } if (ActionPoint - Action.Now_Move_Point < 0) { if (!Check) Action = null; return false; } ActionPoint -= Action.Now_Move_Point; cost += Action.Now_Move_Point; RealCost = cost; if (!Check) { GetComponent<SpriteRenderer>().color -= new Color(0.3f, 0.3f, 0.3f, -1); Prev_Highlighted = GetComponent<SpriteRenderer>().color; if (_obstacle != null) _obstacle.Change(); } Check = true; if (X - 1 >= 0 && X - 1 != Prev[0]) { _Tile.MY_Tile[X - 1][Y].Action = Action; _Tile.MY_Tile[X - 1][Y].CanMove(ActionPoint, new int[] { X, Y },cost); } if (X + 1 < _Tile.X && X + 1 != Prev[0]) { _Tile.MY_Tile[X + 1][Y].Action = Action; _Tile.MY_Tile[X + 1][Y].CanMove(ActionPoint, new int[] { X, Y }, cost); } if (Y - 1 >= 0 && Y - 1 != Prev[1]) { _Tile.MY_Tile[X][Y - 1].Action = Action; _Tile.MY_Tile[X][Y - 1].CanMove(ActionPoint, new int[] { X, Y },cost); } if (Y + 1 < _Tile.Y && Y + 1 != Prev[1]) { _Tile.MY_Tile[X][Y + 1].Action = Action; _Tile.MY_Tile[X][Y + 1].CanMove(ActionPoint, new int[] { X, Y }, cost); } return true; }
public void LateStart() { Kind = _Tile.TileMap[X][Y]; if (_Obstacle != null) return; switch(Kind) { case Tile_Manager.Cover_Kind.CanNot: case Tile_Manager.Cover_Kind.Default: case Tile_Manager.Cover_Kind.Others: View = View_Kind.None; break; case Tile_Manager.Cover_Kind.Debris: View = View_Kind.Low; _Obstacle = Instantiate(Obstacle_Manager.Obstacles[0], transform); break; case Tile_Manager.Cover_Kind.HalfCover: _Obstacle = Instantiate(Obstacle_Manager.Obstacles[1], transform); View = View_Kind.Half; break; case Tile_Manager.Cover_Kind.HighCover: _Obstacle = Instantiate(Obstacle_Manager.Obstacles[2], transform); View = View_Kind.Full; break; } if (_Obstacle != null) { _obstacle = _Obstacle.GetComponent<Obstacle>(); _obstacle.Change(); } //gameObject.layer = 9; CompleteStart = true; }