70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
import JiaZai from "../../Script/JiaZai";
|
|
const { ccclass, property } = cc._decorator;
|
|
//排行榜
|
|
@ccclass
|
|
export default class GachaManager extends cc.Component {
|
|
@property(cc.Node) //用户头像换图
|
|
avatar: cc.Node = null;
|
|
|
|
avatarData: any = null;
|
|
own = 0;
|
|
|
|
onLoad() {
|
|
this.avatarData = [];
|
|
this.own = 0;
|
|
// this.init();
|
|
}
|
|
//初始化数据
|
|
init(data) {
|
|
this.avatarData = [];
|
|
console.log("初始化数据", data);
|
|
if (data) {
|
|
this.avatarData = data;
|
|
this.own = this.avatarData.length;
|
|
}
|
|
for (let i = 0; i < this.avatarData.length; i++) {
|
|
let iphone = this.avatarData[i] - 19;
|
|
this.avatar.children[iphone].getChildByName("own").active = true;
|
|
}
|
|
|
|
let cost = this.getCostFilm();
|
|
let botoom = this.node.getChildByName("bottom");
|
|
botoom.getChildByName("total").getComponent(cc.Label).string = cost.toString();
|
|
console.log("抽卡所需film", cost);
|
|
botoom.getChildByName("no").active = false;
|
|
botoom.getChildByName("yes").active = false;
|
|
|
|
if (cc.fx.GameConfig.GM_INFO.film >= cost) {
|
|
botoom.getChildByName("yes").active = true;
|
|
console.log("有足够film");
|
|
botoom.getChildByName("yes").getComponent(cc.Label).string = cc.fx.GameConfig.GM_INFO.film.toString();
|
|
}
|
|
else {
|
|
console.log("没有足够film");
|
|
botoom.getChildByName("no").active = true;
|
|
botoom.getChildByName("no").getComponent(cc.Label).string = cc.fx.GameConfig.GM_INFO.film.toString();
|
|
}
|
|
console.log("拥有film", cc.fx.GameConfig.GM_INFO.film);
|
|
}
|
|
|
|
getCostFilm() {
|
|
let film = [5, 10, 25, 35, 55, 70, 100, 120];
|
|
return film[this.own - 1];
|
|
}
|
|
|
|
closeGacha() {
|
|
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
|
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
|
|
if (jiazaiComp) {
|
|
jiazaiComp.closeGacha();
|
|
|
|
} else {
|
|
console.log("无法获取JiaZai组件");
|
|
}
|
|
}
|
|
|
|
start() {
|
|
}
|
|
|
|
}
|