示例#1
0
        /// <summary> Get the Inputs for the Source to add it to the States </summary>
        internal virtual void GetInputs(bool add)
        {
            InputSource = GetComponentInParent <IInputSource>();

            if (InputSource != null)
            {
                //Enable Disable the Inputs for the States
                foreach (var state in states)
                {
                    if (state.Input != string.Empty)
                    {
                        var input = InputSource.GetInput(state.Input);
                        if (input != null)
                        {
                            if (add)
                            {
                                input.OnInputChanged.AddListener(state.ActivatebyInput);
                            }
                            else
                            {
                                input.OnInputChanged.RemoveListener(state.ActivatebyInput);
                            }
                        }
                    }
                }


                //Enable Disable the Inputs for the States
                foreach (var mode in modes)
                {
                    if (mode.Input != string.Empty)
                    {
                        var input = InputSource.GetInput(mode.Input);

                        if (input != null)
                        {
                            if (add)
                            {
                                input.OnInputChanged.AddListener(mode.ActivatebyInput);
                            }
                            else
                            {
                                input.OnInputChanged.RemoveListener(mode.ActivatebyInput);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary> Get the Inputs for the Source to add it to the States </summary>
        internal virtual void SetModesInput(Mode mode, bool connect)
        {
            if (!string.IsNullOrEmpty(mode.Input)) //If a mode has an Input
            {
                var input = InputSource.GetInput(mode.Input);

                if (input != null)
                {
                    if (connect)
                    {
                        input.InputChanged.AddListener(mode.ActivatebyInput);
                    }
                    else
                    {
                        input.InputChanged.RemoveListener(mode.ActivatebyInput);
                    }
                }
            }
        }
        //  public virtual void SetAction(Action actionID)
        //  {
        //      Mode_Activate(ModeEnum.Action, actionID);          //4 is the ID for the Actions
        //  }

        //  public virtual void SetAction(int actionID)
        //  {
        //      Mode_Activate(ModeEnum.Action, actionID);          //4 is the ID for the Actions
        //  }

        //  #region Attacks Commands
        //  /// <summary> Tries to Activate the Primary Attack Mode with an Attack ID Animation</summary>
        //  public virtual void SetAttack(int attackID) { Mode_Activate(ModeEnum.Attack1, attackID); }

        //  /// <summary> Tries to Activate the Primary Attack Mode with an Random Attack Animation</summary>
        //  public virtual void SetAttack() { Mode_Activate(ModeEnum.Attack1, -1); }

        //  ///// <summary> Tries to Activate the Primary Attack Forever... until StopAttack Is Called... usefull for AI</summary>
        //  //public virtual void SetAttack_Endless(int attackID) { Mode_Activate_Endless(ModeEnum.Attack1); }

        //  /// <summary> Stop Primary Attack Animations... usefull for AI</summary>
        //  public virtual void StopAttack() { Mode_Stop(); }

        //  /// <summary> Tries to Activate the Secondary Attack Mode with an Attack ID Animation</summary>
        //  public virtual void SetAttack2(int attackID) { Mode_Activate(ModeEnum.Attack2, attackID); }

        //  /// <summary> Try to Activate the Secondary Attack Mode with an Random Attack Animation</summary>
        //  public virtual void SetAttack2() { Mode_Activate(ModeEnum.Attack2, -1); }

        ////  /// <summary> Try to Activate the Secondary Attack Forever... until StopAttack Is Called... usefull for AI</summary>
        ////  public virtual void SetAttack2_Endless(int attackID) { Mode_Activate_Endless(ModeEnum.Attack2); }

        //  /// <summary> Stop Secondary Attack Animations... usefull for AI</summary>
        //  public virtual void StopAttack2() { Mode_Stop(); }
        #endregion


        #region Movement

        /// <summary> Get the Inputs for the Source to add it to the States </summary>
        internal virtual void GetInputs(bool add)
        {
            InputSource = GetComponentInParent <IInputSource>();

            if (InputSource != null)
            {
                //Enable Disable the Inputs for the States
                foreach (var state in states)
                {
                    if (state.Input != string.Empty)
                    {
                        var input = InputSource.GetInput(state.Input);

                        if (input != null)
                        {
                            if (add)
                            {
                                if (input.GetPressed == InputButton.Down || input.GetPressed == InputButton.Up)
                                {
                                    input.OnInputDown.AddListener(() => { state.ActivatebyInput(true); });
                                    input.OnInputUp.AddListener(() => { state.ActivatebyInput(false); });
                                }
                                else
                                {
                                    input.OnInputChanged.AddListener(state.ActivatebyInput);
                                }
                            }
                            else
                            {
                                if (input.GetPressed == InputButton.Down || input.GetPressed == InputButton.Up)
                                {
                                    input.OnInputDown.RemoveAllListeners();
                                    input.OnInputUp.RemoveAllListeners();
                                }
                                else
                                {
                                    input.OnInputChanged.RemoveListener(state.ActivatebyInput);
                                }
                            }
                        }
                    }
                }


                //Enable Disable the Inputs for the States
                foreach (var mode in modes)
                {
                    if (mode.Input != string.Empty)
                    {
                        var input = InputSource.GetInput(mode.Input);

                        if (input != null)
                        {
                            if (add)
                            {
                                input.OnInputChanged.AddListener(mode.ActivatebyInput);
                            }
                            else
                            {
                                input.OnInputChanged.RemoveListener(mode.ActivatebyInput);
                            }
                        }
                    }
                }
            }
        }