fgm24/Assets/Scripts/Animation/PlayerAnimationHandler.cs

68 lines
1.7 KiB
C#
Raw Normal View History

2024-02-03 11:42:50 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimationHandler : MonoBehaviour
{
2024-02-04 05:40:23 +01:00
public Animator animator;
2024-02-04 11:09:26 +01:00
private float previousMop1Clean;
private float previousMop2Clean;
2024-02-03 11:42:50 +01:00
void Start()
{
animator = GetComponentInChildren<Animator>();
2024-02-04 11:09:26 +01:00
previousMop1Clean = BloodComputeShader.Instance.mop1Clean;
previousMop2Clean = BloodComputeShader.Instance.mop2Clean;
}
private void Update()
{
2024-02-04 16:32:14 +01:00
var playerInput = GetComponent<PlayerInput>();
if (playerInput.PlayerNum == 0)
{
RunMop1(BloodComputeShader.Instance.mop1Clean >= 10);
}
else
{
RunMop2(BloodComputeShader.Instance.mop2Clean >= 10);
}
2024-02-04 11:09:26 +01:00
// Current frame values
//float currentMop1Clean = BloodComputeShader.Instance.mop1Clean;
//float currentMop2Clean = BloodComputeShader.Instance.mop2Clean;
//RunMop(currentMop1Clean < previousMop1Clean);
//RunMop(currentMop2Clean < previousMop2Clean);
//// Update previous values for the next frame
//previousMop1Clean = currentMop1Clean;
//previousMop2Clean = currentMop2Clean;
}
2024-02-03 11:42:50 +01:00
2024-02-03 13:07:46 +01:00
public void Idle()
2024-02-03 11:42:50 +01:00
{
2024-02-03 13:07:46 +01:00
animator.SetTrigger("Idle");
2024-02-03 11:42:50 +01:00
}
2024-02-04 02:56:12 +01:00
public void Run(bool state)
2024-02-03 11:42:50 +01:00
{
2024-02-04 11:09:26 +01:00
animator.SetBool("IsRunning", state);
2024-02-03 11:42:50 +01:00
}
2024-02-04 05:40:23 +01:00
public void Swing(bool state)
2024-02-03 11:42:50 +01:00
{
2024-02-04 05:40:23 +01:00
animator.SetBool("IsSwinging", state);
2024-02-03 11:42:50 +01:00
}
2024-02-03 13:07:46 +01:00
public void Mop()
2024-02-03 11:42:50 +01:00
{
2024-02-03 13:07:46 +01:00
animator.SetTrigger("Mop");
2024-02-03 12:21:41 +01:00
}
2024-02-04 11:09:26 +01:00
public void RunMop1(bool active)
{
animator.SetBool("RunMop1", active);
}
public void RunMop2(bool active)
2024-02-03 12:21:41 +01:00
{
2024-02-04 11:09:26 +01:00
animator.SetBool("RunMop2", active);
2024-02-03 11:42:50 +01:00
}
}