|
|
@@ -3,12 +3,26 @@ import { RewardType } from "../../data/GameData";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
/**
|
|
|
+ * 盖子类型
|
|
|
+ */
|
|
|
+enum LidType {
|
|
|
+ /** 无盖子 */
|
|
|
+ none = 0,
|
|
|
+ /** 幸运红包盖子 */
|
|
|
+ luck = 1,
|
|
|
+ /** 通关红包盖子 */
|
|
|
+ mission = 2
|
|
|
+}
|
|
|
+/**
|
|
|
* 获取奖励界面-红包
|
|
|
* @author 薛鸿潇
|
|
|
*/
|
|
|
@ccclass
|
|
|
export default class Reward extends cc.Component {
|
|
|
|
|
|
+
|
|
|
+ @property({ displayName: '红包类型', type: cc.Enum(LidType), tooltip: 'none无类型,luck幸运红包,mission通关红包' })
|
|
|
+ private lid_type: LidType = LidType.none;
|
|
|
@property({ displayName: '幸运红包', type: cc.Node })
|
|
|
private node_luck: cc.Node = null;
|
|
|
@property({ displayName: '通关红包', type: cc.Node })
|
|
|
@@ -44,11 +58,6 @@ export default class Reward extends cc.Component {
|
|
|
}
|
|
|
|
|
|
update(dt) {
|
|
|
- if (gData.reward.init_luck_style) {
|
|
|
- gData.reward.init_luck_style = null;
|
|
|
- this.initLid();
|
|
|
- return;
|
|
|
- }
|
|
|
if (gData.reward.init_cash_style) {
|
|
|
gData.reward.init_cash_style = null;
|
|
|
this.initCashOutStyle();
|
|
|
@@ -66,18 +75,21 @@ export default class Reward extends cc.Component {
|
|
|
* 初始化封面样式
|
|
|
*/
|
|
|
private initLid() {
|
|
|
- if (gData.reward.lid_type === gData.reward.type_lid.none) {// 无盖子样式
|
|
|
+ if (this.lid_type === LidType.none) {// 无盖子样式
|
|
|
this.node_luck.active = false;
|
|
|
this.node_mission.active = false;
|
|
|
+ this.btn_watch_video.node.active = false;
|
|
|
this.watchVideoCall();
|
|
|
mk.audio.playEffect("rewardOpen");
|
|
|
- } else if (gData.reward.lid_type === gData.reward.type_lid.luck) {
|
|
|
- this.node_luck.active = false;
|
|
|
- this.node_mission.active = true;
|
|
|
+ } else if (this.lid_type === LidType.luck) {
|
|
|
+ this.node_luck.active = true;
|
|
|
+ this.node_mission.active = false;
|
|
|
+ this.btn_watch_video.node.active = true;
|
|
|
mk.audio.playEffect("reward");
|
|
|
- } else if (gData.reward.lid_type === gData.reward.type_lid.mission) {
|
|
|
+ } else if (this.lid_type === LidType.mission) {
|
|
|
this.node_luck.active = false;
|
|
|
this.node_mission.active = true;
|
|
|
+ this.btn_watch_video.node.active = true;
|
|
|
mk.audio.playEffect("reward");
|
|
|
}
|
|
|
}
|
|
|
@@ -86,9 +98,10 @@ export default class Reward extends cc.Component {
|
|
|
* 底部提现相关样式
|
|
|
*/
|
|
|
private initCashOutStyle() {
|
|
|
- const cash_bar = gData.redBagCash.cash_bar
|
|
|
- let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar)
|
|
|
-
|
|
|
+ const cash_bar = gData.redBagCash.cash_bar;
|
|
|
+ let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
|
|
|
+ if (!cash_data) return;
|
|
|
+
|
|
|
this.lbl_cash.string = cash_data.money + '元';
|
|
|
this.lbl_cash_out.string = gData.gameData.gameData.redMoney + '/' + cash_data.type_value;
|
|
|
this.spr_cash_out.fillRange = gData.gameData.gameData.redMoney / cash_data.type_value;
|
|
|
@@ -99,7 +112,7 @@ export default class Reward extends cc.Component {
|
|
|
*/
|
|
|
private clickWatchVideo() {
|
|
|
cc.log('看广告请求');
|
|
|
- if (gData.reward.data[0].rewardType === 1) {
|
|
|
+ if (gData.reward.data[0] && gData.reward.data[0].rewardType === 1) {
|
|
|
gData.adData.watchVideo(AdFun.settlement)// 关卡结算视频
|
|
|
} else {
|
|
|
gData.adData.watchVideo(AdFun.bubble);// 气泡视频
|
|
|
@@ -165,7 +178,7 @@ export default class Reward extends cc.Component {
|
|
|
|
|
|
}
|
|
|
|
|
|
- onDestroy(){
|
|
|
+ onDestroy() {
|
|
|
mk.audio.playEffect("rewardClose");
|
|
|
}
|
|
|
|