1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // 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 EventName, { EventLabel, PopType } from "../EventName/EventName";
- import { Global } from "../Global";
- import LocalData from "../LocalData";
- import SDKManager from "../SDKManager";
- import MyComponent, { ButtonLock } from "../Template/MyComponent";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class Gold extends MyComponent {
- Label: cc.Label = null
- onLoad(): void {
- this.regEvent(EventName.changeGold, this.UpdataGold, this)
- }
- start() {
- let add = this.node.getChildByName("add")
- this.Label = this.node.getChildByName("Label").getComponent(cc.Label)
- switch (cc.director.getScene().name) {
- case 'Game':
- add.active = false
- break;
- case 'Hall':
- add.active = true
- break;
- default:
- break;
- }
- this.Label.string = LocalData.getInstance().getGold().toString()
- }
- UpdataGold() {
- this.Label.string = LocalData.getInstance().getGold().toString()
- }
- @ButtonLock(1, null)
- ClickGold() {
- let temp: PopType = new PopType()
- temp.string = EventLabel.OpenVideo
- temp.Title = '提示'
- temp.OK = () => {
- let OPenVideo: PopType = new PopType()
- OPenVideo.OK = () => {
- LocalData.getInstance().setGold(Global.adReward, '+')
- }
- SDKManager.instance.OPenVideo(OPenVideo)
- }
- temp.Fail = () => {
- }
- this.Pop(temp)
- }
- // update (dt) {}
- }
|