public void Activate(Vector3 pos = default(Vector3)) { useCount += 1; currentCD = GetCooldown(); if (AbilityManager.UseRscManagerForCost()) { RscManager.SpendRsc(GetCostRsc()); } else { AbilityManager.SpendRsc(GetCost()); } effectOnActivate.Spawn(pos, Quaternion.identity); AudioManager.PlaySound(soundOnActivate); //activateCallback(); if (effectType != _EffectType.Default) { return; } AbilityManager.GetInstance().StartCoroutine(AbilityEffect(pos)); }
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(); } }
public void Upgrade(int upgradeIdx = 0) { if (GetUpgradeType() == 0) { RscManager.SpendRsc(GetUpgradeCost(0)); Build(true); } else { TowerManager.RemoveTower(this); if (buildPlatform != null) { buildPlatform.RemoveTower(nodeID); } TowerManager.BuildTower(upgradeTowerList[upgradeIdx], buildPlatform, nodeID); Destroy(thisObj); } }
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); }
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(); } } }
// 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(); } } }
public _Status Purchase(bool useRsc = true) { if (useRsc) { if (PerkManager.UseRscManagerForCost()) { RscManager.SpendRsc(GetPurchaseCostRsc()); } else { PerkManager.SpendRsc(GetPurchaseCost()); } } status = _Status.Purchased; if (PerkManager.InGameScene()) { if (type == _PerkType.NewTower) { TowerManager.AddBuildable(newTowerPID, replaceTowerPID); } if (type == _PerkType.NewAbility) { AbilityManager.AddAbility(newAbilityPID, replaceAbilityPID); } else if (type == _PerkType.ModifyTower) // || type==_PerkType.TowerAll){ { PerkManager.AddUnitPerkID(prefabID); SetupCallback(); } else if (type == _PerkType.ModifyAbility) // || type==_PerkType.AbilityAll){ { PerkManager.AddAbilityPerkID(prefabID); SetupCallback(); } else if (type == _PerkType.ModifyEffect) { PerkManager.AddEffectPerkID(prefabID); SetupCallback(); } else if (type == _PerkType.ModifyPerkCost) { PerkManager.AddPerkPerkID(prefabID); } else if (type == _PerkType.LifeCap) { GameControl.ModifyLifeCap((int)gain); } else if (type == _PerkType.GainLife) { GameControl.GainLife((int)gain); } else if (type == _PerkType.LifeRegen) { if (!IsMultiplier()) { GameControl.ModifyLifeRegen(gain); } else { GameControl.ModifyLifeRegenMultiplier(gain); } } else if (type == _PerkType.LifeGainWaveCleared) { if (!IsMultiplier()) { PerkManager.lifeGainOnWaveClearedMod += (int)Mathf.Round(gain); } else { PerkManager.lifeGainOnWaveClearedMul *= gain; } } else if (type == _PerkType.GainRsc) { RscManager.GainRsc(gainList); } else if (type == _PerkType.RscRegen) { if (!IsMultiplier()) { RscManager.ModifyRegenModRate(gainList); } else { RscManager.ModifyRegenMulRate(gainList); } } else if (type == _PerkType.RscGain) { if (!IsMultiplier()) { PerkManager.AddRscGainMod((int)gain); PerkManager.AddRscGainModList(gainList); } else { PerkManager.AddRscGainMul(gain); PerkManager.AddRscGainMulList(gainList); } } else if (type == _PerkType.RscGainCreepDestroyed) { if (!IsMultiplier()) { PerkManager.AddRscGainModCreepKilled((int)gain); PerkManager.AddRscGainModCreepKilledList(gainList); } else { PerkManager.AddRscGainMulCreepKilled(gain); PerkManager.AddRscGainMulCreepKilledList(gainList); } } else if (type == _PerkType.RscGainWaveCleared) { if (!IsMultiplier()) { PerkManager.AddRscGainModWaveCleared((int)gain); PerkManager.AddRscGainModWaveClearedList(gainList); } else { PerkManager.AddRscGainMulWaveCleared(gain); PerkManager.AddRscGainMulWaveClearedList(gainList); } } else if (type == _PerkType.RscGainResourceTower) { if (!IsMultiplier()) { PerkManager.AddRscGainModRscTower((int)gain); PerkManager.AddRscGainModRscTowerList(gainList); } else { PerkManager.AddRscGainMulRscTower(gain); PerkManager.AddRscGainMulRscTowerList(gainList); } } else if (type == _PerkType.AbilityRscCap) { if (!IsMultiplier()) { AbilityManager.MultiplyRscCap((int)Mathf.Round(gain)); } else { AbilityManager.ModifyRscCap((int)Mathf.Round(gain)); } } else if (type == _PerkType.AbilityRscRegen) { if (!IsMultiplier()) { AbilityManager.ModifyRscRegen(gain); } else { AbilityManager.ModifyRscRegenMultiplier(gain); } } else if (type == _PerkType.AbilityRscGainWaveCleared) { if (!IsMultiplier()) { PerkManager.abRscGainOnWaveClearedMod += (int)Mathf.Round(gain); } else { PerkManager.abRscGainOnWaveClearedMul *= gain; } } } return(status); }