咸鱼的反击
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/JieDao/JieDaoItemNode.ts

103 lines
4.3 KiB

3 months ago
// 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 TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import BagManager from "../Manager/BagManager";
2 months ago
import JieDaoManager from "../Manager/JieDaoManager";
3 months ago
import LevelUpManager from "../Manager/LevelUpManager";
import ShipuManager from "../Manager/ShipuManager";
import UserManager from "../Manager/UserManager";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
const { ccclass, property } = cc._decorator;
@ccclass
export default class JieDaoItemNode extends cc.Component {
@property(cc.Sprite)
icon: cc.Sprite = null;
@property(cc.Label)
title_str: cc.Label = null;
2 months ago
@property(cc.RichText)
lockBeiShu: cc.RichText = null;
3 months ago
@property(cc.Label)
2 months ago
unlockBeiShu: cc.Label = null;
3 months ago
config: any;
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start() {
2 months ago
EventMgr.onEvent_custom(ryw_Event.RefreshJieDao, () => {
this.refreshState()
}, this)
3 months ago
}
init(data) {
this.config = data
2 months ago
Common5.getSpriteFrameFromBundle("JieDao", this.config.icon, this.icon)
3 months ago
// Common5.addUrlSprite_custom(this.config.icon, this.icon)
this.refreshState()
}
2 months ago
onTouchQieHuan() {
JieDaoManager.setJieDaoInUse(this.config.level)
EventMgr.emitEvent_custom(ryw_Event.RefreshJieDao)
3 months ago
}
2 months ago
refreshState() {
this.title_str.string = this.config.descLab
let inUse = JieDaoManager.getJieDaoInUse()
if (inUse == this.config.level) {
this.icon.node.getChildByName("图片遮罩").active = false
this.node.getChildByName("使用中").active = true
this.node.getChildByName("切换").active = false
this.node.getChildByName("加成框").active = true
this.node.getChildByName("加成框锁").active = false
this.unlockBeiShu.string = this.config.jiesuoBeiShu == 1 ? '无加成' : `单价加成${this.config.jiesuoBeiShu * 100}%`
this.unlockBeiShu["_forceUpdateRenderData"](true);
this.unlockBeiShu.node.parent.setContentSize(cc.size(this.lockBeiShu.node.getContentSize().width + 30, this.lockBeiShu.node.parent.getContentSize().height))
3 months ago
} else {
2 months ago
this.icon.node.getChildByName("图片遮罩").active = true
this.node.getChildByName("切换").active = true
this.node.getChildByName("使用中").active = false
this.node.getChildByName("加成框").active = false
this.node.getChildByName("加成框锁").active = true
let str1 = `<color=#ffffff><outline color=#3677A2 width=1><bold>无加成</color>`
let str2 = `<color=#ffffff><outline color=#3677A2 width=1><bold>单价加成</c><color=#FFF669><outline color=#3677A2 width=1>${this.config.jiesuoBeiShu * 100}%<bold></color>`
this.lockBeiShu.string = this.config.jiesuoBeiShu == 1 ? str1 : str2
3 months ago
}
}
checkTask() {
let ziChanData = User.getZiChanData()
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
// if (mainId == MainTaskIdEnum.MainTask_514_2 && ziChanData.unLockNum[0] >= 1) {
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_514_2)
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_515)
// }else if (mainId == MainTaskIdEnum.MainTask_532 && ziChanData.unLockNum[1] >= 1) {
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_532)
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_533)
// }else if (mainId == MainTaskIdEnum.MainTask_542 && ziChanData.unLockNum[2] >= 1) {
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_542)
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_543_1)
// }
}
// update (dt) {}
}