// Character frame update (Dummy, probably you want do this with a state machine!)
    public void DoFrame(InputEntryInfo command)
    {
        //If already in a locked animation, do nothing
        if (!locked)
        {
            //Special skill
            if (command != null && (!in_animation || command.isSpecialSkill))
            {
                locked       = !command.isCancelable;
                in_animation = true;
                gameObject.GetComponent <Animator>().SetTrigger(command.animationTrigger);
                inputManager.ClearKeys();
            }
            //Basic command or sequence
            else
            {
                //Basic commands can't start in the middle of an animation
                if (!in_animation)
                {
                    var found = false;
                    //Check basic commmands
                    foreach (var cmd in info.BasicCommands)
                    {
                        if (inputManager.IsPressedInFrameWindow(cmd.input) || cmd == bufferedCommand)
                        {
                            // If not in sequence, do standard things
                            if (!CheckSequence(cmd.code))
                            {
                                Debug.Log("Play basic " + cmd.input);
                                locked = !cmd.isCancelable; in_animation = true;
                                gameObject.GetComponent <Animator>().SetTrigger(cmd.animationTrigger);
                            }
                            bufferedCommand = null;
                            found           = true;
                            inputManager.ClearKeys();
                        }
                    }

                    //Sequence reset after some frames
                    if (!found && framesSinceMotionEnded > 0)
                    {
                        framesSinceMotionEnded--;
                        if (framesSinceMotionEnded == 0)
                        {
                            currentSequence = "";
                        }
                    }
                }
            }
        }
    }
Esempio n. 2
0
    //Look for commands
    public InputEntryInfo FindCommandInBuffer()
    {
        InputEntryInfo pattern = null;

        pattern = Parse(result);

        result = pattern != null && pattern.isSpecialSkill ? pattern.code : result;

        if (result.Length > 15)
        {
            result = result.Substring(1);
        }
        t.text = result.Replace("_", " ");

        return(pattern);
    }
 //We can save one basic command during animation for playing at the end
 void UpdateInAnimationBuffer()
 {
     if (in_animation)
     {
         framesSinceLastBufferUpdate++;
         foreach (var cmd in info.BasicCommands)
         {
             if (inputManager.IsPressedInFrameWindow(cmd.input))
             {
                 Debug.Log("Buffered " + cmd.input);
                 bufferedCommand             = cmd;
                 framesSinceLastBufferUpdate = 0;
             }
         }
     }
     else
     {
         bufferedCommand = null;
     }
 }