示例#1
0
 public void AssignLocalInputController(Player plyr)
 {
     //If the player isn't controlled locally, just set the plyr's controller to null since it's not our job to control them
     if (NetworkMatchSetup.IsLocallyOwned(plyr.id) == false)
     {
         plyr.SetInputType(LocalInputType.InputType.NONE);
     }
     else
     {
         //Otherwise, this character is controlled by this local client - figure out which input type they'll need and add it
         plyr.SetInputType(NetworkMatchSetup.GetInputType(plyr.id));
     }
 }
    //Figure out what type of draft action we were waiting on (foreign/local) and react appropriately to completing it
    public void EndWaitingOnDraftInput()
    {
        //Check what type of input we're waiting on
        if (NetworkMatchSetup.IsLocallyOwned(draftactionWaitingOn.iPlayer))
        {
            //Let anyone (UI effects probably) know that the current player has finished their selection
            subEndChooseLocally.NotifyObs();
        }
        else
        {
            subEndChooseForeign.NotifyObs();
        }

        //Clear the action we were waiting on
        draftactionWaitingOn = null;
    }
示例#3
0
    public void FinishSelections()
    {
        //Only allow manual selections when the local player is human
        Debug.Assert(ContTurns.Get().GetNextActingChr().plyrOwner.inputController.GetInputType() == LocalInputType.InputType.HUMAN,
                     "Error - can only submit skills for locally-owned >human<'s characters");

        Debug.Assert(NetworkMatchSetup.IsLocallyOwned(ContTurns.Get().GetNextActingChr().plyrOwner.id),
                     "Error - can only submit skills for >locally-owned< human's characters");

        //By this point, we have built up our local selectionsInProgress skill selection into a valid selection of targets,
        // so let's pass a reference into the Skill Engine's matchinputToFillOut so it can be submitted
        ContSkillEngine.Get().matchinputToFillOut = selectionsInProgress;

        NetworkMatchSender.Get().SendNextInput(ContSkillEngine.Get().matchinputToFillOut);

        //Clean up the selection process (clears out the stored selections structure, sends notifications, etc.)
        ExitSelectionsProcess();
    }
    public void OnDraftableChrClicked(CharType.CHARTYPE chrClicked)
    {
        //Check if we've been told by the master to choose a character to draft/ban
        if (draftactionWaitingOn == null)
        {
            Debug.Log("We aren't waiting on any input right now");
            return;
        }

        //Check if it's even our turn to draft
        if (NetworkMatchSetup.IsLocallyOwned(draftactionWaitingOn.iPlayer) == false)
        {
            Debug.LogError("Can't draft/ban since it's not your turn");
            return;
        }

        //Check if this character is available to draft/ban
        if (IsCharAvailable(chrClicked) == false)
        {
            Debug.LogError("Can't draft/ban an unavailable character");
            return;
        }

        Debug.Log("Current step of draft is " + GetNextDraftPhaseStep().draftactionType);

        //At this point, it's valid to pick/ban the character so send along the appropriate signal to the Master
        if (GetNextDraftPhaseStep().draftactionType == DraftAction.DRAFTACTIONTYPE.BAN)
        {
            Debug.Log("Sending ban of " + chrClicked);
            NetworkDraftSender.Get().SendBan(chrClicked);
        }
        else if (GetNextDraftPhaseStep().draftactionType == DraftAction.DRAFTACTIONTYPE.DRAFT)
        {
            Debug.Log("Sending draft of " + chrClicked);
            NetworkDraftSender.Get().SendDraft(chrClicked);
        }
    }
    public void WaitForDraftInput()
    {
        //If we're already waiting, then we don't need to do anything further
        if (draftactionWaitingOn != null)
        {
            return;
        }

        //Raise the flag that we're waiting for input
        draftactionWaitingOn = GetNextDraftPhaseStep();

        //Check what type of input we're waiting on
        if (NetworkMatchSetup.IsLocallyOwned(draftactionWaitingOn.iPlayer))
        {
            //Prompt the local player to select input
            subBeginChooseLocally.NotifyObs();
        }
        else
        {
            //Let anyone (UI effects probably) know that we're waiting for another player to make a selection
            subBeginChooseForeign.NotifyObs();
        }
        return;
    }
    //The main loop that will process the effects of the game.  If it needs inputs, it will flag what
    //  it's waiting on and pull input from the network buffer to decide what action should be taken
    public IEnumerator CRMatchLoop()
    {
        //Do any animation processing that needs to be done before the match processing actually starts
        yield return(StartCoroutine(CRPrepMatch()));

        //Initially decide if we want to do any fast forwarding from early loaded input
        HandleFastForwarding();

        //Do any initial processing for beginning of match effects
        yield return(ProcessStackUntilInputNeeded());

        //Keep processing effects while the match isn't finished
        while (!IsMatchOver())
        {
            // At this point, we should have an input field that's been set up that needs to be filled out
            Debug.Assert(matchinputToFillOut != null);

            bool bNeedsLocalInput = false;

            //If we need input, let's check if we already have input waiting in our buffer for that input
            if (NetworkMatchReceiver.Get().IsCurMatchInputReady() == false)
            {
                // Now that input is needed by some player, check if we locally control that player
                if (NetworkMatchSetup.IsLocallyOwned(matchinputToFillOut.iPlayerActing))
                {
                    bNeedsLocalInput = true;
                    //Let the match input prepare to start gathering manual input
                    matchinputToFillOut.StartManualInputProcess();
                }
                else
                {
                    //If we don't locally control the player who needs to decide an input
                    DebugDisplay.Get().SetDebugText("Waiting for foreign input");
                }

                //Wait until we have input waiting for us in the network buffer
                while (NetworkMatchReceiver.Get().IsCurMatchInputReady() == false)
                {
                    //Keep spinning until we get the input we're waiting on

                    DebugDisplay.Get().SetDebugText("Waiting for input");
                    yield return(null);
                }

                //Do any cleanup that we need to do if we were waiting on input
                //TODO - figure out what needs to be done and under what circumstances - careful of potentially changing local input controllers
                if (bNeedsLocalInput == true)
                {
                    //Have the match input let the local input controller know that we're done with gathering input
                    matchinputToFillOut.EndManualInputProcess();
                }
            }

            //Check if we should be master forwarding through our inputs if we have a bunch stacked up waiting to be processed (like from loading a log file or reconnecting)
            HandleFastForwarding();

            //At this point, we have an input in the buffer that we are able to process
            MatchInput matchinput = NetworkMatchReceiver.Get().GetCurMatchInput();

            //Make a record of which input we're going to be processing in our logs
            LogManager.Get().LogMatchInput(matchinput);

            //Clear out the matchinput we prompting to be filled out
            matchinputToFillOut = null;

            //Process that match input by deferring to its execute method
            yield return(matchinput.Execute());

            //The execute method should have pushed new executables/clauses onto the stack, so we can process them
            // Pass control over to the stack-processing loop until it needs player input to continue the simulation
            yield return(ProcessStackUntilInputNeeded());

            //Since we're done processing all the effects that may need access to the most recent input, we can advance to the next needed input
            NetworkMatchReceiver.Get().FinishCurMatchInput();
        }

        //Do any animation process that needs to be done before we leave the match scene
        yield return(StartCoroutine(CRCleanUpMatch()));

        //Do any fill wrap-up for the match
        FinishMatch();
    }