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.
118 lines
4.5 KiB
118 lines
4.5 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
import User from "../../FrameWork/User/User";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import List from "../../Platform/th/List";
|
|
import ChengJiuManager from "../Manager/ChengJiuManager";
|
|
import NewGuideScript from "../NewGuide/NewGuideScript";
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
import ChengJiuItemNode from "./ChengJiuItemNode";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class ChengJiu extends cc.Component {
|
|
|
|
@property(cc.Prefab)
|
|
item: cc.Prefab = null;
|
|
|
|
@property(List)
|
|
listCJ: List = null;
|
|
dataListCJ: any[];
|
|
Config: ({ configId: number; icon: string; isNeedAd: boolean; descLab: string; miaoshu: string; needTime?: undefined; needDayNum?: undefined; needADNum?: undefined; } | { configId: number; icon: string; isNeedAd: boolean; descLab: string; miaoshu: string; needTime: number; needDayNum?: undefined; needADNum?: undefined; } | { configId: number; icon: string; isNeedAd: boolean; descLab: string; miaoshu: string; needDayNum: number; needTime?: undefined; needADNum?: undefined; } | { configId: number; icon: string; isNeedAd: boolean; descLab: string; miaoshu: string; needADNum: number; needTime?: undefined; needDayNum?: undefined; })[];
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
start() {
|
|
cc.sys.localStorage.setItem("成就引导", '1')
|
|
this.Config = ChengJiuManager.getManagerConfigs()
|
|
let saveDay = User.getSaveDay()
|
|
let curDay = this.getYMD()
|
|
if (curDay != saveDay) {
|
|
User.setSaveDay(curDay)
|
|
User.addDengLuDayNum()
|
|
//新的一天重置在线几分钟奖励
|
|
let onlineGameRewards = User.getChengJiuReward()
|
|
for (let i = 0; i < this.Config.length; i++) {
|
|
if (this.Config[i].needTime) {
|
|
onlineGameRewards[this.Config[i].configId] = 0
|
|
}
|
|
if (this.Config[i].needDayNum && User.getDengLuDayNum() >= this.Config[i].needDayNum) {
|
|
onlineGameRewards[this.Config[i].configId] = 0
|
|
}
|
|
}
|
|
}
|
|
this.scheduleOnce(() => {
|
|
this.setList()
|
|
|
|
// if (User.getFirstStepIndex() == 9 && !Common5.isCeBianLanEnter) {
|
|
// let node = this.node.getChildByName('guide')
|
|
// this.guideView([node], 100)
|
|
// }
|
|
}, 0.01)
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.closeChengJiu, () => {
|
|
User.setFirstStepIndex(1003)
|
|
EventMgr.emitEvent_custom(ryw_Event.My_Guide)
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
},this)
|
|
}
|
|
|
|
setList() {
|
|
let array = this.Config
|
|
this.dataListCJ = []
|
|
for (let n = 0; n < array.length; n++) {
|
|
this.dataListCJ.push(array[n]);
|
|
}
|
|
this.listCJ.numItems = this.dataListCJ.length;
|
|
|
|
// let index = TanWeiManager.getLockItemIndex()
|
|
this.listCJ.scrollTo(0)
|
|
}
|
|
onListMGridRender(item: cc.Node, idx: number) {
|
|
|
|
let config = this.dataListCJ[idx]
|
|
// console.log(config)
|
|
let danItem: ChengJiuItemNode = item.getComponent('ChengJiuItemNode')
|
|
danItem.init(config)
|
|
}
|
|
|
|
onTouchClose() {
|
|
// User.setFirstStepIndex(1003)
|
|
// EventMgr.emitEvent_custom(ryw_Event.My_Guide)
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
}
|
|
|
|
getYMD() {
|
|
let today = new Date();
|
|
let year = today.getFullYear();
|
|
let month = today.getMonth() + 1; // 注意月份从0开始,所以要加1
|
|
let date = today.getDate();
|
|
return `${year}${month}${date}`
|
|
}
|
|
|
|
guideView(nodeArray, opacity = -1) {
|
|
PrefabManage.loadPrefabByType(GameType.GuideMskNode, null, (prefab) => {
|
|
// prefab.zIndex = 199
|
|
let guideNodeArray = nodeArray
|
|
let firstNode = guideNodeArray.shift()
|
|
prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
|
|
if (opacity != -1) {
|
|
prefab.getComponent(NewGuideScript).setOpacityMaskNode(opacity)
|
|
}
|
|
})
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|
|
|