Ejemplo n.º 1
0
        public HFTGame AddPlayerToGame(HFTPlayer player, string gameId, object data)
        {
            HFTGameGroup gameGroup = GetGameGroup(gameId);

            if (gameGroup == null)
            {
                return(null);
            }
            return(gameGroup.AddPlayer(player, data));
        }
Ejemplo n.º 2
0
        public HFTGame(string id, HFTGameGroup group, HFTRuntimeOptions options)
        {
            id_        = id;
            gameGroup_ = group;
            options_   = options;

            SetGameId();

            log_ = new HFTLog("HFTGame[" + gameId_ + "]");
            log_.Info("created game");
        }
Ejemplo n.º 3
0
        public void AssignAsClientForGame(HFTRuntimeOptions data, HFTSocket client)
        {
            string       gameId    = String.IsNullOrEmpty(data.gameId) ? "HFTUnity" : data.gameId;
            HFTGameGroup gameGroup = GetGameGroup(gameId, true);

            if (!gameGroup.HasClient())
            {
                ++gameCount_;
            }
            gameGroup.AssignClient(client, data);
        }
Ejemplo n.º 4
0
        public HFTGameGroup GetGameGroup(string gameId, bool makeGroup = false)
        {
            HFTGameGroup gameGroup = null;

            if (String.IsNullOrEmpty(gameId))
            {
                log_.Error("no game id");
            }
            else
            {
                if (!gameGroups_.TryGetValue(gameId, out gameGroup))
                {
                    if (makeGroup)
                    {
                        gameGroup           = new HFTGameGroup(gameId, this);
                        gameGroups_[gameId] = gameGroup;
                        log_.Info("added game group: " + gameId + ", num game groups = " + gameGroups_.Count);
                    }
                }
            }
            return(gameGroup);
        }
Ejemplo n.º 5
0
 public HFTGameGroup GetGameGroup(string gameId, bool makeGroup = false)
 {
     HFTGameGroup gameGroup = null;
     if (String.IsNullOrEmpty(gameId))
     {
         log_.Error("no game id");
     }
     else
     {
         if (!gameGroups_.TryGetValue(gameId, out gameGroup))
         {
             if (makeGroup)
             {
                 gameGroup = new HFTGameGroup(gameId, this);
                 gameGroups_[gameId] = gameGroup;
                 log_.Info("added game group: " + gameId + ", num game groups = " + gameGroups_.Count);
             }
         }
     }
     return gameGroup;
 }