Exemple #1
0
        private IEnumerator DoIt(BS_MatchParams info, BS_MatchResult result)
        {
            string label = "";

            foreach (var teamId in info.TeamIds)
            {
                BS_Team team = GM_Game.Finder.Get <BS_Team>(teamId);
                if (label.Length == 0)
                {
                    label = "Team ";
                }
                else
                {
                    label += " vs ";
                }
                label += team.DisplayName;
            }


            GM_Game.Popup.ShowPopup(label, "Simulating Match");
            for (int i = 0; i < 5; i++)
            {
                yield return(null);
            }

            _isRunning = false;
            Dbg.Log("Match simulation finished");
            GM_Game.Popup.ClearStatus(true);
        }
Exemple #2
0
        // ### TODO: in the future, prepare the combatant list earlier.

        // ---------------------------------------------------------------------------------------
        public IEnumerable <BS_Combatant> GetCombatantsForMatch(BS_MatchParams info)
        // ---------------------------------------------------------------------------------------
        {
            for (int i = 0; i < 4 && i < AllTeamMembers.Count; i++)
            {
                yield return(AllTeamMembers[i]);  //### TODO: make better algorithm for selecting match combatants
            }
        }
Exemple #3
0
 // --------------------------------------------------------------------------
 /// <summary>
 /// When a match is completed, this event is sent. We check to see if it's the
 /// last one and if it is, then we send the end of day message.
 /// Note that the update loop will see if we have queued matches and will
 /// start to run the next one
 /// </summary>
 /// <param name="ev"></param>
 void OnMatchCompleted(LG_SimMatchEndedEvent ev)
 // --------------------------------------------------------------------------
 {
     _curMatch = null;
     if (_queuedMatches.Count == 0)
     {
         AdvanceDay();
     }
 }
Exemple #4
0
        // ----------------------------------------------------------------------------------------------------
        void PlayNextQueuedMatch()
        // ----------------------------------------------------------------------------------------------------
        {
            Dbg.Assert(_queuedMatches.Count > 0);
            BS_MatchParams match = _queuedMatches.Dequeue();

            Dbg.Assert(match != null);
            _curMatch = match;
            PT_Game.Match.StartMatch(match, IsToBeViewed(match) ? GetArenaDescriptor(match.ArenaNdx) : null);
        }
Exemple #5
0
        // -------------------------------------------------------------------------------
        void StartSimulatedMatch(BS_MatchParams info)
        // -------------------------------------------------------------------------------
        {
            // TODO: Implement simulated matches

            // Dbg.Log("Starting simulating match between " + info.HomeTeamId + " " + info.AwayTeamId);
            // TODO: loop through teams

//            _matchState = State.Exiting;
        }
Exemple #6
0
        //IEnumerator SimulateMatch(LG_MatchInfo info)
        //{
        //    info.Result = new MT_Result();
        //    info.Result.WasSimulated = true;
        //    yield return null;
        //    Events.SendGlobal(new LG_SimMatchEndedEvent(info));
        //}

        // ----------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="match"></param>
        /// <returns></returns>
        bool IsToBeViewed(BS_MatchParams match)
        // ----------------------------------------------------------------------------------
        {
            for (int i = 0; i < match.TeamIds.Count; i++)
            {
                if (PT_Game.Finder.Get <BS_Team>(match.TeamIds[i]).IsAI)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #7
0
        // ---------------------------------------------------------------------------------------
        /// <summary>
        /// Called when we're preparing to go into the match. I.e. still in League, about to go to Match.
        /// Creates list of MatchCombatant structures
        /// </summary>
        /// <param name="ndx"></param>
        /// <param name="team"></param>
        /// <param name="matchParams"></param>
        public void Initialize(int ndx, BS_Team team, BS_MatchParams matchParams)
        // ---------------------------------------------------------------------------------------
        {
            Combatants = new List <MT_Combatant>();
            Score      = 0;
            TeamNdx    = ndx;
            Team       = team;

            foreach (var v in team.GetCombatantsForMatch(matchParams))
            {
                MT_Combatant cmbt = new MT_Combatant();
                cmbt.Initialize(v, this);
                Combatants.Add(cmbt);
            }
        }
Exemple #8
0
        // -------------------------------------------------------------------------------
        public void SetTeams(BS_MatchParams param, LG_League league)
        // -------------------------------------------------------------------------------
        {
            _teams = new List <MT_Team>();

            for (int teamNdx = 0; teamNdx < param.TeamIds.Count; teamNdx++)
            {
                var     teamId = param.TeamIds[teamNdx];
                MT_Team ti     = new MT_Team();

                // TO DO add syntactic sugar to get teams from league rather than finder

                ti.Initialize(teamNdx, PT_Game.Finder.Get <BS_Team>(teamId), param);
                _teams.Add(ti);
            }
            ;
        }
Exemple #9
0
        // ------------------------------------------------------------------------------
        /// <summary>
        /// This is called while still in the league scene to set up the match for play.
        /// It configures some data and moves to the given arena
        /// </summary>
        /// <param name="matchParam"></param>
        /// <param name="arena"></param>
        public void StartMatch(BS_MatchParams matchParam, LG_ArenaDescriptor arena)
        // ------------------------------------------------------------------------------
        {
            _arenaDesc   = arena;
            _matchState  = State.Loading;
            _matchResult = new BS_MatchResult();

            SetTeams(matchParam, PT_Game.League);

            // if we don't have an rena, then we are doing a simulated match.
            if (_arenaDesc == null)
            {
                _matchState = State.Running;
                _matchSimulator.Run(matchParam, _matchResult);
            }
            else  // otherwise, load that level and go to town with the mission
            {
                PT_GamePhaseMatch gpMatch = PT_Game.Phases.GetPhase <PT_GamePhaseMatch>();
                gpMatch.SceneName = arena.Name;
                PT_Game.Phases.QueuePhase(gpMatch);
            }
        }
Exemple #10
0
 public MatchInfoEvent(BS_MatchParams info)
 {
     Info = info;
 }
Exemple #11
0
 public void Run(BS_MatchParams info, BS_MatchResult result)
 {
     Dbg.Assert(_isRunning == false);
     StartCoroutine(DoIt(info, result));
 }
Exemple #12
0
        // TODO : this only supports 1v1 matches
        public void MakeRoundRobinSchedule(int numTeams, int numRounds)
        {
            Dbg.Log("Making round robin schedule");

            // TODO fix this numteam limitation
            Dbg.Assert((numTeams % 2) == 0);


            for (int t1 = 0; t1 < numTeams; t1++)
            {
                for (int t2 = t1 + 1; t2 < numTeams; t2++)
                {
                    BS_Team tm1 = PT_Game.League.Teams[t1];
                    BS_Team tm2 = PT_Game.League.Teams[t2];

                    GM_IDList idList = new GM_IDList();
                    idList.Add(tm1.Id);
                    idList.Add(tm2.Id);

                    BS_MatchParams match = new BS_MatchParams();
                    match.TeamIds = idList;
                    match.Day     = -1;
                    bool found = false;
                    for (int dayNdx = 0; dayNdx < numTeams; dayNdx++)
                    {
                        found = false;
                        foreach (var m in Matches)
                        {
                            if (m.Day == dayNdx && (m.TeamIds.Contains(tm1.Id) || m.TeamIds.Contains(tm2.Id)))
                            {
                                found = true;
                                break;
                            }
                        }
                        if (found == false)
                        {
                            match.Day = dayNdx;
                            break;
                        }
                    }

                    Dbg.Assert(match.Day != -1);

                    Matches.Add(match);


                    Dbg.Log(t1 + " vs " + t2 + " day: " + match.Day);
                }
            }
            Matches.Sort((x, y) => { return((x.Day < y.Day) ? -1 : ((x.Day > y.Day) ? 1 : 0)); });


            /*
             *
             * // this generates a full set of each team playing every other team once.
             * int[,] matchInfo = GenerateRoundRobin(numTeams);
             * NumDays = matchInfo.GetLength(1);
             * for (int teamIndex1 = 0; teamIndex1 < matchInfo.GetLength(0); teamIndex1++)
             * {
             * for (int round = 0; round < matchInfo.GetLength(1); round++)
             * {
             *  BS_Team t1 = PT_Game.League.Teams[teamIndex1];
             *  BS_Team t2 = PT_Game.League.Teams[matchInfo[teamIndex1, round]];
             *
             *  //TODO add support for multiple teams
             *  GM_IDList idList = new GM_IDList();
             *  idList.Add(t1.Id);
             *  idList.Add(t2.Id);
             *
             *  if (Matches.Find(FindMatch(idList, round)) == null)
             *  {
             *      BS_MatchParams match = new BS_MatchParams();
             *      match.Day = round;
             *      match.TeamIds = idList;
             *
             *      Matches.Add(match);
             *  }
             * }
             * }
             *
             * Matches.Sort((x, y) => { return (x.Day < y.Day) ? -1 : ((x.Day > y.Day) ? 1 : 0); });
             */
        }
Exemple #13
0
 public LG_SimMatchStartedEvent(BS_MatchParams match) : base(match)
 {
 }
Exemple #14
0
 public LG_SimMatchEndedEvent(BS_MatchParams match) : base(match)
 {
 }