觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
6.9 KiB

1 week ago
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import Common5 from "../../Platform/th/Common5";
import JuQingManager from "../JuQingChat/JuQingManager";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import BagManager from "../Manager/BagManager";
import InterfaceManager from "../Manager/InterfaceManager";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import GetAward from "../SCommon/GetAward";
let PingGaiPosTab = [
[{ x: -100, y: 0 }, { x: 100, y: 0 }],
[{ x: -100, y: 100 }, { x: 100, y: 100 }, { x: -200, y: -100 }, { x: 0, y: -100 }, { x: 200, y: -100 }]
]
const { ccclass, property } = cc._decorator;
@ccclass
export default class JiuPingHuiShou extends cc.Component {
@property(cc.Node)
chuanSongDaiSpine: cc.Node = null;
@property(cc.Node)
pingGaiSpine: cc.Node = null;
isPlaySpine: boolean = true
selectNum: number = 0
start() {
this.startSpine()
}
startSpine() {
this.chuanSongDaiSpine.getComponent(sp.Skeleton).setAnimation(0, '送进来', false)
this.scheduleOnce(() => {
this.isPlaySpine = false
}, 1)
}
qiaoPingZiSpine() {
this.isPlaySpine = true
if (this.selectNum == 2) {
this.chuanSongDaiSpine.getComponent(sp.Skeleton).setAnimation(0, '敲两个', false)
this.scheduleOnce(() => {
let isHaveTaskGood = true
for (let i = 0; i < PingGaiPosTab[0].length; i++) {
let pingGai = cc.instantiate(this.pingGaiSpine)
pingGai.parent = this.node
pingGai.active = true
pingGai.setPosition(PingGaiPosTab[0][i].x, PingGaiPosTab[0][i].y)
if (isHaveTaskGood && i == 0) {
pingGai.getComponent(sp.Skeleton).setAnimation(0, '特等奖', false)
} else {
pingGai.getComponent(sp.Skeleton).setAnimation(0, '三等奖', false)
}
cc.tween(pingGai)
.delay(1.4)
.call(() => {
pingGai.removeFromParent()
})
.start()
}
this.chuanSongDaiSpine.getComponent(sp.Skeleton).setAnimation(0, '两个送进去', false)
this.scheduleOnce(() => {
this.showAward(2, false)
this.scheduleOnce(() => {
this.startSpine()
})
}, 1.2)
}, 0.6)
} else if (this.selectNum == 5) {
this.chuanSongDaiSpine.getComponent(sp.Skeleton).setAnimation(0, '敲五个', false)
this.scheduleOnce(() => {
let isHaveTaskGood = true
for (let i = 0; i < PingGaiPosTab[1].length; i++) {
let pingGai = cc.instantiate(this.pingGaiSpine)
pingGai.parent = this.node
pingGai.active = true
pingGai.setPosition(PingGaiPosTab[1][i].x, PingGaiPosTab[1][i].y)
if (isHaveTaskGood && i == 3) {
pingGai.getComponent(sp.Skeleton).setAnimation(0, '特等奖', false)
} else {
pingGai.getComponent(sp.Skeleton).setAnimation(0, '三等奖', false)
}
cc.tween(pingGai)
.delay(1.4)
.call(() => {
pingGai.removeFromParent()
})
.start()
}
this.chuanSongDaiSpine.getComponent(sp.Skeleton).setAnimation(0, '五个送进去', false)
this.scheduleOnce(() => {
this.showAward(5, true)
this.scheduleOnce(() => {
this.startSpine()
})
}, 1.2)
}, 1.5)
}
}
onBtnQiaoYiQiao() {
if (this.isPlaySpine) {
return
}
Common5.playEffectCustom('jiuPingHuiShou','sound/砸酒瓶2次')
this.selectNum = 2
this.qiaoPingZiSpine()
}
onBtnQiaoWuCi() {
if (this.isPlaySpine) {
return
}
let tab = {
onClose: (finish) => {
if (finish) {
Common5.ReportDY("inLevel", '废瓶回收-AD-敲五次');
Common5.playEffectCustom('jiuPingHuiShou','sound/砸酒瓶5次')
this.selectNum = 5
this.qiaoPingZiSpine()
} else {
Common5.showTips_custom("广告未观看完");
}
}, onFailed: () => {
}
}
AppPlatform.playVideo_custom(tab)
}
showAward(num, isVideo) {
let goodArray = InterfaceManager.getMangheGoodsListByType('JiuPingHuiShou', num, isVideo)
PrefabManage.loadPrefabByType(GameType.GetAward, null, (prefabNode) => {
prefabNode.getComponent(GetAward).initView(goodArray, () => {
let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_505) {
let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan;
for (const goodId of taskCaiGouDan) {
if (BagManager.getBagGoodNums(goodId) == 0) {
return;
}
}
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_505);
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_506);
JuQingManager.unLockNewJuQing('WX_503');
}else if(mainId == MainTaskIdEnum.MainTask_302){
let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan;
for (const goodId of taskCaiGouDan) {
if (BagManager.getBagGoodNums(goodId) == 0) {
return;
}
}
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_302);
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_303);
}else if(mainId == MainTaskIdEnum.MainTask_1702){
let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan;
for (const goodId of taskCaiGouDan) {
if (BagManager.getBagGoodNums(goodId) == 0) {
return;
}
}
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1702);
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1703);
}
});
})
}
}