Example #1
0
 public void BulidPrefabs(TurrentData turrentData)//在小方块上建造炮台
 {
     isUpdate  = false;
     TurrentOn = Instantiate(turrentData.Turrent, transform.position + new Vector3(0, 1, 0), Quaternion.identity);
     Instantiate(DustParticle, transform.position, Quaternion.identity);
     this.Turrentdata = turrentData;
 }
Example #2
0
    private void Update()
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);



        if (Input.GetMouseButtonDown(0))                                //鼠标左键按下
        {
            if (EventSystem.current.IsPointerOverGameObject() == false) //这里的Gameobject是UI上的游戏物体,意为当前碰到的不是UI上的游戏物体
            {
                //满足以上2种条件才可建造炮台

                bool iscolliion = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("SpaceCube"));//只检测这个图层下的游戏物体
                if (iscolliion)
                {
                    //碰撞到的那个方块,获取上面的Mapcube组件
                    mapcube = hit.collider.gameObject.GetComponent <MapCube>();

                    Mapcube = mapcube;//之前一直不知道怎么在下面的方法中得到选中的小方块,想不到这么简单!!!!!!!!
                    //直接在上面public一个mapcube然后把这个值赋给它就可以在下面调用了

                    if (CurrentTurrent.Turrent != null && mapcube.TurrentOn == null)
                    {
                        //上面没有炮台//当前炮台游戏物体不为空的前提下
                        if (CurrentMoney > CurrentTurrent.Moneycost)
                        {
                            OnMoneyChanged(CurrentTurrent.Moneycost);
                            mapcube.BulidPrefabs(CurrentTurrent);
                            CanvasHide();
                        }
                        else
                        {
                            //提示钱不够
                        }
                    }
                    else if (mapcube.TurrentOn != null)
                    {
                        //mapcube.BuildUpdateButton();
                        CanvasOn(mapcube.transform.position + new Vector3(0, 10, 0), mapcube.isUpdate); //获取点击小方块的坐标,如果生成了炮台isuodate为true,按钮可以点击

                        if (mapcube.TurrentOn == SelecedTurrent && UpdateCanvas.activeInHierarchy)      //此按钮在层级列表中是否激活
                        {
                            CanvasHide();
                        }
                        SelecedTurrent = mapcube.TurrentOn;//保存下来的炮台,通过mapcube生成的游戏物体赋值
                        CurrentTurrent = mapcube.Turrentdata;
                    }
                }
            }
        }
    }
Example #3
0
 public void OnClickMortar(bool isOn)
 {
     if (isOn)
     {
         TurrentData Mortar = new TurrentData();
         Mortar.price            = 400;
         Mortar.upOnePrice       = 120;
         Mortar.upTwoPrice       = 130;
         Mortar.Tower_Base       = prefab.Towers[9];
         Mortar.Tower_UpgradeOne = prefab.Towers[10];
         Mortar.Tower_UpgradeTwo = prefab.Towers[11];
         Mortar.turrentType      = TurrentType.Mortar;
         mCurrentSelectWeapon    = Mortar;
     }
 }
Example #4
0
 public void OnClickLaser(bool isOn)
 {
     if (isOn)
     {
         TurrentData Laser = new TurrentData();
         Laser.price            = 300;
         Laser.upOnePrice       = 100;
         Laser.upTwoPrice       = 110;
         Laser.Tower_Base       = prefab.Towers[6];
         Laser.Tower_UpgradeOne = prefab.Towers[7];
         Laser.Tower_UpgradeTwo = prefab.Towers[8];
         Laser.turrentType      = TurrentType.Laser;
         mCurrentSelectWeapon   = Laser;
     }
 }
Example #5
0
 public void OnClickGatling(bool isOn)
 {
     if (isOn)
     {
         TurrentData Gatling = new TurrentData();
         Gatling.price            = 200;
         Gatling.upOnePrice       = 80;
         Gatling.upTwoPrice       = 90;
         Gatling.Tower_Base       = prefab.Towers[3];
         Gatling.Tower_UpgradeOne = prefab.Towers[4];
         Gatling.Tower_UpgradeTwo = prefab.Towers[5];
         Gatling.turrentType      = TurrentType.Gatling;
         mCurrentSelectWeapon     = Gatling;
     }
 }
Example #6
0
 public void OnClickCannon(bool isOn)
 {
     if (isOn)
     {
         TurrentData Cannon = new TurrentData();
         Cannon.price            = 100;
         Cannon.upOnePrice       = 50;
         Cannon.upTwoPrice       = 70;
         Cannon.Tower_Base       = prefab.Towers[0];
         Cannon.Tower_UpgradeOne = prefab.Towers[1];
         Cannon.Tower_UpgradeTwo = prefab.Towers[2];
         Cannon.turrentType      = TurrentType.Cannon;
         mCurrentSelectWeapon    = Cannon;
     }
 }
Example #7
0
 public void IsFire(bool on)
 {
     CurrentTurrent = FireTurrent;
 }
Example #8
0
 public void IsLaserTurrent(bool on)
 {
     CurrentTurrent = LaserTurrent;
 }
Example #9
0
 public void IsClassic(bool on)
 {
     CurrentTurrent = ClassicTurrent;
 }