protected void OnPlayerActionChanged(PlayerControlActions playerAction)
 {
     if (PlayerActionChanged != null)
     {
         PlayerActionChanged(playerAction);
     }
 }
Ejemplo n.º 2
0
    private void Start()
    {
        playerActions = PlayerControlActions.CreateWithGamePadBindings();
        inputHandler  = new DefaultMenuInputHandler(playerActions);

        menuManager = GetComponent <AbstractMenuManager>();
        menuManager.ComponentSelected += SwitchSlideShowState;
    }
    //Keyboard Controls
    public static PlayerControlActions CreateNullBinding()
    {
        PlayerControlActions p = new PlayerControlActions();

        p.NullAction = p.CreatePlayerAction("Null");
        p.NullAction.AddDefaultBinding(InputControlType.None);
        return(p);
    }
Ejemplo n.º 4
0
    private void Awake()
    {
        LevelEndManager.levelExitEvent += ResetValues;

        playerActions = PlayerControlActions.CreateWithGamePadBindings();
        if (inputDevice != null)
        {
            playerActions.Device = inputDevice;
        }

        InitializeWaitForSeconds();
    }
    public void SetPlayerControlActions(PlayerControlActions action)
    {
        if (menuInputHandler != null)
        {
            menuInputHandler.DestroyPlayerAction();
        }

        if (action != null)
        {
            menuInputHandler = new DefaultMenuInputHandler(action);
        }

        OnPlayerActionChanged(action);
    }
Ejemplo n.º 6
0
    private void Start()
    {
        playerActions = PlayerControlActions.CreateWithGamePadBindings();
        gameObject.transform.position = startPosition;

        gradient = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>().GetComponent <GradientImageEffect>();

        menuManager         = GetComponentInChildren <AbstractMenuManager>();
        menuManager.enabled = false;
        menuManager.SetMenuInputActive(false);

        LevelEndManager.levelExitEvent += DeRegister;

        playerActionList = new List <PlayerControlActions>();
        GameObject g = GameObject.FindGameObjectWithTag("GlobalScripts");

        if (g != null)
        {
            playerSelectionContainer = g.GetComponent <PlayerSelectionContainer>();
            if (playerSelectionContainer != null)
            {
                for (int i = 0; i < playerSelectionContainer.playerInputDevices.Length; i++)
                {
                    if (playerSelectionContainer.playerInputDevices[i] != null)
                    {
                        PlayerControlActions p = PlayerControlActions.CreateWithGamePadBindings();
                        p.Device = playerSelectionContainer.playerInputDevices[i];
                        playerActionList.Add(p);
                    }
                }
            }
        }


        steamManager = SteamManager.Instance;
        if (steamManager != null)
        {
            steamManager.OnOverlayActivated += OnOverlayActivated;
        }

        PlayerManager.AllPlayersDeadEventHandler += () => {
            gameEnded = true;
        };
    }
    void OnEnable()
    {
        playerCount      = 0;
        playerReadyCount = 0;
        waitTime         = new WaitForSeconds(TWEEN_TIME);

        slots.Clear();
        usedInputDevices.Clear();


        GatherNeededReferences();

        InputManager.OnDeviceDetached += OnDeviceDetached;
        gamepadListener         = PlayerControlActions.CreateWithGamePadBindings();
        specificGamepadListener = PlayerControlActions.CreateWithGamePadBindings();


        characterSelectionHelper.OnCharacterSelected   += IncreasePlayerReadyCount;
        characterSelectionHelper.OnCharacterDeselected += DecreasePlayerReadyCount;
    }
    //GamePad Controls
    public static PlayerControlActions CreateWithGamePadBindings()
    {
        PlayerControlActions p = new PlayerControlActions();

        p.Join.AddDefaultBinding(InputControlType.Action1);
        p.Back.AddDefaultBinding(InputControlType.Action2);
        //xbox one specific
        p.Pause.AddDefaultBinding(InputControlType.Menu);
        //xbox 360 specific
        p.Pause.AddDefaultBinding(InputControlType.Start);
        p.Pause.AddDefaultBinding(InputControlType.Action8);
        p.Ability.AddDefaultBinding(InputControlType.LeftBumper);
        p.LeftLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
        p.LeftRight.AddDefaultBinding(InputControlType.LeftStickRight);
        p.LeftUp.AddDefaultBinding(InputControlType.LeftStickUp);
        p.LeftDown.AddDefaultBinding(InputControlType.LeftStickDown);
        p.RightLeft.AddDefaultBinding(InputControlType.RightStickLeft);
        p.RightRight.AddDefaultBinding(InputControlType.RightStickRight);
        p.RightUp.AddDefaultBinding(InputControlType.RightStickUp);
        p.RightDown.AddDefaultBinding(InputControlType.RightStickDown);
        return(p);
    }
Ejemplo n.º 9
0
    private void HandlePlayerActionChanged(PlayerControlActions playerAction)
    {
        if (playerAction == null)
        {
            foreach (var pair in MenuComponents)
            {
                RectTransform r = pair.Value.GetComponent <RectTransform>();
                r.localScale = Vector3.zero;
            }
            Debug.Log("<b>No Player registered! Hide Menu.</b>");
        }
        else
        {
            // Fade in Menu -> Controller registered
            StartCoroutine(TriggerMenuSpawnTween(() => {
                InitializeComponentSize();
            }));

            OnPlayerRegistered();
            Debug.Log("<b>" + PlayerSlot + " registered!</b>");
        }
    }
Ejemplo n.º 10
0
    void Start()
    {
        // Define playerControlActions
        playerControlActions = new PlayerControlActions();

        // Player default bindings - Controller
        playerControlActions.pitchDown.AddDefaultBinding(InputControlType.LeftStickUp);
        playerControlActions.pitchUp.AddDefaultBinding(InputControlType.LeftStickDown);
        playerControlActions.steerLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
        playerControlActions.steerRight.AddDefaultBinding(InputControlType.LeftStickRight);
        playerControlActions.speedUp.AddDefaultBinding(InputControlType.RightTrigger);
        playerControlActions.slowDown.AddDefaultBinding(InputControlType.LeftTrigger);
        playerControlActions.stop.AddDefaultBinding(InputControlType.LeftBumper);
        playerControlActions.accept.AddDefaultBinding(InputControlType.Action1);
        playerControlActions.decline.AddDefaultBinding(InputControlType.Action2);
        playerControlActions.cameraXAxisPositive.AddDefaultBinding(InputControlType.RightStickRight);
        playerControlActions.cameraXAxisNegative.AddDefaultBinding(InputControlType.RightStickLeft);
        playerControlActions.cameraYAxisPositive.AddDefaultBinding(InputControlType.RightStickUp);
        playerControlActions.cameraYAxisNegative.AddDefaultBinding(InputControlType.RightStickDown);
        // Player default bindings - Keyboard
        playerControlActions.pitchDown.AddDefaultBinding(Key.W);
        playerControlActions.pitchUp.AddDefaultBinding(Key.S);
        playerControlActions.steerLeft.AddDefaultBinding(Key.A);
        playerControlActions.steerRight.AddDefaultBinding(Key.D);
        playerControlActions.speedUp.AddDefaultBinding(Key.Shift);
        playerControlActions.slowDown.AddDefaultBinding(Key.LeftControl);
        playerControlActions.stop.AddDefaultBinding(Key.Space);
        playerControlActions.accept.AddDefaultBinding(Key.Return);
        playerControlActions.decline.AddDefaultBinding(Key.Backspace);

        // Menu navigation default bindins
        playerControlActions.menuUp.AddDefaultBinding(InputControlType.LeftStickUp);
        playerControlActions.menuDown.AddDefaultBinding(InputControlType.LeftStickDown);
        playerControlActions.pause.AddDefaultBinding(InputControlType.Command);
        playerControlActions.menuUp.AddDefaultBinding(Key.UpArrow);
        playerControlActions.menuDown.AddDefaultBinding(Key.DownArrow);
        playerControlActions.pause.AddDefaultBinding(Key.Escape);
    }
 private bool BackButtonWasPressedOnListener(PlayerControlActions actions)
 {
     return(actions.Back);
 }
 private bool JoinButtonWasPressedOnListener(PlayerControlActions actions)
 {
     return(actions.Join);
 }
Ejemplo n.º 13
0
 public DefaultMenuInputHandler(PlayerControlActions playerControlActions)
 {
     this.playerControlActions = playerControlActions;
 }
 protected virtual void InitializePlayerControlActions()
 {
     SetPlayerControlActions(PlayerControlActions.CreateWithGamePadBindings());
 }