91 lines
3.6 KiB
C#
91 lines
3.6 KiB
C#
using System.Collections.Generic;
|
|
using Cielonos.UI;
|
|
using Sirenix.OdinInspector;
|
|
using SLSFramework.General;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public partial class Player : CharacterBase
|
|
{
|
|
[TitleGroup("Presets")]
|
|
public PlayerViewPreset baseViewPreset;
|
|
|
|
[TitleGroup("Subcontrollers")]
|
|
[Required]
|
|
public PlayerInputSubcontroller inputSc;
|
|
[Required]
|
|
public PlayerOperationSubcontroller operationSc;
|
|
[Required]
|
|
public PlayerViewSubcontroller viewSc;
|
|
[Required]
|
|
public PlayerLandMovementSubcontroller landMovementSc => base.movementSc as PlayerLandMovementSubcontroller;
|
|
[Required]
|
|
public PlayerInventorySubcontroller inventorySc;
|
|
[HideInEditorMode]
|
|
public new PlayerAnimationSubcontroller animationSc => base.animationSc as PlayerAnimationSubcontroller;
|
|
}
|
|
|
|
public partial class Player
|
|
{
|
|
protected override void InitializeSubmodules()
|
|
{
|
|
base.InitializeSubmodules();
|
|
eventSm.onGetHit.InsertByPriority("Feedback_GetHit", new PrioritizedAction<AttackAreaBase>(Feedback_GetHit));
|
|
eventSm.onGetAttacked.InsertByPriority("UI_HealthBarUpdate", new PrioritizedAction<AttackAreaBase, AttackResult>(UI_HealthBarUpdate));
|
|
eventSm.onGetAttacked.InsertByPriority("Feedback_GetAttacked", new PrioritizedAction<AttackAreaBase, AttackResult>(Feedback_GetAttacked));
|
|
eventSm.onUseEnergy.InsertByPriority("UI_EnergyBarUpdate", new PrioritizedAction<CharacterBase, float>(UI_EnergyBarUpdate));
|
|
}
|
|
|
|
protected override void InitializeSubcontrollers()
|
|
{
|
|
base.InitializeSubcontrollers();
|
|
inputSc.Initialize();
|
|
operationSc.Initialize();
|
|
viewSc.Initialize();
|
|
inventorySc.Initialize();
|
|
|
|
reactionSc.Initialize();
|
|
reactionSc.originalBreakthroughResistances[BreakthroughType.Medium] = false;
|
|
reactionSc.originalBreakthroughResistances[BreakthroughType.Heavy] = false;
|
|
reactionSc.breakthroughResistances[BreakthroughType.Medium] = false;
|
|
reactionSc.breakthroughResistances[BreakthroughType.Heavy] = false;
|
|
}
|
|
}
|
|
|
|
public partial class Player
|
|
{
|
|
private void UI_HealthBarUpdate(AttackAreaBase attackArea, AttackResult attackResult)
|
|
{
|
|
if (attackResult.finalDamage > 0) PlayerCanvas.Instance.playerInfoUIArea.UpdateHealth();
|
|
}
|
|
|
|
private void UI_EnergyBarUpdate(CharacterBase user, float energyUsed)
|
|
{
|
|
if(energyUsed > 0) PlayerCanvas.Instance.playerInfoUIArea.UpdateEnergy();
|
|
}
|
|
|
|
private void Feedback_GetHit(AttackAreaBase attackArea)
|
|
{
|
|
Debug.Log("Play GetHit Feedback");
|
|
BreakthroughType breakthroughType = attackArea.attackSm.modifiedAttackValue.breakthroughType;
|
|
if(breakthroughType == BreakthroughType.None) return;
|
|
string feedbackName = "GetHit" + breakthroughType.ToString();
|
|
feedbackSc[feedbackName]?.Play();
|
|
}
|
|
|
|
private void Feedback_GetAttacked(AttackAreaBase attackArea, AttackResult attackResult)
|
|
{
|
|
float ratio = attackResult.finalDamage / (attributeSm["MaximumHealth"] * 0.2f);
|
|
float intensity = Mathf.Lerp(0.25f, 1f, ratio);
|
|
PostProcessingManager.Instance.rgbSplitGlitchSm.ModifyIntensity(intensity);
|
|
feedbackSc["GetAttacked"]?.Play();
|
|
}
|
|
}
|
|
|
|
public interface IPlayerSubcontroller
|
|
{
|
|
Player player { get; }
|
|
}
|
|
} |