private void dataSnapshotToleaderboardEntries() { for (int i = 1; i <= 10; i++) { IDataSnapshot snapshot = shot.Child(i.ToString()); leaderboardEntries [i - 1].name = snapshot.Child("Name").StringValue; leaderboardEntries [i - 1].score = int.Parse(snapshot.Child("Score").StringValue); } }
public Painting(IDataSnapshot data) { decimal tempPrice = 0m; this.ID = data.Key; this.Artist = data.Child("artist").Value(); this.ImageSource = data.Child("imgSrc").Value(); decimal.TryParse(data.Child("price").Value(), out tempPrice); this.Price = tempPrice; this.Title = data.Child("title").Value(); }
private void getPlayer_Battle_EnemyId() { FireBase_battlelist = Firebase.CreateNew(FIRE_BASE_HOST + BATTLE_LIST); playerId = System.Guid.NewGuid().ToString(); //IFirebase FireBase_battle = FireBase_battlelist.Push(); //battleId = FireBase_battle.Key; Logger.gameControl("getPlayer_Battle_EnemyId playerId {0}, battleId {1}", playerId, BATTLE_ID); FireBase_battlelist.ChildAdded += (object sender, ChangedEventArgs e) => { IDataSnapshot dataSnap = e.DataSnapshot; Logger.gameControl("FireBase_battlelist ChildAdded {0}, {1}", dataSnap.Key, dataSnap.StringValue); }; battlelistvalueUpdateEventHandler = (object sender, ChangedEventArgs e) => { IDataSnapshot dataSnap = e.DataSnapshot; Logger.gameControl("FireBase_battlelist ValueUpdated {0}, {1}", dataSnap.Key, dataSnap.StringValue); try { Dictionary <string, object> dic = dataSnap.DictionaryValue; object temp = null; bool findBattleId = false; foreach (string battleId in dic.Keys) { if (battleId.Contains("skip")) { continue; } //dic.TryGetValue(battleId, out temp); string status = dataSnap.Child(battleId).Child(BATTLE_STATUS).StringValue; Logger.gameControl("FireBase_battlelist ValueUpdated {0}, {1}", battleId, status); if (BATTLE_STATUS_WAITING.Equals(status)) { dataSnap.Child(battleId).Ref.Child(playerId).SetValue(playerId); dataSnap.Child(battleId).Child(BATTLE_STATUS).Ref.SetValue(BATTLE_STATUS_FIGHTING); BATTLE_ID = battleId; findBattleId = true; break; } //Dictionary<string, object> battlevalue = (Dictionary<string, object>)temp; //object temp2 = null; //foreach (string battleinfo in battlevalue.Keys) //{ // if ("status".Equals(battleinfo)) // { // battlevalue.TryGetValue(battleId, out temp2); // } //} } if (!findBattleId) { IFirebase ref_battle = FireBase_battlelist.Push(); BATTLE_ID = ref_battle.Key; ref_battle.Child(playerId).SetValue(playerId); ref_battle.Child(BATTLE_STATUS).SetValue(BATTLE_STATUS_WAITING); } FireBase_battlelist.ValueUpdated -= battlelistvalueUpdateEventHandler; getEnemyId(); } catch (Exception ex) { Debug.Log(ex.Message); } }; FireBase_battlelist.ValueUpdated += battlelistvalueUpdateEventHandler; FireBase_battlelist.ChildChanged += (object sender, ChangedEventArgs e) => { IDataSnapshot dataSnap = e.DataSnapshot; Logger.gameControl("FireBase_battlelist ChildChanged {0}, {1}", dataSnap.Key, dataSnap.StringValue); }; }