Ejemplo n.º 1
0
 protected GameManager(DominoList dominos, params Player[] players)
 {
     _playerList.Clear();
     _playerList.AddPlayers(players);
     PublicTrain = new PublicTrain();
     _dominoList = dominos;
 }
Ejemplo n.º 2
0
        public static GameManager Init(params Player[] players)
        {
            DominoList list = new DominoList();

            foreach (var player in players)
            {
                player.SetPickList(list);
            }

            Instance = new GameManager(list, players);
            return(Instance);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates from config.
        /// </summary>
        /// <returns>The from config.</returns>
        /// <param name="game">Game.</param>
        public static GameManager CreateFromConfig(GameConfiguration game)
        {
            DominoList list = new DominoList(game.InitialDomino.ToDomino(),
                                             game.PickList.ToDominos());

            List <Player> allPlayers = new List <Player>();

            foreach (var p in game.Players)
            {
                IStrategy strategy  = Activator.CreateInstance(Type.GetType(p.Type)) as IStrategy;
                Player    newPlayer = new Player(p.Name, list, strategy);

                foreach (var d in p.Dominos)
                {
                    newPlayer.Pick(d.ToDomino());
                }

                allPlayers.Add(newPlayer);
            }

            GameManager.Init(list, allPlayers.ToArray());

            return(GameManager.Instance);
        }
Ejemplo n.º 4
0
 public static GameManager Init(DominoList dominos, params Player[] players)
 {
     Instance = new GameManager(dominos, players);
     return(Instance);
 }