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)); }
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); }
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); }
/// <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); }
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 }
/// <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> /// 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; }
// 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); }
private void ReceiveDelete(NetworkInMessage msg) { // Parse the message long userID = msg.ReadInt64(); int ind = msg.ReadInt32(); ReceiveDeleteSticky(ind); }
public static int ReadCount(NetworkInMessage msg) { // read userID, not used msg.ReadInt64(); int count = msg.ReadInt32(); return(count); }
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); }
public static byte[] ReadIRImageByString(NetworkInMessage msg) { byte[] tempImage; msg.ReadInt64(); msg.ReadInt32(); tempImage = System.Convert.FromBase64String(msg.ReadString()); return(tempImage); }
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; } } } } }
// 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); }
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(); } }
/* * 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); }
/// <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)); }
/// <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); }
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); }
/// <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); }
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); }
//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); }
/// <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); }
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); } }
/* * 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); }