void Awake() { // Setting up the references. anim = GetComponent <Animator> (); playerAudio = GetComponent <AudioSource> (); spawnController = GetComponent <SpawnController> (); firstPersonController = GameObject.FindGameObjectWithTag("GameController").GetComponent <FirstPersonController>(); // playerMovement = GetComponent <PlayerMovement> (); // playerShooting = GetComponentInChildren <PlayerShooting> (); damageImage.color = Color.black; currentHealth = maxHealth; spawnPoint = "PlayerSpawn0"; spawnController.spawn(spawnPoint); firstPersonController.enabled = true; }
void Update() { if (Input.GetButtonDown("Cancel")) { Application.Quit(); } timer += Time.deltaTime; if (isVictorious) { firstPersonController.enabled = false; Debug.Log("V I C T O R Y"); Color damageImageSnapshot = damageImage.color; damageImage.color = Color.Lerp(damageImageSnapshot, victoryColor, timer / totalFadeLength); if (timer > totalFadeLength) { damageImage.color = victoryColor; Debug.Log(" WINNING COMPLETED "); Color a = Color.white; a.a = 255; victoryAlert.color = a; } } else if (respawning) { firstPersonController.enabled = true; damageImage.color = Color.Lerp(Color.black, Color.clear, timer / totalFadeLength); // Debug.Log(damageImage.color); if (timer > totalFadeLength) { Debug.Log("Respawning finished"); respawning = false; timer = 0; instructions.color = Color.clear; } } else if (isDead) { Debug.Log("Dying"); Color damageImageSnapshot = damageImage.color; damageImage.color = Color.Lerp(damageImageSnapshot, deathColor, timer / totalFadeLength); Debug.Log("Death fade timer: " + timer); if (timer > totalFadeLength) { respawning = true; isDead = false; currentHealth = maxHealth; damaged = false; timer = 0; spawnController.spawn(spawnPoint); } } else { // Debug.Log ("Timer:" + timer); if (timer > timeBetweenDamageFeedback) { timer = 0f; // If the player has just been damaged... if (damaged) { // ... set the colour of the damageImage to the flash colour. damageImage.color = flashColor; audio.PlayOneShot(hurtSfx, 1.0F); } // Otherwise... damaged = false; } damageImage.color = Color.Lerp(damageImage.color, Color.clear, damageFlashSpeed * Time.deltaTime); } }
void Awake() { // Setting up the references. anim = GetComponent <Animator> (); playerAudio = GetComponent <AudioSource> (); spawnController = GetComponent <SpawnController> (); firstPersonController = GameObject.FindGameObjectWithTag ("GameController").GetComponent<FirstPersonController>(); // playerMovement = GetComponent <PlayerMovement> (); // playerShooting = GetComponentInChildren <PlayerShooting> (); damageImage.color = Color.black; currentHealth = maxHealth; spawnPoint = "PlayerSpawn0"; spawnController.spawn(spawnPoint); firstPersonController.enabled = true; }