Ejemplo n.º 1
0
    /// <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    = PlayerPrefab.GetComponent <PlayerAvatarParameters>(); //WSLNOW 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 = PlayerPrefab.GetComponent <PlayerAvatarParameters>();//WLSNOW 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();
    }
        /// <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();
            }
        }
Ejemplo n.º 3
0
    /// <summary>
    /// 收到 BeginGame 指令
    /// </summary>
    /// <param name="msg"></param>
    private void BeginGameCommandReceived(UserData userData, NetworkInMessage msg)
    {
        var participantsString = msg.ReadString();

        Participants = JsonUtility.FromJson <Dictionary <string, int> >(participantsString);
        OnParticipantsUpdated();
    }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
0
    private void ReceiveDeleteShareVoice(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        DeleteShareTextList();
    }
Ejemplo n.º 6
0
    void OnLogout(NetworkInMessage msg)
    {
        msg.ReadInt64();

        Debug.Log("This is Logout Message.");
        Debug.Log("srcIP : " + CustomMessages.Instance.ReadString(msg));
    }
        /*
         * /// <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();
        }
Ejemplo n.º 8
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;
    }
Ejemplo n.º 9
0
 private void OnCubePositionReceived(NetworkInMessage msg)
 {
     if (!isMoving)
     {
         transform.position = CustomMessages240.ReadCubePostion(msg);
     }
 }
Ejemplo n.º 10
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(PlayerPrefab); // WSLNOW 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;
    }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
    /// <summary>
    /// When a remote system has a transform for us, we'll get it here.
    /// </summary>
    void OnResetStage(NetworkInMessage msg)
    {
        GotTransform = false;

        GetComponent <EnergyHubBase>().ResetAnimation();
        AppStateManager.Instance.ResetStage();
    }
 public override void OnMessageReceived(NetworkConnection connection, NetworkInMessage message)
 {
     if (this.MessageReceivedCallback != null)
     {
         this.MessageReceivedCallback(connection, message);
     }
 }
    public void ProcessTransform(NetworkInMessage msg)
    {
        long userID = msg.ReadInt64();

        Position = CustomMessages.Instance.ReadVector3(msg);
        Rotation = CustomMessages.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");
        }
    }
Ejemplo n.º 16
0
    // 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);
        }
    }
 public override void OnMessageReceived(NetworkConnection connection, NetworkInMessage message)
 {
     if (this.MessageReceivedCallback != null)
     {
         this.MessageReceivedCallback(connection, message);
     }
 }
Ejemplo n.º 18
0
    private void ReceiveResetShareLine(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        ResetShareLine();
    }
Ejemplo n.º 19
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);
    }
Ejemplo n.º 20
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));
    }
 private void NewAnchorPlacementMessage(NetworkInMessage msg)
 {
     // TODO: Load New Anchor
     remoteAnchorName = CustomMessages2.Instance.ReadString(msg);
     DebugDisplay(string.Format(">>> NEW ANCHOR MESSAGE: {0}", remoteAnchorName));
     ClearPlacementObjectAnchors();
     CurrentState = AnchorManagementState.GetRemoteAnchor;
 }
Ejemplo n.º 22
0
    void OnMessageReceived(NetworkInMessage msg)
    {
        msg.ReadInt64();
        string i = msg.ReadString();

        //  ReceivingString.text = i;
        Debug.Log("Receiving at " + i.ToString());
    }
Ejemplo n.º 23
0
 // Update is called once per frame
 void UpdateDepthData(NetworkInMessage msg)
 {
     DepthData = new ushort[(int)Message.Instance.ReadSize(msg)];      // CHECK !!!  -> This should be called once.
     for (int i = 0; i < DepthData.Length; i++)
     {
         DepthData[i] += (ushort)Message.Instance.ReadDepth(msg);
     }
 }
 /// <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;
 }
Ejemplo n.º 25
0
    // 读取Cube的位置
    public static Vector3 ReadCubePosition(NetworkInMessage msg)
    {
        // 读取用户编号,但不使用
        msg.ReadInt64();

        // 依次读取XYZ,这个和发送Cube时,写入参数顺序是一致的
        return(new Vector3(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()));
    }
Ejemplo n.º 26
0
    /// <summary>
    /// When a remote system has a transform for us, we'll get it here.
    /// </summary>
    void OnResetStage(NetworkInMessage msg)
    {
        GotTransform = false;
        //mriManager.UpdateClippingForRepositioning(GotTransform);
        HideUI();

        AppStateManager.Instance.ResetStage();
    }
    //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);
    }
Ejemplo n.º 28
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);
                }
            }
        }
    //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;
        }
    }
Ejemplo n.º 30
0
    public static int ReadCount(NetworkInMessage msg)
    {
        // read userID, not used
        msg.ReadInt64();

        int count = msg.ReadInt32();

        return(count);
    }
Ejemplo n.º 31
0
    public void MessageReceived(NetworkInMessage msg)
    {
        // This reads the user ID which we do not need
        msg.ReadInt64();

        // The message contains a byte (1 or 0) to pass the boolean value through
        isRotating = msg.ReadByte() == 1;
        ToggleRotate();
    }
 public override void OnMessageReceived(NetworkConnection connection, NetworkInMessage message)
 {
     Profile.BeginRange("OnMessageReceived");
     if (this.MessageReceivedCallback != null)
     {
         this.MessageReceivedCallback(connection, message);
     }
     Profile.EndRange();
 }
 public virtual void OnMessageReceived(NetworkConnection connection, NetworkInMessage message) {
   if (SwigDerivedClassHasMethod("OnMessageReceived", swigMethodTypes3)) SharingClientPINVOKE.NetworkConnectionListener_OnMessageReceivedSwigExplicitNetworkConnectionListener(swigCPtr, NetworkConnection.getCPtr(connection), NetworkInMessage.getCPtr(message)); else SharingClientPINVOKE.NetworkConnectionListener_OnMessageReceived(swigCPtr, NetworkConnection.getCPtr(connection), NetworkInMessage.getCPtr(message));
   if (SharingClientPINVOKE.SWIGPendingException.Pending) throw SharingClientPINVOKE.SWIGPendingException.Retrieve();
 }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(NetworkInMessage obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }