Example #1
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);
    }
    public DateTime ReadDateTime(NetworkInMessage msg)
    {
        int hour = msg.ReadInt32();
        int min  = msg.ReadInt32();
        int sec  = msg.ReadInt32();
        int msec = msg.ReadInt32();

        Debug.Log(hour + ":" + min + ":" + sec + "." + msec);
        return(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hour % 24, min % 60, sec % 60, msec % 1000));
    }
Example #3
0
    void OnHandTransform(NetworkInMessage msg)
    {
        //read user id etc of the front of the message
        msg.ReadInt32();
        msg.ReadInt32();

        Vector3    position = CustomMessages.Instance.ReadVector3(msg);
        Quaternion rotation = CustomMessages.Instance.ReadQuaternion(msg);

        this.AdjustTransform(otherPlayerHand, position, rotation);
    }
Example #4
0
        private void SharedWallPos(NetworkInMessage msg)
        {
            // Parse the message
            long userID = msg.ReadInt64();

            Vector3    MovePos = CustomMessages.Instance.ReadVector3(msg);
            Quaternion rt      = CustomMessages.Instance.ReadQuaternion(msg);
            int        id      = msg.ReadInt32();
            int        isD     = msg.ReadInt32();

            WallPosition(MovePos, rt, id, isD);
            //MakeSticky(message, StickyPos, colorIndex);
        }
Example #5
0
        /// <summary>
        /// Handles the story control network messages
        /// </summary>
        /// <param name="message">
        /// The network message.
        /// </param>
        public void HandleStoryControlNetworkMessage(NetworkInMessage message)
        {
            message.ReadInt64();
            var action = (StoryAction)message.ReadByte();
            int l      = message.ReadInt32();
            var args   = new int[l];

            for (var i = 0; i < l; ++i)
            {
                args[i] = message.ReadInt32();
            }

            this.triggerStory(action, args);
        }
Example #6
0
        void OnSpatialMapping(NetworkInMessage msg)
        {
#if UNITY_EDITOR
            if (SpatialMappingManager.Instance == null)
            {
                return;
            }

            RemoteSpatialMappingSource rsms = SpatialMappingManager.Instance.GetComponent <RemoteSpatialMappingSource>();

            if (rsms == null)
            {
                return;
            }

            msg.ReadInt64();

            List <Vector3> vertices  = new List <Vector3>();
            List <Vector3> normals   = new List <Vector3>();
            List <int>     triangles = new List <int>();

            int vertexCount   = msg.ReadInt32();
            int normalCount   = msg.ReadInt32();
            int triangleCount = msg.ReadInt32();

            for (int i = 0; i < vertexCount; i++)
            {
                Vector3 vertex = SV_CustomMessages.Instance.ReadVector3(msg);
                vertices.Add(vertex);
            }

            for (int i = 0; i < normalCount; i++)
            {
                Vector3 normal = SV_CustomMessages.Instance.ReadVector3(msg);
                normals.Add(normal);
            }

            for (int i = 0; i < triangleCount; i++)
            {
                int index = msg.ReadInt32();
                triangles.Add(index);
            }

            SpatialMappingManager.Instance.transform.parent        = transform;
            SpatialMappingManager.Instance.transform.localPosition = Vector3.zero;
            SpatialMappingManager.Instance.transform.localRotation = Quaternion.identity;

            rsms.AddSurface(vertices, normals, triangles);
#endif
        }
Example #7
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;
    }
Example #8
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);
        }
    /// <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;
    }
Example #10
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);
    }
Example #11
0
    private void ReceiveDelete(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        int ind = msg.ReadInt32();

        ReceiveDeleteSticky(ind);
    }
Example #12
0
    public static int ReadCount(NetworkInMessage msg)
    {
        // read userID, not used
        msg.ReadInt64();

        int count = msg.ReadInt32();

        return(count);
    }
Example #13
0
    private UserData ReadUserData(long userId, NetworkInMessage msg)
    {
        var userData = new UserData();

        userData.Id    = userId;
        userData.Name  = msg.ReadString();
        userData.Score = msg.ReadInt32();

        return(userData);
    }
    public String ReadString(NetworkInMessage msg)
    {
        int length = msg.ReadInt32();

        byte[] result = new byte[1354753];

        msg.ReadArray(result, (uint)length);

        return(System.Text.Encoding.Default.GetString(result));
    }
    public byte[] ReadByteArray(NetworkInMessage msg)
    {
        int length = msg.ReadInt32();

        byte[] result = new byte[1354753];

        msg.ReadArray(result, (uint)length);

        return(result);
    }
Example #16
0
    public static byte[] ReadIRImageByString(NetworkInMessage msg)
    {
        byte[] tempImage;
        msg.ReadInt64();
        msg.ReadInt32();

        tempImage = System.Convert.FromBase64String(msg.ReadString());

        return(tempImage);
    }
Example #17
0
        private void UpdateAnimationHash(NetworkInMessage msg)
        {
            msg.ReadInt64();
            int   animationHash  = msg.ReadInt32();
            int   animationType  = msg.ReadInt32();
            float animationValue = msg.ReadFloat();

            if (NetworkAnimator != null)
            {
                if (animatorHashes == null)
                {
                    animatorHashes = NetworkAnimator.parameters;
                }

                for (var i = 0; i < animatorHashes.Length; i++)
                {
                    if (animatorHashes[i].nameHash == animationHash)
                    {
                        switch (animationType)
                        {
                        case (int)NetworkMessages.AnimationTypes.Boolean:
                            NetworkAnimator.SetBool(animationHash, animationValue >= 0.5);
                            break;

                        case (int)NetworkMessages.AnimationTypes.Integer:
                            NetworkAnimator.SetInteger(animationHash, (int)animationValue);
                            break;

                        case (int)NetworkMessages.AnimationTypes.Float:
                            NetworkAnimator.SetFloat(animationHash, animationValue);
                            break;

                        case (int)NetworkMessages.AnimationTypes.Trigger:
                            NetworkAnimator.SetTrigger(animationHash);
                            break;

                        default: break;
                        }
                    }
                }
            }
        }
Example #18
0
    // Parameter-msg: a Network message corresponding to a SendOrb type message
    // Creates the Orb specified in the message
    public void ProcessRemoteOrb(NetworkInMessage msg)
    {
        // userID not used for now
        long    userID            = msg.ReadInt64();
        Vector3 remoteOrbPosition = CustomMessages.Instance.ReadVector3(msg);
        int     remoteIndex       = msg.ReadInt32();

        Transform anchor = ImportExportAnchorManager.Instance.gameObject.transform;

        GenerateOrb(anchor.TransformPoint(remoteOrbPosition), remoteIndex);
    }
Example #19
0
    void OnHandStatus(NetworkInMessage msg)
    {
        //read user id etc of the front of the message
        msg.ReadInt32();
        msg.ReadInt32();

        int status = msg.ReadInt32();

        //Debug.Log("### ### ### ### Hand Status Received: " + status);
        if (status == 1)
        {
            this.OtherHandDetected = true;
            this.DisPlayOtherHand();
        }
        else if (status == 0)
        {
            this.OtherHandDetected = false;
            this.HideOtherHand();
        }
    }
Example #20
0
    /*
     * Used to process a spell cast from another player
     */
    public void ProcessRemoteProjectile(NetworkInMessage msg)
    {
        long userID = msg.ReadInt64();
        Vector3 remoteProjectilePosition = CustomMessages.Instance.ReadVector3(msg);

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

        int spellIndex = msg.ReadInt32();
        Transform anchor = ImportExportAnchorManager.Instance.gameObject.transform;
        ShootProjectile(anchor.TransformPoint(remoteProjectilePosition), anchor.TransformDirection(remoteProjectileDirection), userID, spellIndex);
    }
Example #21
0
    /// <summary>
    /// <summary>Read Int from message. Don't forget read user id first (long)</summary>
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public SharingData ReadInt(NetworkInMessage msg, bool onlyValue = false)
    {
        long   userId = 0;
        string tag    = "";

        // firstly we read user_id and message_tag if onlyValue == false
        ReadIdAndTag(msg, onlyValue, out userId, out tag);

        var value = msg.ReadInt32(); // lastly we read value

        return(new SharingData(userId, tag, value));
    }
Example #22
0
    /// <summary>
    /// Called when a remote user sends a head transform.
    /// </summary>
    /// <param name="msg"></param>
    private void SharedSticky(NetworkInMessage msg)
    {
        // Parse the message
        long userID = msg.ReadInt64();

        Vector3 StickyPos  = CustomMessages.Instance.ReadVector3(msg);
        string  message    = msg.ReadString();
        int     colorIndex = msg.ReadInt32();

        Debug.Log("colorIndex=" + colorIndex);
        MakeSticky(message, StickyPos, colorIndex);
    }
Example #23
0
    public static byte[] ReadIRImageByArray(NetworkInMessage msg)
    {
        byte[] tempImage;
        int    length = 0;

        msg.ReadInt64();
        length    = msg.ReadInt32();
        tempImage = new byte[length];

        msg.ReadArray(tempImage, Convert.ToUInt32(length));

        return(tempImage);
    }
Example #24
0
    /// <summary>
    /// 读取 msg 里的bytes
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public static byte[] ReadIRImage(NetworkInMessage msg)
    {
        byte[] tempImage;
        int    length = 0;

        msg.ReadInt64();
        length    = msg.ReadInt32();
        tempImage = new byte[length];
        for (int i = 0; i < length; i++)
        {
            tempImage[i] = msg.ReadByte();
        }
        return(tempImage);
    }
Example #25
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);
    }
Example #26
0
    //public void ResetShareLines()
    //{
    //    for (int i = 0; i < Data.shareLineList.Count; i++)
    //    {
    //        Destroy(Data.shareLineList[i]);
    //        Data.shareLineList[i] = null;
    //    }
    //    Data.shareLineList.Clear();
    //}

    private void Shared3dDraw(NetworkInMessage msg)
    {
        //Debug.Log("Shared3dDraw");

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

        Vector3 Pos      = CustomMessages.Instance.ReadVector3(msg);
        int     DragFlag = msg.ReadInt32();

        //uint id = msg.ReadUint32();
        //Debug.Log("id =", + id);
        Make3dDraw(Pos, DragFlag);
    }
Example #27
0
        /// <summary>
        ///     Handles the network message from a button click
        /// </summary>
        /// <param name="message">
        ///     The network message.
        /// </param>
        public void HandleMenuButtonClickNetworkMessage(NetworkInMessage message)
        {
            message.ReadInt64();
            int l = message.ReadInt32();
            var methodNameChars = new char[l];

            for (var i = 0; i < l; ++i)
            {
                methodNameChars[i] = Convert.ToChar(message.ReadByte());
            }

            var methodName = new string(methodNameChars);

            this.Invoke(methodName, 0);
        }
Example #28
0
    public void RemoteModelSpawned(NetworkInMessage msg)
    {
        Debug.Log("Received remote model spawn");
        long userId = msg.ReadInt64();

        if (userId != SharingStage.Instance.Manager.GetLocalUser().GetID())
        {
            string           modelName     = msg.ReadString();
            int              localBoxId    = msg.ReadInt32();
            BoundingBoxId    boundingBoxId = new BoundingBoxId(userId, localBoxId);
            Vector3          spawnPosition = CustomMessages.Instance.ReadVector3(msg);
            ModelLoadManager manager       = new ModelLoadManager(spawnPosition, worldAnchor, boundingBoxId, true);
            manager.Load(modelName);
        }
    }
Example #29
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;
        }
    }
    /// <summary>
    /// We call this when a remote player tries to manipulate our local maze
    /// </summary>
    /// <param name="msg">The msg that tells us which way to rotate the maze</param>
    void OnMazeTransform(NetworkInMessage msg)
    {
        // We read the user ID but we don't use it here.
        long temp = msg.ReadInt64();

        //get our local user id and store it
        //we do this here since we are assured the IDs have been set
        long localUserId = CustomMessages.Instance.localUserID;

        if (temp != localUserId)
        {
            pScript.Rotate(msg.ReadInt32());
        }


        //rDirection = CustomMessages.Instance.ReadInt(msg);
        //Rotate(rDirection);
    }