Esempio n. 1
0
    public InputManager()
    {
        _controls = new PlayerInput();

        #region Game
        _controls.Game.Movement.started   += ctx => ShipMove.Invoke(true);
        _controls.Game.Movement.canceled  += ctx => ShipMove.Invoke(false);
        _controls.Game.Rotation.performed += ctx => ShipRotate.Invoke(ctx.ReadValue <float>());
        _controls.Game.Rotation.canceled  += ctx => ShipRotate.Invoke(0);
        _controls.Game.Fire.started       += ctx => ShipFire.Invoke(true);
        _controls.Game.Fire.canceled      += ctx => ShipFire.Invoke(false);
        _controls.Game.Pause.started      += ctx => GamePause.Invoke();
        _controls.Game.Restart.started    += ctx => GameRestart.Invoke();
        #endregion

        #region Pause
        _controls.Pause.Exit.started   += ctx => PauseExit.Invoke();
        _controls.Pause.Resume.started += ctx => PauseResume.Invoke();
        #endregion

        #region Game Over
        _controls.GameOver.Restart.started += ctx => GameOverRestart.Invoke();
        _controls.GameOver.Exit.started    += ctx => GameOverExit.Invoke();
        #endregion

        GameManager.Instance.OnGameStateChanged += SwitchInputType;
    }
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            pauseResume = (PauseResume)EditorGUILayout.EnumPopup("Method:", pauseResume);

            listSource = (ActionRunActionList.ListSource)EditorGUILayout.EnumPopup("Source:", listSource);
            if (listSource == ActionRunActionList.ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList)EditorGUILayout.ObjectField("ActionList:", actionList, typeof(ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);

                    if (actionList != null && actionList.actions.Contains(this))
                    {
                        EditorGUILayout.HelpBox("An ActionList cannot " + pauseResume.ToString() + " itself - it must be performed indirectly.", MessageType.Warning);
                    }
                }
            }
            else if (listSource == ActionRunActionList.ListSource.AssetFile)
            {
                parameterID = Action.ChooseParameterGUI("ActionList asset:", parameters, parameterID, ParameterType.UnityObject);
                if (parameterID < 0)
                {
                    actionListAsset = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", actionListAsset, typeof(ActionListAsset), false);

                    if (actionListAsset != null && actionListAsset.actions.Contains(this))
                    {
                        EditorGUILayout.HelpBox("An ActionList Asset cannot " + pauseResume.ToString() + " itself - it must be performed indirectly.", MessageType.Warning);
                    }
                }
            }

            if (pauseResume == PauseResume.Pause)
            {
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
                if (willWait)
                {
                    EditorGUILayout.HelpBox("The ActionList will complete any currently-running Actions before it pauses.", MessageType.Info);
                }
            }
            else if (pauseResume == PauseResume.Resume)
            {
                rerunPausedActions = EditorGUILayout.ToggleLeft("Re-run Action(s) at time of pause?", rerunPausedActions);
            }

            AfterRunningOption();
        }