89 lines
1.9 KiB
C#
89 lines
1.9 KiB
C#
using UFS2.Gameplay;
|
|
using UnityEngine;
|
|
|
|
public class FeederPointerUI : HUDCanvasGroupBase
|
|
{
|
|
private Animator animator;
|
|
|
|
private void Start()
|
|
{
|
|
animator = GetComponent<Animator>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
FHook.OnFeederWaterEnter += FHook_OnFeederHookInWater;
|
|
FHook.OnFeederWaterExit += FHook_OnFeederHookOutWater;
|
|
FHook.OnFeederGroundEnter += FHook_OnFeederGroundEnter;
|
|
FHook.OnFeederGroundExit += FHook_OnFeederGroundExit;
|
|
FishEntity.OnPostSpitOutBait += FishEntity_OnPostSpitOutBait;
|
|
FishFightState.OnEnter += FishFightState_OnEnter;
|
|
FishFightState.OnExit += FishFightState_OnExit;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
FHook.OnFeederWaterEnter -= FHook_OnFeederHookInWater;
|
|
FHook.OnFeederWaterExit -= FHook_OnFeederHookOutWater;
|
|
FHook.OnFeederGroundEnter -= FHook_OnFeederGroundEnter;
|
|
FHook.OnFeederGroundExit -= FHook_OnFeederGroundExit;
|
|
FishEntity.OnPostSpitOutBait -= FishEntity_OnPostSpitOutBait;
|
|
FishFightState.OnEnter -= FishFightState_OnEnter;
|
|
FishFightState.OnExit -= FishFightState_OnExit;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
UpdateUIWidth();
|
|
}
|
|
|
|
private void FHook_OnFeederGroundExit()
|
|
{
|
|
animator.SetBool("Grounded", value: false);
|
|
}
|
|
|
|
private void FHook_OnFeederGroundEnter()
|
|
{
|
|
animator.SetBool("Grounded", value: true);
|
|
}
|
|
|
|
private void FishEntity_OnPostSpitOutBait(FishEntity fish)
|
|
{
|
|
animator.SetBool("Take", value: false);
|
|
}
|
|
|
|
private void FishFightState_OnEnter()
|
|
{
|
|
animator.SetBool("Take", value: true);
|
|
}
|
|
|
|
private void FishFightState_OnExit()
|
|
{
|
|
animator.SetBool("Take", value: false);
|
|
}
|
|
|
|
private void FHook_OnFeederHookOutWater()
|
|
{
|
|
animator.SetBool("InWater", value: false);
|
|
SetOff();
|
|
}
|
|
|
|
private void FHook_OnFeederHookInWater()
|
|
{
|
|
animator.SetBool("InWater", value: true);
|
|
SetOn();
|
|
}
|
|
|
|
private void UpdateUIWidth()
|
|
{
|
|
if (canvasGroup.alpha > 0f)
|
|
{
|
|
rectTransform.sizeDelta = originalSizeDelta;
|
|
}
|
|
else
|
|
{
|
|
rectTransform.sizeDelta = new Vector2(0f, originalSizeDelta.y);
|
|
}
|
|
}
|
|
}
|