/// <summary> /// Sends data to other clients or if debg echo then sends to all including this client /// </summary> /// <param name="samples">list of sampels that will be sent over network</param> private void SendDataToNetwork(List <float> samples) { // data in bytes to send over network byte[] bytes = AudioConverter.FloatToByte(samples); Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions { Receivers = debugEcho ? Photon.Realtime.ReceiverGroup.All : Photon.Realtime.ReceiverGroup.Others }; ExitGames.Client.Photon.SendOptions sendOptions = new ExitGames.Client.Photon.SendOptions { Reliability = reliableTransmission }; Photon.Pun.PhotonNetwork.RaiseEvent(Constants.VoiceEventCode, bytes, raiseEventOptions, sendOptions); }
/// <summary> /// Sends data to other clients or if debg echo then sends to all including this client /// </summary> /// <param name="samples">list of sampels that will be sent over network</param> private void SendDataToNetwork(List <float> samples) { //skip second with no sound if (!ripples.positiveInLastSecond) { return; } // data in bytes to send over network byte[] bytes = AudioConverter.FloatToByte(samples); List <int> targets = new List <int>(); var speakers = proximity.listener.Speakers; // skip far away players since they don't hear the sound anyway foreach (int id in speakers.Keys) { //Debug.Log(speakers[id].AudioSource.volume); if (speakers[id].AudioSource.volume > 0) { targets.Add(id); } } // add yourself if debugEcho = true if (debugEcho) { targets.Add(PhotonNetwork.LocalPlayer.ActorNumber); } if (targets.Count == 0) { return; } //Debug.Log("Send data"); // sending data of recorded samples by using raise event feature Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions { TargetActors = targets.ToArray() }; //Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions { Receivers = debugEcho ? Photon.Realtime.ReceiverGroup.All : Photon.Realtime.ReceiverGroup.Others }; ExitGames.Client.Photon.SendOptions sendOptions = new ExitGames.Client.Photon.SendOptions { Reliability = reliableTransmission }; Photon.Pun.PhotonNetwork.RaiseEvent(Constants.VoiceEventCode, bytes, raiseEventOptions, sendOptions); }
IEnumerator SetBoard() { fadeCount = 0; for (int i = tileSet.Count - 1; i > 0; i--) { int j = Random.Range(0, i + 1); Vector2Int temp = tileSet[i]; tileSet[i] = tileSet[j]; tileSet[j] = temp; } int index = 0; while (index < tileSet.Count) { for (int i = index; i < Mathf.Min(index + tileSet.Count / boardWidth, tileSet.Count); i++) { StartCoroutine(FadeInTile(tileSet[i][0], tileSet[i][1])); } index += tileSet.Count / boardWidth; yield return(new WaitForSeconds(0.05f)); } while (fadeCount < tileSet.Count) { yield return(null); } HashSet <Vector2Int> resources = resource.GetResourceTiles(); List <Vector2Int> remove = new List <Vector2Int>(); foreach (Vector2Int r in resources) { if (boardState.ContainsNode(r[0], r[1])) { Tile currTile = boardState.GetNodeTile(r[0], r[1]); Color baseColor = currTile.GetBaseColor(); float lerpRate = 0.2f; while (lerpRate > 0.0f) { lerpRate -= Time.deltaTime; Color lerpedColor = Color.Lerp(baseColor, Color.white * 2, 1.0f - (lerpRate / 0.2f)); currTile.gameObject.GetComponent <MeshRenderer>().material.SetColor("_BaseColor", lerpedColor); yield return(null); } } else { remove.Add(r); } } foreach (Vector2Int r in remove) { resource.RemoveResourceTile(r[0], r[1]); } if (numPlayers == 2) { StartCoroutine(SetBase(baseOffset, boardWidth - baseOffset - 1, 0)); StartCoroutine(SetBase(boardWidth - baseOffset - 1, baseOffset, 1)); } else if (numPlayers == 3) { Vector2Int curr = new Vector2Int(boardWidth - 1, baseOffset); Vector2Int center = new Vector2Int(boardWidth - 1, boardWidth - 1); StartCoroutine(SetBase(curr[0], curr[1], 0)); for (int i = 1; i < numPlayers; i++) { curr = Rotate120(curr, center); StartCoroutine(SetBase(curr[0], curr[1], i)); } } else if (numPlayers == 6) { Vector2Int curr = new Vector2Int(boardWidth - 1, baseOffset); Vector2Int center = new Vector2Int(boardWidth - 1, boardWidth - 1); StartCoroutine(SetBase(curr[0], curr[1], 0)); for (int i = 1; i < numPlayers; i++) { curr = Rotate60(curr, center); StartCoroutine(SetBase(curr[0], curr[1], i)); } } else if (numPlayers == 1) { StartCoroutine(SetBase(baseOffset, boardWidth - baseOffset - 1, 0)); } byte evCode = 0; Photon.Realtime.RaiseEventOptions raiseEventOptions = new Photon.Realtime.RaiseEventOptions { Receivers = Photon.Realtime.ReceiverGroup.MasterClient }; ExitGames.Client.Photon.SendOptions sendOptions = new ExitGames.Client.Photon.SendOptions { Reliability = true }; PhotonNetwork.RaiseEvent(evCode, null, raiseEventOptions, sendOptions); }