dd
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator,v3 } from "cc";
|
||||
import { _decorator,Label,resources,Sprite,SpriteAtlas,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 { smc } from "../common/SingletonModuleComp";
|
||||
@@ -15,6 +15,12 @@ const { ccclass, property } = _decorator;
|
||||
export class CardControllerComp extends CCComp {
|
||||
card_level:number = 1;
|
||||
in_load:boolean = false
|
||||
card1:any ={x:0,y:0,uuid:1101,type:1,active:false}
|
||||
card2:any ={x:0,y:0,uuid:1102,type:1,active:false}
|
||||
card3:any ={x:0,y:0,uuid:1103,type:1,active:false}
|
||||
card4:any ={x:0,y:0,uuid:1104,type:1,active:false}
|
||||
card5:any ={x:0,y:0,uuid:1105,type:1,active:false}
|
||||
card6:any ={x:0,y:0,uuid:1106,type:1,active:false}
|
||||
start() {
|
||||
this.load_cards()
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
@@ -76,40 +82,54 @@ export class CardControllerComp extends CCComp {
|
||||
}
|
||||
load_cards() {
|
||||
this.in_load = true
|
||||
let old_cards = ecs.query(ecs.allOf(HeroCardViewComp))
|
||||
if (old_cards.length > 0) {
|
||||
old_cards.forEach(element => {
|
||||
if (!element.get(HeroCardViewComp).in_destroy) {
|
||||
element.destroy();
|
||||
}
|
||||
let card:any=null
|
||||
for (let index = 1; index <= 6; index++) {
|
||||
card=RandomManager.instance.getRandomByObjectList(CardList, 1);
|
||||
this['card'+index].uuid=card[0].uuid
|
||||
this['card'+index].type=card[0].type
|
||||
let url: string = "";
|
||||
let pathName: string = "";
|
||||
let name: string = "";
|
||||
let level: number = 0;
|
||||
let { uuid, type } = card[0];
|
||||
switch (type) {
|
||||
case 1:
|
||||
url = "game/heros/heros";
|
||||
({ path: pathName, name, level } = smc.heros[uuid]);
|
||||
break;
|
||||
case 2:
|
||||
url = "game/heros/skill";
|
||||
({ path: pathName, name, level } = smc.skills[uuid]);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
url = "game/heros/skill";
|
||||
({ path: pathName, name, level } = smc.skills[uuid]);
|
||||
}
|
||||
let node=this.node.getChildByName('cards').getChildByName('card'+index)
|
||||
node.getChildByName('cost').getComponent(Label).string=level.toString()
|
||||
node.getChildByName('name').getComponent(Label).string=name
|
||||
// const sprite = node.getChildByName("item").getComponent(Sprite);
|
||||
// console.log(this['card'+index],url,pathName,sprite)
|
||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = node.getChildByName("item").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
});
|
||||
this['card'+index].active=true
|
||||
}
|
||||
// console.log(old_cards)
|
||||
let cards_node= this.node.getChildByName("front")
|
||||
let x=0
|
||||
let y=0
|
||||
let lists = this.get_card_list()
|
||||
lists.forEach(element => {
|
||||
let card = ecs.getEntity<HeroCard>(HeroCard);
|
||||
let pos = v3(x,y)
|
||||
card.load(pos,element[0].uuid,cards_node,element[0].type);
|
||||
x=x+142
|
||||
});
|
||||
this.in_load = false;
|
||||
|
||||
|
||||
}
|
||||
load_card(){
|
||||
|
||||
}
|
||||
/** 转场 */
|
||||
protected update(dt: number): void {
|
||||
this.shuaxin(dt)
|
||||
}
|
||||
|
||||
get_card_list(){
|
||||
let lists:any = []
|
||||
for (let index = 0; index < 5; index++) {
|
||||
let list = RandomManager.instance.getRandomByObjectList(CardList[smc.vm_data.cards.level], 1);
|
||||
lists.push(list)
|
||||
}
|
||||
return lists
|
||||
let list = RandomManager.instance.getRandomByObjectList(CardList, 1);
|
||||
return list
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
Reference in New Issue
Block a user