Exemplo n.º 1
0
 public LobbyState()
 {
     Players         = new System.Collections.Generic.List <string>(GameManager.CpuPlayers);
     _readyPlayers   = new HashSet <string>();
     Spec            = new GameSpec();
     Spec.Players    = GameManager.CpuPlayers;
     Spec.Game       = GameType.Taenkeboks;
     Spec.Taenkeboks = TbGameSpecModule.initClassicTournament(Spec.Players.Length);
 }
Exemplo n.º 2
0
        public GameTask CreateGame(GameSpec spec)
        {
            PlayerSpec[] playerSpecs = spec.Players.Select(pn => new PlayerSpec()
            {
                PlayerName = pn,
                PlayerType = CpuPlayers.Contains(pn) ? PlayerType.Cpu : PlayerType.Async
            }).ToArray();
            GameTask game;

            switch (spec.Game)
            {
            case GameType.Taenkeboks:
                game = new GameTask(spec.Taenkeboks, playerSpecs);
                break;

            default:
                throw new Exception("Unknown game type");
            }
            _games[game.Id] = game;
            var gameTask = game.Start();//the task will end when game is completed or game.Stop() is called by cleanup task

            return(game);
        }
Exemplo n.º 3
0
        //public void UnReadyPlayer(string player)
        //{
        //    var pix = Players.IndexOf(player);
        //    if (!Ready[pix])
        //        return;
        //    Ready[pix] = false;
        //    Update();
        //}

        public void UpdateSpec(GameSpec spec)
        {
            Spec = spec;
            Update();
        }
Exemplo n.º 4
0
 //public void ReadyPlayer(string name) => _state.ReadyPlayer(name);
 //public void UnreadyPlayer(string name) => _state.UnReadyPlayer(name);
 public void UpdateSpec(GameSpec spec) => _state.UpdateSpec(spec);