public Player(NetworkPlayer _NetClient, NetworkViewID _NetViewID, PlayerInputDevice _LocalPlayerInput)
 {
     m_NetClient = _NetClient;
     m_NetViewID = _NetViewID;
     m_LocalPlayerInput = _LocalPlayerInput;
     m_PlayerInstance = null;
 }
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < characterCyclers.Length; ++i)
     {
         PlayerInputDevice playerInputDevice = characterCyclers[i].GetComponent <PlayerInputDevice>();
         playerInputDevice.SetPlayerID(i);
     }
 }
Exemple #3
0
    void Start()
    {
        PlayerInputDevice playerInputDevice = GetComponent <PlayerInputDevice>();

        playerInputDevice.SetPlayerID(deviceId);

        inputDevice  = playerInputDevice.GetPlayerInputDevice();
        meshRenderer = GetComponent <MeshRenderer>();

        pMarkersGroupController = GetComponentInParent <PMarkersGroupController>();
    }
    public void AddLocalPlayerToJoin(NetworkPlayer _LocalNetClient, PlayerInputDevice _PlayerInput, bool _IsAuthority)
    {
        Player pendingPlayer = AddLocalPlayerPendingJoin(_LocalNetClient, _PlayerInput);
        System.Diagnostics.Debug.Assert(pendingPlayer.m_NetClient == _LocalNetClient);

        Debug.Log("Adding local player to join (input: " + _PlayerInput.ToString() + ")");
        Debug.Log("IP: "+ _LocalNetClient.ipAddress + ", port:" + _LocalNetClient.port + ", NetViewID: " + pendingPlayer.m_NetViewID.ToString());

        if (_IsAuthority)
        {
            //@NOTE: Unity3d network system doesn't support sending RPCs to server from server when using RPCMode.Server (RPCMode.All is fine)
            PlayerJoinAuthority(pendingPlayer.m_NetClient, pendingPlayer.m_NetViewID);
        }
        else
        {
            if (m_Players.Count == 0)
            {
                networkView.RPC("ClientRequestPlayersJoinAuthority", RPCMode.Server, pendingPlayer.m_NetClient);
            }
            networkView.RPC("PlayerJoinAuthority", RPCMode.Server, pendingPlayer.m_NetClient, pendingPlayer.m_NetViewID);
        }
    }
 public Player(PlayerInputDevice _LocalPlayerInput)
 {
     m_LocalPlayerInput = _LocalPlayerInput;
     m_PlayerInstance = null;
 }
    private Player AddLocalPlayerPendingJoin(NetworkPlayer _LocalNetClient, PlayerInputDevice _PlayerInput)
    {
        NetworkViewID newViewID = Network.AllocateViewID();
        Player newLocalPlayer = new Player(_LocalNetClient, newViewID, _PlayerInput);
        m_PendingLocalPlayers.Add(newLocalPlayer);

        return newLocalPlayer;
    }
    public bool IsLocalPlayerJoining(NetworkPlayer _LocalNetClient, PlayerInputDevice _PlayerInput)
    {
        bool playerJoining = false;
        foreach ( Player joiningPlayer in m_PendingLocalPlayers )
        {
            bool isLocalPlayer = (joiningPlayer.m_NetClient == _LocalNetClient);
            bool matchingInput = (joiningPlayer.m_LocalPlayerInput == _PlayerInput);
            if (isLocalPlayer && matchingInput)
            {
                playerJoining = true;
                break;
            }
        }

        return playerJoining;
    }
    public bool HasLocalPlayerJoined(NetworkPlayer _LocalNetClient, PlayerInputDevice _PlayerInput)
    {
        bool playerJoined = false;
        foreach (Player player in m_Players)
        {
            bool isLocalPlayer = (player.m_NetClient == _LocalNetClient);
            bool matchingInput = (player.m_LocalPlayerInput == _PlayerInput);

            if (isLocalPlayer && matchingInput)
            {
                playerJoined = true;
                break;
            }
        }

        return playerJoined;
    }
Exemple #9
0
    private void updateInputDevice()
    {
        this.device = InputManager.ActiveDevice;

        if (this.device.Name.ToLower ().Contains ("keyboard")) {
            this.playerInputDevice = PlayerInputDevice.KEYBOARD;
        } else if (this.device.Name.ToLower ().Contains ("xbox 360")) {
            this.playerInputDevice = PlayerInputDevice.XBOX360_GAMEPAD;
        } else if (this.device.Name.ToLower ().Contains ("ps3")) {
            this.playerInputDevice = PlayerInputDevice.PS3_GAMEPAD;
        } else if (this.device.Name.ToLower ().Contains ("ouya")) {
            this.playerInputDevice = PlayerInputDevice.OUYA_GAMEPAD;
        }
    }
 void Awake()
 {
     playerInputDevice = GetComponent <PlayerInputDevice>();
 }