Esempio n. 1
0
 public void StartImpact(ImpactInfo impactInfo)
 {
     if (null == impactInfo)
     {
         Debug.LogWarning("ImpactHitFly::StartImpact -- impactInfo is null");
     }
     GeneralStartImpact(impactInfo);
     if (m_ImpactInfo.m_MicroHitFlyConfig.m_UseCustom)
     {
         m_CurCrossFadeTime = m_ImpactInfo.m_HitFlyConfig.m_CrossFadeTime;
         if (m_CurCrossFadeTime > Mathf.Abs(m_ImpactInfo.m_Velocity.y / m_Gravity))
         {
             m_CurCrossFadeTime = Mathf.Abs(m_ImpactInfo.m_Velocity.y / m_Gravity);
         }
         m_MovingTime      = m_ImpactInfo.m_HitFlyConfig.m_MovingTime;
         m_OnLandHoldTime  = m_ImpactInfo.m_HitFlyConfig.m_OnLandHoldTime;
         m_Scale           = m_ImpactInfo.m_MicroHitFlyConfig.m_Scaler;
         m_ScaleStartDelay = m_ImpactInfo.m_MicroHitFlyConfig.m_ScaleDelay;
         m_EndSpeedY       = m_ImpactInfo.m_MicroHitFlyConfig.m_EndSpeedY;
     }
     else
     {
         m_CurCrossFadeTime = Mathf.Abs(m_ImpactInfo.m_Velocity.y / m_Gravity);
         m_MovingTime       = -1;
         m_OnLandHoldTime   = 0;
     }
     SetAnimation(m_HitDirection);
     m_IsSlow   = false;
     m_HasSlow  = false;
     m_State    = HitFlyState.Rise;
     m_Velocity = m_ImpactInfo.m_Velocity;
     //SetFaceDir(new Vector3(-impactInfo.m_Velocity.x, 0, - impactInfo.m_Velocity.z));
     m_AnimationPlayer.CrossFade(m_AnimationDict.RisingAnim.name, m_CurCrossFadeTime);
 }
Esempio n. 2
0
    public static FSMStateMachine GetCharacterEditorFSM(Creature owner)
    {
        FSMTranslationMap translationMap = new FSMTranslationMap();
        DeadState         dead           = new DeadState(owner);
        AttackState       attackState    = new AttackState(owner);
        IdleState         idle           = new IdleState(owner);
        WalkState         walk           = new WalkState(owner);
        HitState          hitState       = new HitState(owner);
        RunState          runState       = new RunState(owner);
        HitMoveState      hitMoveState   = new HitMoveState(owner);
        HitFlyState       hitFlyState    = new HitFlyState(owner);

        translationMap.addState(dead);
        translationMap.addState(idle);
        translationMap.addState(walk);
        translationMap.addState(runState);
        translationMap.addState(hitState);
        translationMap.addState(hitMoveState);
        translationMap.addState(attackState);
        translationMap.addState(hitFlyState);
        translationMap.MixAll();
        translationMap.check();
        FSMStateMachine fsm = new FSMStateMachine(translationMap);

        return(fsm);
    }
Esempio n. 3
0
 public void OnKnockDown()
 {
     if (HitFlyState.Rise == m_State || HitFlyState.Fall == m_State)
     {
         m_State       = HitFlyState.Fall;
         m_Velocity.y -= 5;
     }
 }
Esempio n. 4
0
 public void DoHitFly(Vector3 position, float flyDistance, float flyTime)
 {
     if (FSM != null)
     {
         if (FSM.CurrentState.ID == CreatureStateType.Dead)
         {
             return;
         }
         if (FSM.CurrentState.ID != CreatureStateType.Hit && FSM.CurrentState.ID != CreatureStateType.HitMove && FSM.CurrentState.ID != CreatureStateType.Attack && FSM.CurrentState.ID != CreatureStateType.HitFly)
         {
             HitFlyState hitFlyState = FSM.getStateByID(CreatureStateType.HitFly) as HitFlyState;
             if (hitFlyState != null)
             {
                 hitFlyState.Position    = position;
                 hitFlyState.FlyDistance = flyDistance;
                 hitFlyState.FlyTime     = flyTime;
                 FSM.changeState(CreatureStateType.HitFly);
             }
         }
     }
 }
Esempio n. 5
0
 protected override void TickAnimation(float deltaTime)
 {
     if (HitFlyState.Rise == m_State)
     {
         if (m_Velocity.y <= 0)
         {
             m_State = HitFlyState.Fall;
             m_AnimationPlayer.CrossFade(m_AnimationDict.DropAnim.name, Mathf.Sqrt(Mathf.Abs((this.transform.position.y - GetTerrainHeight(this.transform.position)) * 2 / m_Gravity)));
         }
     }
     else if (HitFlyState.Fall == m_State)
     {
         if (m_CharacterController.isGrounded)
         {
             if (null != m_HitGroundEffect)
             {
                 GameObject obj = ResourceSystem.NewObject(m_HitGroundEffect) as GameObject;
                 if (null != obj)
                 {
                     obj.transform.position = this.transform.position;
                     obj.transform.rotation = Quaternion.identity;
                     GameObject.Destroy(obj, 2.0f);
                 }
             }
             m_State = HitFlyState.OnGround;
             m_AnimationPlayer.Play(m_AnimationDict.HitGroundAnim.name);
             m_HitLandTime = Time.time;
         }
         else
         {
         }
     }
     else if (HitFlyState.OnGround == m_State)
     {
         if (!m_AnimationPlayer.IsPlaying(m_AnimationDict.HitGroundAnim.name) ||
             Time.time > m_HitLandTime + m_AnimationPlayer.AnimationLenth(m_AnimationDict.HitGroundAnim))
         {
             if (m_OnLandHoldTime > 0)
             {
                 m_AnimationPlayer.CrossFade(m_AnimationDict.OnLandHoldAnim.name);
                 m_OnLandHoldTime -= deltaTime;
             }
             else
             {
                 m_State = HitFlyState.Stand;
                 if (IsLogicDead())
                 {
                     NotifyNpcDead(gameObject);
                     StopImpact();
                 }
                 else
                 {
                     m_AnimationPlayer.Play(m_AnimationDict.StandUpAnim.name);
                 }
             }
         }
     }
     else if (HitFlyState.Stand == m_State)
     {
         if (!m_AnimationPlayer.IsPlaying(m_AnimationDict.StandUpAnim.name) ||
             Time.time > m_HitLandTime + m_AnimationPlayer.AnimationLenth(m_AnimationDict.HitGroundAnim) + m_OnLandHoldTime + m_AnimationPlayer.AnimationLenth(m_AnimationDict.StandAnim))
         {
             StopImpact();
         }
     }
 }