public InstantiateObjectInfo(GameObject gameObject, Vector3 position, Quaternion rotation, int id, OnlinePlayerId playerOwner) { GameObject = gameObject; Position = position; Rotation = rotation; Id = id; PlayerOwner = playerOwner; }
public InstantiateObjectInfo() { GameObject = null; Position = Vector3.zero; Rotation = Quaternion.identity; Id = -1; PlayerOwner = OnlinePlayerId.None; }
public InstantiateObjectInfo(byte[] bytes) { var ms = new MemoryStream(bytes); var br = new BinaryReader(ms); GameObject = OnlinePrefabs.GetPrefabBy(br.ReadString()); Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); Rotation = new Quaternion(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); Id = br.ReadInt32(); PlayerOwner = (OnlinePlayerId)br.ReadInt32(); br.Close(); ms.Close(); }
public static void OnlineInstantiate(this UnityEngine.Object obj, GameObject gameObject, Vector3 position, Quaternion rotation, OnlinePlayerId playerOwner) { InstantiateObjectInfo info = null; if (OnlineManager.IsHost()) { info = new InstantiateObjectInfo(gameObject, position, rotation, OnlineObjectManager.GenerateId(), playerOwner); } else { info = new InstantiateObjectInfo(gameObject, position, rotation, -1, playerOwner); } var bytes = BitConverter.GetBytes((int)MsgProtocol.InstantiateObject).Concat(info.Serialize()).ToArray(); OnlineManager.SendMsg(bytes); if (OnlineManager.IsHost()) { OnlineManager.Instantiate(info); } }
public void Set(int objectId, OnlinePlayerId playerOwner) { ObjectId = objectId; PlayerOwner = playerOwner; }