private bool UpdateTileState(BaseTile tile, State state1, State state2) { if (tile.State == state1) { //Changing State Activ or inactive if (state2 == State.Off || state2 == State.Available && state1 == State.Off || state2 == State.Unavailable || state2 == State.Available && state1 == State.Unavailable) { tile.GetComponentInChildren <Renderer>().material.color *= zoneBrightness; } //changing to hovered else if (state2 == State.Hovered) { tile.GetComponentInChildren <Renderer>().material.color += HOVERINGCOLOR; } //changing back from hovered else if (state2 == State.Available && state1 == State.Hovered) { tile.GetComponentInChildren <Renderer>().material.color -= HOVERINGCOLOR; } //appliying changes tile.State = state2; return(true); } return(false); }
public bool CheckRestrictions(BaseTile selectedTile, UnityObject _unityObject) { BaseTile tileType = selectedTile.GetComponentInChildren <BaseTile>(); if (selectedTile.State != State.Unavailable && selectedTile.State != State.Off) { if (tileType is AsphaltTile) { if (_unityObject.CanBePlacedOn().Contains(TileType.Asphalt)) { return(true); } } else if (tileType is GrassTile) { if (_unityObject.CanBePlacedOn().Contains(TileType.Grass)) { return(true); } } else if (tileType is WaterTile) { if (_unityObject.CanBePlacedOn().Contains(TileType.Water)) { return(true); } } } return(false); }
private void UpdateZoneState(int coordinateX, int coordinateY, State state1, State state2) { BaseTile tile = GetTileByCoordinates(coordinateX, coordinateY); if (tile.State == state1) { tile.GetComponentInChildren <Renderer>().material.color *= zoneBrightness; GetTileByCoordinates(coordinateX, coordinateY).State = state2; } }