卡片召唤英雄

This commit is contained in:
2025-03-25 16:34:09 +08:00
parent 9fbad1f405
commit 1a6bff9d49
4 changed files with 320 additions and 276 deletions

View File

@@ -4,6 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { GameEvent } from "../common/config/GameEvent";
import { HeroInfo, HeroList } from "../common/config/heroSet";
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
import { oops } from "db://oops-framework/core/Oops";
const { ccclass, property } = _decorator;
@@ -13,14 +14,20 @@ const { ccclass, property } = _decorator;
export class CardComp extends CCComp {
c_uuid:number=0;
c_type:number=0;
is_used:boolean=false;
onLoad(){
this.on(GameEvent.CardRefresh,this.onCardRefresh,this)
}
start() {
this.init_card()
}
init_card(){
this.is_used=true
this.node.getChildByName("Button").active=false
this.node.getChildByName("show").active=false
}
onCardRefresh(event: string, args: any){
this.is_used=false
let hero_list =HeroList
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
this.c_uuid=hero_list[x]
@@ -30,6 +37,7 @@ export class CardComp extends CCComp {
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
this.scheduleOnce(() => {
this.node.getChildByName("show").active=true
this.node.getChildByName("Button").active=true
}, 0.1);
}
@@ -45,6 +53,23 @@ export class CardComp extends CCComp {
});
}
use_card(){
if(this.is_used) return
switch(this.c_type){
case 0:
oops.message.dispatchEvent(GameEvent.UserHeroCard,{uuid:this.c_uuid})
break
case 1:
oops.message.dispatchEvent(GameEvent.UserSkillCard,{uuid:this.c_uuid})
break
case 2:
oops.message.dispatchEvent(GameEvent.UseCard,{uuid:this.c_uuid})
break
}
this.node.getChildByName("show").active=false
this.is_used=true
this.node.getChildByName("Button").active=false
}
reset() {
this.node.destroy();
}