// Update is called once per frame void Update() { if ((int)state == (int)gameState.battlePhase) { //continue spawning current wave sm.UpdateSpawn(); //execute turret AI foreach (GameObject currentTurret in GameObject.FindGameObjectsWithTag("Turret")) { turret t = (turret)currentTurret.GetComponent("turret"); t.Fire(new Vector2(9, 9)); } //execute creep AI GameObject[] creeps = GameObject.FindGameObjectsWithTag("Creep"); foreach (GameObject currentCreep in creeps) { creep c = (creep)currentCreep.GetComponent("creep"); c.Seek(new Vector2(9, 9), currentPath, 10); c.updateStatuses(); } //update missiles foreach (GameObject currentMissile in GameObject.FindGameObjectsWithTag("Missile")) { missile m = (missile)currentMissile.GetComponent("missile"); m.Fly(); } //check if wave is defeated if (creeps == null || creeps.Length == 0) { Debug.Log("here"); if (sm.isWaveDefeated()) { updateAvailableUnits(sm.currentWave); if (sm.currentWave == sm.totalWaves) { totalWin(); } else { win(); } } } if (tm.selected == selectedState.creep && tm.selectedObject != null) { //apply stun creep c = (creep)tm.selectedObject.GetComponent("creep"); c.applyStatus(creepStatus.stun, 3 * c.durationMultipliers[1]); //tm.selected = selectedState.none; } tm.selected = selectedState.none; tm.clickable = true; } }
void onHit() { GameObject[] creeps = GameObject.FindGameObjectsWithTag("Creep"); foreach (GameObject creep in creeps) { if (creep != null) { float dFromCenter = Vector3.Distance(creep.transform.position, this.transform.position); //Debug.Log(dFromCenter); if (dFromCenter < radius) { //splash removed //float splashDamage = ((radius - dFromCenter)/radius)*damage; creep c = (creep)creep.GetComponent("creep"); c.hit(damage); c.applyStatus((creepStatus)statusEffect, potency); } } } Destroy(this.gameObject); }