コード例 #1
0
 public virtual void RegisterGame(IemGame game)
 {
     if (!games.Contains(game))
     {
         games.Add(game);
     }
 }
コード例 #2
0
            // player who is requesting the game, if its a solo, individual game
            public virtual IemGame SendPlayerToGameManager(BasePlayer player, string level = null)
            {
                IemGame currentGame = null;

                foreach (IemGameBase.IemGame game in games)
                {
                    if (game.CurrentState == IemUtils.State.Before)
                    {
                        me.Puts("existing game in before state");
                        if (game is IemSoloGame)
                        {
                            if (((IemSoloGame)game).UserIDString == player.UserIDString)
                            {
                                currentGame = game;
                            }
                        }
                        else if (game is IemTeamGame)
                        {
                            currentGame = game;
                            ((IemTeamGame)currentGame).SendPlayerToGame(player);
                        }
                    }
                    else if (game.CurrentState == IemUtils.State.Running ||
                             game.CurrentState == IemUtils.State.Paused)
                    {
                        // TODO this exists for the purpose of handling
                        // sending a player back to game they are already in
                        me.Puts("existing game running or paused");
                        if (game is IemSoloGame)
                        {
                            if (((IemSoloGame)game).UserIDString == player.UserIDString)
                            {
                                currentGame = game;
                            }
                        }
                        else if (game is IemTeamGame)
                        {
                            currentGame = game;
                        }
                    }
                    else if (game.CurrentState == IemUtils.State.Complete ||
                             game.CurrentState == IemUtils.State.Cancelled)
                    {
                    }
                }

                if (currentGame == null)
                {
                    //get a new game from the GM implementation
                    currentGame = CreateGame(player, level);
                    RegisterGame(currentGame);
                }
                return(currentGame);
            }