dd
This commit is contained in:
@@ -15,4 +15,5 @@ export enum GameEvent {
|
||||
MissionStart = "MissionStart",
|
||||
MissionEnd = "MissionEnd",
|
||||
CastSkill = "CastSkill",
|
||||
CardRefresh = "CardRefresh",
|
||||
}
|
||||
51
assets/script/game/map/CardComp.ts
Normal file
51
assets/script/game/map/CardComp.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { _decorator, Animation, Label, resources, SpriteAtlas,Sprite } 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 { HeroInfo, HeroList } from "../common/config/heroSet";
|
||||
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('CardCompp')
|
||||
@ecs.register('Card', false)
|
||||
export class CardComp extends CCComp {
|
||||
c_uuid:number=0;
|
||||
c_type:number=0;
|
||||
onLoad(){
|
||||
this.on(GameEvent.CardRefresh,this.onCardRefresh,this)
|
||||
}
|
||||
start() {
|
||||
|
||||
}
|
||||
onCardRefresh(event: string, args: any){
|
||||
|
||||
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.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
}, 0.1);
|
||||
|
||||
}
|
||||
update_card(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
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()
|
||||
var icon_path = "game/heros/herois"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
|
||||
});
|
||||
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/CardComp.ts.meta
Normal file
9
assets/script/game/map/CardComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e06b1406-878e-482d-99dd-46eb7ed2c7a8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -174,7 +174,9 @@ export class MissionComp extends CCComp {
|
||||
smc.hero_back_x=right_x
|
||||
// console.log("count_hero_pos",smc.hero_pos,smc.hero_front_x,smc.mon_front_x)
|
||||
}
|
||||
|
||||
card_refresh(){
|
||||
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user