Spring774
2025-10-30 a972605e1cf8122330de5b6ff53857be130972be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import Global from "./Global";
import Userdata from "./Userdata";
import Menu from "./Menu";
 
const {ccclass, property} = cc._decorator;
 
//打开商城,注册一个常驻节点,以便接收回调信息
@ccclass
export default class ShopHandler extends cc.Component {
    public static instance: ShopHandler;
 
    onLoad(){
        ShopHandler.instance = this;
        //@ts-ignore
        cc.shopHandler = this;
    }
 
    //购买结果
    buyResult(isSuccess: boolean, gem: number){
        if (isSuccess){
            Userdata.addGem(gem);
            Userdata.saveUserdata();
 
            if (Userdata.OpenAudio){
                
            }
 
            if (Menu.instance.shopLayer){
                Menu.instance.shopLayer.updateGemInfo();
            }
 
            if (Menu.instance){
                Menu.instance.updateInfo();
 
                Global.showTip('Got ' + gem + ' gems.');
            }
        }
    }
}