private void LogInput(GameAction gameAction, float value, ControllerID ID)
    {
        // Lock whilst searching.
        if (timer < MAX_TIME)
        {
            switch (gameAction)
            {
            case GameAction.RB_Held:
                cheatList.Add(gameAction);
                break;

            case GameAction.LB_Held:
                cheatList.Add(gameAction);
                break;

            case GameAction.A_Down:
                cheatList.Add(gameAction);
                break;

            case GameAction.B_Down:
                cheatList.Add(gameAction);
                break;
            }
        }
    }
示例#2
0
    private void HandleInput(GameAction gameAction, float value, ControllerID ID)
    {
        if (controllerID != ID)
        {
            return;
        }

        switch (gameAction)
        {
        case GameAction.LS_X_Axis:
            Spin(value);
            break;

        case GameAction.LS_Y_Axis:
            Lift(value);
            break;

        case GameAction.A_Held:
            SprayWater(value);
            break;

        default:
            break;
        }
    }
示例#3
0
    private void HandlePlayers(ControllerStatus controllerStatus, ControllerID controllerID)
    {
        switch (controllerStatus)
        {
        case ControllerStatus.Reconnected:
            Reconnected(controllerID);
            break;

        case ControllerStatus.Disconnected:
            Disconnected(controllerID);
            break;
        }
    }
示例#4
0
    /// <summary>
    /// Before sending the Callback. Check this player exists. If not add the player.
    /// </summary>
    /// <param name="controllerID"></param>
    private void Reconnected(ControllerID controllerID)
    {
        var playerWithController = players.Exists(playerData => { return(playerData.ControllerID == controllerID); });

        if (!playerWithController)
        {
            AddPlayer(controllerID);
        }

        if (playerReconnected != null)
        {
            playerReconnected(controllerID);
        }
    }
示例#5
0
    private void Disconnected(ControllerID controllerID)
    {
        var playerWithController = players.Exists(playerData => { return(playerData.ControllerID == controllerID); });

        if (!playerWithController)
        {
            Debug.Log("ERROR: Player who has not been assigned a controller has been disconnected.");
            return;
        }

        if (playerDisconnected != null)
        {
            playerDisconnected(controllerID);
        }
    }
示例#6
0
    private void Update()
    {
        controllerNames = Input.GetJoystickNames();
        if (controllerNames.Length > MAX_CONTROLLERS)
        {
            Debug.Log("ERROR: The MAX number of controllers connected has been exceeded");
        }

        for (var i = 0; i < controllerNames.Length; i++)
        {
            controllerID = (ControllerID)(i + 1);

            UpdateControllersStatus(i);

            AllAxis();
            AllButtons();
        }
    }
示例#7
0
    private void HandleInput(GameAction gameAction, float value, ControllerID gamepadID)
    {
        if (gamepadID != controllerID)
        {
            return;
        }

        switch (gameAction)
        {
        case GameAction.LS_X_Axis:
            pigeonPhysics.YawData(value);
            break;

        case GameAction.RT_Axis:
            pigeonPhysics.ThrustData(-value);
            break;

        case GameAction.LS_Y_Axis:
            pigeonPhysics.ChangeHeight(value);
            break;
        }
    }
示例#8
0
    /// <summary>
    /// Currently only adding the controllerID
    /// TODO: Setup the PlayerType management so each player is given a different role.
    /// </summary>
    /// <param name="controllerID"></param>
    private void AddPlayer(ControllerID controllerID)
    {
        players.Add(new PlayerData(controllerID));

        Debug.Log("MESSAGE: Adding player " + controllerID);

        // TODO: Turn this into a loop/ clean it up.
        if ((int)controllerID == 1)
        {
            players[players.Count - 1].PlayerType = ObjectType.Aircraft;
        }
        else if ((int)controllerID == 2)
        {
            players[players.Count - 1].PlayerType = ObjectType.Driver;
        }
        else if ((int)controllerID == 3)
        {
            players[players.Count - 1].PlayerType = ObjectType.Cannon_One;
        }
        else if ((int)controllerID == 4)
        {
            players[players.Count - 1].PlayerType = ObjectType.Cannon_Two;
        }
        else
        {
            players[players.Count - 1].PlayerType = ObjectType.Unassigned;
        }



        if (players[players.Count - 1].PlayerType == ObjectType.Unassigned)
        {
            Debug.Log("ERROR: Player has not correctly been assigned a objectType/ role");
            return;
        }
        playerCreated(players[players.Count - 1].ControllerID, players[players.Count - 1].PlayerType);
    }
示例#9
0
 public PlayerData(ControllerID controllerID)
 {
     ControllerID = controllerID;
     PlayerType   = ObjectType.Unassigned;
 }