public void SpawnPlayer(NetworkConnection conn, short playerControllerId, Utils.PlayerType type)
    {
        GameObject prefab = null;

        switch (type)
        {
        case Utils.PlayerType.HoloLens:
            prefab = holoLensPlayerPrefab;
            break;

        case Utils.PlayerType.VR:
            prefab = vrPlayerPrefab;
            break;
        }

        if (!prefab)
        {
            Debug.LogError("Unspawnable player type for client: " + type.ToString());
            return;
        }

        Debug.Log("Spawning a " + type.ToString() + " player.");
        GameObject player = Instantiate(prefab, playersContainer.transform);

        player.GetComponent <PlayerController>().alignmentManagerObject = alignmentManager.gameObject;
        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
        player.GetComponent <PlayerController>().RpcPlayerIsInitialized();
    }
Exemple #2
0
 public void SetupPlayer(Vector3 alignmentTranslation, float alignmentYRotation, Utils.PlayerType playerType, int playerCounter, Vector3 markerOffset, string playerName)
 {
     AlignmentTranslation = alignmentTranslation;
     AlignmentRotation    = alignmentYRotation;
     PlayerType           = playerType;
     PlayerCounter        = playerCounter;
     MarkerOffset         = markerOffset;
     PlayerName           = playerName;
 }
Exemple #3
0
    public void SetAvatar(int playerCounter, Utils.PlayerType playerType, string playerName, bool showHLAvatar = false)
    {
        PlayerType     = playerType;
        _networkPlayer = NetworkPlayerGameObject.GetComponent <NetworkPlayer>();
        MarkerOffset   = _networkPlayer.MarkerOffset;
        TextFieldForPlayerName.text = playerName;

        if (PlayerType == Utils.PlayerType.VR)
        {
            if (showHLAvatar)
            {
                Instantiate(ViveAvatar, gameObject.transform);
                _body = Instantiate(BodyPrefab, gameObject.transform);

                _rightHand = Instantiate(HandPrefabR);
                _rightHand.SetActive(false);

                _leftHand = Instantiate(HandPrefabL);
                _leftHand.SetActive(false);
            }
        }
        else
        {
            if (showHLAvatar)
            {
                if (playerCounter % 2 == 0)
                {
                    Instantiate(HoloLensAvatar, gameObject.transform);
                }
                else
                {
                    Instantiate(HoloLensAvatar2, gameObject.transform);
                }
                _body = Instantiate(BodyPrefab, gameObject.transform);

                _rightHand = Instantiate(HandPrefabHololens);
                _rightHand.SetActive(false);

                _leftHand = Instantiate(HandPrefabHololens);
                _leftHand.SetActive(false);
            }
            else
            {
                TextFieldForPlayerName.gameObject.transform.parent.gameObject.SetActive(false);
            }
        }


        //var comms = FindObjectOfType<DissonanceComms>();
        //comms.OnPlayerJoinedSession += Comms_OnPlayerJoinedSession;
    }
    /// <summary>
    /// Spawns a new network player and sets him up (Runs on server side)
    /// </summary>
    /// <param name="conn">Connection from where the original message came from</param>
    /// <param name="playerControllerId">ID for identifying the playerController</param>
    /// <param name="playerType">Type of the player (VR or HoloLens)</param>
    /// <param name="alignmentPosition">Offset Position for Hololens (equals the Markerposition in the HoloLens coordinate system)</param>
    /// <param name="alignmentRotation">Offset Rotation for HoloLens (equals the Markerrotation in the HoloLens coordinate system)</param>
    public void SpawnPlayer(NetworkConnection conn, short playerControllerId, Utils.PlayerType playerType, Vector3 alignmentPosition, float alignmentRotation, string localPlayerName)
    {
        Debug.Log("Spawning a " + playerType.ToString() + " player.");

        var _alignmentTranslation = playerType == Utils.PlayerType.HoloLens ? alignmentPosition : playersContainer.transform.position;
        var _alignmentRotation    = playerType == Utils.PlayerType.HoloLens ? alignmentRotation : playersContainer.transform.rotation.eulerAngles.y;

        GameObject player = Instantiate(networkPlayer, playersContainer.transform);

        NetworkServer.AddPlayerForConnection(conn, player, playerCounter);

        player.GetComponent <NetworkPlayer>().RpcSetupPlayer(_alignmentTranslation, _alignmentRotation, playerType, playerCounter, MarkerOffset.position, localPlayerName);

        player.GetComponent <NetworkPlayer>().PlayerName = localPlayerName;

        if (playerType == Utils.PlayerType.HoloLens)
        {
            playerCounter++;
        }
    }
Exemple #5
0
 public void RpcSetupPlayer(Vector3 alignmentTranslation, float alignmentYRotation, Utils.PlayerType playerType, int playerCounter, Vector3 markerOffset, string playerName)
 {
     SetupPlayer(alignmentTranslation, alignmentYRotation, playerType, playerCounter, markerOffset, playerName);
 }