internal bool OnClick(UnitBuyButton selectedShopUnit = null) { if (HasInnerLevel()) { doorUnit.HideSphere(); OnLevelZoom?.Invoke(innerLevel); } else if (tileTop.activeInHierarchy) { if (!towerUnit.gameObject.activeInHierarchy && selectedShopUnit.isTower) { OnTowerPlaced?.Invoke(); towerUnit.Activate(); return(true); } } else { if (!doorUnit.gameObject.activeInHierarchy && !selectedShopUnit.isTower && Depth < 30) { doorUnit.Activate(); Vector3 levelPosition = transform.position + GetInnerLevelOffset(); var levelObject = Instantiate(levelPrefab, levelPosition, Quaternion.identity); innerLevel = levelObject.GetComponent <Level>(); innerLevel.Depth = Depth + 1; levelObject.transform.localScale = Vector3.one * GetScale(); return(true); } } return(false); }
private void OnBuyClick(UnitBuyButton clickedButton) { foreach (var buyButton in buyButtons) { if (buyButton != clickedButton) { buyButton.Deselect(); } else { if (clickedButton.cost > gameDirector.CoinAmount) { gameDirector.SelectedShopUnit = null; clickedButton.Deselect(); } else { gameDirector.SelectedShopUnit = clickedButton; clickedButton.Select(); } } } }