Esempio n. 1
0
        public IGame Build(BuilderGameStrategy gameStrategy, BuilderMapStrategy mapStrategy, List<Tuple<string, FactionName>> playersInfo)
        {
            LastBuilderGameStrategy = gameStrategy;
            LastBuilderMapStrategy = mapStrategy;

            List<Player> players = BuildPlayers(playersInfo);
            IGame game = null;

            switch (gameStrategy)
            {
                case BuilderGameStrategy.Local:
                    game = new LocalGame(BuildMap(mapStrategy, 0), players);
                    break;

                case BuilderGameStrategy.Server:
                    game = new ServerGame(BuildMap(mapStrategy, 0), players);
                    break;

                case BuilderGameStrategy.Client:
                    game = new ClientGame(null, players);
                    break;

                default:
                    throw new NotImplementedException();
            }
            return game;
        }
Esempio n. 2
0
        /// <summary>
        /// Creation of a new game
        /// </summary>
        /// <param name="gameStrategy"></param>
        /// <param name="mapStrategy"></param>
        public void NewGame(BuilderGameStrategy gameStrategy, BuilderMapStrategy mapStrategy, List<Tuple<string, FactionName>> listFaction)
        {
            GM.NewGame(gameStrategy, mapStrategy, listFaction);

            // Subscribe to Game events
            GM.CurrentGame.OnStartGame += OnStartGame;
            GM.CurrentGame.OnNextPlayer += OnNextPlayer;
            GM.CurrentGame.OnEndGame += OnEndGame;
            GM.CurrentGame.OnMoveUnit += OnMoveUnit;
            GM.CurrentGame.OnAttackUnit += OnAttackUnit;
            GM.CurrentGame.OnNewChatMessage += OnNewChatMessage;

            // Subscribe to Media event
            this.MediaPlayer.MediaEnded += OnMediaEnded;

            // GUI
            this.btnEndGame.Visibility = Visibility.Collapsed;
            this.btnNextPlayer.Visibility = Visibility.Visible;
            this.btnNextPlayer.Content = "Start Game !";

            if (MapView != null)
                MapView.MapViewGrid.Children.RemoveRange(0, MapView.MapViewGrid.Children.Count);
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new game (map, players...)
        /// </summary>
        public void NewGame(BuilderGameStrategy gameStrategy, BuilderMapStrategy mapStrategy, List<Tuple<string, FactionName>> playersInfo)
        {
            if (CurrentGame != null)
                DestroyGame();

            CurrentGame = GameBuilder.Build(gameStrategy, mapStrategy, playersInfo);
        }