Update Kills count & Passive heal

This commit is contained in:
2023-10-17 13:48:58 +02:00
parent 797a399977
commit d6f946acf1
2 changed files with 29 additions and 3 deletions
+11
View File
@@ -28,8 +28,19 @@ public class Ennemy : MonoBehaviour
if (Life <= 0) if (Life <= 0)
{ {
Destroy(gameObject); Destroy(gameObject);
if (gameObject.name.Contains("Mayor"))
{
_player.GetComponent<PlayerManager>().MayorKills++; _player.GetComponent<PlayerManager>().MayorKills++;
} }
else if (gameObject.name.Contains("Minotaur"))
{
_player.GetComponent<PlayerManager>().MinautorKills++;
}
else if(gameObject.name.Contains("Bringer of Death"))
{
_player.GetComponent<PlayerManager>().BringerOfDeathKills++;
}
}
} }
private void FixedUpdate() private void FixedUpdate()
+17 -2
View File
@@ -2,14 +2,23 @@ using UnityEngine;
public class PlayerManager : MonoBehaviour public class PlayerManager : MonoBehaviour
{ {
// Character stats
public int Health = 100; public int Health = 100;
public int MaxHealth = 100; public int MaxHealth = 100;
public int HealValue = 1;
public float Speed = 2f; public float Speed = 2f;
public int Exp = 0; public int Exp = 0;
public int Level = 1; public int Level = 1;
// Weapons stats
public int BeamDamages = 50;
public int SwordsDamages = 25;
public int ArrowDamages = 15;
// Kills stats // Kills stats
public int MayorKills = 0; public int MayorKills = 0;
public int MinautorKills = 0;
public int BringerOfDeathKills = 0;
[SerializeField] [SerializeField]
private GameObject pauseMenu; private GameObject pauseMenu;
@@ -17,6 +26,11 @@ public class PlayerManager : MonoBehaviour
[SerializeField] [SerializeField]
private GameObject deathScreen; private GameObject deathScreen;
private void Start()
{
InvokeRepeating(nameof(Heal), 1f, 1f);
}
private void Update() private void Update()
{ {
if (Input.GetKeyDown(KeyCode.Escape)) if (Input.GetKeyDown(KeyCode.Escape))
@@ -37,6 +51,7 @@ public class PlayerManager : MonoBehaviour
} }
} }
// --- CHARACTER STATS ---------------------------------------------------------------------
public void TakeDamage(int value) public void TakeDamage(int value)
{ {
Health -= value; Health -= value;
@@ -53,9 +68,9 @@ public class PlayerManager : MonoBehaviour
} }
} }
public void Heal(int value) public void Heal()
{ {
Health += value; Health += HealValue;
if (Health > MaxHealth) if (Health > MaxHealth)
{ {
Health = MaxHealth; Health = MaxHealth;