Add random point moving.
This commit is contained in:
@ -1,39 +1,71 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class CharacterCondition : MonoBehaviour
|
||||
public enum NPCState
|
||||
{
|
||||
public event Action<object> OnKilledEvent;
|
||||
public event Action<int> OnDamageHealthTakenEvent;
|
||||
public event Action<int> OnDamageArmourTakenEvent;
|
||||
public event Action<int> OnAmmunitionTakenEvent;
|
||||
InCover,
|
||||
InBlancPoint,
|
||||
InRunning,
|
||||
}
|
||||
|
||||
[SerializeField] private int HealthPoints;
|
||||
[SerializeField] private int ArmourPoints;
|
||||
[SerializeField] private int Ammunition;
|
||||
public class CharacterCondition
|
||||
{
|
||||
public event Action<int> OnChangeHealthEvent;
|
||||
public event Action<int> OnChangeArmourEvent;
|
||||
public event Action<int> OnChangeAmmunitionEvent;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
|
||||
private int health;
|
||||
public int HealthPoints
|
||||
{
|
||||
get
|
||||
{
|
||||
return health;
|
||||
}
|
||||
private set
|
||||
{
|
||||
health = value;
|
||||
OnChangeHealthEvent?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetDamage(float damage)
|
||||
private int armour;
|
||||
public int ArmourPoints
|
||||
{
|
||||
HealthPoints -= Mathf.RoundToInt(damage * (1 - ArmourPoints * 0.5f));
|
||||
ArmourPoints -= Mathf.RoundToInt(Mathf.Sqrt(damage) * 5);
|
||||
|
||||
OnDamageHealthTakenEvent?.Invoke(HealthPoints);
|
||||
OnDamageArmourTakenEvent?.Invoke(ArmourPoints);
|
||||
if (HealthPoints < 0)
|
||||
OnKilledEvent?.Invoke(gameObject);
|
||||
get
|
||||
{
|
||||
return armour;
|
||||
}
|
||||
private set
|
||||
{
|
||||
armour = value;
|
||||
OnChangeArmourEvent?.Invoke(value);
|
||||
}
|
||||
}
|
||||
private int ammo;
|
||||
public int Ammunition
|
||||
{
|
||||
get
|
||||
{
|
||||
return ammo;
|
||||
}
|
||||
private set
|
||||
{
|
||||
ammo = value;
|
||||
OnChangeAmmunitionEvent?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
[HideInInspector]
|
||||
public NPCState npcState { get; private set; }
|
||||
|
||||
public CharacterCondition()
|
||||
{
|
||||
var settings = SettingsReader.Instance.GetSettings;
|
||||
ammo = settings.maxAmmo;
|
||||
health = settings.maxHealth;
|
||||
armour = settings.maxArmour;
|
||||
}
|
||||
|
||||
public void GiveHealth(int health) => HealthPoints = Mathf.Clamp(health + HealthPoints, 0, 100);
|
||||
public void SetHealth(int health) => HealthPoints = Mathf.Clamp(health, 0, 100);
|
||||
public void GiveArmour(int armour) => ArmourPoints = Mathf.Clamp(armour + ArmourPoints, 0, 100);
|
||||
public void SetArmour(int armour) => ArmourPoints = Mathf.Clamp(armour, 0, 100);
|
||||
public void TakeAmmo(int ammo)
|
||||
{
|
||||
Ammunition += ammo;
|
||||
OnAmmunitionTakenEvent?.Invoke(Ammunition);
|
||||
}
|
||||
public void TakeAmmo(int ammo) => Ammunition += ammo;
|
||||
}
|
Reference in New Issue
Block a user