695 lines
26 KiB
JavaScript
695 lines
26 KiB
JavaScript
var game;
|
|
!(function (game) {
|
|
if (!game.MCUtils1) {
|
|
const MCUtils1 = class MCUtils1 {
|
|
constructor() {}
|
|
static getMc(name, callback = null, action = "") {
|
|
function createMovieClip(actionName) {
|
|
const texture = RES.getRes(name + "_tex_png"),
|
|
data = RES.getRes(name + "_mc_json"),
|
|
factory = new egret.MovieClipDataFactory(data, texture),
|
|
movieClip = new egret.MovieClip(factory.generateMovieClipData(actionName));
|
|
return ((movieClip.fac = factory), (movieClip.touchEnabled = !1), movieClip);
|
|
}
|
|
if (RES.getRes(name + "_tex_png")) {
|
|
const movieClip = createMovieClip(action);
|
|
return (callback && callback(movieClip), movieClip);
|
|
}
|
|
return (
|
|
RES.getResAsync(
|
|
name + "_tex_png",
|
|
function () {
|
|
RES.getResAsync(
|
|
name + "_mc_json",
|
|
function () {
|
|
callback && callback(createMovieClip(action));
|
|
},
|
|
this
|
|
);
|
|
},
|
|
this
|
|
),
|
|
null
|
|
);
|
|
}
|
|
static changeAction(movieClip, action) {
|
|
movieClip.movieClipData = movieClip.fac.generateMovieClipData(action);
|
|
}
|
|
};
|
|
((game.MCUtils1 = MCUtils1), __reflect(MCUtils1.prototype, "game.MCUtils1"));
|
|
}
|
|
})(game || (game = {}));
|
|
|
|
function showServerStatusTips(status) {
|
|
const message = GameConfig.ServerCode[status] || "操作失败";
|
|
TipsUtils.showTipsDownToUp(message);
|
|
}
|
|
|
|
function compactRewardString(rewardString) {
|
|
return game.CostUtils.parseCostString(rewardString)
|
|
.filter(function (reward) {
|
|
return reward.count > 0;
|
|
})
|
|
.map(function (reward) {
|
|
return reward.itemId + ":" + reward.count;
|
|
})
|
|
.join(",");
|
|
}
|
|
|
|
function appendRewardData(rewards, rewardData) {
|
|
if (rewardData && rewardData.item_id && int(rewardData.num) > 0)
|
|
rewards.push(rewardData.item_id + ":" + int(rewardData.num));
|
|
}
|
|
|
|
var Box = class Box {
|
|
constructor() {
|
|
this.id = null;
|
|
this.item_id = null;
|
|
this.end_open_time = 0;
|
|
this.is_get_gift = 0;
|
|
}
|
|
readData(data) {
|
|
((this.id = data.id),
|
|
(this.item_id = int(data.item_id)),
|
|
(this.end_open_time = int(data.end_open_time)),
|
|
(this.is_get_gift = int(data.is_get_gift)));
|
|
}
|
|
};
|
|
__reflect(Box.prototype, "Box");
|
|
|
|
var BoxManager = class BoxManager extends egret.EventDispatcher {
|
|
constructor() {
|
|
super();
|
|
this.curid = null;
|
|
this.delid = null;
|
|
this.gem = 0;
|
|
this.BoxList = [];
|
|
this.lastOpenData = null;
|
|
this.lastOpenedBox = null;
|
|
}
|
|
static getInstance() {
|
|
return this._instance || (this._instance = new BoxManager()), this._instance;
|
|
}
|
|
sendNetGetBoxList(callback, thisObj) {
|
|
((this.callF = callback),
|
|
(this.callObj = thisObj),
|
|
Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "comm/get-box-list", {}, this.onSendNetGetBoxList.bind(this)));
|
|
}
|
|
onSendNetGetBoxList(response) {
|
|
if (0 !== response.status) return void showServerStatusTips(response.status);
|
|
this.curid = null;
|
|
this.BoxList.length = 0;
|
|
const list = response.data || [];
|
|
for (let index = 0; index < list.length; index++) {
|
|
const box = new Box();
|
|
box.readData(list[index]);
|
|
this.BoxList.push(box);
|
|
box.end_open_time > 0 && (this.curid = box.id);
|
|
}
|
|
this.BoxList = _.sortBy(this.BoxList, "end_open_time");
|
|
if (this.BoxList.length > 0) {
|
|
const activeOrLastBox = this.BoxList.pop();
|
|
this.BoxList.unshift(activeOrLastBox);
|
|
}
|
|
(this.callF && this.callObj && this.callF.call(this.callObj),
|
|
game.EventManager.instance.dispatch(SysNotify.BOX_UPDATA));
|
|
}
|
|
sendNetBoxtime() {
|
|
if (null == this.curid) return;
|
|
Global.netProxy.sendRequest(
|
|
GameConfig.SERVER_PATH + "comm/box-start-time",
|
|
{
|
|
box_id: this.curid
|
|
},
|
|
this.onSendNetBoxtime.bind(this)
|
|
);
|
|
}
|
|
onSendNetBoxtime(response) {
|
|
0 === response.status ? this.sendNetGetBoxList(null, null) : showServerStatusTips(response.status);
|
|
}
|
|
sendNetOpenBox() {
|
|
if (null == this.curid) return;
|
|
this.lastOpenedBox = this.getBoxForID(this.curid);
|
|
Global.netProxy.sendRequest(
|
|
GameConfig.SERVER_PATH + "comm/open-box",
|
|
{
|
|
user_id: Global.playerProxy.playerData.id,
|
|
box_id: this.curid,
|
|
use_gem: this.gem > 0 ? 1 : 0
|
|
},
|
|
this.onSendNetOpenBox.bind(this)
|
|
);
|
|
}
|
|
onSendNetOpenBox(response) {
|
|
if (0 !== response.status) return void showServerStatusTips(response.status);
|
|
((this.lastOpenData = response.data || null),
|
|
this.gem > 0 && (Global.playerProxy.playerData.gem = int(Global.playerProxy.playerData.gem) - this.gem),
|
|
game.EventManager.instance.dispatch(SysNotify.BOX_OPEN),
|
|
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE));
|
|
}
|
|
sendNetDelnBox() {
|
|
if (null == this.delid) return;
|
|
Global.netProxy.sendRequest(
|
|
GameConfig.SERVER_PATH + "comm/del-box",
|
|
{
|
|
box_id: this.delid
|
|
},
|
|
this.onSendNetDelBox.bind(this)
|
|
);
|
|
}
|
|
onSendNetDelBox(response) {
|
|
0 === response.status
|
|
? (this.sendNetGetBoxList(null, null), game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE))
|
|
: showServerStatusTips(response.status);
|
|
}
|
|
getBoxForID(id) {
|
|
for (let index = 0; index < this.BoxList.length; index++) if (this.BoxList[index].id == id) return this.BoxList[index];
|
|
return null;
|
|
}
|
|
};
|
|
__reflect(BoxManager.prototype, "BoxManager");
|
|
|
|
var BoxMediator = class BoxMediator extends BaseMediator {
|
|
constructor() {
|
|
super(BoxMediator.NAME);
|
|
this.GroupName = "box";
|
|
}
|
|
listNotificationInterests() {
|
|
return [PanelNotify.OPEN_BOX, PanelNotify.CLOSE_BOX];
|
|
}
|
|
showViewComponent(layer = 7) {
|
|
((this.viewComponent = new BoxPanel()), this.showUI(this.viewComponent, !0, 0, 0, layer));
|
|
}
|
|
handleNotification(notification) {
|
|
switch (notification.getName()) {
|
|
case PanelNotify.OPEN_BOX:
|
|
BoxManager.getInstance().sendNetGetBoxList(this.onGetInfo, this);
|
|
break;
|
|
case PanelNotify.CLOSE_BOX:
|
|
this.closeViewComponent();
|
|
}
|
|
}
|
|
onGetInfo() {
|
|
RES.isGroupLoaded(this.GroupName)
|
|
? this.showViewComponent()
|
|
: (RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this),
|
|
RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this),
|
|
RES.loadGroup(this.GroupName));
|
|
}
|
|
onResourceLoadComplete(event) {
|
|
event.groupName == this.GroupName &&
|
|
(RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this),
|
|
RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this),
|
|
this.showViewComponent());
|
|
}
|
|
onResourceLoadError(event) {
|
|
console.warn("Group:" + event.groupName + " has failed to load");
|
|
this.onResourceLoadComplete(event);
|
|
}
|
|
static NAME = "BoxMediator";
|
|
};
|
|
__reflect(BoxMediator.prototype, "BoxMediator");
|
|
|
|
var BoxPanel = class BoxPanel extends game.BasePanel {
|
|
constructor() {
|
|
super();
|
|
this.skinName = BoxPanelSkin;
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(),
|
|
this.commonPanel && this.commonPanel.setPanelWidth(640),
|
|
this.commonPanel && this.commonPanel.setPanelHeight(840),
|
|
this.commonPanel && this.commonPanel.setTitleIcon("box_json.box_sp1"),
|
|
this.commonPanel && this.commonPanel.setTitle("box_json.box_sp0"),
|
|
this.updata());
|
|
}
|
|
childrenCreated() {
|
|
super.childrenCreated();
|
|
this.mc = game.MCUtils1.getMc("box_faguang");
|
|
this.mc &&
|
|
((this.mc.x = GameConfig.curWidth() / 2),
|
|
(this.mc.y = 800),
|
|
this.addChild(this.mc),
|
|
(this.mc.visible = !1));
|
|
}
|
|
onAdded() {
|
|
(super.onAdded(),
|
|
game.EventManager.instance.addEvent(SysNotify.BOX_UPDATA, this.updata, this),
|
|
game.EventManager.instance.addEvent(SysNotify.BOX_OPEN, this.onNetOpenBox, this),
|
|
this.gemButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onOpenBox, this));
|
|
for (let index = 0; index < 8; index++) this["unit" + index].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTab, this);
|
|
core.TimerManager.instance.addTick(1e3, -1, this.onTimer, this);
|
|
}
|
|
onRemoved() {
|
|
(super.onRemoved(),
|
|
game.EventManager.instance.removeEvent(SysNotify.BOX_UPDATA, this.updata, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.BOX_OPEN, this.onNetOpenBox, this),
|
|
this.gemButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onOpenBox, this),
|
|
core.TimerManager.instance.removeTick(this.onTimer, this));
|
|
for (let index = 0; index < 8; index++) this["unit" + index].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTab, this);
|
|
}
|
|
onTimer() {
|
|
if (null == BoxManager.getInstance().curid) return;
|
|
const box = BoxManager.getInstance().getBoxForID(BoxManager.getInstance().curid);
|
|
if (!box) return;
|
|
const remaining = box.end_open_time - DateTimer.instance.now;
|
|
remaining >= 0
|
|
? (this.timeLabel.text = TimeFormat.showHHMMSS(1e3 * remaining))
|
|
: ((this.timeLabel.text = TimeFormat.showHHMMSS(0)), (this.gemButton.label = "0"));
|
|
}
|
|
onTab(event) {
|
|
const unit = event.currentTarget;
|
|
if (null != unit.id && null == BoxManager.getInstance().curid) {
|
|
((BoxManager.getInstance().curid = unit.id), (unit.fagaungImg.visible = !0), BoxManager.getInstance().sendNetBoxtime());
|
|
}
|
|
}
|
|
onOpenBox() {
|
|
if (null == BoxManager.getInstance().curid) return void TipsUtils.showTipsDownToUp("请选择宝箱");
|
|
const box = BoxManager.getInstance().getBoxForID(BoxManager.getInstance().curid);
|
|
if (!box) return void TipsUtils.showTipsDownToUp("宝箱不存在");
|
|
const boxConfig = Global.gameProxy.getBoxConfigForID(box.item_id) || {};
|
|
BoxManager.getInstance().gem = box.end_open_time > DateTimer.instance.now ? int(boxConfig.Diamond) : 0;
|
|
BoxManager.getInstance().sendNetOpenBox();
|
|
}
|
|
onNetOpenBox() {
|
|
if (!this.mc) return void this.onMoviePlayComplete();
|
|
(this.mc.visible = !0,
|
|
this.mc.gotoAndPlay(1, 1),
|
|
this.mc.addEventListener(egret.Event.COMPLETE, this.onMoviePlayComplete, this));
|
|
}
|
|
onMoviePlayComplete() {
|
|
this.mc && this.mc.removeEventListener(egret.Event.COMPLETE, this.onMoviePlayComplete, this);
|
|
this.mc && (this.mc.visible = !1);
|
|
const manager = BoxManager.getInstance(),
|
|
openedBox = manager.lastOpenedBox,
|
|
boxConfig = openedBox ? Global.gameProxy.getBoxConfigForID(openedBox.item_id) || {} : {},
|
|
rewards = [];
|
|
boxConfig.fixed_id && rewards.push(boxConfig.fixed_id);
|
|
boxConfig.fixed_id2 && rewards.push(boxConfig.fixed_id2);
|
|
appendRewardData(rewards, manager.lastOpenData);
|
|
const rewardString = compactRewardString(rewards.join(","));
|
|
rewardString && Global.playerProxy.addItem1(rewardString);
|
|
manager.sendNetGetBoxList(null, null);
|
|
}
|
|
btnCloseTouchEnded() {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_BOX);
|
|
}
|
|
updata() {
|
|
for (let index = 0; index < 8; index++) {
|
|
const unit = this["unit" + index];
|
|
((unit.icons.source = ""), (unit.fagaungImg.visible = !1), (unit.closeButton.visible = !1), (unit.id = null));
|
|
}
|
|
const manager = BoxManager.getInstance();
|
|
for (let index = 0; index < manager.BoxList.length && index < 8; index++) {
|
|
const box = manager.BoxList[index],
|
|
iconId = Global.gameProxy.getItemImageId(box.item_id),
|
|
unit = this["unit" + index];
|
|
((unit.icons.source = game.URLConfig.getIcon(iconId)),
|
|
(unit.closeButton.visible = !0),
|
|
(unit.id = box.id),
|
|
(unit.fagaungImg.visible = unit.id == manager.curid));
|
|
}
|
|
((this.boxImg.source = ""), (this.gemButton.label = "0"), (this.timeLabel.text = ""));
|
|
const box = null != manager.curid ? manager.getBoxForID(manager.curid) : null;
|
|
if (box) {
|
|
const boxImageMap = {
|
|
201016: "box_bg01_png",
|
|
201015: "box_bg1_png",
|
|
201014: "box_bg2_png",
|
|
201013: "box_bg3_png",
|
|
201012: "box_bg4_png"
|
|
},
|
|
boxConfig = Global.gameProxy.getBoxConfigForID(box.item_id) || {};
|
|
((this.boxImg.source = boxImageMap[box.item_id] || "box_bg1_png"),
|
|
(this.gemButton.label = box.end_open_time >= DateTimer.instance.now ? int(boxConfig.Diamond).toString() : "0"),
|
|
this.onTimer());
|
|
}
|
|
}
|
|
};
|
|
__reflect(BoxPanel.prototype, "BoxPanel");
|
|
|
|
var BoxUnit = class BoxUnit extends eui.Component {
|
|
constructor() {
|
|
super();
|
|
}
|
|
childrenCreated() {
|
|
(super.childrenCreated(), this.closeButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onclose, this));
|
|
}
|
|
onclose(event) {
|
|
(event.stopPropagation(), (BoxManager.getInstance().delid = this.id), BoxManager.getInstance().sendNetDelnBox());
|
|
}
|
|
};
|
|
__reflect(BoxUnit.prototype, "BoxUnit");
|
|
|
|
var FaguangButton = class FaguangButton extends eui.Button {
|
|
constructor() {
|
|
super();
|
|
this.skinName = FaguangButtonSkin;
|
|
}
|
|
childrenCreated() {
|
|
super.childrenCreated();
|
|
this.mc = game.MCUtils1.getMc("box_anniu");
|
|
this.mc && (this.gs.addChild(this.mc), (this.mc.x = this.gs.width / 2), (this.mc.y = this.gs.height / 2), this.mc.play(-1));
|
|
}
|
|
};
|
|
__reflect(FaguangButton.prototype, "FaguangButton");
|
|
|
|
var SignMediter = class SignMediter extends BaseMediator {
|
|
constructor() {
|
|
super(SignMediter.NAME);
|
|
}
|
|
listNotificationInterests() {
|
|
return [PanelNotify.OPEN_SIGN, PanelNotify.CLOSE_SIGN];
|
|
}
|
|
showViewComponent(layer = 7) {
|
|
((this.viewComponent = new SignPanel()), this.showUI(this.viewComponent, !0, 0, 0, layer));
|
|
}
|
|
handleNotification(notification) {
|
|
switch (notification.getName()) {
|
|
case PanelNotify.OPEN_SIGN:
|
|
Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "comm/sign-list", {}, this.onGetSign.bind(this));
|
|
break;
|
|
case PanelNotify.CLOSE_SIGN:
|
|
this.closeViewComponent();
|
|
}
|
|
}
|
|
onGetSign(response) {
|
|
if (0 !== response.status) return void showServerStatusTips(response.status);
|
|
const manager = SignsManager.getInstance();
|
|
((manager.hasNetSignData = (response.data && response.data.list) || []),
|
|
(manager.count = ((response.data && response.data.continue_list) || []).length),
|
|
manager.inithasSign(),
|
|
manager.updata(),
|
|
manager.getReward()
|
|
? game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_SIGN_LIAN)
|
|
: this.showViewComponent(7));
|
|
}
|
|
static NAME = "SignMediter";
|
|
};
|
|
__reflect(SignMediter.prototype, "SignMediter");
|
|
|
|
var SignPanel = class SignPanel extends game.BasePanel {
|
|
constructor() {
|
|
super();
|
|
this.boxArr = [];
|
|
this.maskArr = [];
|
|
this.imgGetArr = [];
|
|
this.imgIconArr = [];
|
|
this.labelNumArr = [];
|
|
this.skinName = SignPanelSkin;
|
|
}
|
|
createChildren() {
|
|
super.createChildren();
|
|
(this.boxArr.push(this.imgBox1, this.imgBox2, this.imgBox3),
|
|
this.maskArr.push(this.rectMask1, this.rectMask2, this.rectMask3, this.rectMask4, this.rectMask5, this.rectMask6, this.rectMask7),
|
|
this.imgGetArr.push(this.imgGet1, this.imgGet2, this.imgGet3, this.imgGet4, this.imgGet5, this.imgGet6, this.imgGet7),
|
|
this.imgIconArr.push(this.imgIcon1, this.imgIcon2, this.imgIcon3, this.imgIcon4, this.imgIcon5, this.imgIcon6, this.imgIcon7),
|
|
this.labelNumArr.push(this.labelNum1, this.labelNum2, this.labelNum3, this.labelNum4, this.labelNum5, this.labelNum6, this.labelNum7),
|
|
(this.imgLineLight.mask = this.groupMask),
|
|
this.updata());
|
|
}
|
|
onAdded() {
|
|
(super.onAdded(), game.EventManager.instance.addEvent(SysNotify.GETSIGNS_UPDATA, this.onUpdata, this));
|
|
}
|
|
onRemoved() {
|
|
(super.onRemoved(), game.EventManager.instance.removeEvent(SysNotify.GETSIGNS_UPDATA, this.onUpdata, this));
|
|
}
|
|
onTouchTap(event) {
|
|
switch (event.target) {
|
|
case this.btnSign:
|
|
SignsManager.getInstance().sendNetsigns();
|
|
break;
|
|
case this.btnAddSign:
|
|
SignsManager.getInstance().sendNetBusigns();
|
|
break;
|
|
case this.imgBox1:
|
|
case this.imgBox2:
|
|
case this.imgBox3:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_SIGN_LIAN);
|
|
}
|
|
}
|
|
btnCloseTouchEnded() {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_SIGN);
|
|
}
|
|
onUpdata() {
|
|
this.updata();
|
|
}
|
|
updata() {
|
|
const manager = SignsManager.getInstance(),
|
|
signedCount = manager.getVirtuyCount();
|
|
((this.barExp.maximum = 7), (this.barExp.minimum = 0), (this.barExp.value = signedCount));
|
|
const rewardBoxCount = manager.getCount();
|
|
for (let index = 0; index < this.boxArr.length; index++)
|
|
this.boxArr[index].source = rewardBoxCount > index ? "sign_box1_png" : 2 == index ? "sign_box2_png" : "sign_box0_png";
|
|
for (let index = 0; index < manager.signArr.length && index < 7; index++) {
|
|
const signData = manager.signArr[index],
|
|
rewards = game.CostUtils.parseCostString(signData.days_id),
|
|
reward = rewards[0] || { itemId: Const.GOLD_ID, count: 0 },
|
|
iconId = Global.gameProxy.getItemImageId(reward.itemId);
|
|
((this.maskArr[index].visible = !!signData.isqian),
|
|
(this.imgGetArr[index].visible = !!signData.isqian),
|
|
(this.imgIconArr[index].source = game.URLConfig.getIcon(iconId)),
|
|
(this.labelNumArr[index].text = "X" + reward.count));
|
|
}
|
|
const card = Global.playerProxy.getHasItemByItemId(103008);
|
|
((this.labelDayNum.text = signedCount.toString()),
|
|
(this.labelCardNum.text = "剩余补签卡" + (card ? card.number : 0) + "张"));
|
|
}
|
|
};
|
|
__reflect(SignPanel.prototype, "SignPanel");
|
|
|
|
var SignsData = class SignsData {
|
|
constructor(data) {
|
|
((this.isqian = !1),
|
|
(this.id = int(data.id)),
|
|
(this.days_id = data.days_id || ""),
|
|
(this.accumulation_id = data.accumulation_id || ""),
|
|
(this.days = int(data.days)),
|
|
(this.accumulation = int(data.accumulation)));
|
|
}
|
|
};
|
|
__reflect(SignsData.prototype, "SignsData");
|
|
|
|
var SignsItem = class SignsItem extends eui.Component {
|
|
constructor() {
|
|
super();
|
|
}
|
|
};
|
|
__reflect(SignsItem.prototype, "SignsItem");
|
|
|
|
var SignsManager = class SignsManager extends egret.EventDispatcher {
|
|
constructor() {
|
|
super();
|
|
this.count = 0;
|
|
this.signArr = [];
|
|
this.hasNetSignData = [];
|
|
this.hasSignData = [];
|
|
this.countArr = [3, 5, 7];
|
|
}
|
|
static getInstance() {
|
|
return this._instance || (this._instance = new SignsManager()), this._instance;
|
|
}
|
|
updata() {
|
|
this.signArr.length = 0;
|
|
const signConfig = Global.gameProxy.getSignConfig();
|
|
for (const key in signConfig) {
|
|
const signData = new SignsData(signConfig[key]);
|
|
this.signArr.push(signData);
|
|
for (let index = 0; index < this.hasSignData.length; index++)
|
|
this.hasSignData[index].id == signData.id && (signData.isqian = !0);
|
|
}
|
|
this.signArr.sort(function (left, right) {
|
|
return left.id - right.id;
|
|
});
|
|
}
|
|
inithasSign() {
|
|
this.hasSignData.length = 0;
|
|
for (let index = 0; index < this.hasNetSignData.length; index++)
|
|
this.hasSignData.push({
|
|
id: this.getIndexForTime(this.hasNetSignData[index].sign_time),
|
|
time: this.hasNetSignData[index].sign_time
|
|
});
|
|
}
|
|
getDataForID(id) {
|
|
for (let index = 0; index < this.signArr.length; index++) if (this.signArr[index].id == id) return this.signArr[index];
|
|
return null;
|
|
}
|
|
getIndexForTime(time) {
|
|
const date = new Date(1e3 * time);
|
|
let day = date.getDay();
|
|
return 0 == day && (day = 7), day;
|
|
}
|
|
sendNetsigns() {
|
|
const today = this.getIndexForTime(DateTimer.instance.now),
|
|
data = this.getDataForID(today);
|
|
if (!data) return void TipsUtils.showTipsDownToUp("签到配置缺失");
|
|
0 == data.isqian
|
|
? ((this.curid = today), Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "comm/sign", {}, this.onGetSign.bind(this)))
|
|
: TipsUtils.showTipsDownToUp("今日已签到");
|
|
}
|
|
onGetSign(response) {
|
|
if (0 !== response.status) return void showServerStatusTips(response.status);
|
|
const data = this.getDataForID(this.curid);
|
|
if (!data) return;
|
|
(Global.playerProxy.addItem1(data.days_id),
|
|
(data.isqian = !0),
|
|
this.hasSignData.push({
|
|
id: data.id,
|
|
time: DateTimer.instance.now
|
|
}),
|
|
this.updata(),
|
|
game.EventManager.instance.dispatch(SysNotify.GETSIGNS_UPDATA),
|
|
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE));
|
|
}
|
|
getcurbuID() {
|
|
for (let index = this.signArr.length - 1; index >= 0; index--) {
|
|
const today = int(this.getIndexForTime(DateTimer.instance.now)),
|
|
id = int(this.signArr[index].id);
|
|
if (0 == this.signArr[index].isqian && today > id) return id;
|
|
}
|
|
return null;
|
|
}
|
|
sendNetBusigns() {
|
|
this.bucurID = this.getcurbuID();
|
|
null != this.bucurID
|
|
? Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "comm/sign-remedy", {}, this.onGetBuSign.bind(this))
|
|
: TipsUtils.showTipsDownToUp("当前不能补签");
|
|
}
|
|
onGetBuSign(response) {
|
|
if (0 !== response.status) return void showServerStatusTips(response.status);
|
|
const data = this.getDataForID(this.bucurID);
|
|
if (!data) return;
|
|
(Global.playerProxy.addItem1(data.days_id),
|
|
Global.playerProxy.sellWareHouseItem({ id: 103008 }, 1),
|
|
(data.isqian = !0),
|
|
this.hasSignData.push({
|
|
id: data.id,
|
|
time: DateTimer.instance.now
|
|
}),
|
|
this.updata(),
|
|
game.EventManager.instance.dispatch(SysNotify.GETSIGNS_UPDATA),
|
|
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE));
|
|
}
|
|
getVirtuyCount() {
|
|
let runningCount = 0,
|
|
maxCount = 0;
|
|
for (let index = 0; index < this.signArr.length; index++)
|
|
1 == this.signArr[index].isqian ? (runningCount++, runningCount > maxCount && (maxCount = runningCount)) : (runningCount = 0);
|
|
return maxCount;
|
|
}
|
|
getCount() {
|
|
const count = this.getVirtuyCount();
|
|
return count >= 3 && count < 5 ? 1 : count >= 5 && count < 7 ? 2 : 7 == count ? 3 : 0;
|
|
}
|
|
getReward() {
|
|
if (this.count < this.getCount()) {
|
|
const rewardDay = 0 == this.count ? 3 : 1 == this.count ? 5 : 2 == this.count ? 7 : null;
|
|
return rewardDay ? this.getDataForID(rewardDay) : null;
|
|
}
|
|
return null;
|
|
}
|
|
getNetbigrewad() {
|
|
const rewardDay = this.countArr[this.count];
|
|
if (!rewardDay) return void TipsUtils.showTipsDownToUp("没有可领取的连续签到奖励");
|
|
((this.curdata = this.getDataForID(rewardDay)),
|
|
Global.netProxy.sendRequest(
|
|
GameConfig.SERVER_PATH + "comm/get-continue-sign-gift",
|
|
{
|
|
user_id: Global.playerProxy.playerData.id,
|
|
count: rewardDay
|
|
},
|
|
this.onGetBigRewardID.bind(this)
|
|
));
|
|
}
|
|
onGetBigRewardID(response) {
|
|
if (0 !== response.status) return void showServerStatusTips(response.status);
|
|
const data = this.curdata;
|
|
data &&
|
|
(Global.playerProxy.addItem1(data.accumulation_id),
|
|
this.count++,
|
|
game.EventManager.instance.dispatch(SysNotify.GETSIGNS_UPDATA),
|
|
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE));
|
|
}
|
|
};
|
|
__reflect(SignsManager.prototype, "SignsManager");
|
|
|
|
var SignsTipsMediter = class SignsTipsMediter extends BaseMediator {
|
|
constructor() {
|
|
super(SignsTipsMediter.NAME);
|
|
}
|
|
listNotificationInterests() {
|
|
return [PanelNotify.OPEN_SIGN_LIAN, PanelNotify.CLOSE_SIGN_LIAN];
|
|
}
|
|
showViewComponent(layer = 7) {
|
|
((this.viewComponent = new SignsTipsPanel()), this.showUI(this.viewComponent, !0, 0, 0, layer));
|
|
}
|
|
handleNotification(notification) {
|
|
switch (notification.getName()) {
|
|
case PanelNotify.OPEN_SIGN_LIAN:
|
|
this.showViewComponent(7);
|
|
break;
|
|
case PanelNotify.CLOSE_SIGN_LIAN:
|
|
this.closeViewComponent();
|
|
}
|
|
}
|
|
static NAME = "SignsTipsMediter";
|
|
};
|
|
__reflect(SignsTipsMediter.prototype, "SignsTipsMediter");
|
|
|
|
var SignsTipsPanel = class SignsTipsPanel extends game.BasePanel {
|
|
constructor() {
|
|
super();
|
|
this.itemArr = [];
|
|
this.boxArr = [];
|
|
this.skinName = SignTipSkin;
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(),
|
|
this.itemArr.push(this.item0, this.item1, this.item2),
|
|
this.boxArr.push(this.imgBox1, this.imgBox2, this.imgBox3),
|
|
this.updata());
|
|
}
|
|
onAdded() {
|
|
(super.onAdded(), game.EventManager.instance.addEvent(SysNotify.GETSIGNS_UPDATA, this.onUpdata, this));
|
|
}
|
|
onRemoved() {
|
|
(super.onRemoved(), game.EventManager.instance.removeEvent(SysNotify.GETSIGNS_UPDATA, this.onUpdata, this));
|
|
}
|
|
onTouchTap(event) {
|
|
switch (event.target) {
|
|
case this.getButton:
|
|
SignsManager.getInstance().getNetbigrewad();
|
|
}
|
|
}
|
|
btnCloseTouchEnded() {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_SIGN_LIAN);
|
|
}
|
|
onUpdata() {
|
|
this.updata();
|
|
}
|
|
updata() {
|
|
const manager = SignsManager.getInstance(),
|
|
signedCount = manager.getVirtuyCount();
|
|
this.prossbar && (this.prossbar.setPross(signedCount, 7), (this.prossbar.prossLabel.visible = !1));
|
|
let openedBoxIndex = -1;
|
|
signedCount >= 3 && signedCount < 5 ? (openedBoxIndex = 0) : signedCount >= 5 && signedCount < 7 ? (openedBoxIndex = 1) : signedCount >= 7 && (openedBoxIndex = 2);
|
|
for (let index = 0; index < this.boxArr.length; index++)
|
|
this.boxArr[index].source = openedBoxIndex >= index ? "sign_box1_png" : 2 == index ? "sign_box2_png" : "sign_box0_png";
|
|
let rewardData = manager.getReward();
|
|
rewardData
|
|
? ((this.disbalButton.visible = !1), (this.getButton.visible = !0))
|
|
: ((this.getButton.visible = !1), (this.disbalButton.visible = !0), (rewardData = manager.getDataForID(7)));
|
|
const rewards = rewardData ? game.CostUtils.parseCostString(rewardData.accumulation_id) : [];
|
|
for (let index = 0; index < this.itemArr.length; index++) {
|
|
const item = this.itemArr[index],
|
|
reward = rewards[index];
|
|
if (reward) {
|
|
const iconId = Global.gameProxy.getItemImageId(reward.itemId);
|
|
((item.visible = !0), (item.iconImg.source = game.URLConfig.getIcon(iconId)), (item.numLabel.text = "X" + reward.count));
|
|
} else item.visible = !1;
|
|
}
|
|
this.dayLabel.text = signedCount.toString();
|
|
}
|
|
};
|
|
__reflect(SignsTipsPanel.prototype, "SignsTipsPanel");
|