//public Round Round { get; private set; }

        public GameRoom(string name, User leader)
        {
            if (leader.GameRoomRef != null)
            {
                throw new Exception(Constants.Instance.ErrorMessage.Is_In_Game_Room);
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                name = GenerateGameRoomName(leader);
            }
            Name = name;

            //be sure game room id is unique
            Id = EnergoServer.GenerateSmallUniqueId();
            //todo setup it according to map settings and also allow to set it in room settings
            MaxPlayers = EnergoServer.MaxPlayersInRoom;

            Players = new Dictionary <string, PlayerInRoom>();
            Players.Add(leader.Id, new PlayerInRoom(leader));
            Leader = leader;

            //todo push mapId here
            //maybe allow to change map (it means and max players too) when room already created?
            var mapId = string.Empty;
            //todo generate context somewhere else
            var gameContext = new GameContext(this, mapId);

            EnergoServer.Current.CreateGameRoom(leader, this);

            Stages = new StateBatch(gameContext)
                     .Add <CreateGameStage>()
                     .Add(new StateBatch(gameContext, context =>
                                         { return(context.Room.Stages.CurrentBatch.RoundNumber < 2); }) //it will re-run round 3 times
                          .Add <BuildPhase>())
                                                                                                        // .Add<ProduceEnergyPhase>())
                     .StartRound();
        }
Exemple #2
0
 public Phase(StateBatch container) : base(container)
 {
 }
 /// <summary>
 /// Add another batch to current batch. It means current batch is container for inner batch
 /// </summary>
 /// <param name="batch"></param>
 /// <returns></returns>
 public StateBatch Add(StateBatch batch)
 {
     batch._container = this;
     List.PushItem(batch);
     return(this);
 }
Exemple #4
0
 public State(StateBatch container)
 {
     _container = container;
     Clear();
 }
Exemple #5
0
 /// <summary>
 /// Stage will finished when there will be <userCount> users and every one will check their ready mark
 /// </summary>
 /// <param name="gameContext"></param>
 /// <param name="userCount"></param>
 public CreateGameStage(StateBatch container) : base(container)
 {
     readyMarks = new Dictionary <string, bool>();
 }
 public ProduceEnergyPhase(StateBatch container) : base(container)
 {
 }