Exemple #1
0
    public void ButtonListener()
    {
        GameObject selectedTower = _towerBuildingUI.SelectedTower;

        FindObjectOfType <TowerBuilding>().UpgradeWithScrap(selectedTower.GetComponent <TowerRessourceManagement>(), (int)_scrapType, _subTypeIndex);
        _towerBuildingUI.CloseTowerBuildingMenu();
    }
Exemple #2
0
    private void TowerUpgradeRayCast()
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, FromUpgradeRaycastAcknowledgedLayer))
        {
            if (hit.transform.gameObject.CompareTag("Tower") && Vector3.Distance(transform.position, hit.transform.position) <= MaxDistanceToTower && IsInDefaultMode)
            {
                _towerBuildingUI.ShowTowerKillNotification();
                TowerRessourceManagement towermanagement = hit.transform.gameObject.GetComponent <TowerRessourceManagement>();
                if (_towerBuilding.CheckForRessources(_scrapInventory.ScrapInventory, towermanagement) && towermanagement.ScrapSlotsOnTowerAreFree())
                {
                    _towerBuildingUI.ShowTowerUpgraeNotification();
                }

                if (Input.GetButtonDown("Upgrade Tower") && IsInDefaultMode)
                {
                    _towerBuildingUI.OpenTowerBuildingMenu(hit.transform.gameObject);
                }

                if (Input.GetButtonDown("Deconstruct Tower") && IsInDefaultMode)
                {
                    _towerBuildingUI.CloseTowerUpgradeNotification();
                    _towerBuildingUI.CloseTowerBuildingMenu();
                    hit.transform.gameObject.GetComponent <Tower>().Kill();
                }

                if (Input.GetButtonDown("QuickUpgrade Tower") && IsInDefaultMode)
                {
                    _towerBuildingUI.CloseTowerUpgradeNotification();
                    _towerBuildingUI.CloseTowerBuildingMenu();
                    _towerBuilding.UpgradeWithAnyScrap(hit.transform.gameObject.GetComponent <TowerRessourceManagement>());
                }
            }
        }
        else
        {
            _towerBuildingUI.CloseTowerKillNotification();
            _towerBuildingUI.CloseTowerUpgradeNotification();
        }
    }