blob: 568863c9477f120a7445f85e468cbdd258043355 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 播放动画,执行帧事件
[DisallowMultipleComponent]
public class UnitAnimation : UnitComponent
{
// animator trigger值,切换动画
public enum ETrigger
{
Nein = 0,
ToIdle ,
ToMove ,
ToSpawn ,
ToDie ,
ToHitAir ,
ToHitAirAir,
ToHitKnockDown,
ToJump,
ToWalk,
}
private Animator m_Animator;
private TimelineEvent m_Timeline;
private UnitActionData m_ActionData;
public override void Initialize()
{
base.Initialize();
m_Timeline = this.m_Owner.unitObj.GetOrAddComponent<TimelineEvent>();
m_Animator = this.m_Owner.unitObj.GetComponent<Animator>();
if(m_Animator == null)
{
LogHelper.LogError("没有挂Animator组件");
}
}
public void Play(ETrigger trigger)
{
string toAnim = trigger.ToString();
m_Animator.SetTrigger(toAnim);
}
}
|