/// <summary> /// 判断战斗胜负决定是否禁用战斗对应的事件 /// </summary> /// <param name="win">If set to <c>true</c> window.</param> public void ReleaseDisableEvent(bool win) { if (handleDisableEvent == null) { return; } if (win) { //如果是通天塔最后一场战斗胜利则提醒玩家胜利返回城镇并且刷新通天塔 if (handleDisableEvent.EventId == "10310020" || handleDisableEvent.EventId == "10310021" || handleDisableEvent.EventId == "10310022") { ClearDisableEventIdMapping(); AlertCtrl.Show("成功闯到通天塔顶层,塔身剧烈震动,赶紧撤退!", () => { Messenger.Broadcast(NotifyTypes.BackToCity); }); } else { PushDisableEvent(handleDisableEvent.Id, handleDisableEvent); } } handleDisableEvent = null; }
/// <summary> /// 发送Http请求 /// </summary> /// <param name="url">URL.</param> /// <param name="param">Parameter.</param> /// <param name="callback">Callback.</param> /// <param name="errorCallback">Error callback.</param> public static void Post(string url, JObject param, System.Action <string> callback = null, System.Action errorCallback = null) { try { // var json = "{ 'receipt-data': '" + receiptData + "'}"; var json = param.ToString(); #if UNITY_EDITOR Debug.LogWarning("Http 上行: url = " + url + ", " + JsonManager.GetInstance().SerializeObject(json)); #endif System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding(); byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(json); System.Net.ServicePointManager.ServerCertificateValidationCallback = myRemoteCertificateValidationCallback; // HttpWebRequest request; var request = System.Net.HttpWebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = postBytes.Length; //Stream postStream = request.GetRequestStream(); //postStream.Write(postBytes, 0, postBytes.Length); //postStream.Close(); using (var stream = request.GetRequestStream()) { stream.Write(postBytes, 0, postBytes.Length); stream.Flush(); } // var sendresponse = (HttpWebResponse)request.GetResponse(); var sendresponse = request.GetResponse(); string sendresponsetext = ""; using (var streamReader = new System.IO.StreamReader(sendresponse.GetResponseStream())) { sendresponsetext = streamReader.ReadToEnd().Trim(); streamReader.Close(); streamReader.Dispose(); } #if UNITY_EDITOR Debug.LogWarning("Http 下行: url = " + url + ", " + sendresponsetext); #endif if (callback != null) { callback(sendresponsetext); } } catch (System.Exception ex) { LoadingBlockCtrl.Hide(); AlertCtrl.Show(ex.Message.ToString()); if (errorCallback != null) { errorCallback(); } SendEvent("HttpErro", ex.Message.ToString(), DbManager.Instance.HostData.Name); } }
void Start() { PlayBgm(); Messenger.Broadcast <AreaTarget, AreaMain>(NotifyTypes.AreaInit, areaTarget, this); RebuildDisableEvents(); if (!string.IsNullOrEmpty(PlayerPrefs.GetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id))) { AlertCtrl.Show("之前与对手的交锋将继续", () => { Messenger.Broadcast <string>(NotifyTypes.CreateBattle, PlayerPrefs.GetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id)); }, "动手"); } MaiHandler.CheckReceipt(); //内购补单 }
/// <summary> /// 检测是否有没有提交的充值成功请求 /// </summary> public static void UnlockProducts(string proId) { if (!string.IsNullOrEmpty(proId)) { string orderId; switch (proId) { case price6: DbManager.Instance.GotSilver(50000); Messenger.Broadcast <string>(NotifyTypes.GetStorePanelData, UserModel.CurrentUserData.CurrentCitySceneId); AlertCtrl.Show("银子 +50000"); orderId = Statics.GetNowTimeStamp().ToString(); TDGAVirtualCurrency.OnChargeRequest(orderId, price6, 6, "CH", 6, "iap"); TDGAVirtualCurrency.OnChargeSuccess(orderId); addPay(6); //记录充值 break; case price18: DbManager.Instance.GotSilver(200000); Messenger.Broadcast <string>(NotifyTypes.GetStorePanelData, UserModel.CurrentUserData.CurrentCitySceneId); AlertCtrl.Show("银子 +200000"); orderId = Statics.GetNowTimeStamp().ToString(); TDGAVirtualCurrency.OnChargeRequest(orderId, price18, 18, "CH", 18, "iap"); TDGAVirtualCurrency.OnChargeSuccess(orderId); addPay(18); //记录充值 break; case prop1: PropItemContainer.SendRewards(PropType.NocturnalClothing, 10); // IOSNativePopUpManager.showMessage("提示", "获得了10件夜行衣"); orderId = Statics.GetNowTimeStamp().ToString(); TDGAVirtualCurrency.OnChargeRequest(orderId, prop1, 1, "CH", 1, "iap"); TDGAVirtualCurrency.OnChargeSuccess(orderId); addPay(1); //记录充值 break; case prop3: PropItemContainer.SendRewards(PropType.Bodyguard, 10); // IOSNativePopUpManager.showMessage("提示", "获得了10位镖师"); orderId = Statics.GetNowTimeStamp().ToString(); TDGAVirtualCurrency.OnChargeRequest(orderId, prop3, 1, "CH", 1, "iap"); TDGAVirtualCurrency.OnChargeSuccess(orderId); addPay(1); //记录充值 break; case prop4: PropItemContainer.SendRewards(PropType.LimePowder, 10); // IOSNativePopUpManager.showMessage("提示", "获得了10包石灰粉"); orderId = Statics.GetNowTimeStamp().ToString(); TDGAVirtualCurrency.OnChargeRequest(orderId, prop4, 1, "CH", 1, "iap"); TDGAVirtualCurrency.OnChargeSuccess(orderId); addPay(1); //记录充值 break; case prop5: PropItemContainer.SendRewards(PropType.Scout, 10); // IOSNativePopUpManager.showMessage("提示", "获得了10个探子"); orderId = Statics.GetNowTimeStamp().ToString(); TDGAVirtualCurrency.OnChargeRequest(orderId, prop5, 1, "CH", 1, "iap"); TDGAVirtualCurrency.OnChargeSuccess(orderId); addPay(1); //记录充值 break; case worker10: DbManager.Instance.SetPlusWorkerNum(DbManager.Instance.GetPlusWorkerNum() + 10); DbManager.Instance.SetMaxWorkerNum(DbManager.Instance.GetMaxWorkerNum() + 10); DbManager.Instance.SetWorkerNum(DbManager.Instance.GetWorkerNum() + 10); WorkshopPanelCtrl.MakeWorkerNumChange(DbManager.Instance.GetWorkerNum(), DbManager.Instance.GetMaxWorkerNum()); AlertCtrl.Show("成功招募了10个家丁"); orderId = Statics.GetNowTimeStamp().ToString(); TDGAVirtualCurrency.OnChargeRequest(orderId, worker10, 3, "CH", 3, "iap"); TDGAVirtualCurrency.OnChargeSuccess(orderId); addPay(3); //记录充值 break; default: IOSNativePopUpManager.showMessage("提示", "不匹配的内购项目"); SendEvent("ProductIdError", DbManager.Instance.HostData.Lv.ToString(), DbManager.Instance.HostData.Name); break; } } }