39 lines
980 B
C#
39 lines
980 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class Player : MonoBehaviour, ICharacter
|
|
{
|
|
[HideInInspector]
|
|
public Character PlayerCharacter;
|
|
public CharacterCondition Condition;
|
|
|
|
public Character GetCharacter => PlayerCharacter;
|
|
|
|
private void Awake()
|
|
{
|
|
PlayerCharacter = new Character();
|
|
Condition = PlayerCharacter.Condition;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Debug.LogWarning("Pooled object was destroyed");
|
|
}
|
|
|
|
public event Action<bool> OnDeathEvent;
|
|
public void GetDamage(int damage)
|
|
{
|
|
PlayerCharacter.LastTimeHit = TimeManager.Instance.CurrentTime;
|
|
Condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - Condition.ArmourPoints * 0.5f)));
|
|
Condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
|
|
|
|
if (Condition.HealthPoints < 0)
|
|
OnDeathEvent?.Invoke(true);
|
|
}
|
|
|
|
public void ResetCharacter()
|
|
{
|
|
Condition = new CharacterCondition();
|
|
}
|
|
}
|