/// <summary> /// Update the state of this placement tile /// </summary> public void SetState(PlacementTileState newState) { State = newState; switch (newState) { case PlacementTileState.Filled: if (TileRenderer != null && FilledMaterial != null) { TileRenderer.sharedMaterial = FilledMaterial; } break; case PlacementTileState.Potential: if (TileRenderer != null && PotentialMaterial != null) { TileRenderer.sharedMaterial = PotentialMaterial; } break; case PlacementTileState.Empty: if (TileRenderer != null && EmptyMaterial != null) { TileRenderer.sharedMaterial = EmptyMaterial; } break; } }
/// <summary> /// Sets a cell range as being occupied by a tower. /// </summary> /// <param name="gridPos">The grid location</param> /// <param name="size">The size of the item</param> /// <param name="state">The state to occupy the grid with; only Filled actually occupies</param> public void Occupy(IntVector2 gridPos, IntVector2 size, PlacementTileState state) { IntVector2 extents = gridPos + size; // Validate the dimensions and size if ((size.x > dimensions.x) || (size.y > dimensions.y)) { throw new ArgumentOutOfRangeException("size", "Given dimensions do not fit in our grid"); } // Out of range of our bounds if ((gridPos.x < 0) || (gridPos.y < 0) || (extents.x > dimensions.x) || (extents.y > dimensions.y)) { throw new ArgumentOutOfRangeException("gridPos", "Given footprint is out of range of our grid"); } // Fill those positions for (int y = gridPos.y; y < extents.y; y++) { for (int x = gridPos.x; x < extents.x; x++) { if (state == PlacementTileState.Filled) { m_AvailableCells[x, y] = true; } // If there's a placement tile, clear it if (m_Tiles != null && m_Tiles[x, y] != null) { m_Tiles[x, y].SetState(state); } } } }
/// <summary> /// Update the state of this placement tile /// </summary> public void SetState(PlacementTileState newState) { switch (newState) { case PlacementTileState.Filled: if (tileRenderer != null && filledMaterial != null) { tileRenderer.sharedMaterial = filledMaterial; } break; case PlacementTileState.Empty: if (tileRenderer != null && emptyMaterial != null) { tileRenderer.sharedMaterial = emptyMaterial; } break; } }
/// <summary> /// Update the state of this placement tile /// </summary> public void SetState(PlacementTileState newState) { switch (newState) { case PlacementTileState.Filled: if (tileRenderer != null && filledSprite != null) { tileRenderer.sprite = filledSprite; tileRenderer.drawMode = SpriteDrawMode.Simple; } break; case PlacementTileState.Empty: if (tileRenderer != null && emptySprite != null) { tileRenderer.sprite = emptySprite; tileRenderer.drawMode = SpriteDrawMode.Tiled; } break; } }