feat: add per-run reborn gift price tiers
This commit is contained in:
@@ -2648,7 +2648,7 @@ export default class JiaZai extends cc.Component {
|
||||
if (order.itemid == "gold_1" || order.itemid == "gold_2" || order.itemid == "gold_3"
|
||||
|| order.itemid == "gold_4" || order.itemid == "gold_5" || order.itemid == "gold_6"
|
||||
|| order.itemid == "unlimited_health_bundle_10" || order.itemid == "unlimited_health_bundle_20"
|
||||
|| order.itemid == "unlimited_health_bundle_30" || order.itemid == "month_Card" || order.itemid == "reborn_Gift"
|
||||
|| order.itemid == "unlimited_health_bundle_30" || order.itemid == "month_Card" || /^reborn_Gift(?:_[2-5])?$/.test(order.itemid)
|
||||
|| order.itemid == "starter_pack" || order.itemid == "battlepass"
|
||||
) {
|
||||
if (canUpdateHome()) this.openLoad();
|
||||
@@ -2678,7 +2678,7 @@ export default class JiaZai extends cc.Component {
|
||||
if (canUpdateHome()) this.openLoad();
|
||||
this.buyMonthCard(productId, order.outTradeNo);
|
||||
}
|
||||
else if (order.itemid == "reborn_Gift") {
|
||||
else if (/^reborn_Gift(?:_[2-5])?$/.test(order.itemid)) {
|
||||
coinTemp = 1000;
|
||||
}
|
||||
else if (order.itemid == "starter_pack") {
|
||||
@@ -2695,7 +2695,7 @@ export default class JiaZai extends cc.Component {
|
||||
let title = "充值补发奖励金币:" + coinTemp;
|
||||
// MiniGameSdk.API.showToast(title);
|
||||
if (order.itemid != "month_Card")
|
||||
cc.fx.GameTool.shopBuy(productId, true, productId === "starter_pack" ? { outTradeNo: order.outTradeNo } : null);
|
||||
cc.fx.GameTool.shopBuy(productId, true, productId === "starter_pack" || /^reborn_Gift(?:_[2-5])?$/.test(productId) ? { outTradeNo: order.outTradeNo } : null);
|
||||
// console.log("充值成功获得金币");
|
||||
let price = parseInt(order.goodsPrice) || 0;
|
||||
// const dataSuccess = {
|
||||
|
||||
@@ -283,6 +283,21 @@ export default class MapConroler extends cc.Component {
|
||||
// 6. 获取场景管理器引用
|
||||
// 7. 获取城市排行榜数据
|
||||
// ============================================
|
||||
// 本局成功购买的礼包次数,与金币复活次数 review 独立;重建关卡时归零。
|
||||
rebornGiftCount: number = 0;
|
||||
private rebornGiftOrders: Set<string> = new Set();
|
||||
|
||||
recordRebornGiftPurchase(order: string) {
|
||||
if (!order || this.rebornGiftOrders.has(order)) return;
|
||||
this.rebornGiftOrders.add(order);
|
||||
this.rebornGiftCount++;
|
||||
}
|
||||
|
||||
getRebornGiftProduct() {
|
||||
const tier = Math.min(this.rebornGiftCount, 4);
|
||||
return { id: tier === 0 ? "reborn_Gift" : "reborn_Gift_" + (tier + 1), price: [600, 800, 1000, 1200, 1500][tier] };
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
// 测试开关开启时,每次进关都从十连胜开始。
|
||||
if (cc.fx.GameConfig.forceRainbowWinStreakB) {
|
||||
|
||||
+87
-41
@@ -25,6 +25,9 @@ export default class Revive extends cc.Component {
|
||||
private iosPrice: number = 0;
|
||||
private iosProductId: string = "";
|
||||
private iosCount: number = 1;
|
||||
private iosMap: MapConroler = null;
|
||||
private iosUid: string = "";
|
||||
private checkingIosOrder: boolean = false;
|
||||
public home: number = 0;
|
||||
|
||||
onLoad() {
|
||||
@@ -36,12 +39,18 @@ export default class Revive extends cc.Component {
|
||||
if (cc.sys.platform === cc.sys.WECHAT_GAME || cc.sys.platform === cc.sys.BYTEDANCE_GAME) {
|
||||
console.log("从后台进入前台订单号:", cc.fx.GameConfig.GM_INFO.iosReviveOrder);
|
||||
if (cc.fx.GameConfig.GM_INFO.iosReviveOrder != null && cc.fx.GameConfig.GM_INFO.iosReviveOrder != "") {
|
||||
if (this.checkingIosOrder) return;
|
||||
this.checkingIosOrder = true;
|
||||
console.log("有苹果订单号,开始轮训");
|
||||
const iosReviveOrder = cc.fx.GameConfig.GM_INFO.iosReviveOrder;
|
||||
this.openLoad();
|
||||
this.btn_Touch = true;
|
||||
this.btn_Touch = false;
|
||||
const purchaseMap = this.iosMap;
|
||||
const purchaseUid = this.iosUid || cc.fx.GameConfig.GM_INFO.uid;
|
||||
Utils.getIosPayInfo(iosReviveOrder,
|
||||
(data) => {
|
||||
this.checkingIosOrder = false;
|
||||
if (purchaseUid !== cc.fx.GameConfig.GM_INFO.uid) return;
|
||||
console.log("获得轮训结果:", data);
|
||||
const iosID = data.data?.payment_name || this.iosProductId;
|
||||
let iosAmount = data.data?.goodsPrice || this.iosPrice;
|
||||
@@ -55,12 +64,10 @@ export default class Revive extends cc.Component {
|
||||
this.btn_Touch = true;
|
||||
console.log("_________正式发货");
|
||||
MiniGameSdk.API.showToast("充值成功");
|
||||
cc.fx.GameTool.shopBuy(iosID, false);
|
||||
this.revivew()
|
||||
if (iosID == "reborn_Gift") {
|
||||
this.buyGift();
|
||||
}
|
||||
cc.fx.GameConfig.GM_INFO.iosReviveOrder = null;
|
||||
this.completePurchase(iosID, iosReviveOrder, purchaseMap, purchaseUid);
|
||||
Utils.setPayInfo(() => {}, iosReviveOrder);
|
||||
if (cc.fx.GameConfig.GM_INFO.iosReviveOrder === iosReviveOrder)
|
||||
cc.fx.GameConfig.GM_INFO.iosReviveOrder = null;
|
||||
//console.log("充值成功获得金币");
|
||||
this.updateGameCoin();
|
||||
|
||||
@@ -81,7 +88,8 @@ export default class Revive extends cc.Component {
|
||||
if (iosID != undefined && iosID != "" && iosID != null) {
|
||||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
|
||||
}
|
||||
cc.fx.GameConfig.GM_INFO.iosReviveOrder = null;
|
||||
if (cc.fx.GameConfig.GM_INFO.iosReviveOrder === iosReviveOrder)
|
||||
cc.fx.GameConfig.GM_INFO.iosReviveOrder = null;
|
||||
}
|
||||
else if (data.code == 2) {
|
||||
this.closeLoad();
|
||||
@@ -112,10 +120,34 @@ export default class Revive extends cc.Component {
|
||||
return;
|
||||
}
|
||||
this.node.active = true;
|
||||
this.updatePrice();
|
||||
this.addListener();
|
||||
this.btn_Touch = true;
|
||||
}
|
||||
|
||||
private updatePrice() {
|
||||
const map = MapConroler._instance;
|
||||
const price = this.node.getChildByName("price");
|
||||
const label = price && price.getComponent(cc.Label);
|
||||
if (!map || !label) return;
|
||||
// 固定数字右边缘,让两位数向左展开,保留旁边独立的“元”节点。
|
||||
price.x += price.width * (1 - price.anchorX);
|
||||
price.anchorX = 1;
|
||||
label.string = String(map.getRebornGiftProduct().price / 100);
|
||||
}
|
||||
|
||||
private completePurchase(productId: string, order: string, purchaseMap: MapConroler, uid: string) {
|
||||
if (uid !== cc.fx.GameConfig.GM_INFO.uid || !order || !/^reborn_Gift(?:_[2-5])?$/.test(productId)) return;
|
||||
const currentRun = purchaseMap && cc.isValid(purchaseMap, true) && MapConroler._instance === purchaseMap;
|
||||
if (currentRun) purchaseMap.recordRebornGiftPurchase(order);
|
||||
if (cc.fx.GameTool.shopBuy(productId, false, { outTradeNo: order }) === false) return;
|
||||
this.buyGift();
|
||||
// 旧局订单仍发奖励,但不能复活新局或提高新局的礼包价格。
|
||||
if (currentRun) {
|
||||
this.revivew(purchaseMap);
|
||||
}
|
||||
}
|
||||
|
||||
addListener() {
|
||||
if (cc.sys.platform === cc.sys.WECHAT_GAME || cc.sys.platform === cc.sys.BYTEDANCE_GAME) {
|
||||
if (this.onShowListener) {
|
||||
@@ -141,9 +173,8 @@ export default class Revive extends cc.Component {
|
||||
// update (dt) {}
|
||||
}
|
||||
//发奖励
|
||||
revivew() {
|
||||
revivew(map: MapConroler) {
|
||||
cc.fx.GameConfig.GM_INFO.revive = 0;
|
||||
const map = MapConroler && MapConroler._instance;
|
||||
if (map) map.setPropNum();
|
||||
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
||||
const jiazaiComp = jiazaiNode && jiazaiNode.getComponent(JiaZai);
|
||||
@@ -166,7 +197,7 @@ export default class Revive extends cc.Component {
|
||||
this.node.active = false;
|
||||
}
|
||||
}, 200);
|
||||
if (map && cc.isValid(map)) map.runRewiveCopy(false);
|
||||
if (map && cc.isValid(map)) map.runRewiveCopy();
|
||||
}
|
||||
buyProduct(customData) {
|
||||
// cc.fx.GameTool.shopBuy("revive", false);
|
||||
@@ -174,17 +205,19 @@ export default class Revive extends cc.Component {
|
||||
if (!this.btn_Touch) {
|
||||
return;
|
||||
}
|
||||
this.btn_Touch = false;
|
||||
const productId = "reborn_Gift";
|
||||
let id = "10011";
|
||||
let price = 100;
|
||||
let count = 1;
|
||||
id = productId;
|
||||
switch (productId) {
|
||||
case "reborn_Gift":
|
||||
price = 600;
|
||||
break;
|
||||
if (cc.fx.GameConfig.GM_INFO.iosReviveOrder) {
|
||||
this.onShow();
|
||||
return;
|
||||
}
|
||||
const purchaseMap = MapConroler._instance;
|
||||
if (!purchaseMap || !cc.isValid(purchaseMap, true)) return;
|
||||
const purchaseUid = cc.fx.GameConfig.GM_INFO.uid;
|
||||
this.btn_Touch = false;
|
||||
const product = purchaseMap.getRebornGiftProduct();
|
||||
const productId = product.id;
|
||||
const id = productId;
|
||||
const price = product.price;
|
||||
const count = 1;
|
||||
console.log("获得商品id:", id, count, price);
|
||||
// 判断设备系统
|
||||
let systemType = "Android";
|
||||
@@ -203,8 +236,7 @@ export default class Revive extends cc.Component {
|
||||
// MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
||||
// this.btn_Touch = true;
|
||||
this.openLoad();
|
||||
this.btn_Touch = true;
|
||||
this.iosOldPay(price, productId);
|
||||
this.iosOldPay(price, productId, purchaseMap, purchaseUid);
|
||||
}
|
||||
else {
|
||||
// MiniGameSdk.API.showToast("充值成功");
|
||||
@@ -220,9 +252,9 @@ export default class Revive extends cc.Component {
|
||||
// }, 500);
|
||||
|
||||
this.openLoad();
|
||||
this.btn_Touch = true;
|
||||
console.log("7.14_____________________", "调用充值接口");
|
||||
Utils.buyProp(id, count, price, systemType, productId, (res) => {
|
||||
if (purchaseUid !== cc.fx.GameConfig.GM_INFO.uid) return;
|
||||
console.log("获得充值结果", res);
|
||||
if (res == null) {
|
||||
MiniGameSdk.API.showToast("充值失败");
|
||||
@@ -243,7 +275,7 @@ export default class Revive extends cc.Component {
|
||||
console.log("错误原因:", res.errMsg);
|
||||
if (res.errCode == 16) {
|
||||
// console.log("走ios旧支付");
|
||||
this.iosOldPay(price, productId);
|
||||
this.iosOldPay(price, productId, purchaseMap, purchaseUid);
|
||||
return;
|
||||
}
|
||||
MiniGameSdk.API.showToast("充值失败");
|
||||
@@ -266,7 +298,15 @@ export default class Revive extends cc.Component {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
const orderNumber = res.outTradeNo;
|
||||
if (!orderNumber) {
|
||||
this.btn_Touch = true;
|
||||
this.closeLoad();
|
||||
MiniGameSdk.API.showToast("未获取到充值订单,请稍后重试");
|
||||
return;
|
||||
}
|
||||
Utils.getPayInfo((data) => {
|
||||
if (purchaseUid !== cc.fx.GameConfig.GM_INFO.uid) return;
|
||||
console.log("7.14_______________充值成功,准备轮训");
|
||||
console.log("获得轮训结果:", data);
|
||||
this.closeLoad();
|
||||
@@ -274,7 +314,7 @@ export default class Revive extends cc.Component {
|
||||
this.btn_Touch = true;
|
||||
MiniGameSdk.API.showToast("取消充值");
|
||||
const dataFail2 = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
outTradeNo: orderNumber,
|
||||
pay_amount: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
@@ -284,7 +324,8 @@ export default class Revive extends cc.Component {
|
||||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail2);
|
||||
}
|
||||
else if (data.data.pay_state == 2) {
|
||||
this.btn_Touch = true;
|
||||
if (cc.isValid(purchaseMap, true) && MapConroler._instance === purchaseMap)
|
||||
purchaseMap.recordRebornGiftPurchase(orderNumber);
|
||||
// const dataSuccess = {
|
||||
// outTradeNo: Utils.outTradeNo,
|
||||
// pay_amount: price,
|
||||
@@ -294,41 +335,40 @@ export default class Revive extends cc.Component {
|
||||
// }
|
||||
// cc.fx.GameTool.shushu_Track("payment", dataSuccess);
|
||||
let name = "购买金币道具:" + productId;
|
||||
console.log("引力付费透传", price, Utils.outTradeNo, name);
|
||||
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name)
|
||||
console.log("引力付费透传", price, orderNumber, name);
|
||||
MiniGameSdk.API.yinli_Pay(price, orderNumber, name)
|
||||
console.log("7.14_______________充值成功,轮训成功,准备发货");
|
||||
this.completePurchase(productId, orderNumber, purchaseMap, purchaseUid);
|
||||
Utils.setPayInfo(
|
||||
(res) => {
|
||||
if (purchaseUid !== cc.fx.GameConfig.GM_INFO.uid) return;
|
||||
this.btn_Touch = true;
|
||||
console.log("设置轮训结果:", res);
|
||||
if (res.code === 1) {
|
||||
console.log("7.14_________正式发货");
|
||||
MiniGameSdk.API.showToast("充值成功");
|
||||
cc.fx.GameTool.shopBuy(productId, false);
|
||||
this.revivew();
|
||||
if (productId == "reborn_Gift") {
|
||||
this.buyGift();
|
||||
}
|
||||
//console.log("充值成功获得金币");
|
||||
}
|
||||
else {
|
||||
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
|
||||
MiniGameSdk.API.showToast("充值已到账,订单确认将在登录后重试");
|
||||
const dataFail4 = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
outTradeNo: orderNumber,
|
||||
pay_amount: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
type: systemType,
|
||||
fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货",
|
||||
fail_reason: "充值已到账,确认发货请求失败",
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail4);
|
||||
}
|
||||
this.updateGameCoin();
|
||||
}, Utils.outTradeNo)
|
||||
if (cc.isValid(this, true)) this.updatePrice();
|
||||
}, orderNumber)
|
||||
}
|
||||
else {
|
||||
|
||||
const dataFail3 = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
outTradeNo: orderNumber,
|
||||
pay_amount: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
@@ -339,18 +379,20 @@ export default class Revive extends cc.Component {
|
||||
this.btn_Touch = true;
|
||||
this.updateGameCoin();
|
||||
}
|
||||
})
|
||||
}, orderNumber)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
openLoad() {
|
||||
if (!cc.isValid(this, true)) return;
|
||||
const canvas = cc.find("Canvas");
|
||||
const loading = canvas && canvas.getChildByName("Loading");
|
||||
if (loading) LoadingCatAnimation.play(loading);
|
||||
}
|
||||
|
||||
closeLoad() {
|
||||
if (!cc.isValid(this, true)) return;
|
||||
const canvas = cc.find("Canvas");
|
||||
const loading = canvas && canvas.getChildByName("Loading");
|
||||
if (loading) LoadingCatAnimation.stop(loading);
|
||||
@@ -407,7 +449,7 @@ export default class Revive extends cc.Component {
|
||||
this.onShow();
|
||||
}
|
||||
|
||||
iosOldPay(price, productId) {
|
||||
iosOldPay(price, productId, purchaseMap: MapConroler, uid: string) {
|
||||
// 旧版本ios支付
|
||||
let iosPayInfo = {
|
||||
price: price,
|
||||
@@ -417,6 +459,8 @@ export default class Revive extends cc.Component {
|
||||
this.iosPrice = price;
|
||||
this.iosProductId = productId;
|
||||
this.iosCount = 1;
|
||||
this.iosMap = purchaseMap;
|
||||
this.iosUid = uid;
|
||||
console.log("准备跳客服回话:");
|
||||
console.log(this.iosProductId);
|
||||
Utils.GoKEFu(iosPayInfo, (res) => {
|
||||
@@ -425,6 +469,8 @@ export default class Revive extends cc.Component {
|
||||
}
|
||||
else {
|
||||
console.log("客服回话失败");
|
||||
this.btn_Touch = true;
|
||||
cc.fx.GameConfig.GM_INFO.iosReviveOrder = null;
|
||||
this.closeLoad();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -253,7 +253,7 @@ export default class Utils {
|
||||
cc.fx.GameConfig.GM_INFO.iosMonthOrder = null;
|
||||
cc.fx.GameConfig.GM_INFO.iosMonthOrder = order;
|
||||
}
|
||||
else if (iosPayInfo.payment_name == "reborn_Gift") {
|
||||
else if (/^reborn_Gift(?:_[2-5])?$/.test(iosPayInfo.payment_name)) {
|
||||
cc.fx.GameConfig.GM_INFO.iosReviveOrder = null;
|
||||
cc.fx.GameConfig.GM_INFO.iosReviveOrder = order;
|
||||
}
|
||||
@@ -336,7 +336,7 @@ export default class Utils {
|
||||
const orderNow = order;
|
||||
console.log("请求uid:" + Utils.uid);
|
||||
console.log("outTradeNo:" + orderNow);
|
||||
Utils.POST("wx/iosgetPayInfo", { outTradeNo: orderNow, uid: cc.fx.GameConfig.GM_INFO.uid }, res => {
|
||||
Utils.POST("wx/iosgetPayInfo", { outTradeNo: orderNow, uid: cc.fx.GameConfig.GM_INFO.uid, rebornGiftVersion: 1 }, res => {
|
||||
console.log("查询字符结果IOS");
|
||||
console.log(res);
|
||||
// 清除超时定时器
|
||||
|
||||
@@ -999,6 +999,9 @@ var GameTool = {
|
||||
|
||||
//商城购买
|
||||
shopBuy(productId, compensate, orderContext: any = null) {
|
||||
const rebornOrderKey = /^reborn_Gift(?:_[2-5])?$/.test(productId) && orderContext?.outTradeNo
|
||||
? "RebornGiftGranted_" + cc.fx.GameConfig.GM_INFO.uid + "_" + orderContext.outTradeNo : "";
|
||||
if (rebornOrderKey && cc.fx.StorageMessage.getStorage(rebornOrderKey)) return false;
|
||||
const starterOrderKey = productId === "starter_pack" && orderContext?.outTradeNo
|
||||
? "StarterPackGranted_" + cc.fx.GameConfig.GM_INFO.uid + "_" + orderContext.outTradeNo : "";
|
||||
if (starterOrderKey && cc.fx.StorageMessage.getStorage(starterOrderKey)) return;
|
||||
@@ -1234,9 +1237,13 @@ var GameTool = {
|
||||
]
|
||||
break;
|
||||
case "reborn_Gift":
|
||||
case "reborn_Gift_2":
|
||||
case "reborn_Gift_3":
|
||||
case "reborn_Gift_4":
|
||||
case "reborn_Gift_5":
|
||||
cc.fx.GameTool.changeCoin(1000);
|
||||
coin = 1000;
|
||||
price = 600;
|
||||
price = { reborn_Gift: 600, reborn_Gift_2: 800, reborn_Gift_3: 1000, reborn_Gift_4: 1200, reborn_Gift_5: 1500 }[productId];
|
||||
rewardData = [
|
||||
{ type: "coin", count: coin },
|
||||
{ type: "freeze", count: 1 },
|
||||
@@ -1250,6 +1257,7 @@ var GameTool = {
|
||||
"price": price
|
||||
}
|
||||
this.getShopProp(propData3, compensate);
|
||||
if (rebornOrderKey) cc.fx.StorageMessage.setStorage(rebornOrderKey, true);
|
||||
break;
|
||||
case "starter_pack": {
|
||||
const reward = starterPackReward();
|
||||
|
||||
Reference in New Issue
Block a user