void Awake(){ Time.fixedDeltaTime = timeStep; instance=this; thisT=transform; ObjectPoolManager.Init(); BuildManager buildManager = (BuildManager)FindObjectOfType(typeof(BuildManager)); buildManager.Init(); PathTD[] paths = FindObjectsOfType(typeof(PathTD)) as PathTD[]; for(int i=0; i<paths.Length; i++) paths[i].Init(); for(int i=0; i<buildManager.buildPlatforms.Count; i++) buildManager.buildPlatforms[i].Init(); gameObject.GetComponent<ResourceManager>().Init(); if(loadAudioManager){ //GameObject amObj=Resources.Load("AudioManager", typeof(GameObject)) as GameObject; Instantiate(Resources.Load("AudioManager", typeof(GameObject))); } if(rangeIndicator){ rangeIndicator=(Transform)Instantiate(rangeIndicator); rangeIndicator.parent=thisT; rangeIndicatorObj=rangeIndicator.gameObject; } ClearSelectedTower(); Time.timeScale=1; }
public void OnMenuButton() { GameControl.LoadMainMenu(); }
void OnUnitCleared(UnitCreep creep) { if (GameControl.IsGameOver()) { return; } int waveID = creep.waveID; activeUnitCount -= 1; Wave wave = null; if (spawnLimit == _SpawnLimit.Finite) { wave = waveList[waveID]; } else if (spawnLimit == _SpawnLimit.Infinite) { for (int i = 0; i < waveList.Count; i++) { if (waveList[i].waveID == waveID) { wave = waveList[i]; break; } } if (wave == null) { Debug.Log("error!"); return; } } wave.activeUnitCount -= 1; if (wave.spawned && wave.activeUnitCount == 0) { wave.cleared = true; waveClearedCount += 1; TDTK.OnWaveCleared(waveID); Debug.Log("wave" + (waveID + 1) + " is cleared"); ResourceManager.GainResource(wave.rscGainList, PerkManager.GetRscWaveCleared()); GameControl.GainLife(wave.lifeGain + PerkManager.GetLifeWaveClearedModifier()); AbilityManager.GainEnergy(wave.energyGain + (int)PerkManager.GetEnergyWaveClearedModifier()); if (spawnLimit == _SpawnLimit.Infinite) { waveList.Remove(wave); } if (IsAllWaveCleared()) { GameControl.GameOver(true); //pass true to signify level won } else { if (spawnMode == _SpawnMode.Round) { TDTK.OnEnableSpawn(); // && onEnableSpawnE!=null) onEnableSpawnE(); } } } if (!IsAllWaveCleared() && activeUnitCount == 0 && !spawning) { if (spawnMode == _SpawnMode.WaveCleared) { SpawnWaveFinite(); } } }
public override void ChangeScanAngle(int angle) { base.ChangeScanAngle(angle); GameControl.TowerScanAngleChanged(this); }
// 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 void OnRestartButton(GameObject butObj, int pointerID = -1) { GameControl.RestartLevel(); }
void OnNewWave(int waveID){ int totalWaveCount=SpawnManager.GetTotalWaveCount(); string text=totalWaveCount>0 ? "/"+totalWaveCount : ""; txtWave.text=waveID+text; if(GameControl.IsGameStarted()) buttonSpawn.rootObj.SetActive(false); }
public IEnumerator TurretRoutine() { for (int i = 0; i < shootPoints.Count; i++) { if (shootPoints[i] == null) { shootPoints.RemoveAt(i); i -= 1; } } if (shootPoints.Count == 0) { Debug.LogWarning("ShootPoint not assigned for unit - " + unitName + ", auto assigned", this); shootPoints.Add(thisT); } for (int i = 0; i < stats.Count; i++) { if (stats[i].shootObject != null) { ObjectPoolManager.New(stats[i].shootObject.gameObject, 3); } } yield return(null); while (true) { while (target == null || stunned || IsInConstruction() || !targetInLOS) { yield return(null); } turretOnCooldown = true; Unit currentTarget = target; float animationDelay = PlayAnimAttack(); if (animationDelay > 0) { yield return(new WaitForSeconds(animationDelay)); } AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = currentTarget; attInstance.Process(); for (int i = 0; i < shootPoints.Count; i++) { Transform sp = shootPoints[i]; //Transform objT=(Transform)Instantiate(GetShootObjectT(), sp.position, sp.rotation); GameObject sObj = ObjectPoolManager.Spawn(GetShootObject().gameObject, sp.position, sp.rotation); ShootObject shootObj = sObj.GetComponent <ShootObject>(); shootObj.Shoot(attInstance, sp); if (delayBetweenShootPoint > 0) { yield return(new WaitForSeconds(delayBetweenShootPoint)); } } yield return(new WaitForSeconds(GetCooldown() - animationDelay - shootPoints.Count * delayBetweenShootPoint)); if (GameControl.ResetTargetAfterShoot()) { target = null; } turretOnCooldown = false; } }
public override void Awake() { base.Awake(); instance = (GameControl)target; }
public bool _PurchasePerk(Perk perk) { if (perk.IsAvailable() == false) { return(false); } if (perk.type == _PerkType.GainLife) { GameControl.GainLife((int)Random.Range(perk.perkLevel[perk.level].value, perk.perkLevel[perk.level].valueAlt)); } else if (perk.type == _PerkType.LifeCap) { lifeCap += (int)perk.perkLevel[perk.level].value; GameControl.GainLife(0); } else if (perk.type == _PerkType.LifeRegen) { lifeRegen += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.LifeWaveClearedBonus) { lifeWaveClearedBonus += (int)perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.RscCap) { int _value = (int)perk.perkLevel[perk.level].valueRsc; ResourceManager.GainResource(_value, 0, false); //dont pass multiplier and dont use multiplier } else if (perk.type == _PerkType.RscRegen) { rscRegen += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscGain) { rscGain += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscCreepKilledGain) { rscCreepKilledGain += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscWaveClearedGain) { rscWaveClearedGain += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscResourceTowerGain) { rscRscTowerGain += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.Tower) { ModifyTowerModifier(globalTowerModifier, perk); } else if (perk.type == _PerkType.TowerSpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = TowerModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkTowerModifier towerModifier = new PerkTowerModifier(); towerModifier.prefabID = perk.itemIDList[i]; towerModifierList.Add(towerModifier); ID = towerModifierList.Count - 1; } ModifyTowerModifierInList(ID, perk); } } else if (perk.type == _PerkType.Ability) { ModifyAbilityModifier(globalAbilityModifier, perk); } else if (perk.type == _PerkType.AbilitySpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = AbilityModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkAbilityModifier abilityModifier = new PerkAbilityModifier(); abilityModifier.abilityID = perk.itemIDList[i]; abilityModifierList.Add(abilityModifier); ID = abilityModifierList.Count - 1; } ModifyAbilityModifierInList(ID, perk); } } else if (perk.type == _PerkType.EnergyRegen) { energyRegen += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.EnergyIncreaseCap) { energyCap += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.EnergyCreepKilledBonus) { energyCreepKilledBonus += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.EnergyWaveClearedBonus) { energyWaveClearedBonus += perk.perkLevel[perk.level].value; } return(true); }
public IEnumerator DragNDropRoutine() { GameControl.SelectTower(this); yield return(null); while (true) { Vector3 pos = Input.mousePosition; _TileStatus status = BuildManager.CheckBuildPoint(pos, -1, prefabID); if (status == _TileStatus.Available) { BuildInfo buildInfo = BuildManager.GetBuildInfo(); thisT.position = buildInfo.position; thisT.rotation = buildInfo.platform.thisT.rotation; } else { Ray ray = Camera.main.ScreenPointToRay(pos); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { thisT.position = hit.point; } //this there is no collier, randomly place it 30unit from camera else { thisT.position = ray.GetPoint(30); } } //left-click, build if (Input.GetMouseButtonDown(0) && !UIUtilities.IsCursorOnUI()) { //if current mouse point position is valid, build the tower if (status == _TileStatus.Available) { string exception = BuildManager.BuildTower(srcTower); if (exception != "") { GameControl.DisplayMessage(exception); } } else { BuildManager.ClearBuildPoint(); } GameControl.ClearSelectedTower(); thisObj.SetActive(false); break; } //right-click, cancel if (Input.GetMouseButtonDown(1) || GameControl.GetGameState() == _GameState.Over) { GameControl.ClearSelectedTower(); BuildManager.ClearBuildPoint(); thisObj.SetActive(false); break; } yield return(null); } thisT.position = new Vector3(0, 9999, 0); }
void Awake() { instance = (GameControl)target; LoadDB(); }
void Awake() { Time.fixedDeltaTime = timeStep; instance = this; thisT = transform; ObjectPoolManager.Init(); BuildManager buildManager = (BuildManager)FindObjectOfType(typeof(BuildManager)); if (buildManager != null) { buildManager.Init(); } NodeGenerator nodeGenerator = (NodeGenerator)FindObjectOfType(typeof(NodeGenerator)); if (nodeGenerator != null) { nodeGenerator.Awake(); } PathFinder pathFinder = (PathFinder)FindObjectOfType(typeof(PathFinder)); if (pathFinder != null) { pathFinder.Awake(); } PathTD[] paths = FindObjectsOfType(typeof(PathTD)) as PathTD[]; if (paths.Length > 0) { for (int i = 0; i < paths.Length; i++) { paths[i].Init(); } } if (buildManager != null) { for (int i = 0; i < buildManager.buildPlatforms.Count; i++) { buildManager.buildPlatforms[i].Init(); } } gameObject.GetComponent <ResourceManager>().Init(); PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager)); if (perkManager != null) { perkManager.Init(); } if (loadAudioManager) { Instantiate(Resources.Load("AudioManager", typeof(GameObject))); } if (rangeIndicator) { rangeIndicator = (Transform)Instantiate(rangeIndicator); rangeIndicator.parent = thisT; rangeIndicatorObj = rangeIndicator.gameObject; } if (rangeIndicatorCone) { rangeIndicatorCone = (Transform)Instantiate(rangeIndicatorCone); rangeIndicatorCone.parent = thisT; rangeIndicatorConeObj = rangeIndicatorCone.gameObject; } ClearSelectedTower(); Time.timeScale = 1; }
public static void ClearSelectedTower() //for CameraControl to clear tower when panning the camera (using touch control) { GameControl.SelectTower(); UITowerView.Hide(); }
void Awake(){ instance = (GameControl)target; }
void Awake() { Time.fixedDeltaTime = timeStep; instance=this; thisT=transform; ObjectPoolManager.Init(); BuildManager buildManager = (BuildManager)FindObjectOfType(typeof(BuildManager)); if(buildManager!=null) buildManager.Init(); NodeGenerator nodeGenerator = (NodeGenerator)FindObjectOfType(typeof(NodeGenerator)); if(nodeGenerator!=null) nodeGenerator.Awake(); PathFinder pathFinder = (PathFinder)FindObjectOfType(typeof(PathFinder)); if(pathFinder!=null) pathFinder.Awake(); PathTD[] paths = FindObjectsOfType(typeof(PathTD)) as PathTD[]; if(paths.Length>0){ for(int i=0; i<paths.Length; i++) paths[i].Init(); } if(buildManager!=null){ for(int i=0; i<buildManager.buildPlatforms.Count; i++) buildManager.buildPlatforms[i].Init(); } gameObject.GetComponent<ResourceManager>().Init(); PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager)); if(perkManager!=null) perkManager.Init(); if(loadAudioManager){ Instantiate(Resources.Load("AudioManager", typeof(GameObject))); } if(rangeIndicator){ rangeIndicator=(Transform)Instantiate(rangeIndicator); rangeIndicator.parent=thisT; rangeIndicatorObj=rangeIndicator.gameObject; } if(rangeIndicatorCone){ rangeIndicatorCone=(Transform)Instantiate(rangeIndicatorCone); rangeIndicatorCone.parent=thisT; rangeIndicatorConeObj=rangeIndicatorCone.gameObject; } ClearSelectedTower(); Time.timeScale=1; }
public void OnResumeButton() { Hide(); GameControl.ResumeGame(); }
void OnLife(int changedvalue){ int cap=GameControl.GetPlayerLifeCap(); string text=(cap>0) ? "/"+GameControl.GetPlayerLifeCap() : "" ; txtLife.text=GameControl.GetPlayerLife()+text; }
public void OnResetButton() { Hide(); GameControl.ResetGame(); }
//fixed update for resource, aoe and mine, check '#region support tower' for support void CreepFunction() { if (!GameControl.HasGameStarted()) { return; } if (IsStunned()) { return; } if (cooldown > 0) { return; } if (IsAOE()) { List <Unit> tgtList = TowerManager.GetUnitsWithinRange(this, GetAttackRange()); if (tgtList.Count > 0) { cooldown = GetCooldown(); for (int i = 0; i < tgtList.Count; i++) { tgtList[i].ApplyAttack(new AttackInfo(this, tgtList[i])); } } else { cooldown = 0.1f; } } if (IsSupport()) { float range = GetAttackRange(); for (int i = 0; i < supportTgtList.Count; i++) { if (Vector3.Distance(GetPos(), supportTgtList[i].GetPos()) <= range) { continue; } ClearBuffOnTarget(supportTgtList[i]); supportTgtList.RemoveAt(i); i -= 1; } List <Unit> tgtList = SpawnManager.GetUnitsWithinRange(this, range); for (int i = 0; i < tgtList.Count; i++) { if (tgtList[i] == GetUnit() || tgtList[i].IsSupport()) { continue; } if (supportTgtList.Contains(tgtList[i].GetCreep())) { continue; } Effect effect = GetEffectOnHit(); //.Clone(); effect.duration = Mathf.Infinity; tgtList[i].ApplyEffect(effect); tgtList[i].GetCreep().supportSrcList.Add(this); supportTgtList.Add(tgtList[i].GetCreep()); } cooldown = 0.1f; } if (IsSpawner() && spawnerCount > 0 && spawnerPrefab != null) { float oHP = spawnerOverride.GetHP(this); float oSH = spawnerOverride.GetSH(this); float oSpd = spawnerOverride.GetSpd(this); int oExp = spawnerOverride.GetExp(this); List <int> oRsc = spawnerOverride.GetRsc(this, rscGainOnDestroyed); for (int i = 0; i < spawnerCount; i++) { SpawnSubCreep(spawnerPrefab, oHP, oSH, oSpd, oExp, oRsc); } cooldown = GetCooldown(); } }
public void OnContinueButton(GameObject butObj, int pointerID = -1) { GameControl.NextLevel(); }
public void OnMenuButton(GameObject butObj, int pointerID = -1) { GameControl.MainMenu(); }
public void OnContinueButton() { WindowsClameScore.scoreSubmitted = false; Time.timeScale = 1; GameControl.LoadNextScene(); }
void Awake() { Time.fixedDeltaTime = timeStep; instance = this; thisT = transform; ObjectPoolManager.Init(); NodeGenerator nodeGenerator = (NodeGenerator)FindObjectOfType(typeof(NodeGenerator)); if (nodeGenerator != null) { nodeGenerator.Awake(); } PathFinder pathFinder = (PathFinder)FindObjectOfType(typeof(PathFinder)); if (pathFinder != null) { pathFinder.Awake(); } PathTD[] paths = FindObjectsOfType(typeof(PathTD)) as PathTD[]; if (paths.Length > 0) { for (int i = 0; i < paths.Length; i++) { paths[i].Init(); } } TDTK.InitDB(); ResourceManager rscManager = (ResourceManager)FindObjectOfType(typeof(ResourceManager)); if (rscManager != null) { rscManager.Init(); } PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager)); if (perkManager != null) { perkManager.Init(); } BuildManager buildManager = (BuildManager)FindObjectOfType(typeof(BuildManager)); if (buildManager != null) { buildManager.Init(); } AbilityManager abilityManager = (AbilityManager)FindObjectOfType(typeof(AbilityManager)); if (abilityManager != null) { abilityManager.Init(); } FPSControl fpsControl = (FPSControl)FindObjectOfType(typeof(FPSControl)); if (fpsControl != null) { fpsControl.Init(); } IndicatorControl indicatorControl = (IndicatorControl)FindObjectOfType(typeof(IndicatorControl)); if (indicatorControl != null) { indicatorControl.Init(); } //if(loadAudioManager){ // Instantiate(Resources.Load("AudioManager", typeof(GameObject))); //} Time.timeScale = 1; }
public void OnMainMenuButton() { WindowsClameScore.scoreSubmitted = false; Time.timeScale = 1; GameControl.LoadMainMenu(); }
public IEnumerator DragNDropRoutine(int pointerID = -1) { GameControl.SelectTower(this); yield return(null); Vector3 cursorPos = Vector3.zero; TDTK.OnDragNDrop(true); inDragNDropRoutine = true; while (inDragNDropRoutine) { if (Input.GetKeyDown(KeyCode.Escape)) { break; } bool invalidCursor = false; if (pointerID < 0) { cursorPos = Input.mousePosition; } else { cursorPos = TDTK.GetTouchPosition(pointerID); } if (cursorPos.magnitude < 0) { invalidCursor = true; } BuildInfo buildInfo = null; if (!invalidCursor) { buildInfo = BuildManager.CheckBuildPoint(cursorPos, prefabID); if (buildInfo.status == _TileStatus.NoPlatform) { Ray ray = Camera.main.ScreenPointToRay(cursorPos); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { thisT.position = hit.point; } else { thisT.position = ray.GetPoint(30); //this there is no collier, randomly place it 30unit from camera } } else { thisT.position = buildInfo.position; thisT.rotation = buildInfo.platform.thisT.rotation; } IndicatorControl.SetBuildTileIndicator(buildInfo); } bool cursorOnUI = UI.IsCursorOnUI(pointerID); if (pointerID < 0) { if (Input.GetMouseButtonDown(0)) { if (cursorOnUI) { break; } string exception = BuildManager._BuildTower(srcTower, buildInfo); if (exception != "") { TDTK.OnGameMessage(exception); } break; } if (Input.GetMouseButtonDown(1)) { break; } } else { if (TDTK.IsTouchEnding(pointerID)) { if (cursorOnUI) { break; } string exception = BuildManager._BuildTower(srcTower, buildInfo); if (exception != "") { TDTK.OnGameMessage(exception); } break; } } yield return(null); } inDragNDropRoutine = false; TDTK.OnDragNDrop(false); IndicatorControl.SetDragNDropPhase(false); thisObj.SetActive(false); }
public IEnumerator DragNDropRoutine() { GameControl.SelectTower(this); yield return(null); #if (UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY) && !UNITY_EDITOR _TileStatus status = _TileStatus.NoPlatform; while (Input.touchCount >= 1) { Vector3 pos = Input.touches[0].position; status = BuildManager.CheckBuildPoint(pos, -1, prefabID); if (status == _TileStatus.Available) { BuildInfo buildInfo = BuildManager.GetBuildInfo(); thisT.position = buildInfo.position; thisT.rotation = buildInfo.platform.thisT.rotation; } else { Ray ray = Camera.main.ScreenPointToRay(pos); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { thisT.position = hit.point; } //this there is no collier, randomly place it 30unit from camera else { thisT.position = ray.GetPoint(30); } } if (Input.touches[0].phase == TouchPhase.Ended) { //if current mouse point position is valid, build the tower if (status == _TileStatus.Available) { bool exception = BuildManager.BuildTower(srcTower); if (exception == false) { GameControl.DisplayMessage("Can't build tower"); } } else { BuildManager.ClearBuildPoint(); } break; } yield return(null); } GameControl.ClearSelectedTower(); #else while (true) { Vector3 pos = Input.mousePosition; _TileStatus status = BuildManager.CheckBuildPoint(pos, -1, prefabID); if (status == _TileStatus.Available) { BuildInfo buildInfo = BuildManager.GetBuildInfo(); thisT.position = buildInfo.position; thisT.rotation = buildInfo.platform.thisT.rotation; } else { Ray ray = Camera.main.ScreenPointToRay(pos); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { thisT.position = hit.point; } //this there is no collier, randomly place it 30unit from camera else { thisT.position = ray.GetPoint(30); } } //left-click, build if (Input.GetMouseButtonDown(0) && !UIUtilities.IsCursorOnUI()) { //if current mouse point position is valid, build the tower if (status == _TileStatus.Available) { bool exception = BuildManager.BuildTower(srcTower); if (exception == false) { GameControl.DisplayMessage("Can't build tower"); } } else { BuildManager.ClearBuildPoint(); } GameControl.ClearSelectedTower(); thisObj.SetActive(false); break; } //right-click, cancel if (Input.GetMouseButtonDown(1) || GameControl.GetGameState() == _GameState.Over) { GameControl.ClearSelectedTower(); BuildManager.ClearBuildPoint(); thisObj.SetActive(false); break; } yield return(null); } #endif thisObj.SetActive(false); thisT.position = new Vector3(0, 9999, 0); BuildManager.ShowPlatform(false); }
public void OnRestartButton() { GameControl.RestartScene(); }
//apply the refund ratio from gamecontrol public int GetValueSell() { int newValue = (int)(value * GameControl.GetSellTowerRefundRatio()); return(newValue); }
public string _PurchasePerk(Perk perk, bool useRsc = true) { string text = perk.Purchase(useRsc); if (text != "") { return(text); } if (!purchasedIDList.Contains(perk.ID)) { purchasedIDList.Add(perk.ID); } SavePurchasedPerk(); TDTK.OnPerkPurchased(perk); //process the prereq for other perk for (int i = 0; i < perkList.Count; i++) { Perk perkTemp = perkList[i]; if (perkTemp.purchased || perkTemp.prereq.Count == 0) { continue; } perkTemp.prereq.Remove(perk.ID); } perkPoint += 1; TDTK.OnPerkPoint(); if (perk.type == _PerkType.NewTower) { UnitTower tower = TDTK.GetDBTower(perk.itemIDList[0]); unlockedTowerList.Add(tower); BuildManager.AddNewTower(tower); } else if (perk.type == _PerkType.NewAbility) { Ability ability = TDTK.GetDBAbility(perk.itemIDList[0]); unlockedAbilityList.Add(ability); AbilityManager.AddNewAbility(ability); } else if (perk.type == _PerkType.NewFPSWeapon) { FPSWeapon weapon = TDTK.GetDBFpsWeapon(perk.itemIDList[0]); unlockedWeaponList.Add(weapon); FPSControl.AddNewWeapon(weapon); } else if (perk.type == _PerkType.GainLife) { GameControl.GainLife((int)Random.Range(perk.value, perk.valueAlt)); } else if (perk.type == _PerkType.LifeCap) { lifeCap += (int)perk.value; GameControl.GainLife(0); } else if (perk.type == _PerkType.LifeRegen) { lifeRegen += perk.value; } else if (perk.type == _PerkType.LifeWaveClearedBonus) { lifeWaveClearedBonus += (int)perk.value; } else if (perk.type == _PerkType.GainRsc) { List <int> valueList = new List <int>(); for (int i = 0; i < perk.valueRscList.Count; i++) { valueList.Add((int)perk.valueRscList[i]); } ResourceManager.GainResource(valueList, null, false); //dont pass multiplier and dont use multiplier } else if (perk.type == _PerkType.RscRegen) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscRegen[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscCreepKilledGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscCreepKilledGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscWaveClearedGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscWaveClearedGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscResourceTowerGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscRscTowerGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.Tower) { ModifyTowerModifier(globalTowerModifier, perk); } else if (perk.type == _PerkType.TowerSpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = TowerModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkTowerModifier towerModifier = new PerkTowerModifier(); towerModifier.prefabID = perk.itemIDList[i]; towerModifierList.Add(towerModifier); ID = towerModifierList.Count - 1; } ModifyTowerModifierInList(ID, perk); } } else if (perk.type == _PerkType.Ability) { ModifyAbilityModifier(globalAbilityModifier, perk); } else if (perk.type == _PerkType.AbilitySpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = AbilityModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkAbilityModifier abilityModifier = new PerkAbilityModifier(); abilityModifier.abilityID = perk.itemIDList[i]; abilityModifierList.Add(abilityModifier); ID = abilityModifierList.Count - 1; } ModifyAbilityModifierInList(ID, perk); } } else if (perk.type == _PerkType.FPSWeapon) { ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk); } else if (perk.type == _PerkType.FPSWeaponSpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = FPSWeaponModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkFPSWeaponModifier weaponModifier = new PerkFPSWeaponModifier(); weaponModifier.prefabID = perk.itemIDList[i]; FPSWeaponModifierList.Add(weaponModifier); ID = FPSWeaponModifierList.Count - 1; } ModifyFPSWeaponModifierInList(ID, perk); } } else if (perk.type == _PerkType.EnergyRegen) { energyRegen += perk.value; } else if (perk.type == _PerkType.EnergyIncreaseCap) { energyCap += perk.value; } else if (perk.type == _PerkType.EnergyCreepKilledBonus) { energyCreepKilledBonus += perk.value; } else if (perk.type == _PerkType.EnergyWaveClearedBonus) { energyWaveClearedBonus += perk.value; } return(""); }
public void OnContinueButton() { Time.timeScale = 1; GameControl.LoadNextScene(); }
void Awake() { instance = (GameControl)target; }
public void OnMainMenuButton() { Time.timeScale = 1; GameControl.LoadMainMenu(); }