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.
311 lines
9.4 KiB
311 lines
9.4 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
import GameReport from "../../FrameWork/Report/ZyZyReport";
|
|
import User from "../../FrameWork/User/User";
|
|
import AppPlatform from "../../FrameWork/Util/AppPlatform";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
|
|
import BagManager from "../Manager/BagManager";
|
|
import InterfaceManager from "../Manager/InterfaceManager";
|
|
import TaoFenManager from "../Manager/TaoFenManager";
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
import GameBase from "../SCommon/GameBase";
|
|
import GetAward from "../SCommon/GetAward";
|
|
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class TaoFenScript extends GameBase {
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
|
|
@property(cc.Node)
|
|
taofenSpine: cc.Node = null;
|
|
@property(cc.Node)
|
|
jingaiNode: cc.Node = null;
|
|
@property(cc.Label)
|
|
spendMoney: cc.Label = null;
|
|
|
|
|
|
spendArray = [10,60,300]
|
|
tanhuangMax = 1
|
|
xichenqiMax = 2
|
|
|
|
_chooseIndex = 2
|
|
startPosiX = 0
|
|
|
|
|
|
wulianIndex = 0
|
|
spineAnim = ['gunzi', 'tanhuangguan', 'xichengqi','jiuchidingpa']
|
|
isAnim: boolean = false;
|
|
_dt = 0;
|
|
|
|
onLoad () {
|
|
super.onLoad()
|
|
|
|
}
|
|
onDestroy(){
|
|
super.onDestroy()
|
|
|
|
|
|
|
|
}
|
|
start () {
|
|
|
|
this.refreshBtnVdTimes()
|
|
this.scheduleOnce(()=>{
|
|
this.startPosiX = this.jingaiNode.x
|
|
|
|
cc.tween(this.jingaiNode)
|
|
.to(2,{x: this.startPosiX+410})
|
|
.start()
|
|
|
|
|
|
},0.1)
|
|
|
|
|
|
let _list = TaoFenManager.getCurGoodList()
|
|
//console.log(_list, '_list+++')
|
|
//木棍, 弹簧,吸尘器
|
|
//this.spendArray = [_list[11].priceNum, _list[7].priceNum, _list[22].priceNum]
|
|
this.spendMoney.string = Common5.getNumberChangeHanzi(this.spendArray[this._chooseIndex])+''
|
|
|
|
}
|
|
|
|
refreshBtnVdTimes(){
|
|
|
|
}
|
|
|
|
gunziChooseClickEvent(event, chooseIndex){
|
|
//Common5.playEffect("sound/按键点击")
|
|
|
|
this.reportKey(()=>{
|
|
GameReport.BtnsReport('棍子')
|
|
})
|
|
this._chooseIndex = chooseIndex
|
|
this.spendMoney.string = Common5.getNumberChangeHanzi(this.spendArray[chooseIndex])+''
|
|
}
|
|
|
|
tanhuanChooseClickEvent(event, chooseIndex){
|
|
//Common5.playEffect("sound/按键点击")
|
|
|
|
this.reportKey(()=>{
|
|
GameReport.BtnsReport('弹簧器')
|
|
})
|
|
this._chooseIndex = chooseIndex
|
|
this.spendMoney.string = Common5.getNumberChangeHanzi(this.spendArray[chooseIndex])+''
|
|
}
|
|
|
|
xichenChooseClickEvent(event, chooseIndex){
|
|
//Common5.playEffect("sound/按键点击")
|
|
|
|
this.reportKey(()=>{
|
|
GameReport.BtnsReport('棍子')
|
|
})
|
|
this._chooseIndex = chooseIndex
|
|
this.spendMoney.string = Common5.getNumberChangeHanzi(this.spendArray[chooseIndex])+''
|
|
}
|
|
|
|
taofenOneClickEvent(){
|
|
|
|
if(this.isAnim){
|
|
return
|
|
}
|
|
|
|
this.reportKey(()=>{
|
|
GameReport.BtnsReport('掏一次')
|
|
})
|
|
// if(UserManager.getCurMoney()-this.spendArray[this._chooseIndex]>=0){
|
|
// UserManager.subMoney(this.spendArray[this._chooseIndex])
|
|
// }else{
|
|
// PrefabManage.showTextTips('余额不足,请去地摊或者商人处换钱再来!')
|
|
// return
|
|
// }
|
|
|
|
//Common5.playEffect("sound/按键点击")
|
|
let spineA = this.spineAnim[this._chooseIndex]
|
|
this.isAnim = true
|
|
|
|
|
|
let goodArray = InterfaceManager.getMangheGoodsListByType('TaoFen',1,false, spineA)
|
|
|
|
|
|
cc.tween(this.jingaiNode)
|
|
|
|
.call(()=>{
|
|
this.taofenSpine.getComponent(sp.Skeleton).setAnimation(0, spineA, false)
|
|
})
|
|
.delay(4.0)
|
|
.call(()=>{
|
|
Common5.playEffect("CommonRes/sound/管道疏通")
|
|
})
|
|
.delay(1.0)
|
|
.call(()=>{
|
|
console.log('奖励+++++')
|
|
this.taofenSpine.getComponent(sp.Skeleton).setAnimation(0, 'xunhuan', true)
|
|
//this.jingaiNode.x = this.startPosiX
|
|
|
|
|
|
PrefabManage.loadPrefabByType(GameType.GetAward,null,(prefabNode)=>{
|
|
prefabNode.getComponent(GetAward).initView(goodArray, ()=>{
|
|
|
|
}, false);
|
|
},false)
|
|
this.isAnim = false
|
|
|
|
})
|
|
.start()
|
|
|
|
}
|
|
|
|
|
|
jiuchiAnim(){
|
|
if(this.isAnim){
|
|
return
|
|
}
|
|
//Common5.playEffect("sound/按键点击")
|
|
let spineA = 'jiuchidingpa'//this.spineAnim[this._chooseIndex]
|
|
this.isAnim = true
|
|
|
|
let goodArray = InterfaceManager.getMangheGoodsListByType('TaoFen',5,true, spineA)
|
|
|
|
|
|
cc.tween(this.jingaiNode)
|
|
.call(()=>{
|
|
this.taofenSpine.getComponent(sp.Skeleton).setAnimation(0, spineA, false)
|
|
})
|
|
.delay(4.0)
|
|
.call(()=>{
|
|
Common5.playEffect("CommonRes/sound/管道疏通")
|
|
})
|
|
.delay(1.0)
|
|
.call(()=>{
|
|
console.log('奖励+++++')
|
|
this.taofenSpine.getComponent(sp.Skeleton).setAnimation(0, 'xunhuan', true)
|
|
//this.jingaiNode.x = this.startPosiX
|
|
this.isAnim = false
|
|
|
|
//let goodArray = InterfaceManager.getMangheGoodsListByType('TaoFen',5,true)
|
|
PrefabManage.loadPrefabByType(GameType.GetAward,null,(prefabNode)=>{
|
|
prefabNode.getComponent(GetAward).initView(goodArray, ()=>{
|
|
|
|
},false);
|
|
},false)
|
|
|
|
})
|
|
.start()
|
|
}
|
|
|
|
|
|
jiuchiClickEvent(){
|
|
//Common5.playEffect("sound/按键点击")
|
|
let tab = {
|
|
onClose: (finish)=>{
|
|
if(finish) {
|
|
Common5.ReportDY("inLevel", '管道疏通-AD-五连掏');
|
|
//jiuchidingpa
|
|
this.reportKey(()=>{
|
|
GameReport.ADReport('管道疏通五连掏',1)
|
|
})
|
|
//五莲发???
|
|
this.wulianIndex = 0
|
|
this.jiuchiAnim()
|
|
}
|
|
else{
|
|
this.reportKey(()=>{
|
|
GameReport.ADReport('管道疏通五连掏',0)
|
|
})
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
|
|
},onFailed:()=>{
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
}
|
|
|
|
tanhuanVdClickEvent(){
|
|
//Common5.playEffect("sound/按键点击")
|
|
let tab = {
|
|
onClose: (finish)=>{
|
|
if(finish) {
|
|
Common5.ReportDY("inLevel", '掏粪-AD-弹簧器');
|
|
this.reportKey(()=>{
|
|
GameReport.ADReport('掏粪弹簧器',1)
|
|
})
|
|
let taofenArray = User.getTaofenArray()
|
|
taofenArray.tanhuang++
|
|
User.setTaofenArray(taofenArray)
|
|
|
|
this.refreshBtnVdTimes()
|
|
if(taofenArray.tanhuang>=this.tanhuangMax){
|
|
let chooseIndex = 1
|
|
this.node.getChildByName('toggleContainer').children[chooseIndex].getComponent(cc.Toggle).isChecked = true
|
|
this._chooseIndex = chooseIndex
|
|
this.spendMoney.string = Common5.getNumberChangeHanzi(this.spendArray[chooseIndex])+''
|
|
|
|
}
|
|
|
|
|
|
}
|
|
else{
|
|
this.reportKey(()=>{
|
|
GameReport.ADReport('掏粪弹簧器',0)
|
|
})
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
|
|
},onFailed:()=>{
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
}
|
|
|
|
xichenVdClickEvent(){
|
|
//Common5.playEffect("sound/按键点击")
|
|
let tab = {
|
|
onClose: (finish)=>{
|
|
if(finish) {
|
|
this.reportKey(()=>{
|
|
GameReport.ADReport('掏粪吸尘器',1)
|
|
})
|
|
Common5.ReportDY("inLevel", '掏粪-AD-吸尘器');
|
|
let taofenArray = User.getTaofenArray()
|
|
taofenArray.xichen++
|
|
User.setTaofenArray(taofenArray)
|
|
|
|
this.refreshBtnVdTimes()
|
|
if(taofenArray.xichen>=this.xichenqiMax){
|
|
let chooseIndex = 2
|
|
this.node.getChildByName('toggleContainer').children[chooseIndex].getComponent(cc.Toggle).isChecked = true
|
|
this._chooseIndex = chooseIndex
|
|
this.spendMoney.string = Common5.getNumberChangeHanzi(this.spendArray[chooseIndex])+''
|
|
}
|
|
}
|
|
else{
|
|
|
|
this.reportKey(()=>{
|
|
GameReport.ADReport('掏粪吸尘器',0)
|
|
})
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
|
|
},onFailed:()=>{
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
}
|
|
|
|
|
|
}
|
|
|