Example #1
0
    public void SendDraft(CharType.CHARTYPE chartypeToDraft)
    {
        int indexCurDraftInput = NetworkDraftReceiver.Get().indexCurDraftInput;

        Debug.LogErrorFormat("Sending step {0}: Draft {1}", indexCurDraftInput, chartypeToDraft);

        photonview.RPC("ReceiveDraft", RpcTarget.AllBufferedViaServer, indexCurDraftInput, chartypeToDraft);
    }
    //The main loop that will spin waiting for outside networked input and process
    //  it, once our local simulation is ready for a new input
    public IEnumerator CRDraftLoop()
    {
        //Do any animation processing that needs to be done before the draft input actually starts
        yield return(StartCoroutine(CRPrepDraft()));

        Debug.Log("Done prepping draft");


        //Keep processing turn events while the draft isn't finished
        while (!IsDraftPhaseOver())
        {
            //Check if we have input waiting for us in the network buffer
            while (NetworkDraftReceiver.Get().IsCurSelectionReady() == false)
            {
                //Keep spinning until we get the input we're waiting on

                WaitForDraftInput();
                yield return(null);
            }
            //If we were waiting on input, then clean up the waiting process
            if (draftactionWaitingOn != null)
            {
                EndWaitingOnDraftInput();
            }

            //At this point, we have an input in the buffer that we are able to process
            DraftAction       draftaction   = GetNextDraftPhaseStep();
            CharType.CHARTYPE chartypeInput = NetworkDraftReceiver.Get().GetCurSelection();

            Debug.Log("Got a draft action of type " + draftaction.draftactionType + " for chr " + chartypeInput);

            //Start a coroutine to process whichever event we need to execute
            if (draftaction.draftactionType == DraftAction.DRAFTACTIONTYPE.DRAFT)
            {
                //Draft the character
                yield return(StartCoroutine(CRDraftChr(draftaction.iPlayer, chartypeInput)));
            }
            else
            {
                //Ban the character
                yield return(StartCoroutine(CRBanChr(draftaction.iPlayer, chartypeInput)));
            }

            //Now that the draft/ban is complete and processed, increment our 'current' indices
            NetworkDraftReceiver.Get().FinishCurSelection();
            FinishDraftPhaseStep();
        }

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

        //Wrap up the draft phase
        FinishDraft();
        yield break;
    }