46 lines
973 B
C#
46 lines
973 B
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.Events;
|
||
|
|
using EasyTalk.Controller;
|
||
|
|
using EasyTalk.Nodes;
|
||
|
|
|
||
|
|
public abstract class Character : MonoBehaviour
|
||
|
|
{
|
||
|
|
[Header("Stats")]
|
||
|
|
public int CurHp;
|
||
|
|
public int MaxHp;
|
||
|
|
|
||
|
|
[Header("Components")]
|
||
|
|
public CharacterController Controller;
|
||
|
|
protected Character target;
|
||
|
|
public string charName = "Character";
|
||
|
|
public Dialogue dialogue;
|
||
|
|
protected DialogueController dialogueController;
|
||
|
|
public event UnityAction onTakeDamage;
|
||
|
|
|
||
|
|
void Awake()
|
||
|
|
{
|
||
|
|
dialogueController = FindFirstObjectByType<DialogueController>();
|
||
|
|
CurHp = MaxHp;
|
||
|
|
}
|
||
|
|
public void TakeDamage(int damageToTake)
|
||
|
|
{
|
||
|
|
CurHp -= damageToTake;
|
||
|
|
|
||
|
|
onTakeDamage?.Invoke();
|
||
|
|
|
||
|
|
if (CurHp <= 0)
|
||
|
|
Die();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Die ()
|
||
|
|
{
|
||
|
|
Destroy(gameObject);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetTarget (Character t)
|
||
|
|
{
|
||
|
|
target = t;
|
||
|
|
}
|
||
|
|
}
|