-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character.cs
51 lines (39 loc) · 1.25 KB
/
Character.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Character : MonoBehaviour
{
private CharacterState _currCharacterState;
private InputControl _inputControl;
public CharacterStats CharacterStats;
public GameObject CharacterModel;
public void handleInput()
{
_currCharacterState.handleInput();
}
void Update()
{
if (CharacterStats.EnergyRemaining < CharacterStats.MaxEnergy)
CharacterStats.EnergyRemaining += CharacterStats.EnergyRegen * Time.deltaTime;
if (CharacterStats.EnergyRemaining > CharacterStats.MaxEnergy - 0.001)
CharacterStats.EnergyRemaining = CharacterStats.MaxEnergy;
}
public void TakeDamage(float damageAmount)
{
CharacterStats.HealthRemaining -= damageAmount;
if (CharacterStats.HealthRemaining <= 0)
Die();
}
public void RemoveShieldEnergy()
{
CharacterStats.EnergyRemaining -= CharacterStats.ShieldEnergyRate * Time.deltaTime;
}
public void RemoveShootEnergy()
{
CharacterStats.EnergyRemaining -= CharacterStats.ShootEnergyCost;
}
public void Die()
{
Destroy(this.gameObject);
}
}