예제 #1
0
        private void LoadGameConfig()
        {
            if (string.IsNullOrWhiteSpace(GameId) || !_manager.Games.ContainsKey(GameId))
            {
                return;
            }

            GameBase game = _manager.GetGame(GameId);

            if (game != null)
            {
                Options = game.Options;
                return;
            }

            Options = new List <GameOption>();
            return;
        }
예제 #2
0
        public GameSession(GameServer server, GameBase game)
        {
            StartedAt    = DateTime.UtcNow;
            Server       = server;
            Game         = game;
            Game.Options = server.Options;
            Options      = server.Options;
            Players      = game.OnBuildPlayers(server.Players);
            Criteria     = game.OnBuildRules(Players);
            Actions      = game.OnBuildActions(Players);

            // base game actions required
            Actions.Add(new GameAction
            {
                Id = "end",
                UpdateOnExecute = true,
                OnExecute       = delegate(GameContext ctx)
                {
                    ctx.Session.State = SessionState.Finish;
                    ctx.Server.EndCurrentSession();
                }
            });

            Actions.Add(new GameAction
            {
                Id = "destroy",
                UpdateOnExecute = true,
                OnExecute       = delegate
                {
                    Server.DestroyCurrentSession();
                }
            });

            Properties = game.OnBuildProperties();
            Server.Broadcasts.AddRange(game.OnBuildBroadcasts(Players));
            ActivityDisplay = "Playing a game";
        }