Ejemplo n.º 1
0
    public float ChangeState(EEntityState newState)
    {
        //Legacy Animation
        if (m_animation != null)
        {
            if (m_currentState != newState)
            {
                if (OnAnimationStateChanged != null)
                {
                    OnAnimationStateChanged(newState);
                }
                RpcAnimationChange((int)newState, NetworkTime.Instance.ServerStep());
                m_currentState = newState;
                AnimationClip clip = m_animation.GetClip(newState.ToString());
                if (clip != null)
                {
                    return(clip.length / m_animationDataDict[newState].m_animationSpeed);
                }
                return(0);
            }
        }
        //Animator
        if (m_animator != null)
        {
            if (m_currentState != newState)
            {
                if (OnAnimationStateChanged != null)
                {
                    OnAnimationStateChanged(newState);
                }
                RpcAnimationChange((int)newState, NetworkTime.Instance.ServerStep());
                m_currentState = newState;
                m_animator.Play(newState.ToString());
                //m_animator.SetTrigger(newState.ToString());
                Debug.Log("Changing animation Trigger: " + newState);
                if (m_animatorClipsDict.ContainsKey(m_currentState))
                {
                    return(m_animatorClipsDict[newState].length / m_animator.speed);
                }
            }
        }

        return(0);
    }
Ejemplo n.º 2
0
    public void ClientAnimationChange(EEntityState newState)
    {
        //If using legacy animation
        if (m_animation != null)
        {
            if (newState == EEntityState.Stun)
            {
                if (m_animation.isPlaying)
                {
                    m_animation.Stop();
                }
            }

            if (OnAnimationStateChanged != null)
            {
                OnAnimationStateChanged(newState);
            }
            if (newState == EEntityState.Run)
            {
                m_animation[newState.ToString()].speed = m_animationDataDict[newState].m_animationSpeed * (1 + (m_entity.SpeedMod / 10));
                m_animation.Play(newState.ToString());
            }
            else
            {
                AnimationClip clip = m_animation.GetClip(newState.ToString());
                if (clip != null)
                {
                    m_animation[newState.ToString()].speed = m_animationDataDict[newState].m_animationSpeed;
                    m_animation.Play(newState.ToString());
                }
            }
        }

        //If using Animator
        if (m_animator != null)
        {
            if (newState == EEntityState.Stun)
            {
                m_animator.StopPlayback();
            }

            if (OnAnimationStateChanged != null)
            {
                OnAnimationStateChanged(newState);
            }
            Debug.Log("Playing animation Mecanim " + newState);

            if (newState == EEntityState.Run)
            {
                m_animator.Play(newState.ToString());
                //m_animator.speed = (1 + m_entity.SpeedMod);
            }
            else
            {
                m_animator.Play(newState.ToString());
                //m_animator.speed = 1;
            }
        }
    }
Ejemplo n.º 3
0
    public void Switch(EEntityState state, Vector3 recordPos)
    {
        GameStart.GetInstance().LogModuel.Log(ELogType.Normal, "Switch State : " + state.ToString());
        //播放对应动画
        if (m_characterAnim != null)
        {
            m_characterAnim.PlayAnim(state);
        }

        switch (state)
        {
        case EEntityState.Hit:
            if ((m_characterCollider != null && m_characterCollider.BallEnter) || (m_batCollider != null && m_batCollider.BallEnter))
            {
                HitBall(recordPos);
            }
            break;
        }
    }
Ejemplo n.º 4
0
 private string GetAnimNameByType(EEntityState animType)
 {
     return(animType.ToString());
 }