Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (GameSettings.getInstance().GameMode == "DefenseMode")
     {
         if (Input.GetMouseButtonDown(0))
         {
             if (!CheckGuiRaycastObjects())
             {
                 click_ray = Camera.main.ScreenPointToRay(Input.mousePosition);//把鼠标点击的位置转化成射线
                 if (Physics.Raycast(click_ray, out hit, 100, mask))
                 {
                     if (oldBP != null && oldBP.GetComponent <BuildPlace>().HasTower())
                     {
                         oldBP.GetComponentInChildren <Tower>().HideAccatkRang();
                     }
                     if (hit.transform.gameObject.name == "BP")
                     {
                         if (hit.collider.gameObject.GetComponent <BuildPlace>().HasTower())
                         {
                             hit.collider.gameObject.GetComponentInChildren <Tower>().ShowAccatkRang();
                             TowerData current = hit.collider.gameObject.GetComponent <BuildPlace>().GetTowerData();
                             TowerData next    = null;
                             if (current.level == 3)
                             {
                                 //已经满级
                                 uiControl.UpgradeMenu.GetComponent <UpgradeMenu>().HideUpgrade();
                             }
                             else
                             {
                                 next = TowerDataManage.getInstance().GetTowerData(current.name, current.level + 1);
                                 uiControl.UpgradeMenu.GetComponent <UpgradeMenu>().ShowUpgrade();
                             }
                             uiControl.UpgradeMenu.GetComponent <UpgradeMenu>().InitText(current, next);
                             uiControl.UpgradeMenu.GetComponent <UpgradeMenu>().GetParentTransform(hit.transform);
                             uiControl.UpgradeMenu.SetActive(true);
                             // uiControl.TowerMenu.SetActive(false);
                         }
                         else
                         {
                             //uiControl.TowerMenu.GetComponent<TowerMenu>().GetParentTransform(hit.transform);
                             //uiControl.TowerMenu.GetComponent<TowerMenu>().ResetTowerPos();
                             //uiControl.TowerMenu.SetActive(true);
                             //uiControl.UpgradeMenu.SetActive(false);
                         }
                         oldBP = hit.transform.gameObject;
                     }
                     else
                     {
                         //不是地基就把菜单隐藏
                         uiControl.UpgradeMenu.SetActive(false);
                         //uiControl.TowerMenu.SetActive(false);
                         // uiControl.TowerMenu.GetComponent<TowerMenu>().ResetTowerPos();
                     }
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 private void Start()
 {
     gc      = GameObject.Find("GameControl").GetComponent <GameControl>();
     initpos = moveTower.transform.position;
     td      = TowerDataManage.getInstance().GetTowerData(moveTower.name, 1);
 }
Exemplo n.º 3
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        intro.SetActive(true);

        textIntro.text = TowerDataManage.getInstance().GetTowerData(moveTower.name, 1).intro;
    }
Exemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        /*
         * if (File.Exists(Application.persistentDataPath + "/LevelData.txt"))
         * {
         *  File.Delete(Application.persistentDataPath + "/LevelData.txt");
         *  File.Copy(Application.streamingAssetsPath + "/LevelData.txt", Application.persistentDataPath + "/LevelData.txt");
         * }
         * else
         * {
         *  File.Copy(Application.streamingAssetsPath + "/LevelData.txt", Application.persistentDataPath + "/LevelData.txt");
         * }
         */
        CannonTower[] cannonTowers = this.GetComponentsInChildren <CannonTower>();

        ElectricTower[] electricTowers = this.GetComponentsInChildren <ElectricTower>();

        IceTower[] iceTowers = this.GetComponentsInChildren <IceTower>();

        MagicTower[] magicTowers = this.GetComponentsInChildren <MagicTower>();


        if (GameSettings.getInstance().GameMode == "DefenseMode")
        {
            foreach (CannonTower ct in cannonTowers)
            {
                ObjectPool.getInstance().RecycleObj(ct.gameObject);
            }
            foreach (ElectricTower et in electricTowers)
            {
                ObjectPool.getInstance().RecycleObj(et.gameObject);
            }
            foreach (IceTower it in iceTowers)
            {
                ObjectPool.getInstance().RecycleObj(it.gameObject);
            }
            foreach (MagicTower mt in magicTowers)
            {
                ObjectPool.getInstance().RecycleObj(mt.gameObject);
            }
        }
        else
        {
            foreach (CannonTower ct in cannonTowers)
            {
                ct.SetTowerData(TowerDataManage.getInstance().GetTowerData("CannonTower", 3));
            }
            foreach (ElectricTower et in electricTowers)
            {
                et.SetTowerData(TowerDataManage.getInstance().GetTowerData("ElectricTower", 3));
            }
            foreach (IceTower it in iceTowers)
            {
                it.SetTowerData(TowerDataManage.getInstance().GetTowerData("IceTower", 3));
            }
            foreach (MagicTower mt in magicTowers)
            {
                mt.SetTowerData(TowerDataManage.getInstance().GetTowerData("MagicTower", 3));
            }
        }
    }