示例#1
0
 public void onStandardTurret(bool isOn)
 {
     if (isOn)
     {
         selectedTurretDate = StandardTurret;
     }
 }
示例#2
0
 public void onLaserTurret(bool isOn)
 {
     if (isOn)
     {
         selectedTurretDate = LaserTurret;
     }
 }
示例#3
0
 public void onMissileTurret(bool isOn)
 {
     if (isOn)
     {
         selectedTurretDate = MissileTurret;
     }
 }
示例#4
0
        public void creatTurret(turretDate gam)
        {
            turretDate1 = gam;
            mapCubeGo   = GameObject.Instantiate(gam.turretPrefab[turretLevel], this.transform.position, Quaternion.identity);

            GameObject effect = GameObject.Instantiate(buildEffect, this.transform.position, Quaternion.identity);

            Destroy(effect, 1f);
            turretLevel++;
        }
示例#5
0
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (EventSystem.current.IsPointerOverGameObject() == false)
                {
                    if (isShowUIgrade == true)
                    {
                        HideUpgradeUI();
                    }

                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    bool       iscollider = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("mapCube"));
                    //判断是否碰到了地图块
                    if (iscollider)
                    {
                        //获取地图块数据
                        mapCube mc = hit.collider.gameObject.GetComponent <mapCube>();
                        cube = mc;
                        if (selectedTurretDate != null && mc.mapCubeGo == null)
                        {
                            //判断钱够不够
                            if (money >= selectedTurretDate.turretPrefab[0].GetComponent <turret>().turretCost)
                            {
                                //可以创建,先减钱再创建
                                changeMoney(-selectedTurretDate.turretPrefab[0].GetComponent <turret>().turretCost);
                                mc.creatTurret(selectedTurretDate);
                                foreach (var item in toggles)
                                {
                                    if (item.GetComponent <Toggle>().isOn == true)
                                    {
                                        item.GetComponent <Toggle>().isOn = false;
                                        selectedTurretDate = null;
                                    }
                                }
                            }
                            else
                            {
                                //播放钱不够动画
                                ani.SetTrigger("flicker");
                            }
                        }
                        else if (mc.mapCubeGo != null)
                        {
                            //升级ui显示
                            if (isShowUIgrade == false)
                            {
                                //判断是否已经满级

                                if (cube.turretLevel > 4)
                                {
                                    showUpgradeUI(cube.transform.position, false);
                                }
                                else
                                {
                                    showUpgradeUI(cube.transform.position, true);
                                }
                            }
                            else
                            {
                                HideUpgradeUI();
                            }
                        }
                    }
                }
            }
        }