private void Awake()
 {
     Screen.set_orientation((ScreenOrientation)3);
     this.player = ReInput.get_players().GetPlayer(0);
     ReInput.add_InputSourceUpdateEvent(new Action(this.OnInputUpdate));
     this.controller = (CustomController)((Player.ControllerHelper) this.player.controllers).GetControllerWithTag((ControllerType)20, "TiltController");
 }
Exemple #2
0
        private bool IsMenuAxis(int actionId, int axisIndex)
        {
            if (Object.op_Equality((Object)this.rewiredStandaloneInputModule, (Object)null))
            {
                return(false);
            }
            IList <Player> allPlayers = ReInput.get_players().get_AllPlayers();
            int            count1     = ((ICollection <Player>)allPlayers).Count;

            for (int index1 = 0; index1 < count1; ++index1)
            {
                IList <JoystickMap> maps = (IList <JoystickMap>)((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)allPlayers[index1].controllers).maps).GetMaps <JoystickMap>((int)((Controller)this.joystick).id);
                if (maps != null)
                {
                    int count2 = ((ICollection <JoystickMap>)maps).Count;
                    for (int index2 = 0; index2 < count2; ++index2)
                    {
                        IList <ActionElementMap> axisMaps = ((ControllerMapWithAxes)maps[index2]).get_AxisMaps();
                        if (axisMaps != null)
                        {
                            int count3 = ((ICollection <ActionElementMap>)axisMaps).Count;
                            for (int index3 = 0; index3 < count3; ++index3)
                            {
                                ActionElementMap actionElementMap = axisMaps[index3];
                                if (actionElementMap.get_actionId() == actionId && actionElementMap.get_elementIndex() == axisIndex)
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemple #3
0
 private void Initialize()
 {
     ReInput.add_InputSourceUpdateEvent(new Action(this.OnInputSourceUpdate));
     this.joysticks    = (TouchJoystickExample[])((Component)this).GetComponentsInChildren <TouchJoystickExample>();
     this.buttons      = (TouchButtonExample[])((Component)this).GetComponentsInChildren <TouchButtonExample>();
     this.axisCount    = this.joysticks.Length * 2;
     this.buttonCount  = this.buttons.Length;
     this.axisValues   = new float[this.axisCount];
     this.buttonValues = new bool[this.buttonCount];
     this.controller   = (CustomController)((Player.ControllerHelper)ReInput.get_players().GetPlayer(this.playerId).controllers).GetControllerWithTag <CustomController>(this.controllerTag);
     if (this.controller == null)
     {
         Debug.LogError((object)("A matching controller was not found for tag \"" + this.controllerTag + "\""));
     }
     if (((Controller)this.controller).get_buttonCount() != this.buttonValues.Length || ((ControllerWithAxes)this.controller).get_axisCount() != this.axisValues.Length)
     {
         Debug.LogError((object)"Controller has wrong number of elements!");
     }
     if (this.useUpdateCallbacks && this.controller != null)
     {
         this.controller.SetAxisUpdateCallback(new Func <int, float>(this.GetAxisValueCallback));
         this.controller.SetButtonUpdateCallback(new Func <int, bool>(this.GetButtonValueCallback));
     }
     this.initialized = true;
 }
 private void Update()
 {
     for (int rewiredPlayerId = 0; rewiredPlayerId < ReInput.get_players().get_playerCount(); ++rewiredPlayerId)
     {
         if (ReInput.get_players().GetPlayer(rewiredPlayerId).GetButtonDown("JoinGame"))
         {
             this.AssignNextPlayer(rewiredPlayerId);
         }
     }
 }
Exemple #5
0
        private Player FindPlayerWithoutJoystick()
        {
            IList <Player> players = ReInput.get_players().get_Players();

            for (int index = 0; index < ((ICollection <Player>)players).Count; ++index)
            {
                if (((Player.ControllerHelper)players[index].controllers).get_joystickCount() <= 0)
                {
                    return(players[index]);
                }
            }
            return((Player)null);
        }
 private void AssignNextPlayer(int rewiredPlayerId)
 {
     if (this.playerMap.Count >= this.maxPlayers)
     {
         Debug.LogError((object)"Max player limit already reached!");
     }
     else
     {
         int nextGamePlayerId = this.GetNextGamePlayerId();
         this.playerMap.Add(new PressStartToJoinExample_Assigner.PlayerMap(rewiredPlayerId, nextGamePlayerId));
         Player player = ReInput.get_players().GetPlayer(rewiredPlayerId);
         ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)player.controllers).maps).SetMapsEnabled(false, "Assignment");
         ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)player.controllers).maps).SetMapsEnabled(true, "Default");
         Debug.Log((object)("Added Rewired Player id " + (object)rewiredPlayerId + " to game player " + (object)nextGamePlayerId));
     }
 }
Exemple #7
0
        private void OnDisable()
        {
            if (!ReInput.get_isReady())
            {
                return;
            }
            Player player = ReInput.get_players().GetPlayer(0);

            if (player == null)
            {
                return;
            }
            player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedX));
            player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedY));
            player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnCycleColor));
            player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnCycleColorReverse));
            player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedX));
            player.RemoveInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedY));
        }
 public static Player GetRewiredPlayer(int gamePlayerId)
 {
     if (!ReInput.get_isReady())
     {
         return((Player)null);
     }
     if (Object.op_Equality((Object)PressStartToJoinExample_Assigner.instance, (Object)null))
     {
         Debug.LogError((object)"Not initialized. Do you have a PressStartToJoinPlayerSelector in your scehe?");
         return((Player)null);
     }
     for (int index = 0; index < PressStartToJoinExample_Assigner.instance.playerMap.Count; ++index)
     {
         if (PressStartToJoinExample_Assigner.instance.playerMap[index].gamePlayerId == gamePlayerId)
         {
             return(ReInput.get_players().GetPlayer(PressStartToJoinExample_Assigner.instance.playerMap[index].rewiredPlayerId));
         }
     }
     return((Player)null);
 }
Exemple #9
0
        private void OnEnable()
        {
            if (!ReInput.get_isReady())
            {
                return;
            }
            Player player = ReInput.get_players().GetPlayer(0);

            if (player == null)
            {
                return;
            }
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedX), (UpdateLoopType)0, (InputActionEventType)33, "Horizontal");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedX), (UpdateLoopType)0, (InputActionEventType)34, "Horizontal");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedY), (UpdateLoopType)0, (InputActionEventType)33, "Vertical");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnMoveReceivedY), (UpdateLoopType)0, (InputActionEventType)34, "Vertical");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnCycleColor), (UpdateLoopType)0, (InputActionEventType)3, "CycleColor");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnCycleColorReverse), (UpdateLoopType)0, (InputActionEventType)3, "CycleColorReverse");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedX), (UpdateLoopType)0, (InputActionEventType)33, "RotateHorizontal");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedX), (UpdateLoopType)0, (InputActionEventType)34, "RotateHorizontal");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedY), (UpdateLoopType)0, (InputActionEventType)33, "RotateVertical");
            player.AddInputEventDelegate(new Action <InputActionEventData>(this.OnRotationReceivedY), (UpdateLoopType)0, (InputActionEventType)34, "RotateVertical");
        }
 public void Setting(ControllerType _controllerType, int _controllerId)
 {
     this.controllerName = string.Copy(((Player.ControllerHelper)ReInput.get_players().GetPlayer(0).controllers).GetController(_controllerType, _controllerId).get_hardwareName());
     this.controllerType = _controllerType;
     this.maps           = ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)ReInput.get_players().GetPlayer(0).controllers).maps).GetMaps(_controllerType, _controllerId);
 }
 private void Initialize()
 {
     this.player      = ReInput.get_players().GetPlayer(this.playerId);
     this.initialized = true;
 }
Exemple #12
0
 private string GetControllerName(ControllerType _controllerType, int _controllerId)
 {
     return(string.Copy(((Player.ControllerHelper)ReInput.get_players().GetPlayer(0).controllers).GetController(_controllerType, _controllerId).get_hardwareName()));
 }