游戏开始 初始技能功能 继续完善

This commit is contained in:
2025-06-04 17:16:43 +08:00
parent 899613c689
commit b26efd07fd
11 changed files with 6673 additions and 2395 deletions

View File

@@ -8,6 +8,7 @@ import { oops } from "db://oops-framework/core/Oops";
import { HeroModelComp } from "../hero/HeroModelComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { smc } from "../common/SingletonModuleComp";
import { HeroSkillList, SkillSet } from "../common/config/SkillSet";
const { ccclass, property } = _decorator;
@@ -16,35 +17,58 @@ const { ccclass, property } = _decorator;
@ecs.register('Card', false)
export class CardComp extends CCComp {
c_uuid:number=0;
c_type:number=0;
c_type:number=0; //0英雄,1 技能.2 装备
is_used:boolean=false;
onLoad(){
this.on(GameEvent.HeroSelect,this.onCardRefresh,this)
this.on(GameEvent.HeroSkillSelect,this.onCardRefresh,this)
this.on(GameEvent.HeroSelect,this.onHeroSelect,this)
this.on(GameEvent.HeroSkillSelect,this.onHeroSkillSelect,this)
this.on(GameEvent.CardRefresh,this.onCardRefresh,this)
}
start() {
}
init_card(){
this.node.getChildByName("Button").active=false
this.node.getChildByName("show").active=false
}
onHeroSelect(event: string, args: any){
}
onHeroSkillSelect(event: string, args: any){
}
onCardRefresh(event: string, args: any){
this.c_type=0
let hero_list =HeroList
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
this.c_uuid=hero_list[x]
console.log("onCardRefresh c_uuid:"+this.c_uuid)
this.update_card(this.c_uuid)
this.show_hero(this.c_uuid)
this.node.getChildByName("show").active=false
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);
}
onHeroSkillSelect(event: string, args: any){
this.c_type=1
console.log("card onHeroSkillSelect")
let skill_list =HeroSkillList
let x=RandomManager.instance.getRandomInt(0,skill_list.length,1)
this.c_uuid=skill_list[x]
this.node.getChildByName("show").active=false
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
this.show_skill(this.c_uuid)
this.scheduleOnce(() => {
this.node.getChildByName("show").active=true
this.node.getChildByName("Button").active=true
}, 0.1);
}
onCardRefresh(event: string, args: any){
this.c_type=0
let hero_list =HeroList
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
this.c_uuid=hero_list[x]
// console.log("onCardRefresh c_uuid:"+this.c_uuid)
this.show_hero(this.c_uuid)
this.node.getChildByName("show").active=false
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
this.scheduleOnce(() => {
@@ -53,15 +77,31 @@ export class CardComp extends CCComp {
}, 0.1);
}
update_card(uuid:number){
show_skill(uuid:number){
let show=this.node.getChildByName("show")
show.getChildByName("name").getComponent(Label).string=SkillSet[uuid].name
show.getChildByName("ap").active=false
show.getChildByName("hp").active=false
show.getChildByName("mask").getChildByName("skill").active=true
var icon_path = "game/skills/skill_icon"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path);
});
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
}
show_hero(uuid:number){
let show=this.node.getChildByName("show")
show.getChildByName("ap").active=true
show.getChildByName("hp").active=true
show.getChildByName("mask").getChildByName("skill").active=false
show.getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
show.getChildByName("ap").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].ap.toString()
show.getChildByName("hp").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].hp.toString()
show.getChildByName("type").getChildByName("war").active=HeroInfo[uuid].type==0
show.getChildByName("type").getChildByName("bow").active=HeroInfo[uuid].type==1
show.getChildByName("type").getChildByName("mag").active=HeroInfo[uuid].type==2
show.getChildByName("lv").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].lv.toString()
// show.getChildByName("type").getChildByName("war").active=HeroInfo[uuid].type==0
// show.getChildByName("type").getChildByName("bow").active=HeroInfo[uuid].type==1
// show.getChildByName("type").getChildByName("mag").active=HeroInfo[uuid].type==2
// show.getChildByName("lv").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].lv.toString()
var icon_path = "game/heros/herois"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = show.getChildByName("mask").getChildByName("icon").getComponent(Sprite);
@@ -90,12 +130,16 @@ export class CardComp extends CCComp {
}
oops.message.dispatchEvent(GameEvent.UseHeroCard,{uuid:this.c_uuid})
smc.vmdata.mission_data.gold-=smc.vmdata.mission_data.call_gold
oops.message.dispatchEvent(GameEvent.CardsClose)
break
case 1:
console.log("use_card 技能卡")
oops.message.dispatchEvent(GameEvent.UseSkillCard,{uuid:this.c_uuid})
oops.message.dispatchEvent(GameEvent.CardsClose)
break
case 2:
oops.message.dispatchEvent(GameEvent.UseCard,{uuid:this.c_uuid})
oops.message.dispatchEvent(GameEvent.CardsClose)
break
}
}