dd
This commit is contained in:
@@ -5,13 +5,15 @@ import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { HeroCard } from "../monster/HeroCard";
|
||||
import { HeroCardViewComp } from "../monster/HeroCardViewComp";
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
import { CardList } from "../common/config/CardSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('ControllerComp')
|
||||
@ecs.register('Controller', false)
|
||||
export class ControllerComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
card_level = 1;
|
||||
start() {
|
||||
this.load_cards()
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
@@ -29,7 +31,6 @@ export class ControllerComp extends CCComp {
|
||||
smc.vm_data.shuaxin.min += smc.vm_data.shuaxin.speed*dt;
|
||||
if (smc.vm_data.shuaxin.min >= smc.vm_data.shuaxin.max) {
|
||||
smc.vm_data.shuaxin.min = 0;
|
||||
// oops.message.dispatchEvent("do_add_hero",this)
|
||||
this.load_cards()
|
||||
}
|
||||
}
|
||||
@@ -44,12 +45,13 @@ export class ControllerComp extends CCComp {
|
||||
let cards_node= this.node.getChildByName("cards")
|
||||
let x=0
|
||||
let y=0
|
||||
for (let i = 0; i < 5; i++) {
|
||||
let lists = this.get_card_list()
|
||||
lists.forEach(element => {
|
||||
let card = ecs.getEntity<HeroCard>(HeroCard);
|
||||
let pos = v3(x,y)
|
||||
card.load(pos,1001,cards_node);
|
||||
card.load(pos,element[0],cards_node);
|
||||
x=x+120
|
||||
}
|
||||
});
|
||||
this.node.getChildByName("cards").getChildByName("active").active = false
|
||||
}
|
||||
/** 转场 */
|
||||
@@ -57,6 +59,14 @@ export class ControllerComp extends CCComp {
|
||||
this.shuaxin(dt)
|
||||
}
|
||||
|
||||
get_card_list(){
|
||||
let lists:any = []
|
||||
for (let index = 0; index < 5; index++) {
|
||||
let list = RandomManager.instance.getRandomByObjectList(CardList[this.card_level], 1);
|
||||
lists.push(list)
|
||||
}
|
||||
return lists
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
Reference in New Issue
Block a user