示例#1
0
 // Use this for initialization
 private void Awake()
 {
     m_PlayerSpawnerBeh = m_PlayerSpawner.GetComponent <PlayerSpawner>();
     m_InputManagerBeh  = m_InputManager.GetComponent <InputManager>();
     m_CamBeh           = m_Camera.GetComponent <CameraBeh>();
     if (m_NumPlayers == -1)
     {
         m_NumPlayers = 1;
     }
     m_InfoToRead = FindObjectOfType <InfoPasser>();
     if (m_InfoToRead != null)
     {
         m_NumPlayers = m_InfoToRead.MyInfo.GetNumPlayers();
         m_HowToPlay  = m_InfoToRead.MyInfo.GetHowToPlay();
     }
     else
     {
         m_NumPlayers = (int)1;
         m_HowToPlay  = InfoPasser.Controls.OneXbox;
     }
     if (m_NumPlayers == 1 && m_HowToPlay == InfoPasser.Controls.OneKeyboard)
     {
         SinglePlayerController = false;
     }
 }
示例#2
0
    public void AssignInput(PlayerSpawner _pSpawn, int _numPlayers, bool _singlePlayerController, InfoPasser.Controls _controls)
    {
        if (_pSpawn.GetPlayer == null)
        {
            Debug.Log("NULL PLAYER");
            return;
        }
        GameObject user = _pSpawn.GetPlayer;
        Ball       ball = user.GetComponent <Ball>();

        ball.AttachedPlayers = new BallCtrl[_numPlayers];
        for (int x = 0; x < _numPlayers; x++)
        {
            GameObject obj = new GameObject("Player " + x);
            obj.transform.SetParent(user.transform);
            obj.AddComponent <BallCtrl>();
        }
        //current player we are assigning input too
        int curPlayer = 0;
        //number of players on the ball
        int size = user.transform.childCount;

        //looping through all the input/controls we need to assign to the players on the ball
        for (int x = 0; x < m_InputList.Count; x++)
        {
            //get the transform so we can get the gameobj
            Transform t = user.transform.GetChild(curPlayer);
            //get the ballctrl on the child transform/gameobj
            BallCtrl b = t.gameObject.GetComponentInChildren <BallCtrl>();
            //the player arry in the ball, assign a ballctrl to it
            ball.AttachedPlayers[curPlayer] = b;
            //error checking
            if (b == null)
            {
                Debug.Log("ASSIGN INPUT B IS NULL");
                return;
            }
            //add the input that the player will be responceable for
            b.m_Controls.Add((InputControlsBall)x);
            //set names for unity to read input
            b.SetNames((InputControlsBall)m_InputList[x], curPlayer, _singlePlayerController, _controls);
            //we need to make sure the current player never excides
            if (curPlayer + 1 >= size)
            {
                curPlayer = 0;
            }
            else
            {
                curPlayer++;
            }
        }
    }
示例#3
0
    public void SetNames(InputManager.InputControlsBall _input, int _player, bool _singlePlayerController, InfoPasser.Controls _controls)
    {
        // set the solo player
        // if ther is one pass the bool

        switch (_controls)
        {
        case InfoPasser.Controls.OneKeyboard:
            SPCKEYBOARD(_input, _player);
            break;

        case InfoPasser.Controls.OneXbox:
            SPCXBOX(_input);
            break;

        case InfoPasser.Controls.KeyboardAndXbox:
            bool t = _player == 1 ? true : false;
            DOUBLE_XBOX_AND_KEYBOARD(_input, t);
            break;

        case InfoPasser.Controls.DoubleXbox:
            bool temp = _player == 1 ? true : false;
            DOUBLEXBOX(_input, temp);
            break;

        default:
            break;
        }
    }