/* Manages the damage to an NPC object, reducing its current health. If health is below * zero will increment the players by the passed in amount of points if the object was a * boss then additional changes are set and bigger rewards are provided, level up takes * place to make the game incrementally harder, plus bigger rewards. The current spawn * will return to the jeep. Else if not a boss then one reward is spawned. Also now managed * the explosion effect, which reduces the amount of reat code in other scripts. */ public void DamageNPC(GameObject _obj, float _pts, float _dmg, ref float _hea) { _hea -= _dmg; if (_hea <= 0) { AddPoints(_pts); if (currentSpawn == SPAWN_NPC.Boss && GameObject.FindWithTag("NPCBoss")) { for (int i = 0; i < Mathf.Floor(playerMultipler * 5); i++) { SpawnCollectable(new Vector3(_obj.transform.position.x + Random.Range(-2.0f, 2.0f), _obj.transform.position.y, _obj.transform.position.z + Random.Range(-2.0f, 2.0f))); } bossTimer = Time.timeSinceLevelLoad; LevelUp(); progressionTimer = Time.timeSinceLevelLoad; currentSpawn = SPAWN_NPC.Jeep; audio[0].clip = bigExplosion; } else { SpawnCollectable(_obj.transform.position); audio[0].clip = smallExplosion; } audio[0].transform.position = _obj.transform.position; audio[0].volume = playerPrefs.GetSfXVolume(); audio[0].Play(); NpcDeathEffect(_obj.transform.position); Destroy(_obj); UpdateHUD(); } }
// Use this for initialization void Start() { currentyGameState = GAME_STATE.Playing; playerScore = 0f; playerMultipler = 1; playerPoints = 100f; // Default Amount progressionTimer = Time.timeSinceLevelLoad; progressionIncrementer = 0.8f; progressionCountdown = 10f; bossTimer = Time.timeSinceLevelLoad; bossCountdown = 120f; currentSpawn = SPAWN_NPC.Jeep; scoreDisplay = GameObject.Find("Text_ScoreDisplay").GetComponent <Text>(); multiDisplay = GameObject.Find("Text_MultiplerDisplay").GetComponent <Text>(); healthDisplay = GameObject.Find("Text_HealthDisplay").GetComponent <Text>(); audio = GetComponents <AudioSource>(); playerControl = FindObjectOfType <PlayerController>(); playerPrefs = FindObjectOfType <PlayerPrefsControlScript>(); minHealth = playerPrefs.GetMinimumHealth(); playerHealth += minHealth; upgradedDamage = playerPrefs.GetFirePower(); playerDamage += upgradedDamage; minMultiplier = playerPrefs.GetMinimumMultipler(); playerMultipler += minMultiplier; UpdateHUD(); }
/* Updates the next wave variables, to make the experience progressively harder, * more rewarding and changes the current spawn objecct. */ private void NextWaveUpdate() { ProgressionCalc(ref npcJeepHealth); ProgressionCalc(ref playerMultipler); ProgressionCalc(ref progressionCountdown); if (npcJeepSpeed <= maxSpeed) { ProgressionCalc(ref npcJeepSpeed); ProgressionCalc(ref npcBlockSpeed); } if (Time.timeSinceLevelLoad - bossTimer > bossCountdown) { currentSpawn = SPAWN_NPC.Boss; } else { if (currentSpawn == SPAWN_NPC.Jeep) { currentSpawn = SPAWN_NPC.Block; } else { currentSpawn = SPAWN_NPC.Jeep; } } UpdateHUD(); progressionTimer = Time.timeSinceLevelLoad; }