Example #1
0
    /// <summary>
    /// 给当前的攻击动画增加事件,实现WeaponTrail
    /// </summary>
    private void addCurrentAnimAttackTrail()
    {
        if (!_hasSetAnimEvent)
        {
            AnimatorClipInfo[] info = animator.GetCurrentAnimatorClipInfo(0);
            foreach (AnimatorClipInfo i in info)
            {
                var clip = i.clip;
                //Debug.Log(clip.name + "; " + clip.frameRate + " ;" + clip.length);
                if (clip.name.Contains("attack"))
                {
                    breakTime = Mathf.Repeat(animState.normalizedTime, 1.0f);
                    Debug.Log(breakTime);
                    StartCoroutine(setEvent(0.1f));
                    //加刀光
                    animEvent.AddAnimEvent(clip, 0.41f, trail.TrailStart);
                    animEvent.AddAnimEvent(clip, 0.6f, trail.TrailStop);

                    animEvent.AddAnimEvent(clip, 0.8f, voidEvent);
                    //animEvent.AddAnimEvent(null, clip, 0.51f, attackEvent);



                    _hasSetAnimEvent = true;
                }
            }
        }
    }
Example #2
0
    void getAnimation()
    {
        AnimatorStateInfo currentState = animator.GetCurrentAnimatorStateInfo(0);

        if (currentState.nameHash == Animator.StringToHash("Base Layer.attack2"))
        {
            if (!hasSet)
            {
                AnimatorClipInfo[] info = animator.GetCurrentAnimatorClipInfo(0);

                foreach (AnimatorClipInfo i in info)
                {
                    clip = i.clip;
                    if (clip.name.Contains("attack2"))
                    {
                        animEvent.AddAnimEvent(clip, 0.2f, trail.TrailStart);
                        animEvent.AddAnimEvent(clip, 0.6f, trail.TrailStop);
                        hasSet = true;
                    }
                }
            }
        }
    }
Example #3
0
        protected virtual void AddAnimEvent(AnimatorStateInfo currentState, AnimationClip clip)
        {
            GlobalDelegate.Instance.View.StartCoroutine(playBreakpoint());
            _breakTime = Mathf.Repeat(currentState.normalizedTime, 1.0f);
            //Debug.Log("normalizedTime: " + _breakTime + " length: " + currentState.length);

            //加刀光
            _animEvent.AddAnimEvent(clip, _tarilEvent.StartTime, _trail.TrailStart);
            if (_tarilEvent.Times <= 1)
            {
                _animEvent.AddAnimEvent(clip, _tarilEvent.StopTime, _trail.TrailStop);
            }
            else
            {
                //一个动画循环播放多次,在最后停止
                _trailNeedStopExtra = true;
            }

            //加攻击事件
            foreach (var attackEv in _keyAttacks)
            {
                _animEvent.AddAnimEvent(attackEv.attack, clip, attackEv.keyFrame, attackEvent);
            }
        }