public ReqTowerBtlComEnd(long btlid, Unit[] Player, Unit[] Enemy, int actCount, int round, byte floor, BtlResultTypes result, RandDeckResult[] deck, Network.ResponseCallback response, string trophyprog = null, string bingoprog = null, string maxdata = null) { StringBuilder stringBuilder = WebAPI.GetStringBuilder(); this.name = "tower/btl/end"; stringBuilder.Length = 0; this.SetValue(ref stringBuilder, "\"btlid\":", btlid); stringBuilder.Append("\"btlendparam\":{"); if (Player != null) { stringBuilder.Append("\"pdeck\":["); for (int index = 0; index < Player.Length; ++index) { Unit unit = Player[index]; if (unit.Side == EUnitSide.Player && unit.UnitData.UniqueID != 0L) { stringBuilder.Append("{"); this.SetValue(ref stringBuilder, "\"iid\":", unit.UnitData.UniqueID); this.SetValue(ref stringBuilder, "\"iname\":\"", unit.UnitData.UnitParam.iname, "\","); int num = Mathf.Max(unit.CalcTowerDamege() - MonoSingleton <GameManager> .Instance.FindTowerFloor(SceneBattle.Instance.Battle.QuestID).CalcHelaNum((int)unit.MaximumStatus.param.hp), 0); this.SetValue(ref stringBuilder, "\"damage\":", (long)num); this.SetValue(ref stringBuilder, "\"is_died\":", !unit.IsDeadCondition() ? 0L : 1L, string.Empty); stringBuilder.Append("},"); } } --stringBuilder.Length; stringBuilder.Append("],"); } stringBuilder.Append("\"status\":\""); switch (result) { case BtlResultTypes.Win: stringBuilder.Append("win"); break; case BtlResultTypes.Lose: stringBuilder.Append("lose"); break; case BtlResultTypes.Retire: stringBuilder.Append("retire"); break; case BtlResultTypes.Cancel: stringBuilder.Append("cancel"); break; } stringBuilder.Append("\""); stringBuilder.Append(",\"turn\":"); stringBuilder.Append(actCount); stringBuilder.Append(",\"round\":"); stringBuilder.Append(round); stringBuilder.Append(",\"floor\":"); stringBuilder.Append(floor); if (result == BtlResultTypes.Lose) { stringBuilder.Append(",\"edeck\":["); List <Unit> unitList = new List <Unit>((IEnumerable <Unit>)Enemy); if (MonoSingleton <GameManager> .Instance.TowerResuponse.edeck != null) { List <TowerResuponse.EnemyUnit> edeck = MonoSingleton <GameManager> .Instance.TowerResuponse.edeck; int index1 = 0; for (int index2 = 0; index2 < edeck.Count; ++index2) { if (edeck[index2].hp == 0) { stringBuilder.Append("{"); this.SetValue(ref stringBuilder, "\"eid\":\"", (long)index2, "\","); this.SetValue(ref stringBuilder, "\"iname\":\"", edeck[index2].iname, "\","); this.SetValue(ref stringBuilder, "\"hp\":", 0L); this.SetValue(ref stringBuilder, "\"jewel\":", 0L, string.Empty); stringBuilder.Append("},"); } else { Unit unit = unitList[index1]; ++index1; stringBuilder.Append("{"); this.SetValue(ref stringBuilder, "\"eid\":\"", (long)index2, "\","); this.SetValue(ref stringBuilder, "\"iname\":\"", unit.UnitParam.iname, "\","); if (unit.IsGimmick && !unit.IsDisableGimmick()) { if (unit.IsBreakObj) { this.SetValue(ref stringBuilder, "\"hp\":", (long)(int)unit.CurrentStatus.param.hp); } else { this.SetValue(ref stringBuilder, "\"hp\":", 1L); } } else { this.SetValue(ref stringBuilder, "\"hp\":", !unit.IsDead ? (long)(int)unit.CurrentStatus.param.hp : 0L); } this.SetValue(ref stringBuilder, "\"jewel\":", (long)(int)unit.CurrentStatus.param.mp, string.Empty); stringBuilder.Append("},"); } } } else { for (int index = 0; index < unitList.Count; ++index) { Unit unit = unitList[index]; stringBuilder.Append("{"); this.SetValue(ref stringBuilder, "\"eid\":\"", (long)index, "\","); this.SetValue(ref stringBuilder, "\"iname\":\"", unit.UnitParam.iname, "\","); if (unit.IsGimmick && !unit.IsDisableGimmick()) { if (unit.IsBreakObj) { this.SetValue(ref stringBuilder, "\"hp\":", (long)(int)unit.CurrentStatus.param.hp); } else { this.SetValue(ref stringBuilder, "\"hp\":", 1L); } } else { this.SetValue(ref stringBuilder, "\"hp\":", !unit.IsDead ? (long)(int)unit.CurrentStatus.param.hp : 0L); } this.SetValue(ref stringBuilder, "\"jewel\":", (long)(int)unit.CurrentStatus.param.mp, string.Empty); stringBuilder.Append("},"); } } --stringBuilder.Length; stringBuilder.Append("]"); } SupportData supportData = GlobalVars.SelectedSupport.Get(); if (GlobalVars.SelectedFriendID != null && supportData != null) { stringBuilder.Append(",\"help\":{\"fuid\":\""); stringBuilder.Append(GlobalVars.SelectedFriendID); stringBuilder.Append("\",\"cost\":"); stringBuilder.Append(supportData.Cost); stringBuilder.Append("}"); } stringBuilder.Append("}"); if (!string.IsNullOrEmpty(trophyprog)) { stringBuilder.Append(","); stringBuilder.Append(trophyprog); } if (!string.IsNullOrEmpty(bingoprog)) { stringBuilder.Append(","); stringBuilder.Append(bingoprog); } if (!string.IsNullOrEmpty(maxdata)) { stringBuilder.Append(","); stringBuilder.Append(maxdata); } this.body = WebAPI.GetRequestString(stringBuilder.ToString()); this.callback = response; }
public ReqRankMatchRanking(Network.ResponseCallback response) { this.name = "vs/rankmatch/ranking"; this.body = WebAPI.GetRequestString(string.Empty); this.callback = response; }
public void ExecRequest(WebAPI api) { Network.RequestAPI(api, false); this.mStateMachine = new StateMachine <FlowNode_Network>(this); this.mStateMachine.GotoState <FlowNode_Network.State_WaitForConnect>(); }
public ReqBtlComEnd(long btlid, int time, BtlResultTypes result, int[] beats, int[] itemSteals, int[] goldSteals, int[] missions, string[] fuid, Dictionary <OString, OInt> usedItems, Network.ResponseCallback response, BtlEndTypes apiType, string trophyprog = null, string bingoprog = null, string maxdata = null) { StringBuilder stringBuilder = WebAPI.GetStringBuilder(); stringBuilder.Append("btl/"); stringBuilder.Append(apiType.ToString()); stringBuilder.Append("/end"); this.name = stringBuilder.ToString(); stringBuilder.Length = 0; stringBuilder.Append("\"btlid\":"); stringBuilder.Append(btlid); stringBuilder.Append(','); stringBuilder.Append("\"btlendparam\":{"); stringBuilder.Append("\"time\":"); stringBuilder.Append(time); stringBuilder.Append(','); stringBuilder.Append("\"result\":\""); switch (result) { case BtlResultTypes.Win: stringBuilder.Append("win"); break; case BtlResultTypes.Lose: stringBuilder.Append("lose"); break; case BtlResultTypes.Retire: stringBuilder.Append("retire"); break; case BtlResultTypes.Cancel: stringBuilder.Append("cancel"); break; } if (result == BtlResultTypes.Win) { if (beats == null) { beats = new int[0]; } if (itemSteals == null) { itemSteals = new int[0]; } if (goldSteals == null) { goldSteals = new int[0]; } if (missions == null) { missions = new int[3]; } } if (result != BtlResultTypes.Cancel && usedItems == null) { usedItems = new Dictionary <OString, OInt>(); } stringBuilder.Append("\","); if (beats != null) { stringBuilder.Append("\"beats\":["); for (int index = 0; index < beats.Length; ++index) { if (index > 0) { stringBuilder.Append(','); } stringBuilder.Append(beats[index].ToString()); } stringBuilder.Append("],"); } if (itemSteals != null || goldSteals != null) { stringBuilder.Append("\"steals\":{"); if (itemSteals != null) { stringBuilder.Append("\"items\":["); for (int index = 0; index < itemSteals.Length; ++index) { stringBuilder.Append(itemSteals[index].ToString()); if (index != beats.Length - 1) { stringBuilder.Append(','); } } stringBuilder.Append("]"); } if (goldSteals != null) { if (itemSteals != null) { stringBuilder.Append(','); } stringBuilder.Append("\"golds\":["); for (int index = 0; index < goldSteals.Length; ++index) { stringBuilder.Append(goldSteals[index].ToString()); if (index != beats.Length - 1) { stringBuilder.Append(","); } } stringBuilder.Append("]"); } stringBuilder.Append("},"); } if (missions != null) { stringBuilder.Append("\"missions\":["); for (int index = 0; index < missions.Length; ++index) { if (index > 0) { stringBuilder.Append(','); } stringBuilder.Append(missions[index].ToString()); } stringBuilder.Append("],"); } if (usedItems != null) { stringBuilder.Append("\"inputs\":["); int num = 0; using (Dictionary <OString, OInt> .Enumerator enumerator = usedItems.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <OString, OInt> current = enumerator.Current; if (num > 0) { stringBuilder.Append(','); } stringBuilder.Append("{"); stringBuilder.Append("\"use\":\""); stringBuilder.Append((string)current.Key); stringBuilder.Append("\","); stringBuilder.Append("\"n\":"); stringBuilder.Append((int)current.Value); stringBuilder.Append("}"); ++num; } } stringBuilder.Append("],"); } if (apiType == BtlEndTypes.multi) { stringBuilder.Append("\"token\":\""); stringBuilder.Append(JsonEscape.Escape(GlobalVars.SelectedMultiPlayRoomName)); stringBuilder.Append("\","); } if ((int)stringBuilder[stringBuilder.Length - 1] == 44) { --stringBuilder.Length; } stringBuilder.Append('}'); if (apiType == BtlEndTypes.multi && fuid != null) { stringBuilder.Append(",\"fuids\":["); for (int index = 0; index < fuid.Length; ++index) { if (fuid[index] != null) { if (index != 0) { stringBuilder.Append(", "); } stringBuilder.Append("\""); stringBuilder.Append(fuid[index]); stringBuilder.Append("\""); } } stringBuilder.Append("]"); } if (!string.IsNullOrEmpty(trophyprog)) { stringBuilder.Append(","); stringBuilder.Append(trophyprog); } if (!string.IsNullOrEmpty(bingoprog)) { stringBuilder.Append(","); stringBuilder.Append(bingoprog); } if (!string.IsNullOrEmpty(maxdata)) { stringBuilder.Append(","); stringBuilder.Append(maxdata); } this.body = WebAPI.GetRequestString(stringBuilder.ToString()); this.callback = response; }
public void BeginBingoReqString() { this.is_begin = true; this.sb = WebAPI.GetStringBuilder(); this.sb.Append("\"bingoprogs\":["); }