Exemplo n.º 1
0
        private MoveInfo TestMoveExecution(MoveInfo move, MoveInfo currentMove, ButtonPress[] buttonPress, bool inputUp, bool fromSequence)
        {
            if (move.onRelease && !inputUp)
            {
                return(null);
            }
            if (!move.onRelease && inputUp)
            {
                return(null);
            }
            if (!HasEnoughGauge(move.gaugeUsage))
            {
                return(null);
            }
            if (move.previousMoves.Length > 0 && currentMove == null)
            {
                return(null);
            }
            if (move.previousMoves.Length > 0 && !searchMove(currentMove.name, move.previousMoves))
            {
                return(null);
            }
            if (Array.IndexOf(move.possibleStates, controlsScript.currentState) == -1)
            {
                return(null);
            }

            Array.Sort(buttonPress);
            Array.Sort(move.buttonExecution);

            if (fromSequence)
            {
                if (move.buttonSequence.Length == 0)
                {
                    return(null);
                }
                if (move.chargeMove && !charged)
                {
                    return(null);
                }

                /*string allbp = "";
                 * foreach(ButtonPress bp in lastButtonPresses) allbp += bp.ToString();
                 * string allbp2 = "";
                 * foreach(ButtonPress bp in move.buttonSequence) allbp2 += bp.ToString();
                 * Debug.Log(allbp +"="+ allbp2 +"? "+ ArraysEqual<ButtonPress>(buttonPress, move.buttonExecution));*/

                if (lastButtonPresses.Count >= move.buttonSequence.Length)
                {
                    ButtonPress[] compareSequence = lastButtonPresses.GetRange(
                        lastButtonPresses.Count - move.buttonSequence.Length, move.buttonSequence.Length).ToArray();

                    if (!ArraysEqual <ButtonPress>(compareSequence, move.buttonSequence))
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }

                //Debug.Log("Sequence pass! Testing Execution:"+ ArraysEqual<ButtonPress>(buttonPress, move.buttonExecution));
            }
            else
            {
                if (move.buttonSequence.Length > 0)
                {
                    return(null);
                }
            }

            if (!ArraysEqual <ButtonPress>(buttonPress, move.buttonExecution))
            {
                return(null);
            }

            if (controlsScript.storedMove != null &&
                move.moveName != currentMove.moveName &&
                move.moveName == controlsScript.storedMove.moveName)
            {
                MoveInfo newMove = Instantiate(move) as MoveInfo;
                newMove.name = move.name;
                return(newMove);
            }

            if (controlsScript.currentState == PossibleStates.Jump)
            {
                if (totalAirMoves >= controlsScript.myInfo.possibleAirMoves)
                {
                    return(null);
                }
                totalAirMoves++;
            }

            if (currentMove == null || searchMove(move.name, currentMove.frameLink.linkableMoves))
            {
                changeMoveStances(move.changeCombatStance);
                MoveInfo newMove = Instantiate(move) as MoveInfo;
                newMove.name = move.name;
                UFE.FireMove(newMove, controlsScript.myInfo);
                RemoveGauge(move.gaugeUsage);
                //Debug.Log("move "+ newMove.name +" executed.");
                return(newMove);
            }

            return(null);
        }