コード例 #1
0
 /// <summary>
 /// Sets a reference to the game that the character is currently attached to
 /// </summary>
 /// <param name="toon"></param>
 /// <param name="curGame"></param>
 public static void SetCurrentGame(this ServerCharacterInfo toon, GameServerGame curGame)
 {
     toon.Properties.SetProperty("CurrentGame", curGame);
     toon.Properties.SetLocalFlag("CurrentGame", true);
 }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: kamilion/WISP
        public void SendMatchChangeNotificationToPlayers(MatchNotificationType kind, GameServerGame theGame, ServerCharacterInfo targetPlayer)
        {
            string text = "";
            switch (kind)
            {
                case MatchNotificationType.PlayerRemoved:
                    text = "Goodbye, " + targetPlayer.CharacterName;
                    break;
                case MatchNotificationType.PlayerAdded:
                    text = "Welcome, " + targetPlayer.CharacterName;
                    break;
                case MatchNotificationType.MatchEnded:
                    text = "Game '" + theGame.Name + "' ended.";
                    break;
            }

            theGame.SendMatchChangeNotificationToPlayers(kind, targetPlayer, text, false);
        }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: kamilion/WISP
        /// <summary>
        /// Adds a match to the GamesPerServerMap list of games that a particular server is tracking
        /// </summary>
        /// <param name="serverName">the name of the server to register this game under</param>
        /// <param name="game">the game to register</param>
        /// <param name="lockData">if the match data should be thread-synchronized.  set yes, if you know this method is called first in the stack (i.e. when you're calling it as a response to an inbound packet). Using the wrong will value will decrease performance as unnecessary thread Monitors will be set</param>
        public bool CreateNewGame(GameServerGame game, bool lockData)
        {
            if (lockData)
            {
                Monitor.Enter(MatchDataLock);
            }

            try
            {
                if (GameCreationRequest != null)
                {
                    if (!GameCreationRequest(game))
                    {
                        return false;
                    }
                }
                if (Games.ContainsKey(game.GameID))
                {
                    // hm. we already know about that game.  probably not great.
            #if DEBUG
                    throw new ArgumentException("Tried AddGameToServerTracking for a game that we alrady knew about.");
            #endif
                    return false;
                }

                Games.Add(game.GameID, game);
                m_TotalProjectedPlayerCount += (game.MaxPlayers + game.MaxObservers);
                Log1.Logger("Server").Debug("Padded connection count for server is now [" + m_TotalProjectedPlayerCount + "].");
                Log1.Logger("Server").Info("After adding this one, we are tracking [" + Games.Count.ToString() + " games] on this server now.");

                if(GameCreated!= null)
                {
                    GameCreated(game);
                }
            }
            catch
            {
                return false;
            }
            finally
            {
                if (lockData)
                {
                    Monitor.Exit(MatchDataLock);
                }
            }

            return true;
        }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: kamilion/WISP
 /// <summary>
 /// Gets the game, if this server knows about, regardless if it's local or not
 /// </summary>
 /// <param name="game">the id of the game we want to fetch</param>
 /// <param name="sg">the game, if we found it</param>
 /// <returns>true if we know about the game, false otherwise</returns>
 public bool GetGame(Guid game, out GameServerGame sg)
 {
     return Games.TryGetValue(game, out sg);
 }
コード例 #5
0
 protected virtual GameServerGame OnCreateNewGameServerGame(Game game)
 {
     GameServerGame g = new GameServerGame(game);
     game.Decorator = g;
     return g;
 }