コード例 #1
0
 /// <summary>
 /// 非预览播放状态下,通过滑杆来播放当前动画帧
 /// </summary>
 private void manualUpdate(NFAnimaStateType stateType, float time)
 {
     if (mAnimator != null && stateType != NFAnimaStateType.NONE)
     {
         mAnimator.PlayInFixedTime(stateType.ToString(), -1, time);
         mAnimator.Update(0f);
     }
 }
コード例 #2
0
    public void Update()
    {
        if (mCurrentState != NFAnimaStateType.NONE)
        {
            mStateDictionary[mCurrentState].Execute(this.gameObject);
            mStateDictionary[mCurrentState].OnCheckInput(this.gameObject);
        }
        else
        {
            ChangeState(NFAnimaStateType.Idle, -1);
        }


        if (Application.isEditor)
        {
            curState  = mCurrentState.ToString();
            lastState = mLastState.ToString();
        }
    }
コード例 #3
0
 public void OnEndAnimaEvent(GameObject self, NFAnimaStateType eAnimaType, int index)
 {
     Debug.Log("End Anima " + eAnimaType.ToString() + " " + index.ToString());
 }
コード例 #4
0
 public void OnBulletTouchPositionDelegation(GameObject self, Vector3 position, NFAnimaStateType eAnimaType, int index)
 {
     //show damage
     Debug.Log("show damage --- " + position.ToString() + " " + eAnimaType.ToString() + " " + index.ToString());
 }
コード例 #5
0
 public void OnDamageDelegation(GameObject self, GameObject target, NFAnimaStateType eAnimaType, int index)
 {
     //float damage = Random.Range(900000f, 1100000f);
     //NFPrefabManager.Instance.textManager.Add(damage.ToStringScientific(), target.transform);
     Debug.Log("show damage --- " + target.ToString() + " " + eAnimaType.ToString() + " " + index.ToString());
 }
コード例 #6
0
 public void OnBulletTouchTargetDelegation(GameObject self, GameObject target, NFAnimaStateType eAnimaType, int index)
 {
     //show damage
     Debug.Log("show damage --- " + target.name + " " + eAnimaType.ToString() + " " + index.ToString());
 }
コード例 #7
0
    public int PlayAnimaState(NFAnimaStateType eAnimaType, Vector3 v)
    {
        if (meLastPlayID == eAnimaType)
        {
            return(-1);
        }

        mxAnimationEvent.OnEndAnimaEvent(this.gameObject, meLastPlayID, mnSkillIndex);

        mnSkillIndex++;

        mxAnimationEvent.OnStartAnimaEvent(this.gameObject, eAnimaType, mnSkillIndex);

        for (int i = 0; i < mxSkillData.AnimationSkillList.Count; ++i)
        {
            AnimationSkillStruct xAnimationSkillStruct = mxSkillData.AnimationSkillList [i];
            if (xAnimationSkillStruct.Type == eAnimaType)
            {
                if (xAnimationSkillStruct.AnimationClip != null)
                {
                    mAnimator.Play(eAnimaType.ToString(), 0);
                }
                else
                {
                    UnityEditor.EditorUtility.DisplayDialog("Warning", "The AnimationClip is null!", "OK", "Cancel");
                }

                foreach (EffectStruct es in xAnimationSkillStruct.EffectStructList)
                {
                    if (es.Effect != null)
                    {
                        es.index = mnSkillIndex;
                        StartCoroutine(WaitPlayEffect(es));
                    }
                }
                foreach (AudioStruct es in xAnimationSkillStruct.AudioStructList)
                {
                    if (es.Audio != null)
                    {
                        es.index = mnSkillIndex;
                        StartCoroutine(WaitPlayAudio(es));
                    }
                }

                foreach (BulletStruct es in xAnimationSkillStruct.BulletStructList)
                {
                    if (es.Bullet != null)
                    {
                        es.index = mnSkillIndex;
                        StartCoroutine(WaitPlayBullet(es, v));
                    }
                }
                foreach (MovementStruct es in xAnimationSkillStruct.MovementStructList)
                {
                    es.index = mnSkillIndex;
                    StartCoroutine(WaitPlayMovement(es));
                }

                if (xAnimationSkillStruct.BulletStructList.Count <= 0)
                {
                    foreach (DamageStruct es in xAnimationSkillStruct.DamageStructList)
                    {
                        es.index = mnSkillIndex;
                        StartCoroutine(WaitPlayDamage(es));
                    }
                }

                foreach (CameraStruct es in xAnimationSkillStruct.CameraStructList)
                {
                    es.index = mnSkillIndex;
                    StartCoroutine(WaitPlayCamera(es));
                }

                meLastPlayID = eAnimaType;

                //get time
                if (eAnimaType != NFAnimaStateType.Idle)
                {
                    StartCoroutine(WaitPlayNextAnim(xAnimationSkillStruct.fTime, xAnimationSkillStruct.NextType));
                }
            }
        }

        return(mnSkillIndex);
    }
コード例 #8
0
        public int PlayAnimaState(NFAnimaStateType eAnimaType, int index, bool force = false)
        {
            foreach (GameObject go in effectList)
            {
                if (go != null)
                {
                    Destroy(go);
                }
            }

            effectList.Clear();

            if (eAnimaType == NFAnimaStateType.Idle)
            {
                float f = Random.Range(0, 100);
                if (f < 15.0f)
                {
                    for (int i = 0; i < mxSkillData.AnimationSkillList.Count; ++i)
                    {
                        AnimationSkillStruct xAnimationSkillStruct = mxSkillData.AnimationSkillList[i];
                        if (xAnimationSkillStruct.Type == NFAnimaStateType.Idle1)
                        {
                            if (xAnimationSkillStruct.AnimationClip != null)
                            {
                                eAnimaType = NFAnimaStateType.Idle1;
                                break;
                            }
                        }
                    }
                }
                else if (f < 30.0f)
                {
                    for (int i = 0; i < mxSkillData.AnimationSkillList.Count; ++i)
                    {
                        AnimationSkillStruct xAnimationSkillStruct = mxSkillData.AnimationSkillList[i];
                        if (xAnimationSkillStruct.Type == NFAnimaStateType.Idle1)
                        {
                            if (xAnimationSkillStruct.AnimationClip != null)
                            {
                                eAnimaType = NFAnimaStateType.Idle2;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                if (eAnimaType == meLastPlayID && !force)
                {
                    return(-1);
                }
            }

            if (mBodyIdent == null)
            {
                mBodyIdent = GetComponent <NFBodyIdent>();
                if (mBodyIdent.xRenderObject)
                {
                    mAnimator = mBodyIdent.xRenderObject.GetComponent <Animator>();
                }
            }

            mxAnimationEvent.OnEndAnimaEvent(this.gameObject, meLastPlayID, index);

            meLastPlayID = eAnimaType;

            mxAnimationEvent.OnStartAnimaEvent(this.gameObject, eAnimaType, index);

            for (int i = 0; i < mxSkillData.AnimationSkillList.Count; ++i)
            {
                AnimationSkillStruct xAnimationSkillStruct = mxSkillData.AnimationSkillList[i];
                if (xAnimationSkillStruct.Type == eAnimaType)
                {
                    if (mBodyIdent.xRenderObject)
                    {
                        mBodyIdent.xRenderObject.gameObject.SetActive(xAnimationSkillStruct.visible);
                    }

                    if (xAnimationSkillStruct.AnimationClip != null)
                    {
                        //mAnimator.Play(eAnimaType.ToString());
                        if (mAnimator)
                        {
                            mAnimator.CrossFade(eAnimaType.ToString(), 0.1f);
                        }
                    }
                    else
                    {
                        //continue;
                        //Debug.LogWarning(eAnimaType.ToString() + " The AnimationClip is null!");
                        //UnityEditor.EditorUtility.DisplayDialog ("Warning", "The AnimationClip is null!", "OK", "Cancel");
                    }

                    foreach (EffectStruct es in xAnimationSkillStruct.EffectStructList)
                    {
                        if (es.Effect != null)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayEffect(es));
                        }
                    }
                    foreach (AudioStruct es in xAnimationSkillStruct.AudioStructList)
                    {
                        if (es.Audio != null)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayAudio(es));
                        }
                    }

                    foreach (BulletStruct es in xAnimationSkillStruct.BulletStructList)
                    {
                        if (es.Bullet != null)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayBullet(es));
                        }
                    }

                    foreach (MovementStruct es in xAnimationSkillStruct.MovementStructList)
                    {
                        es.Index = index;
                        StartCoroutine(WaitPlayMovement(es));
                    }

                    if (xAnimationSkillStruct.ActiveStructList.Count > 0)
                    {
                        foreach (ActiveStruct es in xAnimationSkillStruct.ActiveStructList)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayActive(es));
                        }
                    }

                    if (xAnimationSkillStruct.DamageStructList.Count > 0)
                    {
                        foreach (DamageStruct es in xAnimationSkillStruct.DamageStructList)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayDamage(es));
                        }
                    }
                    else
                    {
                        // no bullet
                        if (xAnimationSkillStruct.BulletStructList.Count <= 0)
                        {
                            for (int j = 0; j < EnemyList.Count; ++j)
                            {
                                if (EnemyList[j] != null)
                                {
                                    mxAnimationEvent.NoDamageEvent(this.gameObject, EnemyList[j], eAnimaType, index);
                                }
                            }
                        }
                    }

                    foreach (CameraStruct es in xAnimationSkillStruct.CameraStructList)
                    {
                        es.Index = index;
                        StartCoroutine(WaitPlayCamera(es));
                    }

                    if (xAnimationSkillStruct.Type != NFAnimaStateType.Idle)
                    {
                        if (xAnimationSkillStruct.AnimationClip)
                        {
                            if (!xAnimationSkillStruct.AnimationClip.isLooping)
                            {
                                StartCoroutine(WaitPlayNextAnim(xAnimationSkillStruct.fTime, xAnimationSkillStruct.NextType, -1));
                            }
                        }
                        else if (xAnimationSkillStruct.Type != xAnimationSkillStruct.NextType)
                        {
                            StartCoroutine(WaitPlayNextAnim(xAnimationSkillStruct.fTime, xAnimationSkillStruct.NextType, -1));
                        }
                    }

                    //get time
                    if (eAnimaType != NFAnimaStateType.Idle)
                    {
                    }

                    break;
                }
            }

            return(index);
        }