Example #1
0
        /// <summary>
        /// Do stuff when the attack is triggered
        /// </summary>
        /// <param name="attack"></param>
        private void OnAttackTriggered(AttackAnim attack)
        {
            if (attack != this)
            {
                return;
            }

            HasStarted = true;
        }
        internal static void OnGenericEvent(AttackAnim attack, uint index, string key)
        {
            var handler = GenericEvent;

            if (handler != null)
            {
                handler(attack, index, key);
            }
        }
        internal static void OnAttackTriggered(AttackAnim attack)
        {
            var handler = AttackTriggered;

            if (handler != null)
            {
                handler(attack);
            }
        }
        internal static void OnHitScanning(AttackAnim attack, uint scanIndex, float damage)
        {
            var handler = HitScanning;

            if (handler != null)
            {
                handler(attack, scanIndex, damage);
            }
        }
        /// <summary>
        /// Check if a current animation in the link is active under its conditions
        /// </summary>
        /// <param name="currentAnim"></param>
        /// <param name="targetLayer">the layer which the anim is on</param>
        /// <returns></returns>
        protected internal bool IsCurrentlyActive(AttackAnim currentAnim, int targetLayer)
        {
            if (currentAnim == null)
            {
                return(false);
            }

            var nameCond = Animator.GetCurrentAnimatorStateInfo(targetLayer).shortNameHash == currentAnim.AnimHash;

            return(nameCond && currentAnim.HasStarted);
        }
        /// <summary>
        /// Check if the anim is within its LinkBegin and LinkEnd
        /// </summary>
        /// <param name="attk"></param>
        /// <param name="layer"></param>
        /// <returns></returns>
        protected internal bool WithinLink(AttackAnim attk, int layer)
        {
            if (attk == null)
            {
                return(false);
            }

            var nameCondition = Animator.GetCurrentAnimatorStateInfo(layer).shortNameHash == attk.AnimHash; //name match
            var normTime      = nameCondition ? Mathf.Clamp01(Animator.GetCurrentAnimatorStateInfo(layer).normalizedTime) : 0;
            var timeCondition = Utilities.InRange(normTime, attk.LinkBegin, attk.LinkEnd);

            return(nameCondition && timeCondition);
        }
        /// <summary>
        /// Trigger Events on special-predefined time stamps in the Animation's timeline
        /// </summary>
        /// <param name="attk"></param>
        /// <param name="layer"></param>
        protected internal void ScanTimeline(AttackAnim attk, int layer)
        {
            //for now the special timestamps are defined in the inspector

            if (attk == null)
            {
                return;
            }

            var normTime = Mathf.Clamp01(Animator.GetCurrentAnimatorStateInfo(layer).normalizedTime);

            attk.TriggerEvents(normTime);
        }
 /// <summary>
 /// Call the next animation
 /// </summary>
 protected internal void NextAnimation(AttackAnim currentAnim, int targetLayer)
 {
     if (currentAnim != null)
     {
         if (IsCurrentlyActive(currentAnim, targetLayer) == false)
         {
             Animator.CrossFadeInFixedTime(currentAnim.AnimName, currentAnim.TransitionDuration, targetLayer);
         }
     }
     else
     {
         Debug.LogError("The current Anim is null");
     }
 }
        /// <summary>
        /// check if a anim has crossed the LinkEnd time stamp AND has been fully played
        /// </summary>
        /// <param name="attk"></param>
        /// <param name="layer"></param>
        /// <returns></returns>
        protected internal bool IsExisting(AttackAnim attk, int layer)
        {
            if (attk == null)
            {
                return(false);
            }

            var nameCondition     = Animator.GetCurrentAnimatorStateInfo(layer).shortNameHash == attk.AnimHash; //name match
            var normTime          = nameCondition ? Mathf.Clamp01(Animator.GetCurrentAnimatorStateInfo(layer).normalizedTime) : 0;
            var timeCondition     = Utilities.InRange(normTime, attk.LinkEnd - Time.deltaTime, 1f);
            var existingCondition = Animator.IsInTransition(layer);

            return(nameCondition && timeCondition && existingCondition);
        }
Example #10
0
            /// <summary>
            /// Trigger a generic event
            /// </summary>
            /// <param name="attack"></param>
            /// <param name="index"></param>
            /// <param name="callback"></param>
            internal void Trigger(AttackAnim attack, uint index, Action callback)
            {
                if (Triggered)
                {
                    return;
                }

                Dispatcher.OnGenericEvent(attack, index, Key);
                Triggered = true;

                if (callback != null)
                {
                    callback.Invoke();
                }
            }
Example #11
0
            /// <summary>
            /// Trigger a damage data
            /// </summary>
            /// <param name="attack"></param>
            /// <param name="index"></param>
            /// <param name="callback"></param>
            internal void Trigger(AttackAnim attack, uint index, Action callback)
            {
                if (Triggered)
                {
                    return;
                }

                Dispatcher.OnHitScanning(attack, index, Damage);
                Triggered = true;

                if (callback != null)
                {
                    callback.Invoke();
                }
            }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="combo"></param>
 public ChainLink(AttackAnim combo)
 {
     _mainCombos.Add(combo);
     Combos.Enqueue(combo);
     HasFinished = true;
 }