角色能力,存档
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using BaseGames.Core.Events;
|
||||
using BaseGames.Input;
|
||||
|
||||
namespace BaseGames.Player
|
||||
{
|
||||
@@ -16,6 +17,7 @@ namespace BaseGames.Player
|
||||
{
|
||||
[Header("配置")]
|
||||
[SerializeField] private FormConfigSO _config;
|
||||
[SerializeField] private InputReaderSO _input;
|
||||
|
||||
[Header("事件频道")]
|
||||
[SerializeField] private IntEventChannelSO _onFormChanged; // 广播当前形态索引(UI/Save)
|
||||
@@ -33,6 +35,22 @@ namespace BaseGames.Player
|
||||
Debug.Assert(_config != null, "[FormController] _config 未赋值,请在 Inspector 中指定 FormConfigSO。", this);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_input == null) return;
|
||||
_input.SwitchSkyFormEvent += OnSwitchSky;
|
||||
_input.SwitchEarthFormEvent += OnSwitchEarth;
|
||||
_input.SwitchDeathFormEvent += OnSwitchDeath;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_input == null) return;
|
||||
_input.SwitchSkyFormEvent -= OnSwitchSky;
|
||||
_input.SwitchEarthFormEvent -= OnSwitchEarth;
|
||||
_input.SwitchDeathFormEvent -= OnSwitchDeath;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_config.forms != null && _config.forms.Length > 0)
|
||||
@@ -67,5 +85,10 @@ namespace BaseGames.Player
|
||||
if (form != null)
|
||||
SwitchForm(form.formType);
|
||||
}
|
||||
|
||||
// ── 内部输入处理 ────────────────────────────────────────────────────────
|
||||
private void OnSwitchSky() => SwitchForm(FormType.TianHun);
|
||||
private void OnSwitchEarth() => SwitchForm(FormType.DiHun);
|
||||
private void OnSwitchDeath() => SwitchForm(FormType.MingHun);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user