diff --git a/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration.meta b/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration.meta new file mode 100644 index 0000000..da5ee29 --- /dev/null +++ b/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21c2212b420fd48a1b3552af8d219f80 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestVelGameServer/Assets/VelGameServer/VelAudioMixer.mixer b/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelAudioMixer.mixer similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/VelAudioMixer.mixer rename to TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelAudioMixer.mixer diff --git a/TestVelGameServer/Assets/VelGameServer/VelAudioMixer.mixer.meta b/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelAudioMixer.mixer.meta similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/VelAudioMixer.mixer.meta rename to TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelAudioMixer.mixer.meta diff --git a/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelCommsNetwork.cs b/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelCommsNetwork.cs new file mode 100644 index 0000000..52613c8 --- /dev/null +++ b/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelCommsNetwork.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Dissonance; +using Dissonance.Extensions; +using Dissonance.Networking; +using UnityEngine; + + +public class VelCommsNetwork : MonoBehaviour, ICommsNetwork +{ + public ConnectionStatus Status + { + get + { + return manager.connected?ConnectionStatus.Connected:ConnectionStatus.Disconnected; + } + } + + public NetworkMode Mode + { + get + { + return NetworkMode.Client; + } + } + + public event Action ModeChanged; + public event Action PlayerJoined; + public event Action PlayerLeft; + public event Action VoicePacketReceived; + public event Action TextPacketReceived; + public event Action PlayerStartedSpeaking; + public event Action PlayerStoppedSpeaking; + public event Action PlayerEnteredRoom; + public event Action PlayerExitedRoom; + + ConnectionStatus _status = ConnectionStatus.Disconnected; + CodecSettings initSettings; + public string dissonanceId; + public DissonanceComms comms; + public NetworkManager manager; + + public Action> voiceQueued = delegate { }; //listen to this if you want to send voice + + public void Initialize(string playerName, Rooms rooms, PlayerChannels playerChannels, RoomChannels roomChannels, CodecSettings codecSettings) + { + dissonanceId = playerName; + initSettings = codecSettings; + comms.ResetMicrophoneCapture(); + } + + public void voiceReceived(string sender,byte[] data) + { + uint sequenceNumber = BitConverter.ToUInt32(data, 0); + VoicePacket vp = new VoicePacket(sender, ChannelPriority.Default, 1, true, new ArraySegment(data,4,data.Length-4), sequenceNumber); + VoicePacketReceived(vp); + } + + public void SendText(string data, ChannelType recipientType, string recipientId) + { + Debug.Log("sending text"); + } + + public void SendVoice(ArraySegment data) + { + voiceQueued(data); + } + + // Start is called before the first frame update + void Start() + { + _status = ConnectionStatus.Connected; + comms = GetComponent(); + + } + + public void playerJoined(string id) + { + Debug.Log("dissonance player joined"); + PlayerJoined(id, initSettings); + RoomEvent re = new RoomEvent(); + re.Joined = true; + re.Room = "Global"; + re.PlayerName = id; + PlayerEnteredRoom(re); + } + + public void playerLeft(string id) + { + RoomEvent re = new RoomEvent(); + re.Joined = false; + re.Room = "Global"; + re.PlayerName = id; + PlayerExitedRoom(re); + PlayerLeft(id); + } + + public void playerStartedSpeaking(string id) + { + PlayerStartedSpeaking(id); + } + public void playerStoppedSpeaking(string id) + { + PlayerStoppedSpeaking(id); + } + +} + diff --git a/TestVelGameServer/Assets/VelGameServer/VelCommsNetwork.cs.meta b/TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelCommsNetwork.cs.meta similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/VelCommsNetwork.cs.meta rename to TestVelGameServer/Assets/VelGameServer/DissonanceIntegration/VelCommsNetwork.cs.meta diff --git a/TestVelGameServer/Assets/VelGameServer/Example.meta b/TestVelGameServer/Assets/VelGameServer/Example.meta new file mode 100644 index 0000000..5de344a --- /dev/null +++ b/TestVelGameServer/Assets/VelGameServer/Example.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2fc687ece57d64c7082cd32261ac438b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestVelGameServer/Assets/VelGameServer/NetworkGUI.cs b/TestVelGameServer/Assets/VelGameServer/Example/NetworkGUI.cs similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/NetworkGUI.cs rename to TestVelGameServer/Assets/VelGameServer/Example/NetworkGUI.cs diff --git a/TestVelGameServer/Assets/VelGameServer/NetworkGUI.cs.meta b/TestVelGameServer/Assets/VelGameServer/Example/NetworkGUI.cs.meta similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/NetworkGUI.cs.meta rename to TestVelGameServer/Assets/VelGameServer/Example/NetworkGUI.cs.meta diff --git a/TestVelGameServer/Assets/VelGameServer/Example/PlayerController.cs b/TestVelGameServer/Assets/VelGameServer/Example/PlayerController.cs new file mode 100644 index 0000000..9cc71c5 --- /dev/null +++ b/TestVelGameServer/Assets/VelGameServer/Example/PlayerController.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Dissonance; +using System.Text; +public class PlayerController : NetworkObject, Dissonance.IDissonancePlayer +{ + VelCommsNetwork comms; + bool isSpeaking = false; + uint lastAudioId = 0; + public string dissonanceID=""; + //required by dissonance for spatial audio + public string PlayerId => dissonanceID; + public Vector3 Position => transform.position; + public Quaternion Rotation => transform.rotation; + public NetworkPlayerType Type => this.owner.isLocal ? NetworkPlayerType.Local : NetworkPlayerType.Remote; + public bool IsTracking => true; + + public Vector3 targetPosition; + public Quaternion targetRotation; + + + public byte[] getSyncMessage() + { + float[] data = new float[7]; + for (int i = 0; i < 3; i++) + { + data[i] = transform.position[i]; + data[i + 3] = transform.rotation[i]; + } + data[6] = transform.rotation[3]; + + byte[] toReturn = new byte[sizeof(float) * data.Length]; + Buffer.BlockCopy(data, 0, toReturn, 0, toReturn.Length); + return toReturn; + } + + public override void handleMessage(string identifier, byte[] message) + { + switch (identifier) + { + case "s": //sync message + float[] data = new float[7]; + Buffer.BlockCopy(message, 0, data, 0, message.Length); + for (int i = 0; i < 3; i++) + { + targetPosition[i] = data[i]; + targetRotation[i] = data[i + 3]; + } + targetRotation[3] = data[6]; + break; + case "a": //audio data + { + if (isSpeaking) + { + comms.voiceReceived(dissonanceID, message); + } + break; + } + case "d": //dissonance id (player joined) + { + if (dissonanceID == "") //I don't have this yet + { + dissonanceID = Encoding.UTF8.GetString(message); + //tell the comms network that this player joined the channel + comms.playerJoined(dissonanceID); //tell dissonance + comms.comms.TrackPlayerPosition(this); //tell dissonance to track the remote player + } + break; + } + case "x": //speaking state + { + if (message[0]==0) + { + comms.playerStoppedSpeaking(dissonanceID); + isSpeaking = false; + } + else + { + Debug.Log("here"); + comms.playerStartedSpeaking(dissonanceID); + isSpeaking = true; + } + break; + } + } + } + + // Start is called before the first frame update + void Start() + { + + //handle dissonance stuff + comms = GameObject.FindObjectOfType(); + if(comms != null) + { + if (owner.isLocal) + { + setDissonanceID(comms.dissonanceId); + comms.voiceQueued += sendVoiceData; + + //we also need to know when other players join, so we can send the dissonance ID again + + owner.manager.onPlayerJoined += (player) => + { + byte[] b = Encoding.UTF8.GetBytes(dissonanceID); + owner.sendMessage(this, "d", b); + }; + } + } + if (owner.isLocal) + { + StartCoroutine(syncBehavior()); + } + } + + void sendVoiceData(ArraySegment data) + { + //need to send it + if(owner != null && owner.isLocal) + { + byte[] toSend = new byte[data.Count+4]; + byte[] lastAudioIdBytes = BitConverter.GetBytes(lastAudioId++); + Buffer.BlockCopy(lastAudioIdBytes, 0, toSend, 0, 4); + Buffer.BlockCopy(data.Array, data.Offset, toSend, 4, data.Count); + owner.sendMessage(this, "a", toSend); + } + } + + public void setDissonanceID(string id) //this sort of all initializes dissonance + { + dissonanceID = id; + byte[] b = Encoding.UTF8.GetBytes(dissonanceID); + owner.sendMessage(this, "d", b); + comms.comms.TrackPlayerPosition(this); + } + + void voiceInitialized(string id) + { + dissonanceID = id; + } + + void OnDestroy() + { + comms.playerLeft(dissonanceID); + } + + + IEnumerator syncBehavior() + { + while (true) + { + owner.sendMessage(this, "s", getSyncMessage()); + yield return new WaitForSeconds(.1f); + } + } + // Update is called once per frame + void Update() + { + + + + + if (owner != null && !owner.isLocal) + { + transform.position = Vector3.Lerp(transform.position, targetPosition, .1f); + transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, .1f); + } + else if(owner != null && owner.isLocal) + { + + //handle dissonance comms + + //if we're not speaking, and the comms say we are, send a speaking event, which will be received on other network players and sent to their comms accordingly + if (comms.comms.FindPlayer(dissonanceID).IsSpeaking != isSpeaking) //unfortunately, there does not seem to be an event for this + { + isSpeaking = !isSpeaking; + byte[] toSend = new byte[1]; + toSend[0] = isSpeaking ? (byte)1 : (byte)0; + owner.sendMessage(this, "x", toSend); + + if (!isSpeaking) + { + lastAudioId = 0; + } + + } + + + + Vector3 movement = new Vector3(); + movement.x += Input.GetAxis("Horizontal"); + movement.y += Input.GetAxis("Vertical"); + movement.z = 0; + transform.Translate(movement * Time.deltaTime); + + if (Input.GetKeyDown(KeyCode.Space)) + { + owner.networkInstantiate("TestNetworkedGameObject"); + } + + if (Input.GetKeyDown(KeyCode.BackQuote)) + { + foreach(KeyValuePair kvp in owner.manager.objects) + { + owner.takeOwnership(kvp.Key); + } + } + if (Input.GetKeyDown(KeyCode.Backspace)) + { + foreach (KeyValuePair kvp in owner.manager.objects) + { + owner.networkDestroy(kvp.Key); + } + } + } + } +} diff --git a/TestVelGameServer/Assets/VelGameServer/PlayerController.cs.meta b/TestVelGameServer/Assets/VelGameServer/Example/PlayerController.cs.meta similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/PlayerController.cs.meta rename to TestVelGameServer/Assets/VelGameServer/Example/PlayerController.cs.meta diff --git a/TestVelGameServer/Assets/VelGameServer/PlayerPrefab.prefab b/TestVelGameServer/Assets/VelGameServer/Example/PlayerPrefab.prefab similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/PlayerPrefab.prefab rename to TestVelGameServer/Assets/VelGameServer/Example/PlayerPrefab.prefab diff --git a/TestVelGameServer/Assets/VelGameServer/PlayerPrefab.prefab.meta b/TestVelGameServer/Assets/VelGameServer/Example/PlayerPrefab.prefab.meta similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/PlayerPrefab.prefab.meta rename to TestVelGameServer/Assets/VelGameServer/Example/PlayerPrefab.prefab.meta diff --git a/TestVelGameServer/Assets/VelGameServer/TestNetworkedGameObject.prefab b/TestVelGameServer/Assets/VelGameServer/Example/TestNetworkedGameObject.prefab similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/TestNetworkedGameObject.prefab rename to TestVelGameServer/Assets/VelGameServer/Example/TestNetworkedGameObject.prefab diff --git a/TestVelGameServer/Assets/VelGameServer/TestNetworkedGameObject.prefab.meta b/TestVelGameServer/Assets/VelGameServer/Example/TestNetworkedGameObject.prefab.meta similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/TestNetworkedGameObject.prefab.meta rename to TestVelGameServer/Assets/VelGameServer/Example/TestNetworkedGameObject.prefab.meta diff --git a/TestVelGameServer/Assets/Scenes/test.unity b/TestVelGameServer/Assets/VelGameServer/Example/test.unity similarity index 99% rename from TestVelGameServer/Assets/Scenes/test.unity rename to TestVelGameServer/Assets/VelGameServer/Example/test.unity index 60a1db0..35114a3 100644 --- a/TestVelGameServer/Assets/Scenes/test.unity +++ b/TestVelGameServer/Assets/VelGameServer/Example/test.unity @@ -1826,6 +1826,8 @@ MonoBehaviour: playerPrefab: {fileID: 6139051692386484099, guid: d4158ab9c4a204cdbba28d3273fc1fb3, type: 3} prefabs: - {fileID: 8565720275311462452, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3} + sceneObjects: [] + deletedSceneObjects: [] connected: 0 --- !u!1 &1154194181 GameObject: diff --git a/TestVelGameServer/Assets/Scenes/test.unity.meta b/TestVelGameServer/Assets/VelGameServer/Example/test.unity.meta similarity index 100% rename from TestVelGameServer/Assets/Scenes/test.unity.meta rename to TestVelGameServer/Assets/VelGameServer/Example/test.unity.meta diff --git a/TestVelGameServer/Assets/VelGameServer/NetworkPlayer.cs b/TestVelGameServer/Assets/VelGameServer/NetworkPlayer.cs index 767b3b7..336d79b 100644 --- a/TestVelGameServer/Assets/VelGameServer/NetworkPlayer.cs +++ b/TestVelGameServer/Assets/VelGameServer/NetworkPlayer.cs @@ -3,10 +3,10 @@ using System.Collections.Generic; using UnityEngine; using System.Text; using System; -using Dissonance; + [RequireComponent(typeof(NetworkObject))] -public class NetworkPlayer : MonoBehaviour, Dissonance.IDissonancePlayer +public class NetworkPlayer : MonoBehaviour { public NetworkObject myObject; @@ -20,22 +20,9 @@ public class NetworkPlayer : MonoBehaviour, Dissonance.IDissonancePlayer public int lastObjectId=0; //for instantiation - public Dissonance.VelCommsNetwork commsNetwork; - bool isSpeaking = false; - uint lastAudioId = 0; - public string dissonanceID; - //required by dissonance for spatial audio - public string PlayerId => dissonanceID; - public Vector3 Position => myObject.transform.position; - public Quaternion Rotation => myObject.transform.rotation; - public NetworkPlayerType Type => isLocal?NetworkPlayerType.Local:NetworkPlayerType.Remote; - public bool IsTracking => true; + bool isMaster = false; - public List closePlayers = new List(); //for testing audio communications - public bool changeClosePlayers = true; - - void Start() { myObject.owner = this; @@ -46,23 +33,7 @@ public class NetworkPlayer : MonoBehaviour, Dissonance.IDissonancePlayer // Update is called once per frame void Update() { - //handle dissonance comms - if(isLocal) - { - - //if we're not speaking, and the comms say we are, send a speaking event, which will be received on other network players and sent to their comms accordingly - if (commsNetwork.comms.FindPlayer(dissonanceID).IsSpeaking != isSpeaking) //unfortunately, there does not seem to be an event for this - { - isSpeaking = !isSpeaking; - manager.sendTo(NetworkManager.MessageType.OTHERS, "4," + (isSpeaking?1:0) + ";"); - if (!isSpeaking) - { - lastAudioId = 0; - } - - } - - } + } @@ -111,43 +82,6 @@ public class NetworkPlayer : MonoBehaviour, Dissonance.IDissonancePlayer myObject.handleMessage(identifier, message); break; } - case "2": //audio data - { - - if (isSpeaking) - { - byte[] data = Convert.FromBase64String(sections[1]); - uint sequenceNumber = uint.Parse(sections[2]); - commsNetwork.voiceReceived(dissonanceID, data, sequenceNumber); - } - - break; - } - case "3": //dissonance id (player joined) - { - if (dissonanceID == "") - { - dissonanceID = sections[1]; - //tell the comms network that this player joined the channel - commsNetwork.playerJoined(dissonanceID); //tell dissonance - commsNetwork.comms.TrackPlayerPosition(this); //tell dissonance to track the remote player - } - break; - } - case "4": //speaking state - { - if(sections[1] == "0") - { - commsNetwork.playerStoppedSpeaking(dissonanceID); - isSpeaking = false; - } - else - { - commsNetwork.playerStartedSpeaking(dissonanceID); - isSpeaking = true; - } - break; - } case "5": //sync update for an object I may own { @@ -218,30 +152,6 @@ public class NetworkPlayer : MonoBehaviour, Dissonance.IDissonancePlayer } - public void OnDestroy() - { - commsNetwork.playerLeft(dissonanceID); - } - - public void sendAudioData(ArraySegment data) - { - if (changeClosePlayers) - { - manager.setupMessageGroup("close", closePlayers.ToArray()); - changeClosePlayers = false; - } - string b64_data = Convert.ToBase64String(data.Array,data.Offset,data.Count); - //manager.sendTo(NetworkManager.MessageType.OTHERS, "2," + b64_data + "," + (lastAudioId++) + ";"); - manager.sendToGroup("close", "2,"+b64_data + ","+ (lastAudioId++) +";"); - } - - public void setDissonanceID(string id) //this sort of all initializes dissonance - { - dissonanceID = id; - manager.sendTo(NetworkManager.MessageType.OTHERS, "3," + id+";"); - commsNetwork.comms.TrackPlayerPosition(this); - } - public void setAsMasterPlayer() { isMaster = true; diff --git a/TestVelGameServer/Assets/VelGameServer/PlayerController.cs b/TestVelGameServer/Assets/VelGameServer/PlayerController.cs deleted file mode 100644 index f8510e9..0000000 --- a/TestVelGameServer/Assets/VelGameServer/PlayerController.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PlayerController : NetworkObject -{ - - public Vector3 targetPosition; - public Quaternion targetRotation; - - - public byte[] getSyncMessage() - { - float[] data = new float[7]; - for (int i = 0; i < 3; i++) - { - data[i] = transform.position[i]; - data[i + 3] = transform.rotation[i]; - } - data[6] = transform.rotation[3]; - - byte[] toReturn = new byte[sizeof(float) * data.Length]; - Buffer.BlockCopy(data, 0, toReturn, 0, toReturn.Length); - return toReturn; - } - - public override void handleMessage(string identifier, byte[] message) - { - switch (identifier) - { - case "s": - float[] data = new float[7]; - Buffer.BlockCopy(message, 0, data, 0, message.Length); - for (int i = 0; i < 3; i++) - { - targetPosition[i] = data[i]; - targetRotation[i] = data[i + 3]; - } - targetRotation[3] = data[6]; - break; - } - } - - // Start is called before the first frame update - void Start() - { - StartCoroutine(syncBehavior()); - } - - IEnumerator syncBehavior() - { - while (true) - { - if (owner != null && owner.isLocal) - { - - owner.sendMessage(this, "s", getSyncMessage()); - } - yield return new WaitForSeconds(.1f); - } - } - // Update is called once per frame - void Update() - { - if (owner != null && !owner.isLocal) - { - transform.position = Vector3.Lerp(transform.position, targetPosition, .1f); - transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, .1f); - } - else if(owner != null && owner.isLocal) - { - Vector3 movement = new Vector3(); - movement.x += Input.GetAxis("Horizontal"); - movement.y += Input.GetAxis("Vertical"); - movement.z = 0; - transform.Translate(movement * Time.deltaTime); - - if (Input.GetKeyDown(KeyCode.Space)) - { - owner.networkInstantiate("TestNetworkedGameObject"); - } - - if (Input.GetKeyDown(KeyCode.BackQuote)) - { - foreach(KeyValuePair kvp in owner.manager.objects) - { - owner.takeOwnership(kvp.Key); - } - } - if (Input.GetKeyDown(KeyCode.Backspace)) - { - foreach (KeyValuePair kvp in owner.manager.objects) - { - owner.networkDestroy(kvp.Key); - } - } - } - } -} diff --git a/TestVelGameServer/Assets/VelGameServer/Util.meta b/TestVelGameServer/Assets/VelGameServer/Util.meta new file mode 100644 index 0000000..5835bd6 --- /dev/null +++ b/TestVelGameServer/Assets/VelGameServer/Util.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: feb473f59814842848dd4183ddeb6d9e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestVelGameServer/Assets/VelGameServer/SyncTransform.cs b/TestVelGameServer/Assets/VelGameServer/Util/SyncTransform.cs similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/SyncTransform.cs rename to TestVelGameServer/Assets/VelGameServer/Util/SyncTransform.cs diff --git a/TestVelGameServer/Assets/VelGameServer/SyncTransform.cs.meta b/TestVelGameServer/Assets/VelGameServer/Util/SyncTransform.cs.meta similarity index 100% rename from TestVelGameServer/Assets/VelGameServer/SyncTransform.cs.meta rename to TestVelGameServer/Assets/VelGameServer/Util/SyncTransform.cs.meta diff --git a/TestVelGameServer/Assets/VelGameServer/VelCommsNetwork.cs b/TestVelGameServer/Assets/VelGameServer/VelCommsNetwork.cs deleted file mode 100644 index dc15d64..0000000 --- a/TestVelGameServer/Assets/VelGameServer/VelCommsNetwork.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Dissonance; -using Dissonance.Extensions; -using Dissonance.Networking; -using UnityEngine; - -namespace Dissonance -{ - public class VelCommsNetwork : MonoBehaviour, ICommsNetwork - { - public ConnectionStatus Status - { - get - { - return manager.connected?ConnectionStatus.Connected:ConnectionStatus.Disconnected; - } - } - - public NetworkMode Mode - { - get - { - return NetworkMode.Client; - } - } - - public event Action ModeChanged; - public event Action PlayerJoined; - public event Action PlayerLeft; - public event Action VoicePacketReceived; - public event Action TextPacketReceived; - public event Action PlayerStartedSpeaking; - public event Action PlayerStoppedSpeaking; - public event Action PlayerEnteredRoom; - public event Action PlayerExitedRoom; - - ConnectionStatus _status = ConnectionStatus.Disconnected; - CodecSettings initSettings; - public string dissonanceId; - public DissonanceComms comms; - public NetworkManager manager; - NetworkPlayer myPlayer; - public void Initialize(string playerName, Rooms rooms, PlayerChannels playerChannels, RoomChannels roomChannels, CodecSettings codecSettings) - { - dissonanceId = playerName; - initSettings = codecSettings; - Debug.Log("Initializing dissonance"); - - manager.onJoinedRoom += (player) => - { - //this is me joining a vel room - myPlayer = player; - myPlayer.commsNetwork = this; - myPlayer.setDissonanceID(playerName); //need to let that new player know my dissonance id (tell everyone again) - }; - - manager.onPlayerJoined += (player) => - { - //this is someone else joining the vel room - myPlayer.setDissonanceID(playerName); //need to let that new player know my dissonance id (tell everyone again) - player.commsNetwork = this; //this will tell us when various things happen of importance - }; - - - - } - - public void voiceReceived(string sender,byte[] data,uint sequenceNumber) - { - - VoicePacket vp = new VoicePacket(sender, ChannelPriority.Default, 1, true, new ArraySegment(data,0,data.Length), sequenceNumber); - VoicePacketReceived(vp); - } - - public void SendText(string data, ChannelType recipientType, string recipientId) - { - Debug.Log("sending text"); - } - - public void SendVoice(ArraySegment data) - { - myPlayer?.sendAudioData(data); - } - - // Start is called before the first frame update - void Start() - { - _status = ConnectionStatus.Connected; - comms = GetComponent(); - - } - - public void playerJoined(string id) - { - Debug.Log("dissonance player joined"); - PlayerJoined(id, initSettings); - RoomEvent re = new RoomEvent(); - re.Joined = true; - re.Room = "Global"; - re.PlayerName = id; - PlayerEnteredRoom(re); - } - - public void playerLeft(string id) - { - RoomEvent re = new RoomEvent(); - re.Joined = false; - re.Room = "Global"; - re.PlayerName = id; - PlayerExitedRoom(re); - PlayerLeft(id); - } - - public void playerStartedSpeaking(string id) - { - PlayerStartedSpeaking(id); - } - public void playerStoppedSpeaking(string id) - { - PlayerStoppedSpeaking(id); - } - - } -} diff --git a/TestVelGameServer/ProjectSettings/EditorBuildSettings.asset b/TestVelGameServer/ProjectSettings/EditorBuildSettings.asset index 21ec17a..5f2b80c 100644 --- a/TestVelGameServer/ProjectSettings/EditorBuildSettings.asset +++ b/TestVelGameServer/ProjectSettings/EditorBuildSettings.asset @@ -6,6 +6,6 @@ EditorBuildSettings: serializedVersion: 2 m_Scenes: - enabled: 1 - path: Assets/Scenes/test.unity + path: Assets/VelGameServer/Example/test.unity guid: e4e43899246c941c78acfc59ce2f664a m_configObjects: {} diff --git a/TestVelGameServer/ProjectSettings/ProjectSettings.asset b/TestVelGameServer/ProjectSettings/ProjectSettings.asset index 07e28d1..2d3bc76 100644 --- a/TestVelGameServer/ProjectSettings/ProjectSettings.asset +++ b/TestVelGameServer/ProjectSettings/ProjectSettings.asset @@ -12,8 +12,8 @@ PlayerSettings: targetDevice: 2 useOnDemandResources: 0 accelerometerFrequency: 60 - companyName: DefaultCompany - productName: TestVelGameServer + companyName: VEL + productName: VelNetUnity defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} @@ -146,7 +146,7 @@ PlayerSettings: androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 applicationIdentifier: - Standalone: com.DefaultCompany.TestVelGameServer + Standalone: com.VEL.VelNetUnity buildNumber: Standalone: 0 iPhone: 0 diff --git a/start_mac.sh b/start_mac.sh index a5e06e7..295f539 100755 --- a/start_mac.sh +++ b/start_mac.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -./TestVelGameServer/build/macbuild.app/Contents/MacOS/TestVelGameServer & +./TestVelGameServer/Build/macbuild.app/Contents/MacOS/TestVelGameServer &