觉醒时刻
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.
 
 
 

304 lines
12 KiB

import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import GameReport from "../../FrameWork/Report/ZyZyReport";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import { DateUtils } from "../../FrameWork/Util/DateUtils";
import Common5 from "../../Platform/th/Common5";
import TaskManager from "../JuQingChat/TaskManager";
import UserManager from "../Manager/UserManager";
import PrefabManage from "../PrefabManager/PrefabManage";
import GameBase from "../SCommon/GameBase";
import MeiNvZhaoMuManager from "./MeiNvZhaoMuManager";
enum PeriodNum {
Period_0,
Period_1,
Period_2,
Period_3
}
const { ccclass, property } = cc._decorator;
@ccclass
export default class MeiNvZhaoMu extends GameBase {
@property(cc.PageView)
pageView: cc.PageView = null
@property(cc.Node)
pageContent: cc.Node = null
@property(cc.Node)
timeNode: cc.Node = null
// @property(cc.Node)
// btnZhaoMu:cc.Node=null
// @property(cc.Node)
// btnZhaoMuAD:cc.Node=null
// LIFE-CYCLE CALLBACKS:
@property(cc.Node)
btnLeftNode: cc.Node = null;
@property(cc.Node)
btnRightNode: cc.Node = null;
curPageIndex = 0
// onLoad () {}
_dt: number = 0
btnPeriod = []
isPlaying: boolean = false
curTypeId: number = 0
onLoad() {
super.onLoad()
}
onDestroy() {
super.onDestroy()
}
//0快递,1松花江,2下水道
initView(typeId) {
this.curTypeId = typeId
this.initBtnPeriod()
this.refreshView()
}
start() {
// MeiNvZhaoMuManager.initManager()
// let beiShu = MeiNvZhaoMuManager.getBeiShu()
// let str = ""
// let numstr = ["一", "二", "三", "四", "五"]
// for (let i = 0; i < beiShu.length; i++) {
// str += `${numstr[i]}个秘书收益x${beiShu[i]}`
// if (i < beiShu.length - 1) {
// str += ','
// }
// }
// this.node.getChildByName("miaoshu").getComponent(cc.Label).string = str
}
update(dt) {
this._dt += dt
if (this._dt >= 1) {
this._dt = 0
this.refreshView()
}
}
initBtnPeriod() {
let localZhaoMuData = MeiNvZhaoMuManager.getMeiNvZhaoMuData()
let AllConfig = MeiNvZhaoMuManager.getAllConfig()
for (var i = 0; i < AllConfig[this.curTypeId].length; i++) {
this.btnPeriod[i] = PeriodNum.Period_2
let skeleton = this.pageContent.getChildByName("page_" + i).getChildByName("skeleton")
// if(localZhaoMuData[i].isZhaoMuZhong){
// skeleton.getComponent(sp.Skeleton).animation = "daijib"
// }else{
// skeleton.getComponent(sp.Skeleton).animation = "daijia"
// }
if (localZhaoMuData[this.curTypeId].unLockTab.indexOf(i) >= 0) {
skeleton.getComponent(sp.Skeleton).setAnimation(0, '呼吸', true)
skeleton.getComponent(sp.Skeleton).setSkin(AllConfig[this.curTypeId][i].skinIndex)
} else {
skeleton.getComponent(sp.Skeleton).setAnimation(0, '黑影', true)
skeleton.getComponent(sp.Skeleton).setSkin(AllConfig[this.curTypeId][i].skinIndex)
}
}
}
refreshView() {
let localZhaoMuData = MeiNvZhaoMuManager.getMeiNvZhaoMuData()
let AllConfig = MeiNvZhaoMuManager.getAllConfig()
for (var i = 0; i < AllConfig[this.curTypeId].length; i++) {
if (i == this.curPageIndex) {
// let skeleton = this.pageContent.getChildByName("page_"+this.curPageIndex).getChildByName("skeleton")
// let btnZhaoMu = this.pageContent.getChildByName("page_"+i).getChildByName("btnZhaoMu")
let btnZhaoMuAD = this.pageContent.getChildByName("page_" + i).getChildByName("btnZhaoMuAD")
if (localZhaoMuData[this.curTypeId].unLockTab.indexOf(i) >= 0) {
this.btnPeriod[i] = PeriodNum.Period_3
btnZhaoMuAD.getComponent(cc.Button).interactable = false
btnZhaoMuAD.active = true
// btnZhaoMu.active = false
this.timeNode.active = true
this.timeNode.getChildByName("timeStr").getComponent(cc.Label).string = `${DateUtils.formatTime_custom(localZhaoMuData[this.curTypeId].zhaoMuTime)}后刷新`
} else {
// if(this.btnPeriod[i] == PeriodNum.Period_0){
// // btnZhaoMu.active = true
// // btnZhaoMu.getChildByName("labM").getComponent(cc.Label).string = Common5.getNumberChangeHanzi(AllConfig[i].buyPrice1,'1',1)+''
// // btnZhaoMu.attr({bindMoney:AllConfig[i].buyPrice1})
// btnZhaoMuAD.active = false
// }else if(this.btnPeriod[i] == PeriodNum.Period_1){
// // btnZhaoMu.active = true
// // btnZhaoMu.getChildByName("labM").getComponent(cc.Label).string = Common5.getNumberChangeHanzi(AllConfig[i].buyPrice2,'1',1)+''
// // btnZhaoMu.attr({bindMoney:AllConfig[i].buyPrice2})
// btnZhaoMuAD.active = false
// }else
if (this.btnPeriod[i] == PeriodNum.Period_2) {
btnZhaoMuAD.getComponent(cc.Button).interactable = true
btnZhaoMuAD.active = true
// btnZhaoMu.active = false
}
this.timeNode.active = false
this.timeNode.getChildByName("timeStr").getComponent(cc.Label).string = ``
}
break
}
}
}
socrllPageEvent() {
console.log('socrllPageEvent++++++++++++++++')
let page = this.pageView.getCurrentPageIndex()
console.log(page, 'page')
this.curPageIndex = page
this.refreshView()
this.btnLeftNode.active = true
this.btnRightNode.active = true
let AllConfig = MeiNvZhaoMuManager.getAllConfig()
if (this.curPageIndex == 0 ) {
this.btnLeftNode.active = false
}else if (this.curPageIndex == AllConfig[this.curTypeId].length - 1) {
this.btnRightNode.active = false
}
}
onBtnZhaoMuADClick() {
Common5.playEffect("CommonRes/sound/按键点击")
if (this.isPlaying) {
return
}
this.isPlaying = true
let skeleton = this.pageContent.getChildByName("page_" + this.curPageIndex).getChildByName("skeleton")
// let btnZhaoMu = this.pageContent.getChildByName("page_"+this.curPageIndex).getChildByName("btnZhaoMu")
let btnZhaoMuAD = this.pageContent.getChildByName("page_" + this.curPageIndex).getChildByName("btnZhaoMuAD")
let tab = {
onClose: (finish) => {
if (finish) {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
Common5.ReportDY("inLevel", `任务${mainId}-AD-雇佣秘书招聘`);
// skeleton.getComponent(sp.Skeleton).setAnimation(0,"渐显",false)
// cc.tween(this.node)
// .delay(0.8)
// .call(()=>{
skeleton.getComponent(sp.Skeleton).setAnimation(0, "呼吸", true)
this.btnPeriod[this.curPageIndex] = PeriodNum.Period_3
// btnZhaoMu.active = false
btnZhaoMuAD.active = true
btnZhaoMuAD.getComponent(cc.Button).interactable = false
MeiNvZhaoMuManager.setMeiNvZhaoMuData(this.curTypeId, this.curPageIndex)
this.isPlaying = false
let localZhaoMuData = MeiNvZhaoMuManager.getMeiNvZhaoMuData()
let zhaoMuBeiShu = localZhaoMuData[this.curTypeId].zhaoMuBeiShu
PrefabManage.showTextTips(`收益已提升至${zhaoMuBeiShu}`)
EventMgr.emitEvent_custom(ryw_Event.refreshMiaoZhuan)
// })
// .start()
}
else {
this.isPlaying = false
this.reportKey(() => {
GameReport.ADReport('招募' + this.curPageIndex, 0)
})
Common5.showTips_custom("广告未观看完");
}
}, onFailed: () => {
}
}
AppPlatform.playVideo_custom(tab)
}
onBtnZhaoMuClick(event) {
Common5.playEffect("CommonRes/sound/按键点击")
this.reportKey(() => {
GameReport.BtnsReport('投资' + this.curPageIndex)
})
if (this.isPlaying) {
return
}
if (!this.subMoney(event.target.bindMoney)) {
return
}
this.isPlaying = true
let skeleton = this.pageContent.getChildByName("page_" + this.curPageIndex).getChildByName("skeleton")
let btnZhaoMu = this.pageContent.getChildByName("page_" + this.curPageIndex).getChildByName("btnZhaoMu")
let btnZhaoMuAD = this.pageContent.getChildByName("page_" + this.curPageIndex).getChildByName("btnZhaoMuAD")
if (this.btnPeriod[this.curPageIndex] == PeriodNum.Period_0) {
skeleton.getComponent(sp.Skeleton).setAnimation(0, "zhezhao1", false)
cc.tween(this.node)
.delay(0.5)
.call(() => {
skeleton.getComponent(sp.Skeleton).setAnimation(0, "zhezhao1b", true)
this.btnPeriod[this.curPageIndex] = PeriodNum.Period_1
this.isPlaying = false
})
.start()
} else if (this.btnPeriod[this.curPageIndex] == PeriodNum.Period_1) {
skeleton.getComponent(sp.Skeleton).setAnimation(0, "zhezhao2", false)
cc.tween(this.node)
.delay(0.5)
.call(() => {
skeleton.getComponent(sp.Skeleton).setAnimation(0, "zhezhao2b", true)
this.btnPeriod[this.curPageIndex] = PeriodNum.Period_2
btnZhaoMu.active = false
btnZhaoMuAD.active = true
this.isPlaying = false
})
.start()
}
}
leftClick() {
Common5.playEffect("CommonRes/sound/按键点击")
this.curPageIndex--
if (this.curPageIndex < 0) {
this.curPageIndex = 0
}
if (this.curPageIndex >= 1 && this.curPageIndex < 4) {
this.btnLeftNode.active = true
this.btnRightNode.active = true
}
this.pageView.scrollToPage(this.curPageIndex, 0.6)
if (this.curPageIndex == 0) {
this.btnLeftNode.active = false
this.btnRightNode.active = true
}
this.refreshView()
}
rightClick() {
Common5.playEffect("CommonRes/sound/按键点击")
this.curPageIndex++
if (this.curPageIndex > 4) {
this.curPageIndex = 4
}
if (this.curPageIndex >= 1 && this.curPageIndex < 4) {
this.btnLeftNode.active = true
this.btnRightNode.active = true
}
this.pageView.scrollToPage(this.curPageIndex, 1)
if (this.curPageIndex == 2) {
this.btnLeftNode.active = true
this.btnRightNode.active = false
}
}
subMoney(money) {
if (money > UserManager.getCurMoney()) {
PrefabManage.showTextTips("余额不足");
return false
}
UserManager.subMoney(money)
return true
}
}