2025-12-08 05:27:53 -05:00
|
|
|
|
using System.Collections.Generic;
|
2026-03-20 12:07:44 -04:00
|
|
|
|
using Cielonos.MainGame.Buffs.Character;
|
2026-02-13 09:22:11 -05:00
|
|
|
|
using Cielonos.MainGame.UI;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
using Sirenix.OdinInspector;
|
2026-02-13 09:22:11 -05:00
|
|
|
|
using SLSUtilities.General;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Serialization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class Player : CharacterBase
|
|
|
|
|
|
{
|
2026-03-20 12:07:44 -04:00
|
|
|
|
[TitleGroup("Data")]
|
|
|
|
|
|
public AttributeData globalAttributeData;
|
|
|
|
|
|
[TitleGroup("Data")]
|
|
|
|
|
|
public PlayerViewPreset baseViewPreset;
|
|
|
|
|
|
|
|
|
|
|
|
[TitleGroup("Submodules")]
|
|
|
|
|
|
public AttributeSubmodule globalAttributeSm;
|
2026-01-03 18:19:39 -05:00
|
|
|
|
public PlayerEventSubmodule eventSm => base.eventSm as PlayerEventSubmodule;
|
|
|
|
|
|
|
2025-11-25 08:19:33 -05:00
|
|
|
|
[Required]
|
2026-03-20 12:07:44 -04:00
|
|
|
|
[TitleGroup("Subcontrollers")]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public PlayerInputSubcontroller inputSc;
|
|
|
|
|
|
[Required]
|
2026-03-20 12:07:44 -04:00
|
|
|
|
[TitleGroup("Subcontrollers")]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public PlayerOperationSubcontroller operationSc;
|
|
|
|
|
|
[Required]
|
2026-03-20 12:07:44 -04:00
|
|
|
|
[TitleGroup("Subcontrollers")]
|
2026-02-13 09:22:11 -05:00
|
|
|
|
public PlayerInteractionSubcontroller interactionSc;
|
|
|
|
|
|
[Required]
|
2026-03-20 12:07:44 -04:00
|
|
|
|
[TitleGroup("Subcontrollers")]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public PlayerViewSubcontroller viewSc;
|
|
|
|
|
|
[Required]
|
2026-03-20 12:07:44 -04:00
|
|
|
|
[TitleGroup("Subcontrollers")]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public PlayerLandMovementSubcontroller landMovementSc => base.movementSc as PlayerLandMovementSubcontroller;
|
|
|
|
|
|
[Required]
|
2026-03-20 12:07:44 -04:00
|
|
|
|
[TitleGroup("Subcontrollers")]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public PlayerInventorySubcontroller inventorySc;
|
|
|
|
|
|
[HideInEditorMode]
|
|
|
|
|
|
public new PlayerAnimationSubcontroller animationSc => base.animationSc as PlayerAnimationSubcontroller;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class Player
|
|
|
|
|
|
{
|
2025-12-08 05:27:53 -05:00
|
|
|
|
protected override void InitializeSubmodules()
|
|
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
//globalAttributeSm = new AttributeSubmodule(this, globalAttributeData);
|
2025-12-08 05:27:53 -05:00
|
|
|
|
base.InitializeSubmodules();
|
2026-01-03 18:19:39 -05:00
|
|
|
|
base.eventSm = new PlayerEventSubmodule(this);
|
2025-12-08 05:27:53 -05:00
|
|
|
|
eventSm.onGetHit.InsertByPriority("Feedback_GetHit", new PrioritizedAction<AttackAreaBase>(Feedback_GetHit));
|
2026-05-23 08:27:50 -04:00
|
|
|
|
eventSm.onAfterGetAttacked.InsertByPriority("Feedback_GetAttacked", new PrioritizedAction<AttackAreaBase, Attack.Result>(Feedback_GetAttacked));
|
2026-04-18 13:57:19 -04:00
|
|
|
|
|
|
|
|
|
|
eventSm.onNormalDodgeSuccess.InsertByPriority("Feedback_NormalDodge", new PrioritizedAction<AttackAreaBase, DodgeSource>(Feedback_NormalDodge));
|
|
|
|
|
|
eventSm.onPerfectDodgeSuccess.InsertByPriority("Feedback_PerfectDodge", new PrioritizedAction<AttackAreaBase, DodgeSource>(Feedback_PerfectDodge));
|
2025-12-08 05:27:53 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 08:27:50 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 注册 Player 特有的属性变更回调:
|
|
|
|
|
|
/// Health/MaxHealth → HealthBar UI 更新;Energy/MaxEnergy → EnergyBar UI 更新。
|
|
|
|
|
|
/// 基类已注册 Health→onHealthChanged、Energy→onEnergyChanged 的自动触发。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected override void RegisterAttributeCallbacks()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.RegisterAttributeCallbacks();
|
|
|
|
|
|
|
|
|
|
|
|
attributeSm.RegisterValueChangedCallback(CharacterAttribute.Health, OnHealthValueChanged);
|
|
|
|
|
|
attributeSm.RegisterValueChangedCallback(CharacterAttribute.MaximumHealth, OnMaxHealthValueChanged);
|
|
|
|
|
|
attributeSm.RegisterValueChangedCallback(CharacterAttribute.Energy, OnEnergyValueChanged);
|
|
|
|
|
|
attributeSm.RegisterValueChangedCallback(CharacterAttribute.MaximumEnergy, OnMaxEnergyValueChanged);
|
|
|
|
|
|
attributeSm.RegisterValueChangedCallback(CharacterAttribute.Shield, OnShieldValueChanged);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 08:19:33 -05:00
|
|
|
|
protected override void InitializeSubcontrollers()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitializeSubcontrollers();
|
|
|
|
|
|
inputSc.Initialize();
|
|
|
|
|
|
operationSc.Initialize();
|
2026-02-13 09:22:11 -05:00
|
|
|
|
interactionSc.Initialize();
|
2025-11-25 08:19:33 -05:00
|
|
|
|
viewSc.Initialize();
|
|
|
|
|
|
inventorySc.Initialize();
|
2026-01-03 18:19:39 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Start();
|
|
|
|
|
|
|
|
|
|
|
|
inventorySc.equipmentSm.EquipMainWeapon(inventorySc.equipmentSm.preparedMainWeapons[0]);
|
|
|
|
|
|
|
2026-05-10 11:47:55 -04:00
|
|
|
|
for (int i = 0; i < inventorySc.backpackSm.supportEquipments.Count; i++)
|
2026-01-03 18:19:39 -05:00
|
|
|
|
{
|
2026-05-10 11:47:55 -04:00
|
|
|
|
inventorySc.equipmentSm.EquipSupportEquipment(inventorySc.backpackSm.supportEquipments[i], i);
|
2026-01-03 18:19:39 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Update();
|
|
|
|
|
|
Regeneration();
|
2025-12-08 05:27:53 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 08:27:50 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 属性变更 → UI 更新回调
|
|
|
|
|
|
/// </summary>
|
2025-12-08 05:27:53 -05:00
|
|
|
|
public partial class Player
|
|
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
private void OnHealthValueChanged(float oldValue, float newValue)
|
2025-12-08 05:27:53 -05:00
|
|
|
|
{
|
2026-05-10 11:47:55 -04:00
|
|
|
|
PlayerCanvas.PlayerInfoUIArea.UpdateHealth();
|
2026-02-13 09:22:11 -05:00
|
|
|
|
|
2026-05-23 08:27:50 -04:00
|
|
|
|
if (newValue < oldValue)
|
2026-02-13 09:22:11 -05:00
|
|
|
|
{
|
2026-05-10 11:47:55 -04:00
|
|
|
|
PlayerCanvas.PlayerInfoUIArea.healthBar.GetHurtGlowBlink();
|
2026-02-13 09:22:11 -05:00
|
|
|
|
}
|
2025-12-08 05:27:53 -05:00
|
|
|
|
}
|
2026-05-23 08:27:50 -04:00
|
|
|
|
|
|
|
|
|
|
private void OnMaxHealthValueChanged(float oldValue, float newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
PlayerCanvas.PlayerInfoUIArea.UpdateHealth();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEnergyValueChanged(float oldValue, float newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
PlayerCanvas.PlayerInfoUIArea.UpdateEnergy();
|
|
|
|
|
|
}
|
2025-12-08 05:27:53 -05:00
|
|
|
|
|
2026-05-23 08:27:50 -04:00
|
|
|
|
private void OnMaxEnergyValueChanged(float oldValue, float newValue)
|
2025-12-08 05:27:53 -05:00
|
|
|
|
{
|
2026-05-10 11:47:55 -04:00
|
|
|
|
PlayerCanvas.PlayerInfoUIArea.UpdateEnergy();
|
2025-12-08 05:27:53 -05:00
|
|
|
|
}
|
2026-05-23 08:27:50 -04:00
|
|
|
|
|
|
|
|
|
|
private void OnShieldValueChanged(float oldValue, float newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 护盾值变更时刷新 HealthBar(护盾通常与血条关联显示)
|
|
|
|
|
|
PlayerCanvas.PlayerInfoUIArea.UpdateHealth();
|
|
|
|
|
|
}
|
2025-12-08 05:27:53 -05:00
|
|
|
|
|
2026-05-23 08:27:50 -04:00
|
|
|
|
private void OnMaxShieldValueChanged(float oldValue, float newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
PlayerCanvas.PlayerInfoUIArea.UpdateHealth();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class Player
|
|
|
|
|
|
{
|
2025-12-08 05:27:53 -05:00
|
|
|
|
private void Feedback_GetHit(AttackAreaBase attackArea)
|
|
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
Breakthrough.Type breakthroughType = attackArea.attackSm.attackValue.breakthroughType;
|
|
|
|
|
|
if(breakthroughType == Breakthrough.Type.None) return;
|
2025-12-08 05:27:53 -05:00
|
|
|
|
string feedbackName = "GetHit" + breakthroughType.ToString();
|
2026-04-28 15:46:32 -04:00
|
|
|
|
feedbackSc.PlayFeedback(feedbackName);
|
2025-12-08 05:27:53 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 08:27:50 -04:00
|
|
|
|
private void Feedback_GetAttacked(AttackAreaBase attackArea, Attack.Result attackResult)
|
2025-12-08 05:27:53 -05:00
|
|
|
|
{
|
|
|
|
|
|
float ratio = attackResult.finalDamage / (attributeSm["MaximumHealth"] * 0.2f);
|
|
|
|
|
|
float intensity = Mathf.Lerp(0.25f, 1f, ratio);
|
2026-04-28 15:46:32 -04:00
|
|
|
|
//feedbackSc.GetFeedbackData("GetAttacked")
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|
2026-04-18 13:57:19 -04:00
|
|
|
|
|
|
|
|
|
|
private void Feedback_PerfectDodge(AttackAreaBase attackArea, DodgeSource dodgeSource)
|
|
|
|
|
|
{
|
|
|
|
|
|
feedbackSc.PlayFeedback("PerfectDodge");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Feedback_NormalDodge(AttackAreaBase attackArea, DodgeSource dodgeSource)
|
|
|
|
|
|
{
|
|
|
|
|
|
feedbackSc.PlayFeedback("NormalDodge");
|
|
|
|
|
|
}
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|
2026-05-23 08:27:50 -04:00
|
|
|
|
}
|