咸鱼的反击
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.
 
 
 
xianyudefanji/assets/Scripts/SignDay/SignDayScript.ts

133 lines
4.7 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 UiBase from "../GameBase/UiBase";
import LevelUpManager from "../Manager/LevelUpManager";
import MiShuManager from "../Manager/MiShuManager";
import UserManager from "../Manager/UserManager";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends UiBase {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
curSignDay:number = 0
signConfig = [
{ goodType:1, goodName:'第一天', priceNum:1000000, GoodNum:1, descStr:'自动点击' },
{ goodType:9999, goodName:'第二天', priceNum:5, GoodNum:1,descStr:'海量金币' },
{ goodType:2, goodName:'第三天', priceNum:20, GoodNum:1, descStr:'等级+20' },
{ goodType:3, goodName:'第四天', mishuId:16, mishuName:'晴萱', priceNum:0, GoodNum:1, descStr:'' },
{ goodType:9999, goodName:'第五天', priceNum:5, GoodNum:1,descStr:'海量金币' },
{ goodType:2, goodName:'第六天', priceNum:40, GoodNum:1,descStr:'等级+40' },
{ goodType:3, goodName:'第七天', mishuId:17, mishuName:'绮罗', priceNum:0, GoodNum:1,descStr:'' },
]
start () {
MiShuManager.initManager()
this.curSignDay = 0
let signList = User.getSignList()
for(let i = 0; i<7; i++){
if(signList[i] == 0){
this.curSignDay = i
break
}
}
this.refreshView()
let level = User.getAutoLevel()
// if(level==0){
// PrefabManage.preloadPrefabByType(GameType.AutoLevelUpTips)
// }
}
refreshView(){
let signList = User.getSignList()
for(let i = 0; i<this.signConfig.length;i++){
let nodeName = 'itemNode'+i
let node = this.node.getChildByName(nodeName)
let zhezhao = node.getChildByName('遮罩')
let tianshu = node.getChildByName('天数').getComponent(cc.Label)
let desc = node.getChildByName('desc').getComponent(cc.Label)
tianshu.string = this.signConfig[i].goodName
desc.string = this.signConfig[i].descStr
if(node){
node['signId'] = i
if(signList[i] == 0){
zhezhao.active = false
}else{
zhezhao.active = true
}
}
}
}
getSignReward(event){
let target = event.target
let signId = target['signId']
let signList = User.getSignList()
let isGetReward = signList[signList.length-1]
if(signId == this.curSignDay && isGetReward == 0){
signList[signId] = 1
signList[signList.length-1] = 1
User.setSignList(signList)
let config = this.signConfig[signId]
if(config.goodType == 9999){
let levelUpSpned = LevelUpManager.getCurClickIncome()
let priceNum = levelUpSpned*config.priceNum
UserManager.addMoney(priceNum)
PrefabManage.showTextTips('获得金钱'+Common5.getNumberChangeHanzi(priceNum,'1',0))
}else if(config.goodType == 1){
let time = User.getAutoClickTime()
User.setAutoClickTime(5*60+time)
User.addAutoLevel()
EventMgr.emitEvent_custom(ryw_Event.RefreshLevelLab)
PrefabManage.showTextTips('获得道具自动点击')
}else if(config.goodType == 2){
let priceNum = config.priceNum
LevelUpManager.peopleLevelUp(priceNum)
PrefabManage.showTextTips('等级增加'+ priceNum)
}else if(config.goodType == 3){
let mishuName = config.mishuName
let mishuId = config.mishuId
PrefabManage.showTextTips('获得秘书'+mishuName)
MiShuManager.setMishuLock(mishuId, true)
// PrefabManage.loadPrefabByType(GameType.MishuReward, null, (prefab)=>{
// prefab.getComponent('MishuReward').setViewDate(mishuId, true, 'lock')
// })
}
this.refreshView()
}
}
// update (dt) {}
}