Exemplo n.º 1
0
        void DrawAnimation()
        {
            if (mData.AnimationSkillList == null)
            {
                return;
            }

            for (int i = 0; i < mData.AnimationSkillList.Count; i++)
            {
                EditorGUILayout.Space();

                AnimationSkillStruct _ass = mData.AnimationSkillList[i];
                if (_ass.Type == NFAnimaStateType.NONE)
                {
                    continue;
                }

                if (_ass.IsFoldout)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    _ass.fCurTime = EditorGUILayout.Slider(_ass.Type.ToString(), _ass.fCurTime, 0f, _ass.fTime);
                    if (_ass.fCurTime > 0)
                    {
                        for (int j = 0; j < mData.AnimationSkillList.Count; j++)
                        {
                            if (i != j)
                            {
                                mData.AnimationSkillList[j].fCurTime = 0f;
                            }
                        }

                        m_CurrentTime  = _ass.fCurTime / _ass.fTime;
                        mManulPlayType = _ass.Type;
                    }

                    _ass.fSpeed = EditorGUILayout.FloatField("Play Speed:", _ass.fSpeed);

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Play"))
                    {
                        //mASC.SetAnimator(mASC.GetComponent<Animator>());
                        _ass.fCurTime  = 0f;
                        m_CurrentTime  = 0f;
                        mManulPlayType = NFAnimaStateType.NONE;
                        mPlayType      = _ass.Type;
                        mASC.PlayAnimaState(mPlayType, -1);
                    }

                    if (GUILayout.Button("Stop"))
                    {
                        _ass.fCurTime  = 0f;
                        m_CurrentTime  = 0f;
                        mManulPlayType = NFAnimaStateType.NONE;
                        mPlayType      = NFAnimaStateType.Idle;
                        mASC.PlayAnimaState(NFAnimaStateType.Idle, -1);

                        for (int j = 0; j < mData.AnimationSkillList.Count; j++)
                        {
                            mData.AnimationSkillList[j].fCurTime = 0f;
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    _ass.AnimationClip = (AnimationClip)EditorGUILayout.ObjectField("AnimaitonClip:", _ass.AnimationClip, typeof(AnimationClip), true);

                    EditorGUILayout.BeginHorizontal();
                    if (_ass.AnimationClip == null)
                    {
                        _ass.fTime = 1f;
                    }
                    else
                    {
                        _ass.fTime = _ass.AnimationClip.length / _ass.fSpeed;
                    }
                    EditorGUILayout.LabelField("NextAnima After:", _ass.fTime.ToString());
                    _ass.NextType = (NFAnimaStateType)EditorGUILayout.EnumPopup(_ass.NextType);

                    EditorGUILayout.EndHorizontal();



                    mData.AnimationSkillList[i] = _ass;

                    //添加特效与删除片断
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("ADD EFFECT"))
                    {
                        EffectStruct _es = new EffectStruct();
                        _es.LifeTime  = 3;
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].EffectStructList.Add(_es);
                    }
                    if (GUILayout.Button("ADD Audio"))
                    {
                        AudioStruct _es = new AudioStruct();
                        _es.LifeTime  = 3;
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].AudioStructList.Add(_es);
                    }
                    if (GUILayout.Button("ADD Bullet"))
                    {
                        BulletStruct _es = new BulletStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].BulletStructList.Add(_es);
                    }



                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("ADD Damage"))
                    {
                        DamageStruct _es = new DamageStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].DamageStructList.Add(_es);
                    }

                    if (GUILayout.Button("ADD Movement"))
                    {
                        MovementStruct _es = new MovementStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].MovementStructList.Add(_es);
                    }

                    if (GUILayout.Button("ADD Camera"))
                    {
                        CameraStruct _es = new CameraStruct();
                        _es.isFoldout = true;
                        mData.AnimationSkillList[i].CameraStructList.Add(_es);
                    }

                    EditorGUILayout.EndHorizontal();

                    if (mData.AnimationSkillList.Count > 0)
                    {
                        DrawEffect(i);
                        DrawAudio(i);
                        DrawMovement(i);
                        DrawDamage(i);
                        DrawBullet(i);
                        DrawCamera(i);
                    }
                    EditorGUILayout.EndVertical();
                }
            }
        }
Exemplo n.º 2
0
        void DrawMovement(int id)
        {
            if (!(id < mData.AnimationSkillList.Count))
            {
                return;
            }

            for (int i = 0; i < mData.AnimationSkillList[id].MovementStructList.Count; i++)
            {
                MovementStruct _eff = mData.AnimationSkillList[id].MovementStructList[i];

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                string _titleName = "Movement" + (i + 1).ToString();
                EditorGUILayout.BeginHorizontal();
                //此子特效的界面折叠
                _eff.isFoldout = EditorGUILayout.Foldout(_eff.isFoldout, _titleName);
                GUILayout.FlexibleSpace();
                //此子特效是否可用
                _eff.isEnabled = EditorGUILayout.Toggle("", _eff.isEnabled);

                if (GUILayout.Button("DELETE"))
                {
                    mData.AnimationSkillList[id].MovementStructList.Remove(_eff);
                    return;
                }

                EditorGUILayout.EndHorizontal();

                mData.AnimationSkillList[id].MovementStructList[i] = _eff;

                if (_eff.isFoldout)
                {
                    EditorGUI.BeginDisabledGroup(!_eff.isEnabled);
                    _eff.DelayTime = EditorGUILayout.FloatField("Delay Time", _eff.DelayTime);
                    if (_eff.DelayTime > mData.AnimationSkillList[id].fTime)
                    {
                        _eff.DelayTime = mData.AnimationSkillList[id].fTime;
                    }

                    string[] _nameArry = mData.VirtualPointList.ToArray();

                    _eff.StartAudio       = (AudioClip)EditorGUILayout.ObjectField("StartAudio", _eff.StartAudio, typeof(AudioClip), true);
                    _eff.StartEffect      = (GameObject)EditorGUILayout.ObjectField("StartEffect", _eff.StartEffect, typeof(GameObject), true);
                    _eff.StartEffLifeTime = EditorGUILayout.FloatField("StartEffLifeTime", _eff.StartEffLifeTime);

                    //运动方式
                    _eff.moveType = (MovementStruct.MoveType)EditorGUILayout.EnumPopup("Move Type", _eff.moveType);
                    _eff.Distance = EditorGUILayout.FloatField("Distance", _eff.Distance);
                    _eff.Speed    = EditorGUILayout.FloatField("Speed", _eff.Speed);

                    _eff.TouchAudio  = (AudioClip)EditorGUILayout.ObjectField("TouchAudio", _eff.TouchAudio, typeof(AudioClip), true);
                    _eff.TouchEffect = (GameObject)EditorGUILayout.ObjectField("TouchEffect", _eff.TouchEffect, typeof(GameObject), true);

                    _eff.TouchEffLifeTime = EditorGUILayout.FloatField("TouchEffLifeTime", _eff.TouchEffLifeTime);

                    mData.AnimationSkillList[id].MovementStructList[i] = _eff;
                }
                EditorGUI.EndDisabledGroup();


                EditorGUILayout.EndVertical();
                EditorGUI.indentLevel--;
            }
        }
Exemplo n.º 3
0
        IEnumerator WaitPlayMovement(MovementStruct es)
        {
            //如果特效没有启用则不进行播放
            if (es.isEnabled)
            {
                yield return(new WaitForSeconds(es.DelayTime));
            }
            else
            {
                yield break;
            }

            if (es.StartEffect)
            {
                GameObject _startEff = GameObject.Instantiate <GameObject>(es.StartEffect, this.gameObject.transform.position, Quaternion.identity);
                _startEff.SetActive(true);
                Destroy(_startEff, es.StartEffLifeTime);
            }
            if (es.StartAudio)
            {
                AudioClip _startEff = GameObject.Instantiate <AudioClip>(es.StartAudio, this.gameObject.transform.position, Quaternion.identity);
                AudioSource.PlayClipAtPoint(_startEff, transform.position);

                Destroy(_startEff, es.StartEffLifeTime);
            }

            Vector3 vForward   = new Vector3();
            Vector3 vTargetPos = new Vector3();

            switch (es.moveType)
            {
            case MovementStruct.MoveType.Forward:
            {
                vForward = this.gameObject.transform.forward;
            }
            break;

            case MovementStruct.MoveType.Back:
            {
                vForward = -this.gameObject.transform.forward;
            }
            break;

            case MovementStruct.MoveType.Left:
            {
                vForward = -this.gameObject.transform.right;
            }
            break;

            case MovementStruct.MoveType.Right:
            {
                vForward = this.gameObject.transform.right;
            }
            break;

            default:
                break;
            }

            vTargetPos = vForward * es.Distance + this.transform.position;

            float fDis = Vector3.Distance(vTargetPos, this.transform.position);

#if DG_Tweening
            Tweener t = this.transform.DOMove(vTargetPos, fDis / es.Speed);
            t.OnComplete(delegate()
            {
                if (es.TouchEffect)
                {
                    GameObject _startEff = GameObject.Instantiate <GameObject>(es.TouchEffect, vTargetPos, Quaternion.identity);
                    _startEff.SetActive(true);
                    Destroy(_startEff, es.TouchEffLifeTime);
                }
                if (es.TouchAudio)
                {
                    AudioClip _startEff = GameObject.Instantiate <AudioClip>(es.TouchAudio, vTargetPos, Quaternion.identity);
                    AudioSource.PlayClipAtPoint(_startEff, transform.position);

                    Destroy(_startEff, es.TouchEffLifeTime);
                }
            });
#endif
            yield return(new WaitForEndOfFrame());
        }