801 lines
31 KiB
JavaScript
801 lines
31 KiB
JavaScript
var game;
|
||
!(function (game) {
|
||
const toInt = function (value, fallback = 0) {
|
||
const parsed = parseInt(value, 10);
|
||
return Number.isFinite(parsed) ? parsed : fallback;
|
||
};
|
||
|
||
const WorldFeatureUtils = class WorldFeatureUtils {
|
||
static request(route, data, callback) {
|
||
Global.netProxy.sendRequest(GameConfig.SERVER_PATH + route, data || {}, callback);
|
||
}
|
||
static table(tableName) {
|
||
return (Global.gameProxy && Global.gameProxy.getTabelConfigByType(tableName)) || {};
|
||
}
|
||
static config(tableName, id) {
|
||
const table = WorldFeatureUtils.table(tableName);
|
||
return table && table[id] ? table[id] : {};
|
||
}
|
||
static itemName(itemId) {
|
||
const config = Global.gameProxy.getItemConfig(itemId) || {};
|
||
return config.name || "道具" + itemId;
|
||
}
|
||
static rewardText(rewardString) {
|
||
if (!rewardString) return "无";
|
||
return String(rewardString)
|
||
.split(",")
|
||
.map(function (itemString) {
|
||
const parts = String(itemString).split(":"),
|
||
itemId = parts[0],
|
||
count = parts.length >= 3 ? parts[2] : parts[1];
|
||
return itemId ? WorldFeatureUtils.itemName(itemId) + "x" + (count || 0) : "";
|
||
})
|
||
.filter(function (text) {
|
||
return !!text;
|
||
})
|
||
.join("、");
|
||
}
|
||
static addRewardToPlayer(data) {
|
||
if (!data) return "";
|
||
if (Array.isArray(data)) {
|
||
const rewardString = data
|
||
.map(function (item) {
|
||
return item && item.item_id ? item.item_id + ":" + (item.num || item.count || 0) : "";
|
||
})
|
||
.filter(function (item) {
|
||
return !!item;
|
||
})
|
||
.join(",");
|
||
rewardString && Global.playerProxy.addItem1(rewardString);
|
||
return rewardString;
|
||
}
|
||
if (data.item_id) {
|
||
const rewardString = data.item_id + ":" + (data.num || data.count || 0);
|
||
Global.playerProxy.addItem1(rewardString);
|
||
return rewardString;
|
||
}
|
||
return "";
|
||
}
|
||
static serverMessage(response, fallback) {
|
||
return (response && GameConfig.ServerCode && GameConfig.ServerCode[response.status]) || fallback || "操作失败";
|
||
}
|
||
static makeButton(label, width = 108, height = 48) {
|
||
const button = new eui.Button();
|
||
button.label = label;
|
||
button.width = width;
|
||
button.height = height;
|
||
button.skinName =
|
||
window.common && window.common.MidButtonSkin ? window.common.MidButtonSkin : "common.MidButtonSkin";
|
||
return button;
|
||
}
|
||
static makeLabel(text, size, color, x, y, width, height) {
|
||
const label = new eui.Label();
|
||
label.text = text || "";
|
||
label.size = size || 22;
|
||
label.textColor = color || 0xfffbf2;
|
||
label.x = x || 0;
|
||
label.y = y || 0;
|
||
label.width = width || 100;
|
||
label.height = height || 28;
|
||
label.fontFamily = "huakanghaibao";
|
||
label.stroke = 1;
|
||
label.strokeColor = 0x724f2e;
|
||
label.verticalAlign = egret.VerticalAlign.MIDDLE;
|
||
return label;
|
||
}
|
||
};
|
||
((game.WorldFeatureUtils = WorldFeatureUtils), __reflect(WorldFeatureUtils.prototype, "game.WorldFeatureUtils"));
|
||
|
||
const WorldFeatureItemRenderer = class WorldFeatureItemRenderer extends game.BaseItemRenderer {
|
||
constructor() {
|
||
super();
|
||
this.width = 520;
|
||
this.height = 126;
|
||
}
|
||
createChildren() {
|
||
super.createChildren();
|
||
this.backgroundShape = new egret.Shape();
|
||
this.addChild(this.backgroundShape);
|
||
this.titleLabel = WorldFeatureUtils.makeLabel("", 23, 0xfffbf2, 18, 10, 360, 30);
|
||
this.titleLabel.bold = !0;
|
||
this.addChild(this.titleLabel);
|
||
this.detailLabel = WorldFeatureUtils.makeLabel("", 18, 0x5b3616, 18, 42, 370, 68);
|
||
this.detailLabel.stroke = 0;
|
||
this.detailLabel.lineSpacing = 5;
|
||
this.detailLabel.verticalAlign = egret.VerticalAlign.TOP;
|
||
this.addChild(this.detailLabel);
|
||
this.statusLabel = WorldFeatureUtils.makeLabel("", 18, 0xd03d1c, 390, 12, 118, 24);
|
||
this.statusLabel.stroke = 0;
|
||
this.statusLabel.textAlign = egret.HorizontalAlign.CENTER;
|
||
this.addChild(this.statusLabel);
|
||
this.actionButton = WorldFeatureUtils.makeButton("领取", 108, 48);
|
||
this.actionButton.x = 394;
|
||
this.actionButton.y = 52;
|
||
this.actionButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onActionTap, this);
|
||
this.addChild(this.actionButton);
|
||
this.drawBackground();
|
||
}
|
||
onRemoved() {
|
||
this.actionButton &&
|
||
this.actionButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onActionTap, this);
|
||
super.onRemoved();
|
||
}
|
||
drawBackground() {
|
||
const graphics = this.backgroundShape.graphics;
|
||
graphics.clear();
|
||
graphics.lineStyle(2, 0x9c6a2f, 1);
|
||
graphics.beginFill(0xffefc9, 0.92);
|
||
graphics.drawRoundRect(0, 0, 520, 116, 12, 12);
|
||
graphics.endFill();
|
||
}
|
||
dataChanged() {
|
||
const row = this.data || {};
|
||
this.drawBackground();
|
||
this.titleLabel.text = row.title || "";
|
||
this.detailLabel.text = (row.lines || []).join("\n");
|
||
this.statusLabel.text = row.status || "";
|
||
this.actionButton.visible = !!row.actionLabel;
|
||
this.actionButton.label = row.actionLabel || "";
|
||
this.actionButton.enabled = row.actionEnabled !== !1;
|
||
}
|
||
onActionTap(event) {
|
||
event.stopPropagation();
|
||
const row = this.data || {};
|
||
row.actionEnabled !== !1 && row.onAction && row.onAction(row);
|
||
}
|
||
};
|
||
__reflect(WorldFeatureItemRenderer.prototype, "WorldFeatureItemRenderer");
|
||
|
||
const WorldFeaturePanel = class WorldFeaturePanel extends game.BasePanel {
|
||
constructor(title, closeNotify) {
|
||
super();
|
||
this.featureTitle = title;
|
||
this.closeNotify = closeNotify;
|
||
this.isFullScreen = !0;
|
||
this.isVisibleAnimate = !0;
|
||
this.width = Const.WIN_W;
|
||
this.height = Const.WIN_H;
|
||
}
|
||
createChildren() {
|
||
super.createChildren();
|
||
this.buildFrame();
|
||
}
|
||
buildFrame() {
|
||
this.modalBlocker = new egret.Shape();
|
||
this.modalBlocker.graphics.beginFill(0x000000, 0.01);
|
||
this.modalBlocker.graphics.drawRect(0, 0, Const.WIN_W, Const.WIN_H);
|
||
this.modalBlocker.graphics.endFill();
|
||
this.modalBlocker.touchEnabled = !0;
|
||
this.addChild(this.modalBlocker);
|
||
|
||
const panelBg = new eui.Image("common_json.c_panel2_png");
|
||
panelBg.x = 20;
|
||
panelBg.y = 126;
|
||
panelBg.width = 600;
|
||
panelBg.height = 790;
|
||
panelBg.scale9Grid = new egret.Rectangle(118, 58, 10, 10);
|
||
this.addChild(panelBg);
|
||
|
||
const titleBg = new eui.Image("common2_json.common2_diban_png");
|
||
titleBg.x = 168;
|
||
titleBg.y = 120;
|
||
titleBg.width = 304;
|
||
titleBg.height = 70;
|
||
this.addChild(titleBg);
|
||
|
||
const title = WorldFeatureUtils.makeLabel(this.featureTitle, 34, 0xfffbf2, 170, 134, 300, 48);
|
||
title.textAlign = egret.HorizontalAlign.CENTER;
|
||
title.bold = !0;
|
||
this.addChild(title);
|
||
|
||
this.closeButton = new eui.Button();
|
||
this.closeButton.label = "";
|
||
this.closeButton.width = 54;
|
||
this.closeButton.height = 54;
|
||
this.closeButton.x = 554;
|
||
this.closeButton.y = 130;
|
||
this.closeButton.skinName =
|
||
window.common && window.common.ExitButtonSkin ? window.common.ExitButtonSkin : "common.ExitButtonSkin";
|
||
this.closeButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onCloseTap, this);
|
||
this.addChild(this.closeButton);
|
||
|
||
this.statusLabel = WorldFeatureUtils.makeLabel("", 20, 0x5b3616, 60, 190, 520, 34);
|
||
this.statusLabel.stroke = 0;
|
||
this.statusLabel.textAlign = egret.HorizontalAlign.CENTER;
|
||
this.addChild(this.statusLabel);
|
||
|
||
this.contentGroup = new eui.Group();
|
||
this.contentGroup.x = 60;
|
||
this.contentGroup.y = 232;
|
||
this.contentGroup.width = 520;
|
||
this.contentGroup.height = 642;
|
||
this.addChild(this.contentGroup);
|
||
game.UIUtils.addButtonScaleEffects(this);
|
||
}
|
||
onRemoved() {
|
||
this.closeButton && this.closeButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onCloseTap, this);
|
||
super.onRemoved();
|
||
}
|
||
onCloseTap(event) {
|
||
event.stopPropagation();
|
||
this.closeNotify && game.AppFacade.getInstance().sendNotification(this.closeNotify);
|
||
}
|
||
setStatus(text) {
|
||
this.statusLabel && (this.statusLabel.text = text || "");
|
||
}
|
||
showRows(rows) {
|
||
this.contentGroup.removeChildren();
|
||
this.scroller = new eui.Scroller();
|
||
this.scroller.width = 520;
|
||
this.scroller.height = 642;
|
||
this.list = new eui.List();
|
||
this.list.width = 520;
|
||
this.list.height = 642;
|
||
this.list.useVirtualLayout = !1;
|
||
this.list.itemRenderer = WorldFeatureItemRenderer;
|
||
this.list.dataProvider = new eui.ArrayCollection(rows || []);
|
||
this.scroller.viewport = this.list;
|
||
this.contentGroup.addChild(this.scroller);
|
||
}
|
||
};
|
||
((game.WorldFeaturePanel = WorldFeaturePanel), __reflect(WorldFeaturePanel.prototype, "game.WorldFeaturePanel"));
|
||
|
||
const WorldPetPanel = class WorldPetPanel extends WorldFeaturePanel {
|
||
constructor() {
|
||
super("战宠", PanelNotify.CLOSE_BATTLEPET);
|
||
}
|
||
createChildren() {
|
||
super.createChildren();
|
||
this.loadPets();
|
||
}
|
||
loadPets() {
|
||
this.setStatus("正在读取战宠列表...");
|
||
WorldFeatureUtils.request("pet/get-list", {}, this.onPetsLoaded.bind(this));
|
||
}
|
||
onPetsLoaded(response) {
|
||
if (0 !== response.status) {
|
||
this.setStatus(WorldFeatureUtils.serverMessage(response, "战宠列表读取失败"));
|
||
this.showRows([]);
|
||
return;
|
||
}
|
||
const pets = (response.data && response.data.list) || [];
|
||
if (!pets.length) {
|
||
this.setStatus("当前账号还没有战宠");
|
||
this.showRows([
|
||
{
|
||
title: "暂无战宠",
|
||
lines: ["可在商店购买宠物蛋,孵化后会出现在这里。", "战宠可设置为出战宠物,用于竞技场挑战。"],
|
||
status: "",
|
||
actionLabel: "去商店",
|
||
actionEnabled: !0,
|
||
onAction: function () {
|
||
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_BATTLEPET);
|
||
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_SHOP);
|
||
}
|
||
}
|
||
]);
|
||
return;
|
||
}
|
||
this.setStatus("共 " + pets.length + " 只战宠");
|
||
this.showRows(
|
||
pets.map(
|
||
function (pet) {
|
||
const config = WorldFeatureUtils.config("pet", pet.pet_config_id),
|
||
name = config.name || "战宠" + pet.pet_config_id,
|
||
inWar = toInt(pet.is_enter_war) === 1,
|
||
feed = toInt(pet.feed),
|
||
hunger = toInt(config.hunger),
|
||
status = inWar ? "出战中" : "未出战";
|
||
return {
|
||
title: name + " Lv." + toInt(pet.level, 1),
|
||
lines: [
|
||
"战力 " + toInt(pet.fighting_capacity) + " 饥饿度 " + feed + "/" + hunger,
|
||
"生命 " + toInt(pet.blood) + " 攻击 " + toInt(pet.attack) + " 防御 " + toInt(pet.anti)
|
||
],
|
||
status: status,
|
||
actionLabel: inWar ? "" : "出战",
|
||
actionEnabled: !inWar,
|
||
petId: pet.id,
|
||
onAction: this.setEnterWar.bind(this)
|
||
};
|
||
}.bind(this)
|
||
)
|
||
);
|
||
}
|
||
setEnterWar(row) {
|
||
this.setStatus("正在设置出战宠物...");
|
||
WorldFeatureUtils.request("pet/set-enter-war", { pet_id: row.petId }, this.onEnterWar.bind(this));
|
||
}
|
||
onEnterWar(response) {
|
||
if (0 !== response.status) {
|
||
this.setStatus(WorldFeatureUtils.serverMessage(response, "设置出战失败"));
|
||
return;
|
||
}
|
||
TipsUtils.showTipsDownToUp("已设置出战宠物");
|
||
this.loadPets();
|
||
}
|
||
};
|
||
((game.WorldPetPanel = WorldPetPanel), __reflect(WorldPetPanel.prototype, "game.WorldPetPanel"));
|
||
|
||
const WorldAchievementPanel = class WorldAchievementPanel extends WorldFeaturePanel {
|
||
constructor() {
|
||
super("成就", PanelNotify.CLOSE_CHENGJIU);
|
||
}
|
||
createChildren() {
|
||
super.createChildren();
|
||
this.loadAchievements();
|
||
}
|
||
loadAchievements() {
|
||
this.setStatus("正在读取成就...");
|
||
WorldFeatureUtils.request("ach/get-list", {}, this.onAchievementsLoaded.bind(this));
|
||
}
|
||
onAchievementsLoaded(response) {
|
||
if (0 !== response.status) {
|
||
this.setStatus(WorldFeatureUtils.serverMessage(response, "成就读取失败"));
|
||
this.showRows([]);
|
||
return;
|
||
}
|
||
const configMap = WorldFeatureUtils.table("achievement_list"),
|
||
serverList = (response.data && response.data.list) || [],
|
||
serverMap = {};
|
||
serverList.forEach(function (item) {
|
||
serverMap[item.config_id] = item;
|
||
});
|
||
const rows = Object.keys(configMap)
|
||
.map(
|
||
function (configId) {
|
||
const config = configMap[configId],
|
||
record = serverMap[configId] || {},
|
||
level = toInt(record.level),
|
||
completeList = String(config.complete || "1").split(":"),
|
||
rewardList = String(config.gold_id || "0").split(":"),
|
||
expList = String(config.experience || "0").split(":"),
|
||
threshold = toInt(completeList[Math.min(level, completeList.length - 1)], 1),
|
||
count = Math.min(toInt(record.count), threshold),
|
||
rewardCount = toInt(rewardList[Math.min(level, rewardList.length - 1)]),
|
||
exp = toInt(expList[Math.min(level, expList.length - 1)]),
|
||
canClaim = !!record.id && toInt(record.receive) !== 1 && count >= threshold,
|
||
completed = toInt(record.receive) === 1 && level >= completeList.length - 1,
|
||
progress = threshold > 0 ? Math.floor((count / threshold) * 100) : 0;
|
||
return {
|
||
title: config.name || record.name || "成就" + configId,
|
||
lines: [
|
||
config.content || record.content || "",
|
||
"进度 " + count + "/" + threshold + " (" + progress + "%) 奖励 " + WorldFeatureUtils.itemName(config.item_id) + "x" + rewardCount + " 经验x" + exp
|
||
],
|
||
status: completed ? "已完成" : canClaim ? "可领取" : "进行中",
|
||
actionLabel: canClaim ? "领取" : "",
|
||
actionEnabled: canClaim,
|
||
recordId: record.id,
|
||
rewardString: config.item_id + ":" + rewardCount,
|
||
exp: exp,
|
||
onAction: this.claimAchievement.bind(this),
|
||
sortKey: canClaim ? 0 : completed ? 2 : 1,
|
||
configId: toInt(configId)
|
||
};
|
||
}.bind(this)
|
||
)
|
||
.sort(function (left, right) {
|
||
return left.sortKey - right.sortKey || left.configId - right.configId;
|
||
});
|
||
this.setStatus("系统成就 " + rows.length + " 项");
|
||
this.showRows(rows);
|
||
}
|
||
claimAchievement(row) {
|
||
this.setStatus("正在领取成就奖励...");
|
||
WorldFeatureUtils.request("ach/get-gift", { id: row.recordId }, this.onAchievementClaimed.bind(this, row));
|
||
}
|
||
onAchievementClaimed(row, response) {
|
||
if (0 !== response.status) {
|
||
this.setStatus(WorldFeatureUtils.serverMessage(response, "领取失败"));
|
||
return;
|
||
}
|
||
row.rewardString && Global.playerProxy.addItem1(row.rewardString);
|
||
row.exp > 0 && Global.playerProxy.addExp(row.exp);
|
||
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE);
|
||
TipsUtils.showTipsDownToUp("成就奖励已领取");
|
||
this.loadAchievements();
|
||
}
|
||
};
|
||
((game.WorldAchievementPanel = WorldAchievementPanel),
|
||
__reflect(WorldAchievementPanel.prototype, "game.WorldAchievementPanel"));
|
||
|
||
const WorldSportsPanel = class WorldSportsPanel extends WorldFeaturePanel {
|
||
constructor() {
|
||
super("竞技", PanelNotify.CLOSE_SPORTS);
|
||
this.arenaInfo = null;
|
||
this.arenaError = "";
|
||
this.rankList = [];
|
||
this.challengeList = [];
|
||
this.weekGiftList = [];
|
||
}
|
||
createChildren() {
|
||
super.createChildren();
|
||
this.loadSports();
|
||
}
|
||
loadSports() {
|
||
this.setStatus("正在读取竞技场...");
|
||
WorldFeatureUtils.request("arena/get-arena", {}, this.onArenaLoaded.bind(this));
|
||
}
|
||
onArenaLoaded(response) {
|
||
if (0 === response.status) {
|
||
this.arenaInfo = response.data || {};
|
||
this.arenaError = "";
|
||
} else {
|
||
this.arenaInfo = null;
|
||
this.arenaError = WorldFeatureUtils.serverMessage(response, "请先设置出战宠物");
|
||
}
|
||
WorldFeatureUtils.request("arena/get-rank-list", {}, this.onRankLoaded.bind(this));
|
||
}
|
||
onRankLoaded(response) {
|
||
this.rankList = 0 === response.status && response.data ? response.data.list || [] : [];
|
||
WorldFeatureUtils.request("arena/get-challenge-list", {}, this.onChallengeLoaded.bind(this));
|
||
}
|
||
onChallengeLoaded(response) {
|
||
this.challengeList = 0 === response.status && response.data ? response.data.list || [] : [];
|
||
WorldFeatureUtils.request("arena/week-gift-list", {}, this.onWeekGiftLoaded.bind(this));
|
||
}
|
||
onWeekGiftLoaded(response) {
|
||
this.weekGiftList = 0 === response.status && response.data ? response.data.list || [] : [];
|
||
this.renderSports();
|
||
}
|
||
renderSports() {
|
||
const rows = [],
|
||
arena = this.arenaInfo,
|
||
canChallenge = !!arena && toInt(arena.remaining_challenges_count) > 0;
|
||
if (arena) {
|
||
rows.push({
|
||
title: "我的竞技",
|
||
lines: [
|
||
"排名 " + (arena.index || "-") + " 战力 " + toInt(arena.fighting_capacity) + " 积分 " + toInt(arena.score),
|
||
"剩余挑战 " + toInt(arena.remaining_challenges_count) + " 胜 " + toInt(arena.win_count) + " / 负 " + toInt(arena.fail_count)
|
||
],
|
||
status: canChallenge ? "可挑战" : "次数不足"
|
||
});
|
||
} else {
|
||
rows.push({
|
||
title: "我的竞技",
|
||
lines: [this.arenaError || "请先设置出战宠物", "战宠出战后才能进行竞技场挑战。"],
|
||
status: "未开启",
|
||
actionLabel: "战宠",
|
||
actionEnabled: !0,
|
||
onAction: function () {
|
||
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_SPORTS);
|
||
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_BATTLEPET);
|
||
}
|
||
});
|
||
}
|
||
rows.push({
|
||
title: "挑战对手",
|
||
lines: [this.challengeList.length ? "可挑战对手:" + this.challengeList.length + " 位" : "暂无可挑战对手", "点击挑战会按双方战力直接结算胜负。"],
|
||
status: ""
|
||
});
|
||
this.challengeList.slice(0, 5).forEach(
|
||
function (item) {
|
||
rows.push({
|
||
title: "第 " + item.index + " 名 " + (item.nickname || "农场主"),
|
||
lines: ["战力 " + toInt(item.fighting_capacity) + " 积分 " + toInt(item.score), "胜 " + toInt(item.win_count) + " / 负 " + toInt(item.fail_count)],
|
||
status: canChallenge ? "可挑战" : "不可挑战",
|
||
actionLabel: "挑战",
|
||
actionEnabled: canChallenge,
|
||
targetUserId: item.user_id,
|
||
targetPower: toInt(item.fighting_capacity),
|
||
onAction: this.challengeOpponent.bind(this)
|
||
});
|
||
}.bind(this)
|
||
);
|
||
rows.push({
|
||
title: "排行榜",
|
||
lines: [this.rankList.length ? "当前前 " + this.rankList.length + " 名:" : "暂无排名数据", this.rankList.slice(0, 3).map(function (item) {
|
||
return item.index + "." + item.nickname + "(" + item.fighting_capacity + ")";
|
||
}).join(" ")],
|
||
status: ""
|
||
});
|
||
rows.push({
|
||
title: "本周奖励",
|
||
lines: [
|
||
this.weekGiftList
|
||
.slice(0, 3)
|
||
.map(function (item) {
|
||
return item.ranking_min_id + "-" + item.ranking_mzx_id + "名:" + WorldFeatureUtils.rewardText(item.fixed_id + "," + item.fixed_id2);
|
||
})
|
||
.join("\n")
|
||
],
|
||
status: ""
|
||
});
|
||
this.setStatus(arena ? "竞技场数据已加载" : this.arenaError || "竞技场未开启");
|
||
this.showRows(rows);
|
||
}
|
||
challengeOpponent(row) {
|
||
const myPower = toInt(this.arenaInfo && this.arenaInfo.fighting_capacity),
|
||
result = myPower >= toInt(row.targetPower) ? 0 : 1;
|
||
this.setStatus("正在结算挑战...");
|
||
WorldFeatureUtils.request(
|
||
"arena/challenge",
|
||
{
|
||
be_user_id: row.targetUserId,
|
||
type: result
|
||
},
|
||
this.onChallengeFinished.bind(this, result)
|
||
);
|
||
}
|
||
onChallengeFinished(result, response) {
|
||
if (0 !== response.status) {
|
||
this.setStatus(WorldFeatureUtils.serverMessage(response, "挑战失败"));
|
||
return;
|
||
}
|
||
TipsUtils.showTipsDownToUp(0 === result ? "挑战成功" : "挑战失败");
|
||
this.loadSports();
|
||
}
|
||
};
|
||
((game.WorldSportsPanel = WorldSportsPanel), __reflect(WorldSportsPanel.prototype, "game.WorldSportsPanel"));
|
||
|
||
const WorldParkPanel = class WorldParkPanel extends WorldFeaturePanel {
|
||
constructor() {
|
||
super("游乐园", PanelNotify.CLOSE_ASUMENT_PARK);
|
||
this.uuid = "";
|
||
this.score = 0;
|
||
this.timeLeft = 0;
|
||
this.gameRunning = !1;
|
||
}
|
||
createChildren() {
|
||
super.createChildren();
|
||
this.loadPark();
|
||
}
|
||
onRemoved() {
|
||
this.clearGameTimer();
|
||
super.onRemoved();
|
||
}
|
||
loadPark() {
|
||
this.setStatus("正在读取游乐园次数...");
|
||
WorldFeatureUtils.request("comm/get-pleasure-ground", {}, this.onParkLoaded.bind(this));
|
||
}
|
||
onParkLoaded(response) {
|
||
const usedCount = 0 === response.status && response.data ? toInt(response.data.count) : 0,
|
||
vipConfig = Global.gameProxy.getVipConfigForID(toInt(Global.playerProxy.playerData.vip, 0)) || {},
|
||
freeCount = toInt(vipConfig.playground_frequency),
|
||
rows = [
|
||
{
|
||
title: "今日次数",
|
||
lines: ["今日已进入 " + usedCount + " 次 VIP免费次数 " + freeCount, "超过免费次数后,后端会按旧规则扣除金币。"],
|
||
status: usedCount <= freeCount ? "可进入" : "需金币"
|
||
},
|
||
{
|
||
title: "泡泡乐园",
|
||
lines: ["15秒内点击按钮获得积分。", "积分达到奖励档位后自动结算奖励。"],
|
||
status: "",
|
||
actionLabel: "开始",
|
||
actionEnabled: !0,
|
||
gameType: 0,
|
||
onAction: this.startGame.bind(this)
|
||
},
|
||
{
|
||
title: "糖果乐园",
|
||
lines: ["15秒内点击按钮获得积分。", "每次点击得分略高。"],
|
||
status: "",
|
||
actionLabel: "开始",
|
||
actionEnabled: !0,
|
||
gameType: 1,
|
||
onAction: this.startGame.bind(this)
|
||
},
|
||
{
|
||
title: "娃娃乐园",
|
||
lines: ["15秒内点击按钮获得积分。", "每次点击得分最高。"],
|
||
status: "",
|
||
actionLabel: "开始",
|
||
actionEnabled: !0,
|
||
gameType: 2,
|
||
onAction: this.startGame.bind(this)
|
||
}
|
||
],
|
||
playground = WorldFeatureUtils.table("playground");
|
||
Object.keys(playground)
|
||
.sort(function (left, right) {
|
||
return toInt(left) - toInt(right);
|
||
})
|
||
.forEach(function (id) {
|
||
const config = playground[id];
|
||
rows.push({
|
||
title: "奖励档位 " + id,
|
||
lines: ["需要积分 " + toInt(config.integral), "奖励池:" + WorldFeatureUtils.rewardText(config.chest)],
|
||
status: ""
|
||
});
|
||
});
|
||
this.setStatus("游乐园已就绪");
|
||
this.showRows(rows);
|
||
}
|
||
startGame(row) {
|
||
if (this.gameRunning) return;
|
||
this.setStatus("正在进入游乐园...");
|
||
WorldFeatureUtils.request("comm/enter-pleasure-ground", {}, this.onGameEntered.bind(this, row.gameType));
|
||
}
|
||
onGameEntered(gameType, response) {
|
||
if (0 !== response.status) {
|
||
this.setStatus(WorldFeatureUtils.serverMessage(response, "进入游乐园失败"));
|
||
return;
|
||
}
|
||
this.uuid = response.data && response.data.uuid;
|
||
this.showGame(gameType);
|
||
}
|
||
showGame(gameType) {
|
||
this.contentGroup.removeChildren();
|
||
this.gameRunning = !0;
|
||
this.score = 0;
|
||
this.timeLeft = 15;
|
||
this.gameType = gameType;
|
||
const names = ["泡泡乐园", "糖果乐园", "娃娃乐园"],
|
||
perTap = [100, 120, 150][gameType] || 100;
|
||
this.perTap = perTap;
|
||
this.gameTitle = WorldFeatureUtils.makeLabel(names[gameType] || "游乐园", 30, 0xfffbf2, 0, 20, 520, 44);
|
||
this.gameTitle.textAlign = egret.HorizontalAlign.CENTER;
|
||
this.contentGroup.addChild(this.gameTitle);
|
||
this.scoreLabel = WorldFeatureUtils.makeLabel("积分:0", 28, 0x5b3616, 0, 100, 520, 44);
|
||
this.scoreLabel.stroke = 0;
|
||
this.scoreLabel.textAlign = egret.HorizontalAlign.CENTER;
|
||
this.contentGroup.addChild(this.scoreLabel);
|
||
this.timeLabel = WorldFeatureUtils.makeLabel("剩余:15秒", 24, 0xd03d1c, 0, 150, 520, 40);
|
||
this.timeLabel.stroke = 0;
|
||
this.timeLabel.textAlign = egret.HorizontalAlign.CENTER;
|
||
this.contentGroup.addChild(this.timeLabel);
|
||
this.hitButton = WorldFeatureUtils.makeButton("点击得分 +" + perTap, 240, 70);
|
||
this.hitButton.x = 140;
|
||
this.hitButton.y = 235;
|
||
this.hitButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onHitTap, this);
|
||
this.contentGroup.addChild(this.hitButton);
|
||
this.finishButton = WorldFeatureUtils.makeButton("结束结算", 160, 56);
|
||
this.finishButton.x = 180;
|
||
this.finishButton.y = 340;
|
||
this.finishButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.finishGame, this);
|
||
this.contentGroup.addChild(this.finishButton);
|
||
this.setStatus("游乐园进行中");
|
||
this.gameTimer = new egret.Timer(1000, 15);
|
||
this.gameTimer.addEventListener(egret.TimerEvent.TIMER, this.onGameTimer, this);
|
||
this.gameTimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.finishGame, this);
|
||
this.gameTimer.start();
|
||
}
|
||
onHitTap(event) {
|
||
event.stopPropagation();
|
||
if (!this.gameRunning) return;
|
||
this.score += this.perTap;
|
||
this.scoreLabel.text = "积分:" + this.score;
|
||
}
|
||
onGameTimer() {
|
||
this.timeLeft--;
|
||
this.timeLabel.text = "剩余:" + Math.max(0, this.timeLeft) + "秒";
|
||
}
|
||
clearGameTimer() {
|
||
if (this.gameTimer) {
|
||
this.gameTimer.stop();
|
||
this.gameTimer.removeEventListener(egret.TimerEvent.TIMER, this.onGameTimer, this);
|
||
this.gameTimer.removeEventListener(egret.TimerEvent.TIMER_COMPLETE, this.finishGame, this);
|
||
this.gameTimer = null;
|
||
}
|
||
this.hitButton && this.hitButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onHitTap, this);
|
||
this.finishButton && this.finishButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.finishGame, this);
|
||
}
|
||
finishGame(event) {
|
||
event && event.stopPropagation && event.stopPropagation();
|
||
if (!this.gameRunning) return;
|
||
this.gameRunning = !1;
|
||
this.clearGameTimer();
|
||
this.setStatus("正在结算游乐园奖励...");
|
||
WorldFeatureUtils.request(
|
||
"comm/pleasure-ground",
|
||
{
|
||
uuid: this.uuid,
|
||
score: this.score
|
||
},
|
||
this.onGameFinished.bind(this)
|
||
);
|
||
}
|
||
onGameFinished(response) {
|
||
if (0 !== response.status) {
|
||
this.setStatus(WorldFeatureUtils.serverMessage(response, "结算失败"));
|
||
return;
|
||
}
|
||
const rewardString = WorldFeatureUtils.addRewardToPlayer(response.data);
|
||
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE);
|
||
this.setStatus(rewardString ? "结算完成:" + WorldFeatureUtils.rewardText(rewardString) : "结算完成:分数不足");
|
||
this.loadPark();
|
||
}
|
||
};
|
||
((game.WorldParkPanel = WorldParkPanel), __reflect(WorldParkPanel.prototype, "game.WorldParkPanel"));
|
||
|
||
const WorldPetMediator = class WorldPetMediator extends BaseMediator {
|
||
constructor() {
|
||
super("WorldPetMediator");
|
||
}
|
||
listNotificationInterests() {
|
||
return [PanelNotify.OPEN_BATTLEPET, PanelNotify.CLOSE_BATTLEPET];
|
||
}
|
||
showViewComponent() {
|
||
((this.viewComponent = new game.WorldPetPanel()), (this.viewComponent.mediator = this), this.showUI(this.viewComponent, !0, 0, 0, 7));
|
||
}
|
||
handleNotification(notification) {
|
||
switch (notification.getName()) {
|
||
case PanelNotify.OPEN_BATTLEPET:
|
||
this.showViewComponent();
|
||
break;
|
||
case PanelNotify.CLOSE_BATTLEPET:
|
||
this.closeViewComponent(1);
|
||
}
|
||
}
|
||
static NAME = "WorldPetMediator";
|
||
};
|
||
((game.WorldPetMediator = WorldPetMediator), __reflect(WorldPetMediator.prototype, "game.WorldPetMediator"));
|
||
|
||
const WorldAchievementMediator = class WorldAchievementMediator extends BaseMediator {
|
||
constructor() {
|
||
super("WorldAchievementMediator");
|
||
}
|
||
listNotificationInterests() {
|
||
return [PanelNotify.OPEN_CHENGJIU, PanelNotify.CLOSE_CHENGJIU];
|
||
}
|
||
showViewComponent() {
|
||
((this.viewComponent = new game.WorldAchievementPanel()),
|
||
(this.viewComponent.mediator = this),
|
||
this.showUI(this.viewComponent, !0, 0, 0, 7));
|
||
}
|
||
handleNotification(notification) {
|
||
switch (notification.getName()) {
|
||
case PanelNotify.OPEN_CHENGJIU:
|
||
this.showViewComponent();
|
||
break;
|
||
case PanelNotify.CLOSE_CHENGJIU:
|
||
this.closeViewComponent(1);
|
||
}
|
||
}
|
||
static NAME = "WorldAchievementMediator";
|
||
};
|
||
((game.WorldAchievementMediator = WorldAchievementMediator),
|
||
__reflect(WorldAchievementMediator.prototype, "game.WorldAchievementMediator"));
|
||
|
||
const WorldSportsMediator = class WorldSportsMediator extends BaseMediator {
|
||
constructor() {
|
||
super("WorldSportsMediator");
|
||
}
|
||
listNotificationInterests() {
|
||
return [PanelNotify.OPEN_SPORTS, PanelNotify.CLOSE_SPORTS];
|
||
}
|
||
showViewComponent() {
|
||
((this.viewComponent = new game.WorldSportsPanel()),
|
||
(this.viewComponent.mediator = this),
|
||
this.showUI(this.viewComponent, !0, 0, 0, 7));
|
||
}
|
||
handleNotification(notification) {
|
||
switch (notification.getName()) {
|
||
case PanelNotify.OPEN_SPORTS:
|
||
this.showViewComponent();
|
||
break;
|
||
case PanelNotify.CLOSE_SPORTS:
|
||
this.closeViewComponent(1);
|
||
}
|
||
}
|
||
static NAME = "WorldSportsMediator";
|
||
};
|
||
((game.WorldSportsMediator = WorldSportsMediator), __reflect(WorldSportsMediator.prototype, "game.WorldSportsMediator"));
|
||
|
||
const WorldParkMediator = class WorldParkMediator extends BaseMediator {
|
||
constructor() {
|
||
super("WorldParkMediator");
|
||
}
|
||
listNotificationInterests() {
|
||
return [PanelNotify.OPEN_ASUMENT_PARK, PanelNotify.CLOSE_ASUMENT_PARK];
|
||
}
|
||
showViewComponent() {
|
||
((this.viewComponent = new game.WorldParkPanel()), (this.viewComponent.mediator = this), this.showUI(this.viewComponent, !0, 0, 0, 7));
|
||
}
|
||
handleNotification(notification) {
|
||
switch (notification.getName()) {
|
||
case PanelNotify.OPEN_ASUMENT_PARK:
|
||
this.showViewComponent();
|
||
break;
|
||
case PanelNotify.CLOSE_ASUMENT_PARK:
|
||
this.closeViewComponent(1);
|
||
}
|
||
}
|
||
static NAME = "WorldParkMediator";
|
||
};
|
||
((game.WorldParkMediator = WorldParkMediator), __reflect(WorldParkMediator.prototype, "game.WorldParkMediator"));
|
||
})(game || (game = {}));
|