Skip to content
Snippets Groups Projects
Commit 1c25e55d authored by bewe's avatar bewe
Browse files

feat: final stage HUD

parent 8a3ebce3
Branches
Tags
1 merge request!78RELEASE
......@@ -26,7 +26,6 @@ Material:
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _METALLICSPECGLOSSMAP
- _NORMALMAP
m_InvalidKeywords:
- _METALLICGLOSSMAP
m_LightmapFlags: 4
......
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Azathoth : MonoBehaviour
{
......@@ -15,6 +16,13 @@ public class Azathoth : MonoBehaviour
private bool negativeEffect;
private float movementSpeedDebuff = 0.5f;
private float damageDebuff = 0.5f;
[Header("Health Bar")]
public float chipSpeed = 2f;
public Image frontHealthBar;
public Image backHealthBar;
private float lerpTimer;
void Start()
{
isSpawnReady = true;
......@@ -56,6 +64,8 @@ public class Azathoth : MonoBehaviour
RemoveNegativeEffect();
}
}
UpdateHealthUI();
}
private void SpawnSlave()
......@@ -88,4 +98,34 @@ public class Azathoth : MonoBehaviour
player.GetComponent<PlayerMotor>().speed /= movementSpeedDebuff;
player.GetComponent<PlayerHealth>().damageMultiplier /= damageDebuff;
}
public void UpdateHealthUI()
{
float health = GetComponent<Enemy>().health;
float maxHealth = GetComponent<Enemy>().maxHealth;
health = Mathf.Clamp(health, 0, maxHealth);
float fillF = frontHealthBar.fillAmount;
float fillB = backHealthBar.fillAmount;
float hFraction = health / maxHealth;
Debug.Log("Health:" + health);
Debug.Log("Max:" + maxHealth);
if (fillB > hFraction)
{
frontHealthBar.fillAmount = hFraction;
lerpTimer += Time.deltaTime;
float percentComplete = lerpTimer / chipSpeed;
percentComplete = percentComplete * percentComplete;
backHealthBar.fillAmount = Mathf.Lerp(fillB, hFraction, percentComplete);
}
if (fillF < hFraction)
{
backHealthBar.fillAmount = hFraction;
lerpTimer += Time.deltaTime;
float percentComplete = lerpTimer / chipSpeed;
percentComplete = percentComplete * percentComplete;
frontHealthBar.fillAmount = Mathf.Lerp(fillF, backHealthBar.fillAmount, percentComplete);
}
}
}
......@@ -28,6 +28,7 @@ public class Enemy : MonoBehaviour
[Header("Health")]
public int health = 100;
public int maxHealth;
public float deathTimer = 0f;
[Header("Dropped Object")]
......@@ -71,6 +72,7 @@ public class Enemy : MonoBehaviour
}
health = (int)(health * difficultyMultiplier);
maxHealth = health;
damage = (int)(damage * difficultyMultiplier);
}
......
......@@ -7,7 +7,7 @@ using UnityEngine.AI;
public class WolfPetAttackState : StateMachineBehaviour
{
public float attackDistance = 5f;
public int attackDamage = 10;
public int attackDamage = 1;
private GameObject target;
NavMeshAgent agent;
......
......@@ -73,7 +73,7 @@ public class LoadMenu : MonoBehaviour
FadeOut.SetActive(true);
if (data.stageNumber == 4)
{
StartCoroutine(StartGameWithDelay(3));
StartCoroutine(StartGameWithDelay(5));
}
else
{
......@@ -88,7 +88,7 @@ public class LoadMenu : MonoBehaviour
FadeOut.SetActive(true);
if (data.stageNumber == 4)
{
StartCoroutine(StartGameWithDelay(3));
StartCoroutine(StartGameWithDelay(5));
}
else
{
......@@ -103,7 +103,7 @@ public class LoadMenu : MonoBehaviour
FadeOut.SetActive(true);
if (data.stageNumber == 4)
{
StartCoroutine(StartGameWithDelay(3));
StartCoroutine(StartGameWithDelay(5));
}
else
{
......
......@@ -34,11 +34,11 @@ public class PauseMenu : MonoBehaviour
{
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.JoystickButton7))
{
if (GameIsPaused && !player.GetComponent<PlayerHealth>().isDead && !shopHUD.activeSelf)
if (GameIsPaused && !player.GetComponent<PlayerHealth>().isDead)
{
Resume();
}
else if (!GameIsPaused && !player.GetComponent<PlayerHealth>().isDead && !shopHUD.activeSelf)
else if (!GameIsPaused && !player.GetComponent<PlayerHealth>().isDead)
{
Pause();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment