/// <summary>
    /// Process user hit.
    /// </summary>
    /// <param name="msg"></param>
    void ProcessUserHit(NetworkInMessage msg)
    {
        // Parse the message
        long userID    = msg.ReadInt64();
        long hitUserId = msg.ReadInt64();

        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);
        FriendlyDrone  soh      = headInfo.HeadObject.GetComponentInChildren <FriendlyDrone>();

        if (soh != null)
        {
            soh.Happy();
        }
        headInfo.HitCount++;

        AudioSource            remoteHeadAudio = headInfo.HeadObject.GetComponentInChildren <AudioSource>();
        PlayerAvatarParameters playerParams    = PlayerAvatarStore.Instance.PlayerAvatars[headInfo.PlayerAvatarIndex].GetComponent <PlayerAvatarParameters>();

        if (hitUserId == customMessages.localUserID)
        {
            // ack they hit ME!!!
            // Play the 'they hit me' sound.
            AudioSource            localAudioSource  = Camera.main.GetComponent <AudioSource>();
            PlayerAvatarParameters localPlayerParams = PlayerAvatarStore.Instance.PlayerAvatars[LocalPlayerManager.Instance.AvatarIndex].GetComponent <PlayerAvatarParameters>();
            localAudioSource.clip = localPlayerParams.SomeoneHitPlayerClip;
            localAudioSource.Play();
        }

        // Play the 'I hit someone' sound for the user who hit someone.
        remoteHeadAudio.clip = playerParams.PlayerHitSomeoneClip;
        remoteHeadAudio.Play();
    }
示例#2
0
    /// <summary>
    /// Called when a remote user sends a head transform.
    /// </summary>
    /// <param name="msg"></param>
    void UpdateHeadTransform(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        Vector3 headPos = customMessages.ReadVector3(msg);

        Quaternion headRot = customMessages.ReadQuaternion(msg);

        // If head info does not exist for this userID, a new one will be created
        // with the call to GetRemoteHeadInfo.
        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

        if (headInfo.HeadObject != null)
        {
            // If we don't have our anchor established, don't draw the remote head.
            headInfo.HeadObject.SetActive(headInfo.Anchored);

            headInfo.HeadObject.transform.localPosition = headPos;

            //headInfo.HeadObject.transform.localRotation = headRot;

            /* Our code for testing */
            Transform anchor = ImportExportAnchorManager.Instance.gameObject.transform;
            Vector3   remoteHealthDisplayPos = anchor.TransformPoint(headPos);

            GameObject healthDisplay = headInfo.HeadObject;
            healthDisplay.transform.parent   = this.transform;
            healthDisplay.transform.position = remoteHealthDisplayPos;
        }

        headInfo.Anchored = (msg.ReadByte() > 0);
    }
    /// <summary>
    /// Called when a user's avatar has changed.
    /// </summary>
    /// <param name="msg"></param>
    void UpdateUserAvatar(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

        headInfo.PlayerAvatarIndex = msg.ReadInt32();

        // Configure the remote user's head object
        if (headInfo.HeadObject != null)
        {
            Destroy(headInfo.HeadObject);
        }

        headInfo.HeadObject = Instantiate(PlayerAvatarStore.Instance.PlayerAvatars[headInfo.PlayerAvatarIndex]);
        headInfo.headObjectPositionOffset    = headInfo.HeadObject.transform.localPosition;
        headInfo.HeadObject.transform.parent = this.transform;
        headInfo.HeadObject.GetComponent <PlayerAvatarParameters>();
        FriendlyDrone droneScript = headInfo.HeadObject.GetComponentInChildren <FriendlyDrone>();

        droneScript.OwningUserId = userID;

        // And since we've been sent an avatar, the user is now ready to play.
        headInfo.HeadObject.GetComponentInChildren <MeshRenderer>().enabled = true;
        headInfo.Active = true;
    }
示例#4
0
        /// <summary>
        /// Gets the data structure for the remote users' head position.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public RemoteHeadInfo GetRemoteHeadInfo(long userID)
        {
            RemoteHeadInfo headInfo;

            // Get the head info if its already in the list, otherwise add it
            if (!this.remoteHeads.TryGetValue(userID, out headInfo))
            {
                headInfo            = new RemoteHeadInfo();
                headInfo.UserID     = userID;
                headInfo.HeadObject = CreateRemoteHead(userID);
                this.remoteHeads.Add(userID, headInfo);
            }

#if UNITY_EDITOR
            if (headInfo.IP != null && HolographicCameraManager.Instance != null &&
                !HolographicCameraManager.Instance.IsCurrentlyActive && SharingStage.Instance != null &&
                SharingStage.Instance.SessionUsersTracker != null)
            {
                if (headInfo.IP == HolographicCameraManager.Instance.HolographicCameraIP.Trim() &&
                    HolographicCameraManager.Instance.HolographicCameraIP.Trim() != String.Empty)
                {
                    headInfo.HeadObject.name = "SpectatorViewCamera";
                    HolographicCameraManager.Instance.EnableHolographicCamera(headInfo.HeadObject.transform);
                    User user = SharingStage.Instance.SessionUsersTracker.GetUserById((int)userID);
                    if (user != null)
                    {
                        HolographicCameraManager.Instance.tppcUser = user;
                    }
                }
            }
#endif

            return(headInfo);
        }
示例#5
0
        /// <summary>
        /// Called when a remote user sends a head transform.
        /// </summary>
        /// <param name="msg"></param>
        void UpdateHeadTransform(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();
            long ipSize = msg.ReadInt64();

            byte[] ipData = new byte[(uint)ipSize];
            msg.ReadArray(ipData, (uint)ipSize);

            Vector3    headPos = SV_CustomMessages.Instance.ReadVector3(msg);
            Quaternion headRot = SV_CustomMessages.Instance.ReadQuaternion(msg);

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

            if (headInfo.HeadObject != null)
            {
#if UNITY_EDITOR
                if (HolographicCameraManager.Instance != null &&
                    HolographicCameraManager.Instance.tppcUser != null &&
                    HolographicCameraManager.Instance.tppcUser.GetID() == userID)
                {
                    if (SV_Cam == null)
                    {
                        SV_Cam = headInfo.HeadObject.AddComponent <SV_Camera>();
                    }

                    if (networkMovement == null)
                    {
                        networkMovement = headInfo.HeadObject.AddComponent <NetworkMovement>();
                    }

                    // update SV_cam info
                    SV_Cam.info = headInfo;
                    // update SV_cam position and rotation
                    SV_Cam.position = headPos;
                    SV_Cam.rotation = headRot;

                    networkMovement.AddTransform(
                        new NetworkMovement.NetworkTransform()
                    {
                        Position = headPos,
                        Rotation = headRot
                    }
                        );
                }
                else
#endif
                {
                    headInfo.HeadObject.transform.localPosition = headPos;
                    headInfo.HeadObject.transform.localRotation = headRot;
                }

                if (string.IsNullOrEmpty(headInfo.IP))
                {
                    headInfo.IP = System.Text.Encoding.ASCII.GetString(ipData);
                }
            }
        }
示例#6
0
    /// <summary>
    /// リストに入れるリモートユーザの情報を生成する
    /// たぶんありえないけど、既存のものがいたら流用
    /// </summary>
    /// <param name="userId"></param>
    private RemoteHeadInfo GetRemoteHeadInfo(long userId)
    {
        RemoteHeadInfo headInfo;

        if (!remoteHeads.TryGetValue(userId, out headInfo))
        {
            headInfo            = new RemoteHeadInfo();
            headInfo.UserID     = userId;
            headInfo.HeadObject = CreateRemoteHead(userId); // GameObjectの生成

            remoteHeads.Add(userId, headInfo);              // リストに追加
        }
        return(headInfo);
    }
示例#7
0
    /// <summary>
    /// メッセージ受信時のハンドラ
    /// </summary>
    /// <param name="msg">リモートユーザからのメッセージ、ブロードキャストされてくる</param>
    private void UpdateHeadTransform(NetworkInMessage msg)
    {
        long userID = msg.ReadInt64();  // ユーザIDを取得

        // メッセージ内のPosition, Rotationデータを取得
        Vector3    headPos = EasySharingMessages.Instance.ReadVector3(msg);
        Quaternion headRot = EasySharingMessages.Instance.ReadQuaternion(msg);

        // シーン上のオブジェクトに受信データを反映
        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

        headInfo.HeadObject.transform.localPosition = headPos;
        headInfo.HeadObject.transform.localRotation = headRot;
    }
        /// <summary>
        /// Called when a remote user sends a head transform.
        /// </summary>
        /// <param name="msg"></param>
        private void UpdateHeadTransform(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            Vector3 headPos = CustomMessages.Instance.ReadVector3(msg);

            Quaternion headRot = CustomMessages.Instance.ReadQuaternion(msg);

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

            headInfo.HeadObject.transform.localPosition = headPos;
            headInfo.HeadObject.transform.localRotation = headRot;
        }
        /// <summary>
        /// Called when a remote user sends a head transform.
        /// </summary>
        /// <param name="msg"></param>
        private void UpdateHeadTransform(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            Vector3 headPos = CustomMessages.Instance.ReadVector3(msg);

            Quaternion headRot = CustomMessages.Instance.ReadQuaternion(msg);

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

            headInfo.HeadObject.transform.localPosition = headPos; // += new Vector3(0,0,0); Leaving these here so we can easily modify in future builds
            headInfo.HeadObject.transform.localRotation = headRot;
        }
    /// <summary>
    /// Gets the data structure for the remote users' head position.
    /// </summary>
    /// <param name="userID"></param>
    /// <returns></returns>
    public RemoteHeadInfo GetRemoteHeadInfo(long userID)
    {
        RemoteHeadInfo headInfo;

        // Get the head info if its already in the list, otherwise add it
        if (!this.remoteHeads.TryGetValue(userID, out headInfo))
        {
            headInfo        = new RemoteHeadInfo();
            headInfo.UserID = userID;
            LocalPlayerManager.Instance.SendUserAvatar();

            this.remoteHeads.Add(userID, headInfo);
        }

        return(headInfo);
    }
        /// <summary>
        /// Gets the data structure for the remote users' head position.
        /// </summary>
        /// <param name="userId">User ID for which the remote head info should be obtained.</param>
        /// <returns>RemoteHeadInfo for the specified user.</returns>
        public RemoteHeadInfo GetRemoteHeadInfo(long userId)
        {
            RemoteHeadInfo headInfo;

            // Get the head info if its already in the list, otherwise add it
            if (!remoteHeads.TryGetValue(userId, out headInfo))
            {
                headInfo            = new RemoteHeadInfo();
                headInfo.UserID     = userId;
                headInfo.HeadObject = CreateRemoteHead();

                remoteHeads.Add(userId, headInfo);
            }

            return(headInfo);
        }
示例#12
0
/// <summary>
/// Called when a remote user sends a head transform.
/// </summary>
/// <param name="msg"></param>
    void UpdateHeadTransform(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        Vector3 headPos = customMessages.ReadVector3(msg);

        Quaternion headRot = customMessages.ReadQuaternion(msg);

        Vector3 headTarget   = customMessages.ReadVector3(msg);
        Vector3 targetNormal = customMessages.ReadVector3(msg);

        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);


        Vector3 A = new Vector3();
        Vector3 B = new Vector3();

        if (headInfo.HeadObject != null)
        {
            // If we don't have our anchor established, don't draw the remote head.
            headInfo.HeadObject.SetActive(headInfo.Anchored);

            headInfo.HeadObject.transform.localPosition = headPos + headRot * headInfo.headObjectPositionOffset;

            headInfo.HeadObject.transform.localRotation = headRot;

            //if this manager add into volume
            if (AppStateManager.Instance.isCommandCenter)
            {
                //update head
                if (!OctreeManager.Instance.GetMarkers(headTarget, ref A, ref B))
                {
                    OctreeManager.Instance.Add(headTarget);


                    CustomMessages.Instance.SendMarkerList(headTarget, targetNormal, 0x1);
                    GameObject a = Instantiate(MarkerPrefab, headTarget, Quaternion.identity);

                    // Orient the cursor to match the surface being gazed at.
                    a.transform.up = GazeManager.Instance.Normal;
                }
            }
        }

        headInfo.Anchored = (msg.ReadByte() > 0);
    }
示例#13
0
    /*
     * Updates other players' health in the game world.
     */
    void UpdatePlayerHealth(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

        headInfo.playerHealth = msg.ReadInt32();
        // Configure the remote user's head sprite
        HealthDisplayBehavior remote = headInfo.HeadObject.transform.FindChild("Sprite").GetComponent <HealthDisplayBehavior>();

        remote.setHealth(headInfo.playerHealth);
        if (headInfo.playerHealth <= 0)
        {
            alive = false;
        }
    }
示例#14
0
        /// <summary>
        /// Called when a remote user sends a head transform.
        /// </summary>
        /// <param name="msg"></param>
        private void UpdateHeadTransform(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            Vector3 headPos = CustomMessages.Instance.ReadVector3(msg);

            Quaternion headRot = CustomMessages.Instance.ReadQuaternion(msg);

#if MIKET_CHANGE
            long remoteRoomId = msg.ReadInt64();
#endif

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);
            headInfo.HeadObject.transform.localPosition = headPos;
            headInfo.HeadObject.transform.localRotation = headRot;

#if MIKET_CHANGE
            var rayLength = maxRayDistance;

            RaycastHit hitInfo;

            if (Physics.Raycast(
                    headInfo.HeadObject.transform.position,
                    headInfo.HeadObject.transform.forward,
                    out hitInfo))
            {
                rayLength = hitInfo.distance;
            }
            var lineRenderer = headInfo.HeadObject.GetComponent <LineRenderer>();
            lineRenderer.SetPosition(1, Vector3.forward * rayLength);

            if ((remoteRoomId == -1) || (this.roomId == -1) ||
                (remoteRoomId != this.roomId))
            {
                headInfo.BodyObject.SetActive(true);
                headInfo.BodyObject.transform.localPosition = headPos;
                headInfo.BodyObject.transform.localRotation = headRot;
            }
            else
            {
                headInfo.BodyObject.SetActive(false);
            }
#endif
        }
示例#15
0
        /// <summary>
        /// Gets the data structure for the remote users' head position.
        /// </summary>
        /// <param name="userId">User ID for which the remote head info should be obtained.</param>
        /// <returns>RemoteHeadInfo for the specified user.</returns>
        public RemoteHeadInfo GetRemoteHeadInfo(long userId)
        {
            RemoteHeadInfo headInfo;

            // Get the head info if its already in the list, otherwise add it
            if (!remoteHeads.TryGetValue(userId, out headInfo))
            {
                headInfo            = new RemoteHeadInfo();
                headInfo.UserID     = userId;
                headInfo.HeadObject = CreateRemoteHead();

#if MIKET_CHANGE
                headInfo.BodyObject = Instantiate(this.remoteBodyPrefab);
                headInfo.BodyObject.transform.parent = this.gameObject.transform;
#endif
                remoteHeads.Add(userId, headInfo);
            }

            return(headInfo);
        }
示例#16
0
    /// <summary>
    /// Gets the data structure for the remote users' head position.
    /// </summary>
    /// <param name="userID"></param>
    /// <returns></returns>
    public RemoteHeadInfo GetRemoteHeadInfo(long userID)
    {
        RemoteHeadInfo headInfo;

        // Get the head info if its already in the list, otherwise add it
        if (!this.remoteHeads.TryGetValue(userID, out headInfo))
        {
            headInfo        = new RemoteHeadInfo();
            headInfo.UserID = userID;

            headInfo.HeadObject = Instantiate(HealthIcon);
            HealthDisplayBehavior remote = headInfo.HeadObject.transform.FindChild("Sprite").GetComponent <HealthDisplayBehavior>();
            remote.setHealth(headInfo.playerHealth);
            headInfo.headObjectPositionOffset    = headInfo.HeadObject.transform.localPosition;
            headInfo.HeadObject.transform.parent = this.transform;
            headInfo.Active = true;

            this.remoteHeads.Add(userID, headInfo);
        }
        return(headInfo);
    }
示例#17
0
        private void UpdateOverheadText(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            Vector3 overheadPos = CustomMessages.Instance.ReadVector3(msg);

            String overheadStr = msg.ReadString();

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

            headInfo.Interjection.transform.localPosition = overheadPos;

            TextMesh tmpTxt = headInfo.Interjection.transform.GetComponent <TextMesh>();

            tmpTxt.text = overheadStr;

            GameObject tmpPlayer = GameObject.Find("Cube");

            headInfo.Interjection.transform.rotation = Quaternion.LookRotation(headInfo.Interjection.transform.position - Camera.main.transform.position);
            //MakeOverheadText(overheadPos, overheadStr);
        }
    /// <summary>
    /// Called when a remote user sends a head transform.
    /// </summary>
    /// <param name="msg"></param>
    void UpdateHeadTransform(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        Vector3 headPos = CustomMessages.Instance.ReadVector3(msg);

        Quaternion headRot    = CustomMessages.Instance.ReadQuaternion(msg);
        GameObject chessboard = GameObject.Find("Chessboard");


        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);


        headPos = chessboard.transform.position;

        headPos.z = headPos.z + chessboard.transform.localScale.z + 0.5f;
        headPos.x = headPos.x + (headInfo.HeadObject.transform.transform.localScale.x * 0.25f);
        headPos.y = chessboard.transform.position.y - (headInfo.HeadObject.transform.transform.localScale.y * 0.25f);
        headInfo.HeadObject.transform.localPosition = headPos;
        headInfo.HeadObject.transform.localRotation = headRot;
    }
    /// <summary>
    /// Called when a remote user sends a head transform.
    /// </summary>
    /// <param name="msg"></param>
    void UpdateHeadTransform(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        Vector3 headPos = customMessages.ReadVector3(msg);

        Quaternion headRot = customMessages.ReadQuaternion(msg);

        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

        if (headInfo.HeadObject != null)
        {
            // If we don't have our anchor established, don't draw the remote head.
            headInfo.HeadObject.SetActive(headInfo.Anchored);

            headInfo.HeadObject.transform.localPosition = headPos + headRot * headInfo.headObjectPositionOffset;

            headInfo.HeadObject.transform.localRotation = headRot;
        }

        headInfo.Anchored = (msg.ReadByte() > 0);
    }
示例#20
0
        /// <summary>
        /// Called when a remote user sends a head transform.
        /// </summary>
        /// <param name="msg"></param>
        void UpdateHeadTransform(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();
            long ipSize = msg.ReadInt64();

            byte[] ipData = new byte[(uint)ipSize];
            msg.ReadArray(ipData, (uint)ipSize);

            Vector3    headPos = SpectatorView.SV_CustomMessages.Instance.ReadVector3(msg);
            Quaternion headRot = SpectatorView.SV_CustomMessages.Instance.ReadQuaternion(msg);

            RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

            if (headInfo.HeadObject != null)
            {
#if UNITY_EDITOR
                if (SpectatorView.HolographicCameraManager.Instance != null &&
                    SpectatorView.HolographicCameraManager.Instance.tppcUser != null &&
                    SpectatorView.HolographicCameraManager.Instance.tppcUser.GetID() == userID)
                {
                    SetHologramPose(headRot.x, headRot.y, headRot.z, headRot.w,
                                    headPos.x, headPos.y, headPos.z);
                }
                else
#endif
                {
                    headInfo.HeadObject.transform.localPosition = headPos;
                    headInfo.HeadObject.transform.localRotation = headRot;
                }

                if (string.IsNullOrEmpty(headInfo.IP))
                {
                    headInfo.IP = System.Text.Encoding.ASCII.GetString(ipData);
                }
            }
        }
    /// <summary>
    /// Called when a remote user sends a head transform.
    /// </summary>
    /// <param name="msg"></param>
    private void UpdateHeadTransform(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();
        // read position
        Vector3 headPos = svSharing.ReadVector3(msg, true).vector3Value;
        // read rotation
        Quaternion headRot = svSharing.ReadQuaternion(msg, true).quaternionValue;
        // read rotation
        RemoteHeadInfo headInfo = GetRemoteHeadInfo(userID);

        // activates users head object and set it position and rotation
        if (headInfo.HeadObject != null)
        {
            // If we don't have our anchor established, don't draw the remote head.
            headInfo.HeadObject.SetActive(headInfo.Anchored);

            headInfo.HeadObject.transform.localPosition = headPos + headRot * headInfo.headObjectPositionOffset;

            headInfo.HeadObject.transform.localRotation = headRot;
        }

        headInfo.Anchored = (msg.ReadByte() > 0);
    }
示例#22
0
 public HeadInfo(RemoteHeadInfo headInfo, RemoteHeadInfo headProxyInfo)
 {
     this.headInfo      = headInfo;
     this.headProxyInfo = headProxyInfo;
 }