Example #1
0
        public void Hide()
        {
            _selectedTowerSlot = null;
            _gameManager.PlayerController.OnCoinsAmountChangedEvent -= OnCoinsAmountChangedEventHandler;

            _selfPopup.SetActive(false);
        }
        public void SellTower(TowerSlot selectedTowerSlot)
        {
            TowerSettings towerSettings = SettingsDataUtils.GetTowerSettingsByType(selectedTowerSlot.TowerType);

            _gameManager.PlayerController.ChangeCoinsAmount(towerSettings.buildPrice);
            selectedTowerSlot.SellTower();
        }
        public void BuildTower(TowerSlot selectedTowerSlot, Enumerators.TowerType towerType)
        {
            TowerSettings towerSettings = SettingsDataUtils.GetTowerSettingsByType(towerType);

            _gameManager.PlayerController.ChangeCoinsAmount(-towerSettings.buildPrice);
            selectedTowerSlot.BuildTower(towerType);
        }
        public void StartLevel()
        {
            _towerSlots = new TowerSlot[_gameManager.LevelController.CurrentLevel.TowerSlots.Length];

            for (int i = 0; i < _towerSlots.Length; i++)
            {
                _towerSlots[i] = new TowerSlot(_gameManager.LevelController.CurrentLevel.TowerSlots[i]);
            }
        }
 private void SelectTowerSlot(TowerSlot towerSlot)
 {
     if (towerSlot.IsEmpty)
     {
         _uiManager.DrawPopup <BuildTowerPopup>(new BuildTowerPopupInfo()
         {
             selectedTowerSlot       = towerSlot,
             towerSlotScreenPosition = _gameManager.MainCamera.WorldToScreenPoint(towerSlot.TowerSlotPosition),
         });
     }
     else
     {
         _uiManager.DrawPopup <TowerPopup>(new TowerPopupInfo()
         {
             selectedTowerSlot       = towerSlot,
             towerSlotScreenPosition = _gameManager.MainCamera.WorldToScreenPoint(towerSlot.TowerSlotPosition),
         });
     }
 }
Example #6
0
        public void Show(object data)
        {
            if (data != null && data is TowerPopupInfo towerPopupInfo)
            {
                if (_selectedTowerSlot == towerPopupInfo.selectedTowerSlot)
                {
                    Hide();
                    return;
                }

                Vector3 targetPos = Utilites.ScreenToCanvasPoint(_uiManager.Canvas, towerPopupInfo.towerSlotScreenPosition);

                float canvasRectWidth  = _uiManager.Canvas.GetComponent <RectTransform>().rect.width;
                float canvasRectHeight = _uiManager.Canvas.GetComponent <RectTransform>().rect.height;

                if (targetPos.x + (_container.rect.width / 2f) > canvasRectWidth - _whiteSpaceToScreenBorders)
                {
                    targetPos.x = canvasRectWidth - (_container.rect.width / 2f) - _whiteSpaceToScreenBorders;
                }
                else if (targetPos.x - (_container.rect.width / 2f) < 0f + _whiteSpaceToScreenBorders)
                {
                    targetPos.x = (_container.rect.width / 2f) + _whiteSpaceToScreenBorders;
                }

                if (targetPos.y + (_container.rect.height / 2f) > canvasRectHeight - _whiteSpaceToScreenBorders)
                {
                    targetPos.y = canvasRectHeight - (_container.rect.height / 2f) - _whiteSpaceToScreenBorders;
                }
                else if (targetPos.y - (_container.rect.height / 2f) < 0f + _whiteSpaceToScreenBorders)
                {
                    targetPos.y = (_container.rect.height / 2f) + _whiteSpaceToScreenBorders;
                }

                _container.anchoredPosition    = targetPos;
                _selectedTowerSlot             = towerPopupInfo.selectedTowerSlot;
                _sellTowerButtonLabelText.text = "SELL" + "\n<b>" + SettingsDataUtils.GetTowerSettingsByType(_selectedTowerSlot.TowerType).buildPrice + "$</b>";
            }

            Show();
        }
Example #7
0
        public void Show(object data)
        {
            if (data != null && data is BuildTowerPopupInfo buildTowerPopupInfo)
            {
                if (_selectedTowerSlot == buildTowerPopupInfo.selectedTowerSlot)
                {
                    Hide();
                    return;
                }

                Vector3 targetPos = Utilites.ScreenToCanvasPoint(_uiManager.Canvas, buildTowerPopupInfo.towerSlotScreenPosition);

                float canvasRectWidth  = _uiManager.Canvas.GetComponent <RectTransform>().rect.width;
                float canvasRectHeight = _uiManager.Canvas.GetComponent <RectTransform>().rect.height;

                if (targetPos.x + (_container.rect.width / 2f) > canvasRectWidth - _whiteSpaceToScreenBorders)
                {
                    targetPos.x = canvasRectWidth - (_container.rect.width / 2f) - _whiteSpaceToScreenBorders;
                }
                else if (targetPos.x - (_container.rect.width / 2f) < 0f + _whiteSpaceToScreenBorders)
                {
                    targetPos.x = (_container.rect.width / 2f) + _whiteSpaceToScreenBorders;
                }

                if (targetPos.y + (_container.rect.height / 2f) > canvasRectHeight - _whiteSpaceToScreenBorders)
                {
                    targetPos.y = canvasRectHeight - (_container.rect.height / 2f) - _whiteSpaceToScreenBorders;
                }
                else if (targetPos.y - (_container.rect.height / 2f) < 0f + _whiteSpaceToScreenBorders)
                {
                    targetPos.y = (_container.rect.height / 2f) + _whiteSpaceToScreenBorders;
                }

                _container.anchoredPosition = targetPos;
                _selectedTowerSlot          = buildTowerPopupInfo.selectedTowerSlot;
            }

            Show();
        }
Example #8
0
        public void Hide()
        {
            _selectedTowerSlot = null;

            _selfPopup.SetActive(false);
        }