浏览代码

Added reset health SO action

/main
Amel 4 年前
当前提交
9a3e73a6
共有 3 个文件被更改,包括 46 次插入0 次删除
  1. 6
      UOP1_Project/Assets/Scripts/Characters/Damageable.cs
  2. 29
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ResetHealthSO.cs
  3. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ResetHealthSO.cs.meta

6
UOP1_Project/Assets/Scripts/Characters/Damageable.cs


OnDie.Invoke();
}
}
public void ResetHealth()
{
_currentHealth = _healthConfigSO.MaxHealth;
IsDead = false;
}
}

29
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ResetHealthSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "ResetHealth", menuName = "State Machines/Actions/Reset Health")]
public class ResetHealthSO : StateActionSO
{
protected override StateAction CreateAction() => new ResetHealth();
}
public class ResetHealth : StateAction
{
private Damageable _damageableEntity;
public override void Awake(StateMachine stateMachine)
{
_damageableEntity = stateMachine.GetComponent<Damageable>();
}
public override void OnUpdate()
{
}
public override void OnStateExit()
{
_damageableEntity.ResetHealth();
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ResetHealthSO.cs.meta


fileFormatVersion: 2
guid: 5455c4a73b1ee9d409aa3ce9ac7a1470
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存