summaryrefslogtreecommitdiff
path: root/Erika/Assets/Scripts/Unit/Components/UnitStatemachine/Common/IdleState.cs
blob: 7eb4f67f167c0329408a0282fe1834780fe44297 (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
54
55
56
57
58
59
60
61
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace UnitStates.Common
{

    public class IdleState : UnitStateBase
    {
        public struct IdleParam : IStateParam
        {
        }

        public bool bCrossfade;

        public override void ModifyNextState(EUnitState state, UnitStateBase nextState)
        {
        }

        public override void OnEnter(IStateParam param)
        {
            if(m_Owner.isInAir)
            {
                //m_Owner.unitStatemachine.ChangeState(EUnitState.Landing);
                UnitStates.Common.LandingState.Param landingParam = new LandingState.Param();
                landingParam.height = m_Owner.height;
                landingParam.process = LandingState.EProcess.Landing_Loop;
                landingParam.useLastMotion = false;
                landingParam.lastMotion =  unitMotion.currentMotionData;
                fsm.ChangeState(EUnitState.Landing, landingParam);
            }
            else
            {
                if (bCrossfade)
                {
                    MotionData motion = m_Motion.GetMotionDataByAnimationType(EAnimationType.Idle);
                    m_Motion.CrossFade(motion.uid, 1f, motion.extraData.crossfadeNormalizedTimeOffset);
                }
                else 
                {
                    m_Motion.Trigger(EAnimationType.Idle);
                }
            }
            bCrossfade = false;
        }

        public override void OnExit()
        {
        }

        public override void OnFixedUpdate()
        {

        }

        public override void OnUpdate()
        {
        }
    }
}