示例#1
0
        /// <summary>
        /// This is called if the button is not interacting, thus we call the normal method defined by a feature.
        /// </summary>
        /// <param name="buttonPressed">The button pressed.</param>
        /// <param name="action">The button action related to the method.</param>
        /// <param name="fixedMethod">The fixed method.</param>
        private void CallAction(Button.ButtonName buttonPressed, Button.ButtonActions action, bool isRight)
        {
            ControlSet platformControls = ((GenericControllerPlatform)coreSettings.CurrentPlatform).GetPlatformControls();

            if (platformControls == null)
            {
                Debug.LogError("No controller scheme found.");
            }

            // This list are the methods that override the controller interaction.
            List <Action> methods;

            if (isRight)
            {
                methods = platformControls.GetButtonMethods(buttonPressed, action,
                                                            ControlSet.Options.isRight);
            }
            else
            {
                methods = platformControls.GetButtonMethods(buttonPressed, action,
                                                            ControlSet.Options.isLeft);
            }

            if (methods.Count == 0)
            {
                Debug.Log("Pressing the button: " + buttonPressed + ". Action type: " + action +
                          ". Is on right hand? " + isRight + ". But no method found..");
            }

            // Run the methods..
            foreach (Action act in methods)
            {
                act.Invoke();
            }
        }
示例#2
0
        /// <summary>
        /// Figures out if should call the interaction method or the feature method for control.
        /// </summary>
        /// <param name="buttonPressed">The button pressed.</param>
        /// <param name="action">The button action related to the method.</param>
        /// <param name="interactionMethods">An interaction method.</param>
        /// <param name="isRight">True if right hand.</param>
        private void CallAction(Button.ButtonName buttonPressed, Button.ButtonActions action, List <Action> interactionMethods, bool isRight)
        {
            ControlSet platformControls = ((GenericControllerPlatform)coreSettings.CurrentPlatform).GetPlatformControls();

            if (platformControls == null)
            {
                Debug.LogError("No controller scheme found.");
            }

            // This list are the methods that override the controller interaction.
            List <Action> methodsThatOverride;

            if (isRight)
            {
                methodsThatOverride = platformControls.GetButtonMethods(buttonPressed, action,
                                                                        ControlSet.Options.isRight, ControlSet.Options.OverrideInteraction);
            }
            else
            {
                methodsThatOverride = platformControls.GetButtonMethods(buttonPressed, action,
                                                                        ControlSet.Options.isLeft, ControlSet.Options.OverrideInteraction);
            }

            // If there is something the list above meant that we will not call the interaction,istead we will call the method.
            if (methodsThatOverride.Count > 0)
            {
                foreach (Action act in methodsThatOverride)
                {
                    act.Invoke();
                }

                // Don't call interaction method.
                Debug.Log("Interaction was overriden by a button.");
                return;
            }
            else
            {
                // On this case there is no method that overrides an interaction, we call the interaction normally.
                foreach (Action act in interactionMethods)
                {
                    act.Invoke();
                }
            }
        }