卡组刷新 及预置广告 抽紫装, 成功后刷紫装未做

This commit is contained in:
2025-06-23 16:17:58 +08:00
parent c6fa6838db
commit c62eda84bb
7 changed files with 6285 additions and 5622 deletions

View File

@@ -1,10 +1,11 @@
import { _decorator, tween, v3 } from "cc";
import { _decorator, Label, tween, v3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { GameEvent } from "../common/config/GameEvent";
import { CardComp } from "./CardComp";
import { cardType, getRandomCardsByType } from "../common/config/CardSet";
import { smc } from "../common/SingletonModuleComp";
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
const { ccclass, property } = _decorator;
@@ -25,7 +26,12 @@ export class CardsCompComp extends CCComp {
private cardQueue: Array<{type: GameEvent, data?: any}> = [];
/** 是否正在展示卡牌 */
private isShowing: boolean = false;
//**当前卡组 */
private now_card:any=null;
//**是否正在倒计时 */
private is_countdown:boolean=false;
//**倒计时时间 */
private countdown_time:number=10;
/** 视图层逻辑代码分离演示 */
onLoad() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
@@ -103,11 +109,12 @@ export class CardsCompComp extends CCComp {
const nextCard = this.cardQueue.shift();
this.isShowing = true;
this.now_card=nextCard
this.show_cards(nextCard.type, nextCard.data);
}
show_cards(e:GameEvent,data:any){
this.node.getChildByName("Button").active=false
show_cards(e:GameEvent,data:any,is_refresh:boolean=false){
this.node.getChildByName("btns").getChildByName("cancel").active=false
switch(e){
case GameEvent.HeroSelect:
console.log("[CardsComp]:显示英雄选择卡牌")
@@ -119,15 +126,18 @@ export class CardsCompComp extends CCComp {
break
case GameEvent.FuncSelect:
console.log("[CardsComp]:显示功能卡牌")
this.node.getChildByName("Button").active=true
this.node.getChildByName("btns").getChildByName("cancel").active=true
this.func_select()
break
case GameEvent.EquipSelect:
console.log("[CardsComp]:显示装备选择卡牌")
this.node.getChildByName("btns").getChildByName("cancel").active=true
this.equip_select()
break
}
this.show()
if(!is_refresh) this.show()
}
close_cards(e:GameEvent,data:any){
switch(e){
@@ -146,10 +156,12 @@ export class CardsCompComp extends CCComp {
}
this.hide()
}
show(){
this.node.getChildByName("vip").active=false
// 设置初始状态
smc.mission.pause=true
// this.node.getChildByName("Button").setPosition(v3(0, this.node.getChildByName("Button").getPosition().y, 0))
// this.node.getChildByName("btns").getChildByName("cancel").setPosition(v3(0, this.node.getChildByName("btns").getChildByName("cancel").getPosition().y, 0))
// this.node.getChildByName("top").setPosition(v3(0, this.node.getChildByName("top").getPosition().y, 0))
this.node.setPosition(v3(0, 0, 0));
this.node.setScale(v3(0, 0, 1));
@@ -161,6 +173,13 @@ export class CardsCompComp extends CCComp {
tween().to(0.3, { position: v3(0, 640, 0) }, { easing: 'backOut' })
)
.start();
let vip = RandomManager.instance.getRandomInt(0,100)
console.log("[CardsComp]:vip",vip)
if(vip < 30){
this.node.getChildByName("vip").active=true
this.is_countdown=true
this.countdown_time=10
}
}
hide(){
@@ -182,13 +201,35 @@ export class CardsCompComp extends CCComp {
this.cardQueue = [];
this.close_cards(GameEvent.CardsClose,null)
}
refresh_card(){
this.show_cards(this.now_card.type,this.now_card.data,true)
}
//放弃选择
give_up_select(){
this.hide()
// let mission_data=smc.vmdata.mission_data
// mission_data.gold+=(mission_data.back_gold+mission_data.buff_back_gold) //返还金币
}
//点击看视频广告
to_do_vip(){
if(this.checkout_vip()){
console.log("[CardsComp]:vip检查通过")
}
}
//检测广告是否成功观看
checkout_vip(){
return true
}
update(dt: number) {
if(this.is_countdown){
this.countdown_time-=dt
this.node.getChildByName("vip").getChildByName("num").getComponent(Label).string=Math.floor(this.countdown_time).toString()
if(this.countdown_time<=0){
this.is_countdown=false
this.node.getChildByName("vip").active=false
}
}
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.cardQueue = [];