コード例 #1
0
        public DraftResponse ProcessDraft(string drafterName, DraftAction currentAction, string characterName)
        {
            var currUserIndex   = this.UserList.IndexOf(drafterName);
            var nextUser        = this.UserList.Count() - 1 == currUserIndex ? this.UserList[0] : this.UserList[currUserIndex + 1];
            var character       = this.CharacterPool.First(c => c.Name == characterName);
            var availableHeroes = this.CharacterPool.Where(c => !c.IsSelected);


            switch (currentAction)
            {
            case DraftAction.Pick:
                this.Pick(character, drafterName);
                break;
            }

            // last of this type
            if (this.DraftState.First().Value == 1)
            {
                this.DraftState.RemoveAt(0);
            }
            else
            {
                var copy   = this.DraftState.First();
                var newVal = new KeyValuePair <DraftAction, int>(copy.Key, copy.Value - 1);
                this.DraftState.RemoveAt(0);
                this.DraftState.Insert(0, newVal);
            }

            var heroPool = this.DraftState.First().Key == DraftAction.Finished ? this.CharacterPool : GetRandom(this.CharacterPool.Where(c => !c.IsSelected), 3);

            return(new DraftResponse(heroPool, this.DraftState.First().Key, nextUser));
        }
コード例 #2
0
ファイル: CaptainsDraft.cs プロジェクト: onodigaregs/testrepo
        public DraftResponse ProcessDraft(string drafterName, DraftAction currentAction, string characterName)
        {
            var currUserIndex = this.UserList.IndexOf(drafterName);
            var nextUser      = this.UserList.Count() - 1 == currUserIndex ? this.UserList[0] : this.UserList[currUserIndex + 1];
            var character     = this.CharacterPool.First(c => c.Name == characterName);

            switch (currentAction)
            {
            case DraftAction.Ban:
                this.Ban(character, drafterName);
                break;

            case DraftAction.Pick:
                this.Pick(character, drafterName);
                break;
            }

            // last of this type
            if (this.DraftState.First().Value == 1)
            {
                this.DraftState.RemoveAt(0);
            }
            else
            {
                var copy   = this.DraftState.First();
                var newVal = new KeyValuePair <DraftAction, int>(copy.Key, copy.Value - 1);
                this.DraftState.RemoveAt(0);
                this.DraftState.Insert(0, newVal);
            }


            return(new DraftResponse(this.CharacterPool, this.DraftState.First().Key, nextUser));
        }
コード例 #3
0
    //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;
    }
コード例 #4
0
    //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;
    }
コード例 #5
0
    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;
    }
コード例 #6
0
 public DraftResponse(IEnumerable <ICharacter> heroPool, DraftAction action, string nextDrafter)
 {
     this.HeroPool    = heroPool;
     this.NextAction  = action;
     this.NextDrafter = nextDrafter;
 }