private void issueNewInstruction(int recieverConnectionId) { bool shouldPerformAsWell; if (CustomLobbyManager.allConnections.Count() == 1) { shouldPerformAsWell = true; } else { shouldPerformAsWell = Random.value > instructionPerformerBias; } int performerConnectionId; if (shouldPerformAsWell) { performerConnectionId = recieverConnectionId; } else { performerConnectionId = (from connection in CustomLobbyManager.allConnections where connection.connectionId != recieverConnectionId select connection.connectionId).chooseRandom(); } //Grab the list of panels for the performer List <PanelActionSetBase> panelActionSets; if (!_connectionIdToPanelIds.TryGetValue(performerConnectionId, out panelActionSets)) { throw new System.Exception("Could not find list of panel action sets for connection id " + performerConnectionId); } PanelActionSetBase randomPanelActionSet; int randomVariant; ServerInstruction newInstruction; do { //Choose a random panel for the performer randomPanelActionSet = panelActionSets.chooseRandom(); //Choose a variant that is not currently active on the panel do { randomVariant = Random.Range(0, randomPanelActionSet.getVariantCount()); } while (randomPanelActionSet.currentVariantIndex == randomVariant); newInstruction = new ServerInstruction(recieverConnectionId, performerConnectionId, randomPanelActionSet.setId, randomVariant); } while (_currentInstructions.Contains(newInstruction) || _currentInstructions.Any(s => s.conflictsWith(newInstruction))); _currentInstructions.Add(newInstruction); string instructionText = randomPanelActionSet.getVariant(randomVariant); DisplayInstructionMessage displayInstructionMessage = new DisplayInstructionMessage(instructionText, true); displayInstructionMessage.sendToClient(recieverConnectionId); }
private void instructionHandler(NetworkMessage message) { DisplayInstructionMessage mm = message.ReadMessage <DisplayInstructionMessage>(); GetComponent <Text>().text = mm.instruction; slider.value = 1.0f; if (mm.startTimer) { enabled = true; } else { enabled = false; } }
private void issueNewInstruction(int recieverConnectionId) { bool shouldPerformAsWell; if (CustomLobbyManager.allConnections.Count() == 1) { shouldPerformAsWell = true; }else{ shouldPerformAsWell = Random.value > instructionPerformerBias; } int performerConnectionId; if (shouldPerformAsWell) { performerConnectionId = recieverConnectionId; } else { performerConnectionId = (from connection in CustomLobbyManager.allConnections where connection.connectionId != recieverConnectionId select connection.connectionId).chooseRandom(); } //Grab the list of panels for the performer List<PanelActionSetBase> panelActionSets; if (!_connectionIdToPanelIds.TryGetValue(performerConnectionId, out panelActionSets)) { throw new System.Exception("Could not find list of panel action sets for connection id " + performerConnectionId); } PanelActionSetBase randomPanelActionSet; int randomVariant; ServerInstruction newInstruction; do { //Choose a random panel for the performer randomPanelActionSet = panelActionSets.chooseRandom(); //Choose a variant that is not currently active on the panel do { randomVariant = Random.Range(0, randomPanelActionSet.getVariantCount()); } while (randomPanelActionSet.currentVariantIndex == randomVariant); newInstruction = new ServerInstruction(recieverConnectionId, performerConnectionId, randomPanelActionSet.setId, randomVariant); } while (_currentInstructions.Contains(newInstruction) || _currentInstructions.Any(s => s.conflictsWith(newInstruction))); _currentInstructions.Add(newInstruction); string instructionText = randomPanelActionSet.getVariant(randomVariant); DisplayInstructionMessage displayInstructionMessage = new DisplayInstructionMessage(instructionText, true); displayInstructionMessage.sendToClient(recieverConnectionId); }