Example #1
0
        public void OnUpgradeButtonDown()
        {
            if (money >= selectedMapCub.currentTurretData.costUpgraded)
            {
                ChangeMoney(-selectedMapCub.currentTurretData.costUpgraded);
                selectedMapCub.UpgradeTurret();
            }
            else
            {
                moneyAnimator.SetTrigger("Flicker");
            }

            StartCoroutine(TurretUpgradeUI.HideUpgradeUI());
        }
Example #2
0
        private TurretData selectedTurretData;      //当前选择的炮台

        private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (EventSystem.current.IsPointerOverGameObject() == false)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    bool       isCollider = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("WhiteMapCube"));

                    if (isCollider)
                    {
                        MapCube mapCube = hit.collider.GetComponent <MapCube>();

                        if (selectedTurretData != null && mapCube.turretGo == null)
                        {
                            if (money >= selectedTurretData.cost)
                            {
                                mapCube.BuildTurret(selectedTurretData);
                                ChangeMoney(-selectedTurretData.cost);
                            }
                            else
                            {
                                moneyAnimator.SetTrigger("Flicker");
                            }
                        }
                        else if (mapCube.turretGo != null)                   //炮塔升级处理
                        {
                            if (mapCube == selectedMapCub && TurretUpgradeUI.upgradeCanvas.gameObject.activeInHierarchy)
                            {
                                StartCoroutine(TurretUpgradeUI.HideUpgradeUI());
                            }
                            else
                            {
                                TurretUpgradeUI.ShowUpgradeUI(mapCube.transform.position, mapCube.isUpgradeTurrret);
                            }

                            selectedMapCub = mapCube;
                        }
                    }
                }
            }
        }