2023-08-22 19:08:45 +08:00
|
|
|
namespace Gameplay.Vehicle
|
|
|
|
|
{
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class VehicleAnim
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public BaseVehicle owner;
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
public readonly Animator rawAnim;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
public string currentAnim { get; private set; }
|
2024-04-15 16:14:28 +08:00
|
|
|
public string targetAnim
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
public VehicleAnim(BaseVehicle owner)
|
|
|
|
|
{
|
|
|
|
|
this.owner = owner;
|
|
|
|
|
var rootObj = owner.Node.GameObject;
|
|
|
|
|
var animTrans = rootObj.transform.GetChild(0).GetChild(0);
|
|
|
|
|
rawAnim = animTrans.GetComponent<Animator>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ViewUpdate(float dt)
|
|
|
|
|
{
|
|
|
|
|
if (rawAnim == null) return;
|
|
|
|
|
if (currentAnim != targetAnim)
|
|
|
|
|
{
|
|
|
|
|
if (currentAnim == null)
|
|
|
|
|
{
|
|
|
|
|
rawAnim.Play(targetAnim);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rawAnim.CrossFade(targetAnim, 0.1f);
|
|
|
|
|
}
|
|
|
|
|
currentAnim = targetAnim;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|