Ejemplo n.º 1
0
    protected override void InitAnimation()
    {
        m_bIsDancer = true;

        if (!m_bIsDancer)
        {
            OwnerPlayer.IsToShow = false;
            m_LastPlayerPos      = OwnerPlayer.cachedTransform.position;
            OwnerPlayer.cachedTransform.position = CommonDef.RoleHidePos;
        }
        else
        {
            m_fAniScale = 1;// RoomData.PlaySongBPM / (float)DefaultBpm;

            if (AnimationLoader.StageAniExist && OwnerAni != null)
            {
                string   strPreName = getPreNameBySex();
                WrapMode mode       = getWrapModeBySongMode(RoomData.PlaySongMode);

                OwnerAni.AddClip(AnimationLoader.GetAnimationClip(AnimationLoader.StartDance), DanceStart, WrapMode.Loop, 2, 1, m_fAniScale);
                OwnerAni.AddClip(GetAniClipBySex(DanceStart_HB), DanceStart_HB, WrapMode.Loop, 2, 1f, m_fAniScale);
                OwnerAni.AddClip(GetAniClipBySex(Miss), Miss, WrapMode.Once, 3, 1f, m_fAniScale);
                OwnerAni.AddClip(GetAniClipBySex(Lose), Lose, WrapMode.Once, 3, 1f);
                OwnerAni.AddClip(GetAniClipBySex(Win), Win, mode, 3, 1f);

                if (AnimationLoader.s_AniStates.ContainsKey(strPreName))
                {
                    AniState preState = AnimationLoader.s_AniStates[strPreName];
                    if (preState != null)
                    {
                        OwnerAni.AddClip(AnimationLoader.GetAnimationClip(preState.Motion), DancePrepare, WrapMode.Once, 3, 0f, preState.Speed * m_fAniScale);
                    }
                    else
                    {
                        Debug.LogError("Add animation failed. AniState can not be null.Name=" + strPreName);
                    }
                }
                else
                {
                    Debug.LogError("Add animation failed. Animation can not find.Name=" + strPreName);
                }

                OwnerAni.CrossFade(DanceStart);
            }
        }
    }
Ejemplo n.º 2
0
    private void AddStandAni(List <string> aniList)
    {
        mStandAniList.Clear();
        AnimationClip clip     = null;
        string        clipName = null;

        for (int i = 0; i < aniList.Count; ++i)
        {
            clipName = aniList[i];
            clip     = AnimationLoader.GetAnimationClip(clipName);
            if (clip != null)
            {
                mStandAniList.Add(clipName);
                OwnerAni.AddClip(clip, clipName, WrapMode.Once, 2, 0f);
            }
        }
    }
Ejemplo n.º 3
0
    AnimationState GetAnimationStat(string strAnimation)
    {
        AnimationState state = null;

        if (OwnerAni != null)
        {
            state = OwnerAni[strAnimation];
            if (state == null)
            {
                AnimationClip animClip = AnimationLoader.GetAnimationClip(strAnimation);
                if (animClip != null)
                {
                    state = OwnerAni.AddClip(animClip, strAnimation);
                }
            }
        }

        return(state);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Add By hanyingjun
    /// Date:2017.1.20
    /// Des:添加单个动画,到额外的动画列表中
    /// </summary>
    /// <param name="clipName"></param>
    /// <returns></returns>
    public IEnumerator AddSingleAnimation(string clipName, WrapMode wrapMode, int layer)
    {
        IEnumerator itor = null;

        if (!string.IsNullOrEmpty(clipName))
        {
            if (!m_ExtraclipName.Contains(clipName))
            {
                m_ExtraclipName.Add(clipName);
                itor = AnimationLoader.LoadSingleAnimation(clipName);
                while (itor.MoveNext())
                {
                    yield return(null);
                }

                OwnerAni.AddClip(AnimationLoader.GetAnimationClip(clipName), clipName, wrapMode, layer);
            }
        }
    }
Ejemplo n.º 5
0
    void QueueAddState(float fStartTime, float BPMScale, List <string> danceAniSeq, bool isBoy)
    {
        float startStateTime = fStartTime;
        float startDuration  = 0;
        float fdurtion       = 0;
        float startFrame     = 0;

        for (int i = 0; i < danceAniSeq.Count; i++)
        {
            string stateName = danceAniSeq[i];
            if (!AnimationLoader.s_AniStates.ContainsKey(stateName))
            {
                continue;
            }
            AniState      state    = AnimationLoader.s_AniStates[stateName];
            string        clipName = state.Motion;
            AnimationClip animClip = AnimationLoader.GetAnimationClip(clipName);

            if (animClip == null)
            {
                Debug.LogError("Dance error, animation can not be null." + clipName);
                continue;
            }

            //AddAnimationPlayEvent(startStateTime, stateName, nLayer);
            if (startDuration != 0)
            {
                if (CheckIfAvailableAni(stateName))
                {
                    AddAnimationBlendEvent(startDuration, clipName, fdurtion, startFrame, state.Speed, isBoy);
                }
                if (i > 0)
                {
                    int      tmpIndex = i - 1;
                    AniState revState = AnimationLoader.s_AniStates[AnimationLoader.DanceAniSequence[tmpIndex]];
                    if (CheckIfAvailableAni(revState.Name))
                    {
                        AddAnimationRemoveEvent(startDuration + animClip.length, revState.Motion, isBoy);
                    }
                }
            }
            else
            {
                if (CheckIfAvailableAni(stateName))
                {
                    AddAnimationPlayEvent(startStateTime, clipName, state.Speed, isBoy);
                }
                if (i > 0)
                {
                    int      tmpIndex = i - 1;
                    AniState revState = AnimationLoader.s_AniStates[AnimationLoader.DanceAniSequence[tmpIndex]];
                    if (CheckIfAvailableAni(revState.Name))
                    {
                        AddAnimationRemoveEvent(startDuration + animClip.length, revState.Motion, isBoy);
                    }
                }
            }

            AniState         nextState = null;
            TranState        nextTran  = null;
            List <TranState> trans     = state.Trans;
            foreach (TranState tran in trans)
            {
                if (tran != null && isBoy == tran.IsBoy && AnimationLoader.s_AniStates.ContainsKey(tran.DestState))
                {
                    nextState = AnimationLoader.s_AniStates[tran.DestState];
                    nextTran  = tran;
                    break;
                }
            }

            if (nextState == null)
            {
                foreach (TranState tran in trans)
                {
                    if (tran != null && AnimationLoader.s_AniStates.ContainsKey(tran.DestState))
                    {
                        nextState = AnimationLoader.s_AniStates[tran.DestState];
                        nextTran  = tran;
                        break;
                    }
                }
            }

            if (nextState != null && nextTran != null)
            {
                AnimationClip nextAnimClip = AnimationLoader.GetAnimationClip(nextState.Motion);
                if (nextAnimClip != null)
                {
                    if (state.Speed != 0 && nextTran.ExitTime != 0)
                    {
                        startDuration  = startStateTime + animClip.length / state.Speed * nextTran.ExitTime;
                        startStateTime = startDuration - nextAnimClip.length / AnimationLoader.s_AniStates[nextTran.DestState].Speed * nextTran.TranOffset;
                        fdurtion       = animClip.length * nextTran.TranDuration / state.Speed;

                        startFrame = nextAnimClip.length * nextTran.TranOffset;
                    }
                    else
                    {
                        Debug.LogError("Animation  speed or next ExitTime is zero! Please Check it, aniName is : " + clipName);
                    }
                }
            }
            else
            {
                break;
            }
        }
    }
Ejemplo n.º 6
0
 protected AnimationClip GetAniClipBySex(string clipName)
 {
     return(AnimationLoader.GetAnimationClip(getLoaderClipNameBySex(clipName)));
 }