Esempio n. 1
0
        public void checkForMoveCombination(AnimatorStateInfo stateInfo)
        {
            //if there's an animation playing, no need to check for anything
            if (combatAnimationInitiated)
            {
                skipMoveCombinationCheck = true;
            }

            foreach (var move in tierList)
            {
                if (skipMoveCombinationCheck)
                {
                    break;
                }

                if (Input.GetKeyDown(move.Combo[0].ToString()) && move.ComboPressed.Count == 0)
                {
                    move.ComboPressed.Add(move.Combo[0].ToString());
                }

                if (move.ComboPressed.Count == 1)
                {
                    if (move.ComboPressed[0].Equals(move.Combo[0].ToString()))
                    {
                        if (!move._IsInCoroutine)
                        {
                            if (debug)
                            {
                                Debug.Log("starting coroutine");
                            }
                            StartCoroutine(move.CombatSequnce(Time.time));
                        }
                    }
                }
                if (move.ComboActivated)
                {
                    //if you have queued up a move, then try to use another move during the delay period
                    //add in baseDelay
                    if (!isDelayCoRoutineRunning && !isDelayFinished)
                    {
                        StartCoroutine(WaitForDelay(move.ExciteDelay));
                    }
                    else if (isDelayCoRoutineRunning)
                    {
                        continue;
                    }
                    if (debug)
                    {
                        Debug.Log(isDelayFinished);
                    }
                    if (isDelayFinished)
                    {
                        if (name == "Player")
                        {
                            if (PlayerMovement.inControl(true))
                            {
                                //reset the path so that it stops calculating
                                PlayerMovement.agent.ResetPath();
                            }
                        }
                        else
                        {
                            if (PlayerMovement.inControl(false))
                            {
                                //reset the path so that it stops calculating
                                PlayerMovement.agent.ResetPath();
                            }
                        }

                        currentTierPlaying       = move;
                        combatAnimationInitiated = true;

                        //set the combat to true so the animation goes straight from run -> combat
                        //anim.SetBool(isCombat, true);
                        //set the speed to zero which implies no more movement therefore no more running
                        PlayerMovement.agent.velocity = Vector3.zero;

                        anim.SetTrigger(move.AnimationHash);

                        //clears all combo pressed
                        tierList.ForEach(x => x.ComboPressed.Clear());
                        //print("MOVE EXPANSION RATE: " + move.ExpansionRate);
                        break;
                    }
                    else
                    {
                        //this block is when we are in the delay phase
                    }
                }

                if (move.ComboPressed.Count > 0)
                {
                    //they are in mid-keypress of a combo
                }
            }            //foreach move


            if (combatAnimationInitiated && stateInfo.IsName(currentTierPlaying.AnimationStateName))
            {
                if (debug)
                {
                    Debug.Log("Animation has begun playing");
                }
                animationPlayed = true;
            }


            if (combatAnimationInitiated && animationPlayed)
            {
                StartCoroutine(SphereWithTime(currentTierPlaying.ExpansionRate));
                isAnimationFinished = true;
                //while playing animation
                for (int x = 0; x < tierList.Count; x++)
                {
                    if (tierList[x].ComboActivated)
                    {
                        //reset all variables
                        //anim.ResetTrigger(tierList[x].AnimationHash);
                        //anim.SetBool(isCombat, false);

                        combatAnimationInitiated = false;
                        animationPlayed          = false;

                        tierList[x].ComboActivated   = false;
                        tierList[x]._IsComboFinished = false;
                        isDelayFinished = false;
                    }
                }//iterate tierList
                skipMoveCombinationCheck = false;
                ResetAllCombatTriggers();
            }//stop combat
        }