Example #1
0
        public Map BuildMap(BuilderMapStrategy mapStrategy, int randomSeed)
        {
            IMapBuilder mapBuilder;
            switch (mapStrategy)
            {
                case BuilderMapStrategy.Demo:
                    mapBuilder = new DemoMapBuilder();
                    break;

                case BuilderMapStrategy.Small:
                    mapBuilder = new SmallMapBuilder();
                    break;

                case BuilderMapStrategy.Normal:
                    mapBuilder = new NormalMapBuilder();
                    break;

                default:
                    throw new NotImplementedException();
            }

            Map map = mapBuilder.Build(randomSeed);

            return map;
        }
Example #2
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;
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
0
 private void btnSmall_Click(object sender, RoutedEventArgs e)
 {
     this.mapChosen = BuilderMapStrategy.Small;
     this.AnyButtonClick();
 }