dd
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,50 +0,0 @@
|
|||||||
import { instantiate, Prefab, Vec3 } from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { InfoBoxCom } from "./InfoBoxCom";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
||||||
|
|
||||||
/** InfoBox 模块 */
|
|
||||||
@ecs.register(`InfoBox`)
|
|
||||||
export class InfoBox extends ecs.Entity {
|
|
||||||
/** ---------- 数据层 ---------- */
|
|
||||||
// InfoBoxModel!: InfoBoxModelComp;
|
|
||||||
|
|
||||||
/** ---------- 业务层 ---------- */
|
|
||||||
// InfoBoxBll!: InfoBoxBllComp;
|
|
||||||
|
|
||||||
/** ---------- 视图层 ---------- */
|
|
||||||
InfoBoxView!: InfoBoxCom
|
|
||||||
|
|
||||||
/** 实始添加的数据层组件 */
|
|
||||||
protected init() {
|
|
||||||
// this.addComponents<ecs.Comp>();
|
|
||||||
}
|
|
||||||
load(pos: Vec3 = Vec3.ZERO,uuid:number=101,prefab_path:string) {
|
|
||||||
var path = "game/gui/"+prefab_path;
|
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
var node = instantiate(prefab);
|
|
||||||
var scene = smc.map.MapView.scene;
|
|
||||||
node.parent = scene.SkillLayer!.node!;
|
|
||||||
node.setPosition(pos)
|
|
||||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
|
||||||
// const url = 'game/heros/player';
|
|
||||||
// resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
|
||||||
// const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
|
||||||
|
|
||||||
// sprite.spriteFrame = atlas.getSpriteFrame(RoleSet[uuid].path);
|
|
||||||
// });
|
|
||||||
// var rv = node.getComponent(MonsterViewComp)!;
|
|
||||||
// this.add(rv);
|
|
||||||
var mv = node.getComponent(InfoBoxCom)!;
|
|
||||||
this.add(mv);
|
|
||||||
|
|
||||||
}
|
|
||||||
/** 模块资源释放 */
|
|
||||||
destroy() {
|
|
||||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
||||||
this.remove(InfoBoxCom);
|
|
||||||
super.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
import { _decorator ,Node} from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 视图层对象 */
|
|
||||||
@ccclass('InfoBoxCom')
|
|
||||||
@ecs.register('InfoBox', false)
|
|
||||||
export class InfoBoxCom extends CCComp {
|
|
||||||
@property(Node)
|
|
||||||
n_name:Node =null!
|
|
||||||
@property(Node)
|
|
||||||
n_hp:Node =null!
|
|
||||||
@property(Node)
|
|
||||||
n_atk:Node =null!
|
|
||||||
@property(Node)
|
|
||||||
n_info:Node =null!
|
|
||||||
@property(Node)
|
|
||||||
n_atk_cd:Node =null!
|
|
||||||
@property(Node)
|
|
||||||
n_skillcd:Node =null!
|
|
||||||
|
|
||||||
n_type:number=0; // 0:技能 1 精灵
|
|
||||||
/** 视图层逻辑代码分离演示 */
|
|
||||||
start() {
|
|
||||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
|
||||||
console.log("InfoBoxCom start");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 全局消息逻辑处理 */
|
|
||||||
// private onHandler(event: string, args: any) {
|
|
||||||
// switch (event) {
|
|
||||||
// case ModuleEvent.Cmd:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
||||||
reset() {
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "20c2c0dd-188e-41da-b74e-fdacae24b337",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
70
assets/script/game/gui/ShowInfoCom.ts
Normal file
70
assets/script/game/gui/ShowInfoCom.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import { _decorator, Component, EventTouch, Node, NodeEventType } from 'cc';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('ShowInfoCom')
|
||||||
|
export class ShowInfoCom extends Component {
|
||||||
|
protected onLoad(): void {
|
||||||
|
this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this);
|
||||||
|
this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||||
|
this.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||||
|
this.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||||
|
// oops.message.on("active_card_eid", this.do_active_card_eid, this);
|
||||||
|
}
|
||||||
|
start() {
|
||||||
|
|
||||||
|
}
|
||||||
|
onTouchMove(event: EventTouch) {
|
||||||
|
let delta = event.getDelta();
|
||||||
|
this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y);
|
||||||
|
this.show_info()
|
||||||
|
}
|
||||||
|
show_info(uuid:number,card_type:number){
|
||||||
|
console.log("show_info",this.card_uid)
|
||||||
|
let parent = this.node.parent.parent
|
||||||
|
let node =parent.getChildByName("item_box")
|
||||||
|
if(this.card_type == 2){
|
||||||
|
smc.vm_data.item_box.info = SkillSet[this.card_uid].info
|
||||||
|
smc.vm_data.item_box.name = SkillSet[this.card_uid].name
|
||||||
|
smc.vm_data.item_box.skillcd = SkillSet[this.card_uid].cd
|
||||||
|
smc.vm_data.item_box.skillsd = SkillSet[this.card_uid].sd
|
||||||
|
smc.vm_data.item_box.atk = SkillSet[this.card_uid].atk
|
||||||
|
smc.vm_data.item_box.hp = SkillSet[this.card_uid].hp
|
||||||
|
node.active=true
|
||||||
|
}
|
||||||
|
if(this.card_type == 3){
|
||||||
|
console.log(SkillSet[this.card_uid])
|
||||||
|
smc.vm_data.item_box.info = SkillSet[this.card_uid].info
|
||||||
|
smc.vm_data.item_box.name = SkillSet[this.card_uid].name
|
||||||
|
smc.vm_data.item_box.skillcd = SkillSet[this.card_uid].cd
|
||||||
|
smc.vm_data.item_box.skillsd = SkillSet[this.card_uid].sd
|
||||||
|
smc.vm_data.item_box.atk = SkillSet[this.card_uid].atk
|
||||||
|
smc.vm_data.item_box.hp = SkillSet[this.card_uid].hp
|
||||||
|
smc.vm_data.item_box.shield = SkillSet[this.card_uid].shield
|
||||||
|
node.active=true
|
||||||
|
if(SkillSet[this.card_uid].shield > 0){
|
||||||
|
node.getChildByName("data").getChildByName("shield").active=true
|
||||||
|
}
|
||||||
|
if(SkillSet[this.card_uid].hp > 0){
|
||||||
|
node.getChildByName("data").getChildByName("hp").active=true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onTouchEnd(){
|
||||||
|
if(this.node.position.y-this.pos_y > 150){
|
||||||
|
this.use_card()
|
||||||
|
}else{
|
||||||
|
this.node.setPosition(this.pos_x,this.pos_y);
|
||||||
|
}
|
||||||
|
let parent = this.node.parent.parent
|
||||||
|
let node = parent.getChildByName("item_box")
|
||||||
|
node.active=false
|
||||||
|
node.getChildByName("data").getChildByName("shield").active=false
|
||||||
|
node.getChildByName("data").getChildByName("hp").active=false
|
||||||
|
|
||||||
|
}
|
||||||
|
update(deltaTime: number) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"ver": "4.0.23",
|
"ver": "4.0.23",
|
||||||
"importer": "typescript",
|
"importer": "typescript",
|
||||||
"imported": true,
|
"imported": true,
|
||||||
"uuid": "b64b5d93-6a68-402a-a7ab-bf89db4a153b",
|
"uuid": "d612b0f7-dcf2-499a-993f-8b42291faa18",
|
||||||
"files": [],
|
"files": [],
|
||||||
"subMetas": {},
|
"subMetas": {},
|
||||||
"userData": {}
|
"userData": {}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { _decorator,Label,resources,Sprite,SpriteAtlas,v3 } from "cc";
|
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,v3 } from "cc";
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
@@ -7,20 +7,83 @@ import { HeroCard } from "../monster/HeroCard";
|
|||||||
import { HeroCardViewComp } from "../monster/HeroCardViewComp";
|
import { HeroCardViewComp } from "../monster/HeroCardViewComp";
|
||||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||||
import { CardList } from "../common/config/CardSet";
|
import { CardList } from "../common/config/CardSet";
|
||||||
|
import { HeroModelComp } from "../monster/HeroModelComp";
|
||||||
|
import { SkillSet } from "../common/config/SkillSet";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/** 视图层对象 */
|
/** 视图层对象 */
|
||||||
@ccclass('CardControllerComp')
|
@ccclass('CardControllerComp')
|
||||||
@ecs.register('CardController', false)
|
@ecs.register('CardController', false)
|
||||||
export class CardControllerComp extends CCComp {
|
export class CardControllerComp extends CCComp {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
card_level:number = 1;
|
card_level:number = 1;
|
||||||
in_load:boolean = false
|
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}
|
cards:any = {
|
||||||
card3:any ={x:0,y:0,uuid:1103,type:1,active:false}
|
1:{uuid:1101,type:1,alive:false},
|
||||||
card4:any ={x:0,y:0,uuid:1104,type:1,active:false}
|
2:{uuid:1102,type:1,alive:false},
|
||||||
card5:any ={x:0,y:0,uuid:1105,type:1,active:false}
|
3:{uuid:1103,type:1,alive:false},
|
||||||
card6:any ={x:0,y:0,uuid:1106,type:1,active:false}
|
4:{uuid:1104,type:1,alive:false},
|
||||||
|
5:{uuid:1105,type:1,alive:false},
|
||||||
|
6:{uuid:1106,type:1,alive:false},
|
||||||
|
}
|
||||||
|
protected onLoad(): void {
|
||||||
|
let card1 = this.node.getChildByName("cards").getChildByName("card1");
|
||||||
|
let card2 = this.node.getChildByName("cards").getChildByName("card2");
|
||||||
|
let card3 = this.node.getChildByName("cards").getChildByName("card3");
|
||||||
|
let card4 = this.node.getChildByName("cards").getChildByName("card4");
|
||||||
|
let card5 = this.node.getChildByName("cards").getChildByName("card5");
|
||||||
|
let card6 = this.node.getChildByName("cards").getChildByName("card6");
|
||||||
|
// info_button.on(NodeEventType.TOUCH_START, this.onTouchMove, this);
|
||||||
|
// info_button.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||||
|
card1.on(NodeEventType.TOUCH_START, this.touch1, this);
|
||||||
|
card1.on(NodeEventType.TOUCH_MOVE, this.touch1, this);
|
||||||
|
card2.on(NodeEventType.TOUCH_START, this.touch2, this);
|
||||||
|
card2.on(NodeEventType.TOUCH_MOVE, this.touch2, this);
|
||||||
|
card3.on(NodeEventType.TOUCH_START, this.touch3, this);
|
||||||
|
card3.on(NodeEventType.TOUCH_MOVE, this.touch3, this);
|
||||||
|
card4.on(NodeEventType.TOUCH_START, this.touch4, this);
|
||||||
|
card4.on(NodeEventType.TOUCH_MOVE, this.touch4, this);
|
||||||
|
card5.on(NodeEventType.TOUCH_START, this.touch5, this);
|
||||||
|
card5.on(NodeEventType.TOUCH_MOVE, this.touch5, this);
|
||||||
|
card6.on(NodeEventType.TOUCH_START, this.touch6, this);
|
||||||
|
card6.on(NodeEventType.TOUCH_MOVE, this.touch6, this);
|
||||||
|
|
||||||
|
card1.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||||
|
card1.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||||
|
card2.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||||
|
card2.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||||
|
card3.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||||
|
card3.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||||
|
card4.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||||
|
card4.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||||
|
card5.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||||
|
card5.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||||
|
card6.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||||
|
card6.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||||
|
|
||||||
|
const clickEventHandler = new EventHandler();
|
||||||
|
clickEventHandler.target = this.node; // 这个 node 节点是你的事件处理代码组件所属的节点
|
||||||
|
clickEventHandler.component = 'CardControllerComp';// 这个是脚本类名
|
||||||
|
clickEventHandler.handler = 'user_card';
|
||||||
|
clickEventHandler.customEventData = 'foobar';
|
||||||
|
|
||||||
|
const button1 = this.node.getChildByName('cards').getChildByName('card1').getComponent(Button);
|
||||||
|
const button2 = this.node.getChildByName('cards').getChildByName('card2').getComponent(Button);
|
||||||
|
const button3 = this.node.getChildByName('cards').getChildByName('card3').getComponent(Button);
|
||||||
|
const button4 = this.node.getChildByName('cards').getChildByName('card4').getComponent(Button);
|
||||||
|
const button5 = this.node.getChildByName('cards').getChildByName('card5').getComponent(Button);
|
||||||
|
const button6 = this.node.getChildByName('cards').getChildByName('card6').getComponent(Button);
|
||||||
|
button1.clickEvents.push(clickEventHandler);
|
||||||
|
button2.clickEvents.push(clickEventHandler);
|
||||||
|
button3.clickEvents.push(clickEventHandler);
|
||||||
|
button4.clickEvents.push(clickEventHandler);
|
||||||
|
button5.clickEvents.push(clickEventHandler);
|
||||||
|
button6.clickEvents.push(clickEventHandler);
|
||||||
|
|
||||||
|
}
|
||||||
start() {
|
start() {
|
||||||
this.load_cards()
|
this.load_cards()
|
||||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||||
@@ -34,6 +97,65 @@ export class CardControllerComp extends CCComp {
|
|||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
touch1(event: EventTouch) {
|
||||||
|
console.log("touch 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
touch2(event: EventTouch) {
|
||||||
|
console.log("touch 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
touch3(event: EventTouch) {
|
||||||
|
console.log("touch 3");
|
||||||
|
}
|
||||||
|
|
||||||
|
touch4(event: EventTouch) {
|
||||||
|
console.log("touch 4");
|
||||||
|
}
|
||||||
|
|
||||||
|
touch5(event: EventTouch) {
|
||||||
|
console.log("touch 5");
|
||||||
|
}
|
||||||
|
|
||||||
|
touch6(event: EventTouch) {
|
||||||
|
console.log("touch 6");
|
||||||
|
}
|
||||||
|
show_info(uuid:number,type:number){
|
||||||
|
console.log("show_info",uuid)
|
||||||
|
let node =this.node.getChildByName("item_box")
|
||||||
|
if(type == 2){
|
||||||
|
smc.vm_data.item_box.info = SkillSet[uuid].info
|
||||||
|
smc.vm_data.item_box.name = SkillSet[uuid].name
|
||||||
|
smc.vm_data.item_box.skillcd = SkillSet[uuid].cd
|
||||||
|
smc.vm_data.item_box.skillsd = SkillSet[uuid].sd
|
||||||
|
smc.vm_data.item_box.atk = SkillSet[uuid].atk
|
||||||
|
smc.vm_data.item_box.hp = SkillSet[uuid].hp
|
||||||
|
node.active=true
|
||||||
|
}
|
||||||
|
if(type == 3){
|
||||||
|
console.log(SkillSet[uuid])
|
||||||
|
smc.vm_data.item_box.info = SkillSet[uuid].info
|
||||||
|
smc.vm_data.item_box.name = SkillSet[uuid].name
|
||||||
|
smc.vm_data.item_box.skillcd = SkillSet[uuid].cd
|
||||||
|
smc.vm_data.item_box.skillsd = SkillSet[uuid].sd
|
||||||
|
smc.vm_data.item_box.atk = SkillSet[uuid].atk
|
||||||
|
smc.vm_data.item_box.hp = SkillSet[uuid].hp
|
||||||
|
smc.vm_data.item_box.shield = SkillSet[uuid].shield
|
||||||
|
node.active=true
|
||||||
|
if(SkillSet[uuid].shield > 0){
|
||||||
|
node.getChildByName("data").getChildByName("shield").active=true
|
||||||
|
}
|
||||||
|
if(SkillSet[uuid].hp > 0){
|
||||||
|
node.getChildByName("data").getChildByName("hp").active=true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onTouchEnd(){
|
||||||
|
let node = this.node.getChildByName("item_box")
|
||||||
|
node.active=false
|
||||||
|
node.getChildByName("data").getChildByName("shield").active=false
|
||||||
|
node.getChildByName("data").getChildByName("hp").active=false
|
||||||
|
}
|
||||||
shuaxin(dt: number) {
|
shuaxin(dt: number) {
|
||||||
smc.vm_data.shuaxin.min += smc.vm_data.shuaxin.speed*dt;
|
smc.vm_data.shuaxin.min += smc.vm_data.shuaxin.speed*dt;
|
||||||
if (smc.vm_data.shuaxin.min >= smc.vm_data.shuaxin.max) {
|
if (smc.vm_data.shuaxin.min >= smc.vm_data.shuaxin.max) {
|
||||||
@@ -78,15 +200,14 @@ export class CardControllerComp extends CCComp {
|
|||||||
if(smc.vm_data.shuaxin.min <=0 ){
|
if(smc.vm_data.shuaxin.min <=0 ){
|
||||||
smc.vm_data.shuaxin.min = 0
|
smc.vm_data.shuaxin.min = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
load_cards() {
|
load_cards() {
|
||||||
this.in_load = true
|
this.in_load = true
|
||||||
let card:any=null
|
let card:any=null
|
||||||
for (let index = 1; index <= 6; index++) {
|
for (let index = 1; index <= 6; index++) {
|
||||||
card=RandomManager.instance.getRandomByObjectList(CardList, 1);
|
card=RandomManager.instance.getRandomByObjectList(CardList, 1);
|
||||||
this['card'+index].uuid=card[0].uuid
|
this.cards[index].uuid=card[0].uuid
|
||||||
this['card'+index].type=card[0].type
|
this.cards[index].type=card[0].type
|
||||||
let url: string = "";
|
let url: string = "";
|
||||||
let pathName: string = "";
|
let pathName: string = "";
|
||||||
let name: string = "";
|
let name: string = "";
|
||||||
@@ -115,13 +236,52 @@ export class CardControllerComp extends CCComp {
|
|||||||
const sprite = node.getChildByName("item").getComponent(Sprite);
|
const sprite = node.getChildByName("item").getComponent(Sprite);
|
||||||
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
|
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
|
||||||
});
|
});
|
||||||
this['card'+index].active=true
|
this.cards[index].alive=true
|
||||||
}
|
}
|
||||||
|
// console.log("cards:",this.cards)
|
||||||
|
this.in_load = false
|
||||||
}
|
}
|
||||||
load_card(){
|
load_card(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
use_card(event:Event,index: number){
|
||||||
|
this.cards[index].alive=false
|
||||||
|
this.check_card(index)
|
||||||
|
console.log("cards:",this.cards)
|
||||||
|
}
|
||||||
|
check_card(index:number){
|
||||||
|
let heros = ecs.query(ecs.allOf(HeroModelComp))
|
||||||
|
// let heross= ecs.query(ecs.allOf(MonsterViewComp))
|
||||||
|
// console.log("heross",heross)
|
||||||
|
if(heros.length >= 4&&this.cards[index].type == 1){
|
||||||
|
oops.gui.toast("英雄数量达到上限");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(smc.vm_data.gold.min >= this.card_level){
|
||||||
|
this.cards[index].alive=false
|
||||||
|
this.do_use_card(index)
|
||||||
|
smc.vm_data.gold.min -= this.card_level;
|
||||||
|
}else{
|
||||||
|
oops.gui.toast("金币不够");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
do_use_card(index:number){
|
||||||
|
switch (this.cards[index].type) {
|
||||||
|
case 1:
|
||||||
|
oops.message.dispatchEvent("do_add_hero", { uuid: this.cards[index].uuid });
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
oops.message.dispatchEvent("do_use_skill", { uuid: this.cards[index].uuid });
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
oops.message.dispatchEvent("do_use_skill", { uuid: this.cards[index].uuid });
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
this.shuaxin(dt)
|
this.shuaxin(dt)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { Hero } from "./Hero";
|
|||||||
import { MonsterViewComp } from "./MonsterViewComp";
|
import { MonsterViewComp } from "./MonsterViewComp";
|
||||||
import { MapMonsterComp } from "../map/MapMonsterComp";
|
import { MapMonsterComp } from "../map/MapMonsterComp";
|
||||||
import { MapSkillComp } from "../map/MapSkillComp";
|
import { MapSkillComp } from "../map/MapSkillComp";
|
||||||
import { InfoBox } from "../gui/InfoBox";
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/** 视图层对象 */
|
/** 视图层对象 */
|
||||||
|
|||||||
Reference in New Issue
Block a user