|
|
@@ -1,5 +1,8 @@
|
|
|
import BaseUI from "../../../MOKA/component/BaseUI";
|
|
|
import Time from "../../../MOKA/util/Time";
|
|
|
+import { Utils } from "../../../MOKA/util/Utils";
|
|
|
+import { PLAYERPROP } from "../../data/GameDefinition";
|
|
|
+import GameController from "../../GameController";
|
|
|
import DrawItem from "./DrawItem";
|
|
|
import DrawRecruitModel from "./DrawRecruitModel";
|
|
|
|
|
|
@@ -10,6 +13,9 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
protected static prefabUrl = "module/drawRecruit/drawGeneral";
|
|
|
protected static className = "DrawGeneralUI";
|
|
|
|
|
|
+ @property({ type: cc.Label, displayName: '文本_元宝' })
|
|
|
+ txt_num_yb: cc.Label = null;
|
|
|
+
|
|
|
@property({ type: cc.Node, displayName: '单抽页' })
|
|
|
panel_one: cc.Node = null;
|
|
|
|
|
|
@@ -34,11 +40,30 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
@property({ type: cc.Node, displayName: '十_结束页' })
|
|
|
panelTen_end: cc.Node = null;
|
|
|
|
|
|
+ @property({ type: cc.Label, displayName: '文本_单抽元宝消耗' })
|
|
|
+ txt_cost_one: cc.Label = null;
|
|
|
+
|
|
|
+ @property({ type: cc.Label, displayName: '文本_十连抽元宝消耗' })
|
|
|
+ txt_cost_ten: cc.Label = null;
|
|
|
+
|
|
|
+ @property({ type: cc.Label, displayName: '文本_单抽倒计时' })
|
|
|
+ txt_timer_one: cc.Label = null;
|
|
|
+
|
|
|
+ private time_one: number = 3;
|
|
|
+ private isTimer_one: boolean = false;
|
|
|
+ private isOpenedOne: boolean = false;
|
|
|
+ private isOpenedTen: boolean = false;
|
|
|
isDrawEnd: boolean = false;
|
|
|
isOpenAll: boolean = false;
|
|
|
|
|
|
+ isCanClick: boolean = true; //暂时没用
|
|
|
+
|
|
|
start() {
|
|
|
if (this.ui_data != null) {
|
|
|
+ let cfg = GameController.gameData.serverConfig_data;
|
|
|
+ this.txt_num_yb.string = GameController.gameData.player.getProp(PLAYERPROP.YB) + "";
|
|
|
+ this.txt_cost_one.string = cfg.invite_cost;
|
|
|
+ this.txt_cost_ten.string = cfg.invite_cost * 10 * cfg.invite_discount + "";
|
|
|
this.panel_one.active = this.ui_data.type == 1;
|
|
|
this.panel_ten.active = this.ui_data.type != 1;
|
|
|
|
|
|
@@ -55,8 +80,11 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
}
|
|
|
|
|
|
initPanelOne() {
|
|
|
+ this.isOpenedOne = false;
|
|
|
this.panelOne_start.active = true;
|
|
|
this.panelOne_end.active = false;
|
|
|
+ this.time_one = 3;
|
|
|
+ this.isTimer_one = true;
|
|
|
|
|
|
//this.drawItem_one.openDraw(DrawRecruitModel.Ins.getAGeneral());
|
|
|
}
|
|
|
@@ -67,8 +95,25 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
this.panelTen_end.active = false;
|
|
|
}
|
|
|
|
|
|
+ update(dt) {
|
|
|
+ if (this.isTimer_one) {
|
|
|
+ this.time_one -= dt;
|
|
|
+ if (this.time_one <= 0) {
|
|
|
+ this.time_one = 0;
|
|
|
+ this.isTimer_one = false;
|
|
|
+ if (!this.isOpenedOne) {
|
|
|
+ this.openDraw_One();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.txt_timer_one.string = "点击翻开卡牌(" + Utils.TimeToFormat(this.time_one, 1) + ")";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
async openDraw_One() {
|
|
|
+ if (this.isOpenedOne) return;
|
|
|
+ this.isOpenedOne = true;
|
|
|
+
|
|
|
let general = DrawRecruitModel.Ins.getAGeneral();
|
|
|
this.drawItem_one.openDraw(general);
|
|
|
await Time.WaitForSeconds(0.5);
|
|
|
@@ -77,17 +122,19 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
}
|
|
|
|
|
|
async openDraw_Ten() {
|
|
|
+ this.isCanClick = false;
|
|
|
let general = DrawRecruitModel.Ins.getAGeneral();
|
|
|
- for (let i = 0; i < this.drawItem_tens.length; i++) {
|
|
|
+ for (let i = 0; cc.isValid(this) && i < this.drawItem_tens.length; i++) {
|
|
|
if (!this.isOpenAll) {
|
|
|
this.drawItem_tens[i].openDraw(general);
|
|
|
await Time.WaitForSeconds(0.3);
|
|
|
} else {
|
|
|
return;
|
|
|
}
|
|
|
- if (i == this.drawItem_tens.length - 1) {
|
|
|
+ if (cc.isValid(this) && i == this.drawItem_tens.length - 1) {
|
|
|
this.panelTen_start.active = false;
|
|
|
this.panelTen_end.active = true;
|
|
|
+ this.isCanClick = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -98,8 +145,7 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
|
|
|
click_Draw_OneBtn() {
|
|
|
this.drawItem_one.init();
|
|
|
- this.panelOne_end.active = false;
|
|
|
- this.panelOne_start.active = true;
|
|
|
+ this.initPanelOne();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -114,6 +160,7 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
}
|
|
|
this.panelTen_start.active = false;
|
|
|
this.panelTen_end.active = true;
|
|
|
+ this.isCanClick = true;
|
|
|
}
|
|
|
|
|
|
click_Draw_TenBtn() {
|
|
|
@@ -125,4 +172,8 @@ export default class DrawGeneralUI extends BaseUI {
|
|
|
this.panelTen_end.active = false;
|
|
|
this.openDraw_Ten();
|
|
|
}
|
|
|
+
|
|
|
+ click_AddYBBtn() {
|
|
|
+
|
|
|
+ }
|
|
|
}
|