Ejemplo n.º 1
0
 public override bool Handle(OperationResponse operationResponse)
 {
     if (base.Handle(operationResponse))
     {
         long[] facebookIDs            = (long[])operationResponse.Parameters[(byte)GetHarvestPlayerListResponseParameterCode.FacebookIDArray];
         int[]  levels                 = (int[])operationResponse.Parameters[(byte)GetHarvestPlayerListResponseParameterCode.LevelArray];
         int[]  harvestableCakeNumbers = (int[])operationResponse.Parameters[(byte)GetHarvestPlayerListResponseParameterCode.HarvestableCakeNumberArray];
         HarvestPlayerInfo[] infos     = new HarvestPlayerInfo[facebookIDs.Length];
         for (int i = 0; i < facebookIDs.Length; i++)
         {
             infos[i].facebookID            = facebookIDs[i];
             infos[i].level                 = levels[i];
             infos[i].harvestableCakeNumber = harvestableCakeNumbers[i];
         }
         IANTGame.ResponseManager.FetchDataResponseManager.CallGetHarvestPlayerListResponse(infos);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
 public HarvestPlayerInfo FetchHarvestPlayerInfoWithFacebookID(long facebookID)
 {
     try
     {
         HarvestPlayerInfo info = new HarvestPlayerInfo();
         if (connection.State == System.Data.ConnectionState.Closed)
         {
             connection.Open();
         }
         using (MySqlCommand cmd = new MySqlCommand("SELECT FacebookID, Level, CakeCount FROM player WHERE FacebookID = @fbid LIMIT 1", connection))
         {
             cmd.Parameters.AddWithValue("@fbid", facebookID);
             using (MySqlDataReader reader = cmd.ExecuteReader())
             {
                 if (reader.Read())
                 {
                     info.facebookID            = reader.GetInt64(0);
                     info.level                 = reader.GetInt32(1);
                     info.harvestableCakeNumber = reader.GetInt32(2) / 2;
                 }
                 return(info);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         if (connection.State == System.Data.ConnectionState.Open)
         {
             connection.Close();
         }
     }
 }
Ejemplo n.º 3
0
 private void OnGetHarvestPlayerListResponseAction(HarvestPlayerInfo[] infos)
 {
     for (int i = 0; i < infos.Length; i++)
     {
         if (playerInfoDictionary.ContainsKey(infos[i].facebookID))
         {
             playerInfoDictionary[infos[i].facebookID] = new HarvestPlayerInfo
             {
                 facebookID            = infos[i].facebookID,
                 photo                 = playerInfoDictionary[infos[i].facebookID].photo,
                 name                  = playerInfoDictionary[infos[i].facebookID].name,
                 level                 = infos[i].level,
                 harvestableCakeNumber = infos[i].harvestableCakeNumber
             };
         }
         else
         {
             long fbID = infos[i].facebookID;
             playerInfoDictionary.Add(fbID, infos[i]);
             facebookAction.GetUserName(fbID, (result) =>
             {
                 if (result != null)
                 {
                     HarvestPlayerInfo info = playerInfoDictionary[fbID];
                     if (result.ResultDictionary.ContainsKey("name"))
                     {
                         playerInfoDictionary[fbID] = new HarvestPlayerInfo
                         {
                             facebookID            = fbID,
                             photo                 = info.photo,
                             name                  = (string)result.ResultDictionary["name"],
                             level                 = info.level,
                             harvestableCakeNumber = info.harvestableCakeNumber
                         };
                         harvestModePanelUI.UpdateHarvestPlayerList(playerInfoDictionary.Values.ToList());
                     }
                 }
             });
             facebookAction.GetUserPhoto(fbID, (result) =>
             {
                 if (string.IsNullOrEmpty(result.Error) && result.Texture != null)
                 {
                     HarvestPlayerInfo info = playerInfoDictionary[fbID];
                     if (result.Texture != null)
                     {
                         playerInfoDictionary[fbID] = new HarvestPlayerInfo
                         {
                             facebookID            = fbID,
                             photo                 = result.Texture,
                             name                  = info.name,
                             level                 = info.level,
                             harvestableCakeNumber = info.harvestableCakeNumber
                         };
                         harvestModePanelUI.UpdateHarvestPlayerList(playerInfoDictionary.Values.ToList());
                     }
                 }
             });
         }
     }
     harvestModePanelUI.UpdateHarvestPlayerList(playerInfoDictionary.Values.ToList());
 }