Пример #1
0
    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);
    }
Пример #2
0
    public override bool Equals(object obj)
    {
        ServerInstruction other = obj as ServerInstruction;

        if (other == null)
        {
            return(false);
        }

        return(other.instructionPerformerConnection == instructionPerformerConnection &&
               other.instructionReaderConnection == instructionReaderConnection &&
               other.panelActionSetId == panelActionSetId &&
               other.panelActionVariantIndex == panelActionVariantIndex);
    }
Пример #3
0
 public bool conflictsWith(ServerInstruction other)
 {
     return(other.instructionPerformerConnection == instructionPerformerConnection &&
            other.instructionReaderConnection != instructionReaderConnection &&
            other.panelActionSetId == panelActionSetId);
 }
Пример #4
0
    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);
    }
Пример #5
0
 public bool conflictsWith(ServerInstruction other)
 {
     return other.instructionPerformerConnection == instructionPerformerConnection &&
            other.instructionReaderConnection != instructionReaderConnection &&
            other.panelActionSetId == panelActionSetId;
 }