1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // 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 {
- @property(cc.Label)
- Label: cc.Label
- onLoad(): void {
- if (!this.Label) {
- this.Label = this.node.getComponentInChildren(cc.Label)
- }
- }
- start() {
- this.regEvent(EventName.changeGold, this.UpdataGold, this)
- this.scheduleOnce(() => {
- cc.systemEvent.emit(EventName.changeGold);
- }, 0)
- }
-
- UpdataGold() {
- if (this?.Label) {
- 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) {}
- }
|