public static Dictionary <int, InputDataHolder> GetInputDataHolders() { var conditions = new double[, ] { { 2, -3, 1, 0 }, { -1, -1, 1, 1 } }; var objectiveFunction = new double[] { 1, -4, 1, 0 }; var constraints = new double[] { -3, -6 }; var basisIndices = new HashSet <int>(new[] { 2, 3 }); var holder12 = new InputDataHolder(conditions, objectiveFunction, constraints, basisIndices); conditions = new double[, ] { { -2, 1, 1, 1 }, { 3, 4, 0, 1 } }; objectiveFunction = new double[] { -6, 3, 0, 1 }; constraints = new double[] { -9, -6 }; basisIndices = new HashSet <int>(new[] { 2, 3 }); var holder23 = new InputDataHolder(conditions, objectiveFunction, constraints, basisIndices); var variants = new Dictionary <int, InputDataHolder> { { 12, holder12 }, { 23, holder23 } }; return(variants); }
private IEnumerator DummyStart(Guid g) { yield return(new WaitForSeconds(1f)); InputDataHolder s = new InputDataHolder(g, InputDataType.ready, null); ReceivePlayerInput(s); }
private void PassReceivedMessage(NetworkEventType eventType, InputDataHolder data) { if (!isAlive) { return; } NetworkEventDispatcher.TriggerEvent(eventType, data); }
/// <summary> /// This method is called from a WebRTC thread from <see cref="UWCController"/>. /// Uses <see cref="UnityToolbag.Dispatcher.InvokeAsync()"/> /// to wait for Unitys main thread to be ready before posting events. /// </summary> /// <param name="eventType">Type of the event.</param> /// <param name="data">Converted input data from client.</param> public static void TriggerEvent(NetworkEventType eventType, InputDataHolder data) { AsyncEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventType, out thisEvent)) { Dispatcher.InvokeAsync(() => { thisEvent.Invoke(data); }); } }
public void RegisterPlayer(InputDataHolder playerInfo) { Guid playerGuid = (Guid)playerInfo.data; IPlayer player = InstantiatePlayer(false); playerToGuid.Add(playerGuid, player); StartCoroutine(SendPlayerColor((Player)player)); if (GameManager.instance.GetActiveGameScene() == GameScene.Menu) { GameManager.instance.UpdatePlayerCount(playerToGuid.GetKeys().Count); } }
public void UnregisterPlayer(InputDataHolder playerInfo) { IPlayer player = playerToGuid.Forward[(Guid)playerInfo.identifier]; PlayerConstraints constraints = playerConstraints[player]; playerConstraints.Remove(player); playerToGuid.Remove((Guid)playerInfo.identifier); player.DestroyMe(); Destroy(constraints.MenuPlayer.gameObject); if (GameManager.instance.GetActiveGameScene() == GameScene.Menu) { GameManager.instance.UpdatePlayerCount(playerToGuid.GetKeys().Count); } else if (GameManager.instance.GetActiveGameScene() == GameScene.Game) { CheckRemainingPlayers(); } }
//Gets called from NetworkEventDispatcher -> definitely a client / Player instance. public void ReceivePlayerInput(InputDataHolder data) { Player player = (Player)playerToGuid.Forward[(Guid)data.identifier]; if (player != null) { PlayerConstraints constraints = playerConstraints[player]; if (GameManager.instance.GetActiveGameScene() == GameScene.Menu && ((InputDataType)data.type).Equals(InputDataType.ready)) { SetPlayerReady(player); CheckAllPlayersReady(); } else if (GameManager.instance.GetActiveGameScene() == GameScene.Game) { player.ReceiveInput((InputDataType)data.type, data.data); } } else { Debug.Log($"could not handle message of unknown client. {data.identifier}"); } }