private void Select(ISelectable selected) { if (this.selected != selected) { Deselect(); } //TODO: move this nonsense --------------------- if (selected is ResourceInteractable) { ResourceInteractable resource = selected as ResourceInteractable; resource.OnCancelled += DeselectResource; resource.OnCompleted += DeselectResource; } else if (selected is TowerInteractable) { TowerInteractable tower = selected as TowerInteractable; HexGrid.Instance.displayHexTiles.ShowTiles(tower.GetComponent <Tower>().TilesInRange); } else if (selected is Enemy) { (selected as Enemy).OnDeath += DeselectEnemy; } //------------------------------- this.selected = selected; selectionEffect.SetColor(selected.SelectionColor); SetChildrenLayer(selectedLayer); selectionEffect.enabled = true; }
protected virtual void Awake() { CurrentHealth = Health; towerInteractable = GetComponentInChildren <TowerInteractable>(); healthbar = GetComponent <Healthbar>(); }