/* 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(); } }
private void SetDefaultValues() { optionCanvas.GetComponent <Canvas>().sortingOrder = -1; upgradeCanvas.GetComponent <Canvas>().sortingOrder = -1; evSystem.SetSelectedGameObject(mainStartButton); var sliders = optionCanvas.gameObject.GetComponentsInChildren <Slider>(); foreach (var slider in sliders) { if (slider.name == "Sld_MusicVol") { slider.value = prefsControl.GetMusicVolume(); } else if (slider.name == "Sld_SFXVol") { slider.value = prefsControl.GetSfXVolume(); } } var toggles = optionCanvas.gameObject.GetComponentsInChildren <Toggle>(); foreach (var toggle in toggles) { if (toggle.name == "Tog_AutoFire") { toggle.isOn = prefsControl.GetAutoFire(); } else if (toggle.name == "Tog_Accelerometer") { toggle.isOn = prefsControl.GetAccelerometer(); } } }
void Start() { StartZ = transform.position.z; projectileCooldown = Time.timeSinceLevelLoad; anim = GetComponent <Animator>(); gameControl = FindObjectOfType <GameControlScript>(); audio = GetComponent <AudioSource>(); playerPrefs = FindObjectOfType <PlayerPrefsControlScript>(); audio.volume = playerPrefs.GetSfXVolume(); autoFire = playerPrefs.GetAutoFire(); accelerometer = playerPrefs.GetAccelerometer(); }
// Use this for initialization void Start() { gameControl = FindObjectOfType <GameControlScript>(); playerPrefs = FindObjectOfType <PlayerPrefsControlScript>(); moverScript = FindObjectOfType <NPCObstacle>(); audio = GetComponent <AudioSource>(); audio.volume = playerPrefs.GetSfXVolume(); player = GameObject.FindGameObjectWithTag("Player"); npcDamage = gameControl.GetNpcDamage(); npcHealth = gameControl.GetNpcHealth(); IsShooterAndMaterial(); DestroyGlitchedObject(); }