public void PickFromBox(string group, string setName, string box, string payment, System.Action <string, GachaPickResult> onComplete) { GachaSet set = null; if (this._sets.TryGetValue(group, out set) == true) { if (set.Name != setName) { set = null; } } else { set = null; } if (set != null) { this._api.PickFromBox(group, set.Version, set.Name, box, payment, delegate(string error, Hashtable data){ if (data != null) { GachaPickResult pickResult = new GachaPickResult(data); if (pickResult.Items.Length > 0) { if (payment == "token") { int balance = EB.Dot.Integer("balance", data, -1); if (balance != -1) { this._tokens[box] = balance; } } onComplete(null, pickResult); } else { string errMsg = (error != null) ? error : string.Format("Couldn't afford the Gacha Spin {0}-{1}", box, payment); EB.Debug.LogError(errMsg); onComplete(errMsg, null); } } else { EB.Debug.LogError("Server responded with error to Gacha Pick: '{0}'", error); onComplete(error, null); } }); } else { string error = string.Format("Requested a pick on an unknown set: {0}", setName); EB.Debug.LogError(error); onComplete(error, null); } }
public GachaSet GetGachaSet(string name) { GachaSet gachaSet = null; if (this._sets.TryGetValue(name, out gachaSet) == false) { gachaSet = null; } return(gachaSet); }
private void OnFetchSets(string error, Hashtable data) { if (string.IsNullOrEmpty(error) == true) { if (data != null) { foreach (string group in this._config.Groups) { Hashtable groupData = data[group] as Hashtable; if (groupData != null) { GachaSet gachaSet = new GachaSet(groupData); if (gachaSet.IsValid == true) { this._sets[group] = gachaSet; } else { EB.Debug.LogError("GachaManager.OnSetFetch Group {0} was inproperly formatted from the server", group); State = SubSystemState.Error; } } } } this._setsComplete = true; } else { EB.Debug.LogError("GachaManager.OnFetchSets got Error:{0}", error); State = SubSystemState.Error; } if (State == SubSystemState.Connecting) { if ((this._initialTokensComplete == true) && (this._setsComplete == true)) { State = SubSystemState.Connected; } } }