/// <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();
            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);
                }
            }
        }
示例#3
0
    // Called when reading in Kinect body data
    void UpdateCondition(NetworkInMessage msg)
    {
        // Parse the message
        long surprise   = msg.ReadInt64();
        long trackingID = msg.ReadInt64();

        public_condition = msg.ReadInt64();
        //Debug.Log("Condition Messge reieved: "+trackingID+", "+_condition[trackingID]);
    }
        private void HandleSafeSignal(NetworkInMessage msg)
        {
            msg.ReadInt64();
            long playerID = msg.ReadInt64();

            if (IDisMine(playerID))
            {
                Debug.Log("You are safe");
            }
        }
示例#5
0
    private void PlayerFound(NetworkInMessage msg)
    {
        var userId  = msg.ReadInt64();
        var enemyId = msg.ReadInt64();
        var enemy   = TryGetEnemy(enemyId);

        if (enemy == null)
        {
            return;
        }
        enemy.GetComponent <BaseMonster>().FindPlayer(userId);
    }
示例#6
0
    private void TakeDamageFromPlayer(NetworkInMessage msg)
    {
        var remoteUserId  = msg.ReadInt64();
        var damagedUserId = msg.ReadInt64();

        if (CustomMessages.Instance.localUserID != damagedUserId)
        {
            return;
        }
        var dmgAmt = msg.ReadInt32();

        UIManager.Instance.LogMessage("FRIENDLY FIRE BY USER " + remoteUserId);
        TakeDamage(dmgAmt);
    }
示例#7
0
        private void UpdatePresenterId(NetworkInMessage msg)
        {
            msg.ReadInt64();

            long presenterId = msg.ReadInt64();

            var headInfo = GetRemoteHeadInfo(presenterId);

            for (var i = 0; i < Panels.Length; i++)
            {
                var billboard = Panels[i].GetComponent <Billboard>();

                billboard.TargetTransform = headInfo == null ? Camera.main.transform : headInfo.HeadObject.transform;
            }
        }
示例#8
0
    private GameObject GetEnemy(NetworkInMessage msg)
    {
        GameObject enemy;
        long       userId  = msg.ReadInt64();
        long       enemyId = msg.ReadInt64();

        if (!enemiesPool.TryGetValue(enemyId, out enemy))
        {
            var demon = Instantiate(Cacodemon, CustomMessages.Instance.ReadVector3(msg), CustomMessages.Instance.ReadQuaternion(msg));
            demon.GetComponent <BaseMonster>().Id = enemyId;
            enemiesPool.Add(enemyId, demon);
        }

        return(enemy);
    }
示例#9
0
    private void ReceiveResetShareLine(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        ResetShareLine();
    }
        /*
         * /// <summary>
         * /// Gets the data structure for the remote users' Cube position.
         * /// </summary>
         * /// <param name="userId">User ID for which the remote Cube info should be obtained.</param>
         * /// <returns>RemoteCubeInfo for the specified user.</returns>
         * public RemoteCubeInfo GetRemoteCubeInfo(long userId)
         * {
         *  //AnchorDebugText.text += "\nGet remote cube info";
         *  RemoteCubeInfo CubeInfo;
         *
         *  // Get the Cube info if its already in the list, otherwise add it
         *  if (!remoteCubes.TryGetValue(userId, out CubeInfo))
         *  {
         *      CubeInfo = new RemoteCubeInfo();
         *      CubeInfo.UserID = userId;
         *      DebugLogText.text += "\n[Cube] GetRemoteCubeInfo > user ID: " + userId.ToString();
         *      CubeInfo.CubeObject = CreateRemoteCube();
         *
         *      remoteCubes.Add(userId, CubeInfo);
         *      DebugLogText.text += "\n[Cube] GetRemoteCubeInfo > add cube to remote cubes dictionary";
         *  }
         *
         *  return CubeInfo;
         * }
         */

        /// <summary>
        /// Called when a remote user sends a Cube transform.
        /// </summary>
        /// <param name="msg"></param>
        private void UpdateCubeTransform(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            transform.position = SharingPrefabObject.transform.TransformPoint(
                CustomMessagesMyHolographicAcademy.Instance.ReadVector3(msg));

            /*
             * transform.position = GameObject.Find("Sharing").transform.TransformPoint(
             *  CustomMessagesMyHolographicAcademy.Instance.ReadVector3(msg));
             */
            /*
             * transform.rotation = Quaternion.Inverse(GameObject.Find("Sharing").transform.rotation) *
             *  transform.rotation;
             */
            transform.rotation = Quaternion.Euler(SharingPrefabObject.transform.TransformDirection(
                                                      CustomMessagesMyHolographicAcademy.Instance.ReadQuaternion(msg).eulerAngles));

            /*
             * transform.rotation = Quaternion.Euler(GameObject.Find("Sharing").transform.TransformDirection(
             *  CustomMessagesMyHolographicAcademy.Instance.ReadQuaternion(msg).eulerAngles));
             */
            DebugLog2Text.text += "\nUpdate Cube > " +
                                  "\nPosition: " + transform.position.ToString();
        }
    // When a remote system has a transform for us, we'll get it here.

    private void OnRobotTransfrom(NetworkInMessage msg)
    {
        // We read the user ID but we don't use it here

        msg.ReadInt64();

        if (AnchorManager.Instance.IsAnchored())
        {
            AnchorManager.Instance.RemoveAnchor();

            transform.parent.localPosition = RobotMessages.Instance.ReadVector3(msg);
            transform.parent.localRotation = RobotMessages.Instance.ReadQuaternion(msg);

            Debug.Log(string.Format("Loaded position: {0}, {1}, {2}", transform.parent.localPosition.x, transform.parent.localPosition.y, transform.parent.localPosition.z));
            //if (audioSource != null)
            //    audioSource.Play();

            AnchorManager.Instance.ReplaceAnchor();

            inControl = false;
        }
        else
        {
            RobotMessages.Instance.ReadVector3(msg);
            RobotMessages.Instance.ReadQuaternion(msg);
        }
    }
    void OnStageTransfrom(NetworkInMessage msg)

    {
        msg.ReadInt64();
        transform.localPosition = CustomMessages.Instance.ReadVector3(msg) + adjustPosition;
        transform.localRotation = CustomMessages.Instance.ReadQuaternion(msg);
        transform.localScale    = CustomMessages.Instance.ReadVector3(msg);
        float renderGot = msg.ReadFloat();
        bool  statusgot = false;

        if (renderGot == 0.0f)
        {
            statusgot = false;
            if (render == true && statusgot == false)
            {
                DisableModel();
            }
        }
        else if (renderGot == 1.0f)
        {
            statusgot = true;
            if (render == false && statusgot == true)
            {
                EnableModel();
            }
        }
        else
        {
            Debug.Log("RENDER STATUS ERROR");
        }
    }
示例#13
0
    private void ReceiveDeleteShareVoice(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        DeleteShareTextList();
    }
    public void ProcessTransform(NetworkInMessage msg)
    {
        long userID = msg.ReadInt64();

        Position = CustomMessages.Instance.ReadVector3(msg);
        Rotation = CustomMessages.Instance.ReadQuaternion(msg);
    }
示例#15
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;
    }
示例#17
0
    void OnTexture2DReceived(NetworkInMessage msg)
    {
        // We read the user ID but we don't use it here.
        msg.ReadInt64();

        string instanceUid = msg.ReadString();

        if (!ActiveModelsDictionary.ContainsKey(new Guid(instanceUid)))
        {
            return;
        }

        int w = msg.ReadInt32();
        int h = msg.ReadInt32();

        uint len = (uint)msg.ReadInt32();

        byte[] data = new byte[len];

        msg.ReadArray(data, len);

        Texture2D texture = new Texture2D(w, h);

        texture.LoadImage(data);

        GameObject model = ActiveModelsDictionary[new Guid(instanceUid)];

        model.GetComponent <TexturePainter>().SetTexture(texture);
    }
示例#18
0
        /// <summary>
        ///     Updates the menu around the node
        /// </summary>
        /// <param name="message">
        ///     The network message
        /// </param>
        private void HandleMenuNetworkMessage(NetworkInMessage message)
        {
            message.ReadInt64();
            int clickNodeIndex = message.ReadInt32();

            togglesMenu(clickNodeIndex);
        }
示例#19
0
    private void ReceiveAllDelete(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        ReceiveAllDeleteSticky();
    }
示例#20
0
    void OnLogout(NetworkInMessage msg)
    {
        msg.ReadInt64();

        Debug.Log("This is Logout Message.");
        Debug.Log("srcIP : " + CustomMessages.Instance.ReadString(msg));
    }
示例#21
0
    /// <summary>
    /// リモートユーザから受信したメッセージのハンドラ
    /// リモートユーザキャラクターのTransformをUpdateする
    /// </summary>
    /// <param name="msg"></param>
    private void UpdateRemoteCharacterTransform(NetworkInMessage msg)
    {
        long userID = msg.ReadInt64();      // ユーザIDを取得
        // Transformを取得
        Vector3    remoteCharaPos   = EasySharingMessages.Instance.ReadVector3(msg);
        Quaternion remoteCharaRot   = EasySharingMessages.Instance.ReadQuaternion(msg);
        Vector3    remoteCharaScale = EasySharingMessages.Instance.ReadVector3(msg);
        // キャラクタータイプを取得
        int remoteCharTypeInt = msg.ReadInt32();
        // データ反映
        RemoteCharacterInfo remoteCharaInfo = GetRemoteCharacterInfo(userID);

        if (remoteCharaInfo.characterType == CharacterType.None)
        {
            remoteCharaInfo.characterType   = remoteCharTypeInt == 0 ? CharacterType.Unity_Chan : CharacterType.Nanica_Chan;
            remoteCharaInfo.characterObject = Instantiate(prefabs[remoteCharTypeInt]);
            remoteCharaInfo.characterObject.transform.parent = transform;
            remoteCharaInfo.characterObject.name             = "remote player : " + userID;
            // remotePlayerのTransformControllerはけす
            remoteCharaInfo.characterObject.GetComponent <TransformControllerActivater>().enabled = false;
        }
        // Transformの設定
        remoteCharaInfo.characterObject.transform.localPosition = remoteCharaPos;
        remoteCharaInfo.characterObject.transform.localRotation = remoteCharaRot;
        remoteCharaInfo.characterObject.transform.localScale    = remoteCharaScale;
    }
        /// <summary>
        /// Called when a remote user sends a Magnet transform.
        /// </summary>
        /// <param name="msg"></param>
        private void UpdateMagnetTransform(NetworkInMessage msg)
        {
            if (!transform.hasChanged && !hasUpdatedbyRemote)
            {
                hasUpdatedbyRemote = true;

                // Parse the message
                long userID = msg.ReadInt64();

                transform.position = SharingPrefabObject.transform.TransformPoint(
                    CustomMessagesMyHolographicAcademy.Instance.ReadVector3(msg));

                /*
                 * transform.position = GameObject.Find("Sharing").transform.TransformPoint(
                 *  CustomMessagesMyHolographicAcademy.Instance.ReadVector3(msg));
                 */
                /*
                 * transform.rotation = Quaternion.Inverse(GameObject.Find("Sharing").transform.rotation) *
                 *  transform.rotation;
                 */
                transform.rotation = Quaternion.Euler(SharingPrefabObject.transform.TransformDirection(
                                                          CustomMessagesMyHolographicAcademy.Instance.ReadQuaternion(msg).eulerAngles));

                /*
                 * transform.rotation = Quaternion.Euler(GameObject.Find("Sharing").transform.TransformDirection(
                 *  CustomMessagesMyHolographicAcademy.Instance.ReadQuaternion(msg).eulerAngles));
                 * DebugLog2Text.text += "\nUpdate Magnet > " +
                 *  "\nPosition: " + transform.position.ToString();
                 */
                DebugLog2Text.text += "\nNetworkInMessage msg > " +
                                      "\nuserID: " + userID.ToString();
            }
        }
示例#23
0
    void OnMessageReceived(NetworkInMessage msg)
    {
        msg.ReadInt64();
        string i = msg.ReadString();

        //  ReceivingString.text = i;
        Debug.Log("Receiving at " + i.ToString());
    }
    //handles command that is coming from the server
    void handleNetworkMessage(NetworkInMessage msg)
    {
        Debug.Log("handle command");
        msg.ReadInt64();                   // important! the id of the message.
        string command = msg.ReadString(); //the messages from the server;

        Debug.Log(command);
    }
示例#25
0
    // Parameter-msg: a Network message correspoding to a OrbPickedUp type message
    // Deletes the Orb picked up the other player
    public void RemoveRemoteOrb(NetworkInMessage msg)
    {
        // userID not used for now
        long userID      = msg.ReadInt64();
        int  remoteIndex = msg.ReadInt32();

        RemoveOrb(remoteIndex);
    }
 /// <summary>
 /// Set our difficulty based on the settings of another player
 /// </summary>
 /// <param name="msg">The difficulty value sent from another player in the form of an Int</param>
 void setDifficulty(NetworkInMessage msg)
 {
     // We read the user ID but we don't use it here.
     msg.ReadInt64();
     difficulty = CustomMessages.Instance.ReadInt(msg);
     setupDifficulty();
     isDiffSetup = true;
 }
示例#27
0
    void OnReceiving(NetworkInMessage msg)
    {
        msg.ReadInt64();

        Debug.Log("This is Receiving Message.");
        Debug.Log("srcIP : " + CustomMessages.Instance.ReadString(msg));
        Debug.Log("desIP : " + CustomMessages.Instance.ReadString(msg));
    }
    // 读取Cube的位置
    public static Vector3 ReadCubePosition(NetworkInMessage msg)
    {
        // 读取用户编号,但不使用
        msg.ReadInt64();

        // 依次读取XYZ,这个和发送Cube时,写入参数顺序是一致的
        return(new Vector3(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()));
    }
示例#29
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
        }
    //handles command that is coming from the server
    void handleNetworkMessage(NetworkInMessage msg)
    {
        Debug.Log("handle command");
        msg.ReadInt64();                        // important! the id of the message.
        string message = msg.ReadString();
        string command = message.Split('+')[0]; //the messages from the server;

        Debug.Log("Command received - " + command);
        GameObject srf;

        switch (command)
        {
        case "play":
            play = true;
            CustomMessages.Instance.SendNetworkMessage("startedPlaying");
            break;

        case "pause":
            play = false;
            CustomMessages.Instance.SendNetworkMessage("stoppedPlaying");
            break;

        case "nosrfstatic":
        case "nosrfdynamic":
            srf = GameObject.Find("Static base");
            if (srf != null)
            {
                foreach (Renderer r in srf.GetComponentsInChildren <Renderer>())
                {
                    r.enabled = false;
                }
                CustomMessages.Instance.SendNetworkMessage("srfDisabled");
            }
            break;

        case "srfstatic":
        case "srfdynamic":
            srf = GameObject.Find("Static base");
            if (srf != null)
            {
                foreach (Renderer r in srf.GetComponentsInChildren <Renderer>())
                {
                    r.enabled = true;
                }
                CustomMessages.Instance.SendNetworkMessage("srfEnabled");
            }
            break;

        case "totalball":
            totalBall = Convert.ToInt32(message.Split('+')[1]);
            CustomMessages.Instance.SendNetworkMessage("totalBallUpdated");
            break;

        default:
            break;
        }
    }