/// <summary> /// Adds a wall at the given segment of this tile. /// </summary> /// <param name="Segment">The segment of this tile at which to add a wall.</param> /// <returns>True if the wall was successfully added, false otherwise.</returns> public bool AddWall(TileSegment Segment) { if (CanAdd(Segment)) { m_Walls.Add(new Wall(this, Segment)); return true; } return false; }
/// <summary> /// Is it possible to add a wall at the specified segment for this tile? /// </summary> /// <param name="InSegment">The segment to check against.</param> /// <returns>True if a wall can be added at this segment, false otherwise.</returns> public bool CanAdd(TileSegment InSegment) { foreach (Wall Wll in m_Walls) { if (Wll.Segment == InSegment) return false; } return true; }
/// <summary> /// Adds a wall at the given segment of this tile. /// </summary> /// <param name="Segment">The segment of this tile at which to add a wall.</param> /// <returns>True if the wall was successfully added, false otherwise.</returns> public bool AddWall(TileSegment Segment) { if (CanAdd(Segment)) { m_Walls.Add(new Wall(this, Segment)); return(true); } return(false); }
/// <summary> /// Is it possible to add a wall at the specified segment for this tile? /// </summary> /// <param name="InSegment">The segment to check against.</param> /// <returns>True if a wall can be added at this segment, false otherwise.</returns> public bool CanAdd(TileSegment InSegment) { foreach (Wall Wll in m_Walls) { if (Wll.Segment == InSegment) { return(false); } } return(true); }
/// <summary> /// Gets a wall that occupies a given segment. /// Assumes that HasWall() has been called to /// find out if the given segment has a wall, /// otherwise this will return null. /// </summary> /// <param name="InSegment">The segment for which to return a wall.</param> /// <returns>A wall for the given segment, null if no wall occupied the given segment.</returns> public Wall GetWall(TileSegment InSegment) { foreach (Wall Wll in m_Walls) { if (Wll.Segment == InSegment) { return(Wll); } } return(null); }
/// <summary> /// Removes a wall at the given segment of this tile. /// </summary> /// <param name="InSegment">The segment of this tile at which to remove a wall.</param> /// <returns>True if the wall was successfully added, false otherwise.</returns> public bool RemoveWall(TileSegment InSegment) { foreach (Wall Wll in m_Walls) { if (Wll.Segment == InSegment) { m_Walls.Remove(Wll); return(true); } } return(false); }
private void DestroyPreviousSegment() { TileSegment segment = segments[0]; int countTilesToDispose = segment.GetCountTiles(); for (int i = 0; i < countTilesToDispose; i++) { queuePositions.Dequeue(); } segment.DestroyTiles(); segments.RemoveAt(0); }
private void CreateNextSegment() { //determine definitions Vector2 nextPos; int additionalTiles = widthRoad - 1; bool isUpDirection = Random.Range(0, 2) == 1; //determine random direction if (isUpDirection) { nextPos = currentPos + Vector2.up; } else { nextPos = currentPos + Vector2.right; } List <Tile> tiles = new List <Tile>(); //Create segment depends on difficult for (int x = 0; x < additionalTiles; x++) { float pos_x = nextPos.x - 1 - x; for (int y = 0; y < additionalTiles; y++) { float pos_y = nextPos.y + 1 + y; Vector2 pos = new Vector2(pos_x, pos_y); if (!ExistTileInPos(pos)) { Tile tile = SpawnTile(pos); tiles.Add(tile); } } } //Create next tile currentPos = nextPos; if (!ExistTileInPos(nextPos)) { Tile mainTile = SpawnTile(nextPos); tiles.Add(mainTile); } TileSegment segment = new TileSegment(nextPos, tiles.ToArray()); segments.Add(segment); onSegmentCreated?.Invoke(segment); }
/// <summary> /// Gets a wall that occupies a given segment. /// Assumes that HasWall() has been called to /// find out if the given segment has a wall, /// otherwise this will return null. /// </summary> /// <param name="InSegment">The segment for which to return a wall.</param> /// <returns>A wall for the given segment, null if no wall occupied the given segment.</returns> public Wall GetWall(TileSegment InSegment) { foreach (Wall Wll in m_Walls) { if (Wll.Segment == InSegment) return Wll; } return null; }
/// <summary> /// Removes a wall at the given segment of this tile. /// </summary> /// <param name="InSegment">The segment of this tile at which to remove a wall.</param> /// <returns>True if the wall was successfully added, false otherwise.</returns> public bool RemoveWall(TileSegment InSegment) { foreach (Wall Wll in m_Walls) { if (Wll.Segment == InSegment) { m_Walls.Remove(Wll); return true; } } return false; }
private TileSegment m_Segment; //The segment of a tile that this wall is placed on. /// <summary> /// Constructor for the Wall class. /// </summary> /// <param name="Tle">The tile that this wall is standing on.</param> /// <param name="Segment">The segment of the tile that this wall is occupying.</param> public Wall(Tile Tle, TileSegment Segment) { m_Tile = Tle; m_Segment = Segment; }
private Tile m_Tile; //The tile that this wall is placed on. #endregion Fields #region Constructors /// <summary> /// Constructor for the Wall class. /// </summary> /// <param name="Tle">The tile that this wall is standing on.</param> /// <param name="Segment">The segment of the tile that this wall is occupying.</param> public Wall(Tile Tle, TileSegment Segment) { m_Tile = Tle; m_Segment = Segment; }