示例#1
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < 3; i++)
     {
         controllersActive[i] = GamePadManager.CheckGamepadConnected(i);
     }
 }
示例#2
0
    public void Init()
    {
        uiroot             = GameObject.Find("UI Root");
        resultLayerManager = uiroot.transform.Find("ResultLayer").GetComponent <ResultLayerManager>();
        reviveLayerManager = uiroot.transform.Find("ReviveLayer").GetComponent <ReviveLayerManager>();
        pauseLayerManager  = uiroot.transform.Find("PauseLayer").GetComponent <PauseLayerManager>();
        winLayerManager    = uiroot.transform.Find("WinLayer").GetComponent <WinLayerManager>();
        gamePadManager     = uiroot.transform.Find("GamePad").GetComponent <GamePadManager>();

        resultLayerManager.Init();
        reviveLayerManager.Init();
        winLayerManager.Init();
        pauseLayerManager.Init();
        gamePadManager.Init();

        resultLayerManager.gameObject.SetActive(false);
        reviveLayerManager.gameObject.SetActive(false);
        pauseLayerManager.gameObject.SetActive(false);
        winLayerManager.gameObject.SetActive(false);
        gamePadManager.gameObject.SetActive(true);

        addScoresLabelRes      = Resources.Load("Prefabs/UI/AddScoresLabel") as GameObject;
        addScoresComboLabelRes = Resources.Load("Prefabs/UI/AddScoresComboLabel") as GameObject;

        uicamera = uiroot.transform.Find("Camera").GetComponent <Camera>();
    }
    // initialize.
    void Awake()
    {
        //Create manager if one doesn't exist.
        if (manager != null && manager != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            //Create new gamepad manager instance
            manager = this;
            DontDestroyOnLoad(this.gameObject);

            //Lock gamepadcount based on range
            GamePadCount = Mathf.Clamp(GamePadCount, 1, 4);

            gamepads = new List <xbox_gamepad>();

            //Create gamepads based on gamepad count.
            for (int i = 0; i < GamePadCount; ++i)
            {
                gamepads.Add(new xbox_gamepad(i + 1));
            }
        }
    }
    // initialize.
    void Awake()
    {
        //Create manager if one doesn't exist.
        if (manager != null && manager != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            //Create new gamepad manager instance
            manager = this;
            DontDestroyOnLoad(this.gameObject);

            audioActor             = GetComponent <Audio>();
            itemManager            = GetComponent <ItemManager>();
            lpManager              = GetComponent <LapsManager>();
            posManager             = GetComponent <PositionManager>();
            newPlacementController = GetComponent <NewPlacementController>();
            psActor  = GetComponent <PlayerSelectActor>();
            winActor = GetComponent <WinActor>();

            //Lock gamepadcount based on range
            GamePadCount = Mathf.Clamp(GamePadCount, 1, 4);

            gamepads = new List <xbox_gamepad>();

            //Create gamepads based on gamepad count.
            for (int i = 0; i < GamePadCount; ++i)
            {
                gamepads.Add(new xbox_gamepad(i + 1));
            }
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        var stick1 = pad.pad[0].LeftStickAxis;

        pad = GameObject.Find("PadManager").GetComponent <GamePadManager>();
        if (IsResult)
        {
            if (!pad.pushbutton[0] && !IsSelect)
            {
                if (stick1.y < -0.8 && !slant && num < 2)
                {
                    slant = !slant;
                    num++;
                }

                if (stick1.y > 0.8 && !slant && num > 0)
                {
                    slant = !slant;
                    num--;
                }

                if (-0.8 < stick1.y && stick1.y < 0.8 && slant)
                {
                    slant = !slant;
                }
            }
            if (pad.pad[0].A)
            {
                Debug.Log("aaa");
                Invoke("LoadSelect", 1.0f);
                IsSelect = true;
            }
        }
    }
示例#6
0
    private void OnPlayerInputChanged(InputListener inputListener)
    {
        PlayerControlInfo playerControlInfos = inputListener.m_Player == EPlayer.Player1 ? m_Player1ControlsMapping : m_Player2ControlsMapping;
        List <EInputKey>  unassignedInputs   = new List <EInputKey>(PlayerGamePad.K_ASSIGNABLE_INPUTS);

        for (int i = 0; i < playerControlInfos.m_InputListeners.Length; i++)
        {
            if (playerControlInfos.m_InputListeners[i] != inputListener && playerControlInfos.m_InputListeners[i].m_CurrentInputKey == inputListener.m_CurrentInputKey)
            {
                EGamePadType playerGamepadType = GamePadManager.GetPlayerGamepadType((int)inputListener.m_Player);

                playerControlInfos.m_InputListeners[i].m_CurrentInputKey = inputListener.m_OldInputKey;
                playerControlInfos.m_InputListeners[i].UpdateInputForGamepadType(playerGamepadType);

                GamePadManager.SetPlayerGamepadInputMapping((int)inputListener.m_Player, inputListener.m_OldInputKey, playerControlInfos.m_InputListeners[i].m_DefaultInputKey);
            }

            unassignedInputs.Remove(playerControlInfos.m_InputListeners[i].m_CurrentInputKey);
        }

#if UNITY_EDITOR || DEBUG_DISPLAY
        if (unassignedInputs.Count > 1)
        {
            KakutoDebug.LogError("There should be only one unassigned remaining input after OnPlayerInputChanged");
        }
#endif

        for (int i = 0; i < unassignedInputs.Count; i++)
        {
            GamePadManager.SetPlayerGamepadInputMapping((int)inputListener.m_Player, unassignedInputs[i], PlayerGamePad.K_DEFAULT_UNASSIGNED_INPUT);
        }
    }
示例#7
0
    // Use this for initialization
    void Start()
    {
        startTextGUI = new GUIStyle();
        startTextGUI.alignment = TextAnchor.MiddleCenter;
        startTextGUI.normal.textColor = Color.white;

        m_controller = new GamePadManager(m_player);
    }
 public void PressPlay()
 {
     foreach (PlayerState item in GlobalReferences.PlayerStates)
     {
         GamePadManager.Disconnect(item.Index);
     }
     GlobalReferences.PlayerStates.Clear();
     SceneManager.LoadScene("PlayerAssignment");
 }
示例#9
0
    public void pressExit()
    {
        GamePadManager.Disconnect(PlayerIndex.One);
        GamePadManager.Disconnect(PlayerIndex.Two);
        GamePadManager.Disconnect(PlayerIndex.Three);
        GamePadManager.Disconnect(PlayerIndex.Four);

        GlobalReferences.PlayerStates.Clear();
    }
 // Use this for initialization
 void Start()
 {
     //Grab an instance of the manager.
     manager     = this.gameObject;
     gpmanager   = manager.GetComponent <GamePadManager>();
     rocketActor = Rocket.GetComponentInChildren <RocketActor>();
     psActor     = manager.GetComponent <PlayerSelectActor>();
     fireRocket  = GameObject.Find("RocketSound").GetComponent <AudioSource>();
 }
示例#11
0
    private void Awake()
    {
        padManager = FindObjectOfType <GamePadManager>();

        gamePad = GetComponent <GamePadInput>();

        // add button event
        gamePad.Button1Down += Button1Down;
    }
示例#12
0
 public void Restart()
 {
     PlayerAssignmentScript.gameStarted = false;
     foreach (PlayerState item in GlobalReferences.PlayerStates)
     {
         GamePadManager.Disconnect(item.Index);
     }
     GlobalReferences.PlayerStates.Clear();
     SceneManager.LoadScene("PlayerAssignment");
 }
 public FlightCameraController(string id, ControllerType controllerType,
                               KeyboardManager keyboardManager,
                               MouseManager mouseManager,
                               GamePadManager gamePadManager,
                               Keys[] moveKeys, float moveSpeed, float strafeSpeed, float rotationSpeed)
     : base(id, controllerType,
            keyboardManager, mouseManager, gamePadManager,
            moveKeys, moveSpeed, strafeSpeed, rotationSpeed)
 {
 }
示例#14
0
#pragma warning restore 0649

    protected void Update()
    {
        if (GamePadManager.GetJumpInput((int)EPlayer.Player1) || GamePadManager.GetJumpInput((int)EPlayer.Player2))
        {
            UpdateScrollView(false);
        }
        else if (GamePadManager.GetCrouchInput((int)EPlayer.Player1) || GamePadManager.GetCrouchInput((int)EPlayer.Player2))
        {
            UpdateScrollView(true);
        }
    }
示例#15
0
 public MyFPCC(string id, ControllerType controllerType, KeyboardManager keyboardManager,
               MouseManager mouseManager, GamePadManager gamePadManager, Keys[] moveKeys, float moveSpeed,
               float strafeSpeed, float rotationSpeed, IActor parentActor, Vector3 translationOffset,
               float radius, float height, float accelerationRate, float decelerationRate, float mass,
               float jumpHeight)
     : base(id, controllerType, keyboardManager, mouseManager, gamePadManager, moveKeys,
            moveSpeed, strafeSpeed, rotationSpeed, parentActor, translationOffset,
            radius, height, accelerationRate, decelerationRate, mass, jumpHeight)
 {
     //step 1 - add code to listen for CDCR event
     this.PlayerObject.Body.CollisionSkin.callbackFn += HandleCollision;
 }
示例#16
0
 public void MainMenu()
 {
     PlayerAssignmentScript.gameStarted = false;
     foreach (PlayerState item in GlobalReferences.PlayerStates)
     {
         GamePadManager.Disconnect(item.Index);
     }
     GlobalReferences.PlayerStates.Clear();
     GlobalReferences.CurrentGameState  = GlobalReferences.GameState.Play;
     PlayerAssignmentScript.gameStarted = false;
     SceneManager.LoadScene("MainMenu");
 }
 //useful for objects that need access to ALL managers
 public ManagerParameters(ObjectManager objectManager, CameraManager cameraManager,
                          MouseManager mouseManager, KeyboardManager keyboardManager, GamePadManager gamePadManager,
                          ScreenManager screenManager, SoundManager soundManager)
 {
     this.objectManager   = objectManager;
     this.cameraManager   = cameraManager;
     this.mouseManager    = mouseManager;
     this.keyboardManager = keyboardManager;
     this.gamePadManager  = gamePadManager;
     this.screenManager   = screenManager;
     this.soundManager    = soundManager;
 }
    private int CheckPlayerInput()
    {
        int readyCount = 0;

        for (int i = 0; i < GlobalReferences.PlayerStates.Count; i++)
        {
            GamePadState state = GamePad.GetState(GlobalReferences.PlayerStates[i].Index);
            if (state.Buttons.Start == ButtonState.Pressed && GlobalReferences.PlayerStates[i].PrevState.Buttons.Start == ButtonState.Released)
            {
                GlobalReferences.PlayerStates[i] = new PlayerState(GlobalReferences.PlayerStates[i], state, !GlobalReferences.PlayerStates[i].Ready, GlobalReferences.PlayerStates[i].ClassId);
                //TODO: Change menu
            }

            if (state.Buttons.B == ButtonState.Pressed)
            {
                if (GlobalReferences.PlayerStates[i].Index == PlayerIndex.One)
                {
                    Player1join.enabled     = true;
                    Player1assigned.enabled = false;
                }

                if (GlobalReferences.PlayerStates[i].Index == PlayerIndex.Two)
                {
                    Player2join.enabled     = true;
                    Player2assigned.enabled = false;
                }

                if (GlobalReferences.PlayerStates[i].Index == PlayerIndex.Three)
                {
                    Player3join.enabled     = true;
                    Player3assigned.enabled = false;
                }

                if (GlobalReferences.PlayerStates[i].Index == PlayerIndex.Four)
                {
                    Player4join.enabled     = true;
                    Player4assigned.enabled = false;
                }

                GamePadManager.Disconnect(GlobalReferences.PlayerStates[i].Index);
                GlobalReferences.PlayerStates.RemoveAt(i);
            }
            //TODO: Change classes here

            if (GlobalReferences.PlayerStates[i].Ready)
            {
                readyCount++;
            }
        }

        return(readyCount);
    }
示例#19
0
    private void PlayerScript_OnPlayerExit(object sender, PlayerEventArgs e)
    {
        if (spawnedPlayers.Count > 1)
        {
            e.PlayerScript.OnPlayerExit -= PlayerScript_OnPlayerExit;
            spawnedPlayers.Remove(e.PlayerScript);
            RemovePlayerState(e.PlayerScript.Index);
            GamePadManager.Disconnect(e.PlayerScript.Index);

            Destroy(e.PlayerObject);
            uiScript.OnExit(e.PlayerScript.Index);
        }
    }
示例#20
0
 protected void UpdateCursorVisiblity()
 {
     if (GamePadManager.UpdateGamePadsState() == EGamePadsConnectedState.Connected)
     {
         Cursor.lockState = CursorLockMode.Locked;
         Cursor.visible   = false;
     }
     else
     {
         Cursor.lockState = CursorLockMode.None;
         Cursor.visible   = true;
     }
 }
示例#21
0
    void OnGUI()
    {
        if (ScenesConfig.GetDebugSettings().m_DisplayGamepadInfo)
        {
            int w = Screen.width, h = Screen.height;

            // Display Gamepad Info ///////////////
            {
                DisplaGamepadInfo("Gamepad index : " + GamePadManager.GetJoystickNum(0), TextAnchor.MiddleLeft);
                DisplaGamepadInfo("Gamepad index : " + GamePadManager.GetJoystickNum(1), TextAnchor.MiddleRight);
            }
            //////////////////////////////
        }
    }
示例#22
0
    /*
     * A = 0,
     * B = 1,
     * X = 2,
     * Y = 3,
     *
     * DPad_UP = 4,
     * DPad_DOWN = 5,
     * DPad_LEFT = 6,
     * DPad_RIGHT = 7,
     *
     * Shldr_LEFT = 8,
     * Shldr_RIGHT = 9,
     *
     * ThumbStick_LEFT = 10,
     * ThumbStick_RIGHT = 11,
     *
     * Start = 12,
     * Back = 13
     */
    // Update is called once per frame
    void Update()
    {
        if (!isKeyboard)
        {
            if (manager.state.state == 0)
            {
                commands.jump   = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 0);
                commands.flip   = GamePadManager.GetControllerKeyDown(manager.playerGamepad.gamepad, 8);
                commands.aim    = GamePadManager.GetControllerAxes(manager.playerGamepad.gamepad).l_Trigger > 0.4f;
                commands.shoot  = GamePadManager.GetControllerAxes(manager.playerGamepad.gamepad).r_Trigger > 0.4f;
                commands.sprint = GamePadManager.GetControllerKeyDown(manager.playerGamepad.gamepad, 10);
                commands.slam   = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 2);
                commands.dash   = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 11);
                commands.swap   = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 3);
                commands.crouch = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 1);
                //commands.grenade = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 9);
            }
            commands.pause = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 12);

            commands.menuUp    = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 4);
            commands.menuDown  = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 5);
            commands.menuLeft  = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 6);
            commands.menuRight = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 7);

            commands.back   = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.player, 1);
            commands.select = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.player, 0);
        }
        else
        {
            if (manager.state.state == 0)
            {
                commands.jump   = Input.GetKeyDown(KeyCode.Space);
                commands.flip   = Input.GetKeyDown("q");
                commands.aim    = Input.GetMouseButton(1);
                commands.shoot  = Input.GetMouseButton(0);
                commands.sprint = Input.GetKeyDown(KeyCode.LeftShift);
                commands.slam   = Input.GetKeyDown(KeyCode.LeftControl);
                commands.dash   = Input.GetKeyDown(KeyCode.E);
            }
            commands.pause = Input.GetKeyDown(KeyCode.Escape);

            commands.menuUp    = Input.GetKeyDown(KeyCode.W);
            commands.menuDown  = Input.GetKeyDown(KeyCode.S);
            commands.menuLeft  = Input.GetKeyDown(KeyCode.A);
            commands.menuRight = Input.GetKeyDown(KeyCode.D);

            commands.back   = Input.GetKeyDown(KeyCode.Escape);
            commands.select = Input.GetKeyDown(KeyCode.Return);
        }
    }
示例#23
0
 public void CreditsScreen()
 {
     Win    = false;
     Defeat = false;
     PlayerAssignmentScript.gameStarted = false;
     foreach (PlayerState item in GlobalReferences.PlayerStates)
     {
         GamePadManager.Disconnect(item.Index);
     }
     GlobalReferences.PlayerStates.Clear();
     GlobalReferences.CurrentGameState = GlobalReferences.GameState.Play;
     SceneManager.LoadScene("Credits");
     UnfreezeAllPlayers();
 }
示例#24
0
    public static bool GetCrouchInput(int playerIndex)
    {
        bool isCrouching = false;

        if (GamePadManager.UpdateGamePadsState() == EGamePadsConnectedState.Connected)
        {
            isCrouching = GamePadManager.GetCrouchInput(playerIndex);
        }
        else
        {
            isCrouching = Input.GetKey(K_DOWN);
        }
        return(isCrouching);
    }
示例#25
0
    public static bool GetSubmitInput(out EPlayer submitInputPlayer)
    {
        bool submitInput = false;

        if (GamePadManager.UpdateGamePadsState() == EGamePadsConnectedState.Connected)
        {
            submitInput = GamePadManager.GetAnyPlayerSubmitInput(out submitInputPlayer);
        }
        else
        {
            submitInput       = Input.GetKeyDown(KeyCode.Return);
            submitInputPlayer = EPlayer.Player1;
        }
        return(submitInput);
    }
示例#26
0
    public static bool GetBackInput(out EPlayer backInputPlayer)
    {
        bool backInput = false;

        if (GamePadManager.UpdateGamePadsState() == EGamePadsConnectedState.Connected)
        {
            backInput = GamePadManager.GetAnyPlayerBackInput(out backInputPlayer);
        }
        else
        {
            backInput       = Input.GetKey(KeyCode.Backspace);
            backInputPlayer = EPlayer.Player1;
        }
        return(backInput);
    }
示例#27
0
    private void StopListeningInput()
    {
        UpdateInputSprite();
        GamePadManager.SetPlayerGamepadInputMapping((int)m_Player, m_CurrentInputKey, m_DefaultInputKey);
        m_CurrentEventSystem.enabled = true;

        bool isXboxGamepad = GamePadManager.GetPlayerGamepadType((int)m_Player) == EGamePadType.Xbox;

        m_XboxImageInput.enabled = isXboxGamepad;
        m_PS4ImageInput.enabled  = !isXboxGamepad;
        m_PressAKeyText.enabled  = false;
        m_InputButton.Select();
        m_IsListeningInput = false;
        OnInputChanged?.Invoke(this);
    }
    public void PressBackToMain()
    {
        changeMenu = true;
        foreach (PlayerState item in GlobalReferences.PlayerStates)
        {
            GamePadManager.Disconnect(item.Index);
        }
        GlobalReferences.PlayerStates.Clear();

        SceneManager.LoadScene("MainMenu");

        playerJoined[0] = false;
        playerJoined[1] = false;
        playerJoined[2] = false;
        playerJoined[3] = false;
    }
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="game">Game associated with the manager</param>
        public InputHandlerService(Game game) : base(game)
        {
            KeyboardManager = new KeyboardStateManager(game);
            GamePadManager = new GamePadManager(game);
#if WINDOWS
            MouseManager = new MouseStateManager(game);
#endif
#if WINDOWS_PHONE
        AccelerometerManager = new AccelerometerManager(game);
        TouchManager = new TouchCollectionManager(game);
        GamePadManager = new GamePadManager(game);
#endif
            //#if XBOX
            //        GamePadManager = new GamePadManager(game);
            //#endif
        }
示例#30
0
        private void HandleGamepad(ref Vector2 movement, GameTime time)
        {
            var m = GamePadManager.LeftThumbstickMovement();

            m = new Vector2(m.X, -m.Y);
            if (m == Vector2.Zero)
            {
                return;
            }

            if (this.ViewModel.ShoeType == ShoeType.Rollerblades)
            {
                m *= RollerbladeDelay * (float)time.ElapsedGameTime.TotalSeconds;
            }

            movement += m;
        }
示例#31
0
    protected void OnEnable()
    {
        for (int i = 0; i < m_OptionButtons.Length; i++)
        {
            Navigation buttonNavigation = m_OptionButtons[i].navigation;
            buttonNavigation.selectOnDown = m_DefaultSelectable;
            m_OptionButtons[i].navigation = buttonNavigation;
        }
        UpdateHighlightedGameObject(m_ControlsHighlightInfo);

        EGamePadType playerGamepadType = GamePadManager.GetPlayerGamepadType((int)EPlayer.Player1, OnPlayer1GamepadTypeChanged);

        UpdateInputForGamepadType(playerGamepadType, m_Player1ControlsMapping);

        playerGamepadType = GamePadManager.GetPlayerGamepadType((int)EPlayer.Player2, OnPlayer2GamepadTypeChanged);
        UpdateInputForGamepadType(playerGamepadType, m_Player2ControlsMapping);
    }
        public PickingManager(Game game, StatusType statusType,
                              KeyboardManager keyboardManager,
                              MouseManager mouseManager,
                              GamePadManager gamePadManager,
                              CameraManager <Camera3D> cameraManager,
                              float pickStartDistance, float pickEndDistance, Predicate <CollidableObject> collisionPredicate)
            : base(game, statusType)
        {
            this.keyboardManager = keyboardManager;
            this.mouseManager    = mouseManager;
            this.gamePadManager  = gamePadManager;
            this.cameraManager   = cameraManager;

            this.pickStartDistance  = pickStartDistance;
            this.pickEndDistance    = pickEndDistance;
            this.collisionPredicate = collisionPredicate;
        }
示例#33
0
 // Use this for initialization
 void Start()
 {
     m_zPosition = transform.position.z;
     m_control = (CharacterController)GetComponent<CharacterController>();
     m_movement = new Vector3();
     m_controller = new GamePadManager(m_player);
     PlayClip(m_spawn, WrapMode.Once);
     m_knockback = Vector3.zero;
 }