Exemplo n.º 1
0
 public void Test()
 {
     if (sInfo.HasValidPoint() && sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID))
     {
         if (RscManager.HasSufficientRsc(dndTower.GetCost()))
         {
             RscManager.SpendRsc(dndTower.GetCost());
             Debug.Log("buy");
             SelectControl.ClearUnit();
             if (!UseFreeFormMode())
             {
                 AddTower(dndTower, sInfo.platform, sInfo.nodeID);
             }
             else
             {
                 AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0);
             }
             dndTower.Build();       dndTower = null;  dndCooldown = Time.time;
         }
         else
         {
             GameControl.InvalidAction("Insufficient Resources");
             _ExitDragNDropPhase();
         }
     }
     else
     {
         GameControl.InvalidAction("Invalid Build Point");
         _ExitDragNDropPhase();
     }
 }
Exemplo n.º 2
0
 private bool CheckCost(List <float> cost)
 {
     if (!RscManager.HasSufficientRsc(cost))
     {
         Debug.Log("Insufficient resources");
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
 private bool CheckCost(List <float> cost)
 {
     if (!RscManager.HasSufficientRsc(cost))
     {
         //Debug.Log("Insufficient resources");
         GameControl.InvalidAction("Insufficient resources");
         return(false);
     }
     return(true);
 }
Exemplo n.º 4
0
 public bool HasSufficientRsc()
 {
     if (PerkManager.UseRscManagerForCost())
     {
         return(RscManager.HasSufficientRsc(costRsc));
     }
     else
     {
         return(PerkManager.HasSufficientRsc(cost));
     }
 }
Exemplo n.º 5
0
 public _Status IsReady()
 {
     if (currentCD > 0)
     {
         return(_Status.OnCooldown);
     }
     if (UseLimitReached())
     {
         return(_Status.UseLimitReached);
     }
     if (AbilityManager.UseRscManagerForCost() && !RscManager.HasSufficientRsc(GetCostRsc()))
     {
         return(_Status.InsufficientRsc);
     }
     if (!AbilityManager.UseRscManagerForCost() && !AbilityManager.HasSufficientRsc(GetCost()))
     {
         return(_Status.InsufficientRsc);
     }
     return(_Status.Ready);
 }
Exemplo n.º 6
0
        public static void BuildTower(UnitTower prefab, BuildPlatform platform, int nodeID, bool useRsc = true)
        {
            Debug.Log("BuildTower  " + prefab);

            if (useRsc)
            {
                if (!RscManager.HasSufficientRsc(prefab.GetCost()))
                {
                    Debug.Log("Insufficient resources");
                    return;
                }
                Debug.Log("Get cost " + prefab.GetCost()[0]);
                RscManager.SpendRsc(prefab.GetCost());
            }

            NodeTD     node  = platform.GetNode(nodeID);
            GameObject obj   = (GameObject)Instantiate(prefab.gameObject, node.pos, platform.GetRot() * Quaternion.Euler(-90, 0, 0));
            UnitTower  tower = obj.GetComponent <UnitTower>();

            AddTower(tower, platform, nodeID);
        }
Exemplo n.º 7
0
 public void Test()
 {
     if (m_TowerManager.dndTower != null)
     {
         if (RscManager.HasSufficientRsc(m_TowerManager.dndTower.GetCost()))
         {
             RscManager.SpendRsc(m_TowerManager.dndTower.GetCost());
             Debug.Log("buy");
             m_TSC = m_TowerManager.dndTower.gameObject.GetComponent <TowerSoliderController>();
             SelectControl.ClearUnit();
             TowerManager.AddTower(m_TowerManager.dndTower, TowerManager.CreatePlatformForTower(m_TowerManager.dndTower, TowerManager.GetGridSize()), 0);
             m_TowerManager.dndTower.Build();        m_TowerManager.dndTower = null;                     //TowerManager.dndCooldown=Time.time;
             if (m_TSC != null)
             {
                 m_TSC.ShowSolider();
             }
         }
         else
         {
             GameControl.InvalidAction("Insufficient Resources");
             m_TowerManager._ExitDragNDropPhase();
         }
     }
 }
Exemplo n.º 8
0
        // Update is called once per frame
        void Update()
        {
            //~ if(Input.GetMouseButtonDown(0)){
            //~ ToggleNode(Input.mousePosition, true);
            //~ }
            //~ if(Input.GetMouseButtonDown(1)){
            //~ ToggleNode(Input.mousePosition, false);
            //~ }

            /*
             * //PointNBuild
             * if(Input.GetMouseButtonUp(0)){
             *      sInfo=OnCursorDown(Input.mousePosition);
             *
             *      bool select=false;
             *      bool build=false;
             *
             *      if(sInfo.HasValidPoint()){
             *              if(sInfo.GetTower()!=null){
             *                      select=true;
             *                      //selectTower
             *
             *              }
             *              else if(sInfo.AvailableForBuild()){
             *                      build=true;
             *                      //show build menu
             *              }
             *      }
             *
             *      if(!select){}	//clear selected tower
             *      if(!build){}	//hide build menu
             * }
             */



            /*Daniel Add
             * if(dndTower!=null && Time.unscaledTime-dndCooldown>0.15f){
             *      if(lastDnDCursorPos!=Input.mousePosition){
             *              lastDnDCursorPos=Input.mousePosition;
             *
             *              sInfo=GetSelectInfo(Input.mousePosition, dndInstanceID, dndTower.radius);
             *              if (CheckMouseClick) {
             *                      if (sInfo.HasWorldPoint ())
             *                              dndTower.transform.position = sInfo.GetPos ();
             *                      else
             *                              dndTower.transform.position = Camera.main.ScreenToWorldPoint (Input.mousePosition + new Vector3 (0, 0, 15));
             *              }
             *              CheckMouseClick = false;
             *      }
             *
             *
             *      bool cursorUp=Input.GetMouseButtonUp(0);
             *      if(cursorUp){
             *              if(sInfo.HasValidPoint() && sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID)){
             *                      if(RscManager.HasSufficientRsc(dndTower.GetCost())){
             *                              RscManager.SpendRsc(dndTower.GetCost());
             *                              Debug.Log ("buy");
             *                              SelectControl.ClearUnit();
             *                              if(!UseFreeFormMode()) AddTower(dndTower, sInfo.platform, sInfo.nodeID);
             *                              else AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0);
             *                              dndTower.Build();	dndTower=null;	dndCooldown=Time.time;
             *                              CheckMouseClick = true;
             *                      }
             *                      else{
             *                              GameControl.InvalidAction("Insufficient Resources");
             *                              _ExitDragNDropPhase();
             *                      }
             *              }
             *              else{
             *                      GameControl.InvalidAction("Invalid Build Point");
             *                      _ExitDragNDropPhase();
             *              }
             *      }
             * //End*/

            //這是原本的
            //*
            if (dndTower != null && Time.unscaledTime - dndCooldown > 0.15f)
            {
                if (lastDnDCursorPos != Input.mousePosition)
                {
                    lastDnDCursorPos = Input.mousePosition;

                    sInfo = GetSelectInfo(Input.mousePosition, dndInstanceID, dndTower.radius);
                    if (sInfo.HasWorldPoint())
                    {
                        dndTower.transform.position = sInfo.GetPos();
                    }
                    else
                    {
                        dndTower.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 15));
                    }
                }


                bool cursorUp = Input.GetMouseButtonUp(2);
                if (cursorUp)
                {
                    if (sInfo.HasValidPoint() && sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID))
                    {
                        if (RscManager.HasSufficientRsc(dndTower.GetCost()))
                        {
                            RscManager.SpendRsc(dndTower.GetCost());
                            Debug.Log("buy");
                            SelectControl.ClearUnit();
                            if (!UseFreeFormMode())
                            {
                                AddTower(dndTower, sInfo.platform, sInfo.nodeID);
                            }
                            else
                            {
                                AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0);
                            }
                            testShow();
                            dndTower.Build();       dndTower = null;  dndCooldown = Time.time;
                        }
                        else
                        {
                            GameControl.InvalidAction("Insufficient Resources");
                            _ExitDragNDropPhase();
                        }
                    }
                    else
                    {
                        GameControl.InvalidAction("Invalid Build Point");
                        _ExitDragNDropPhase();
                    }
                }
                //*/


                /*
                 * if(sInfo.HasValidPoint()){
                 *      dndTower.transform.position=sInfo.GetPos();
                 *
                 *      if(sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID)){
                 *              //~ if(cursorDown){
                 *                      //~ if(RscManager.HasSufficientRsc(dndTower.GetCost())){
                 *                              //~ RscManager.SpendRsc(dndTower.GetCost());
                 *                              //~ SelectControl.ClearUnit();
                 *                              //~ if(!UseFreeFormMode()) AddTower(dndTower, sInfo.platform, sInfo.nodeID);
                 *                              //~ else AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0);
                 *                              //~ dndTower.Build();	dndTower=null;	dndCooldown=Time.time;
                 *                      //~ }
                 *                      //~ else{
                 *                              //~ GameControl.InvalidAction("Insufficient Resources");
                 *                              //~ _ExitDragNDropPhase();
                 *                      //~ }
                 *              //~ }
                 *      }
                 * }
                 * else{
                 *      //Debug.Log("this will need some work ");
                 *      dndTower.transform.position=Camera.main.ScreenToWorldPoint(Input.mousePosition+new Vector3(0, 0, 15));
                 *      //~ if(cursorDown){
                 *              //~ GameControl.InvalidAction("Invalid Build Point");
                 *              //~ _ExitDragNDropPhase();
                 *      //~ }
                 * }
                 */

                if (Input.GetMouseButtonDown(1))
                {
                    SelectControl.ClearUnit();
                    _ExitDragNDropPhase();
                }
            }
        }