dd
This commit is contained in:
@@ -61,6 +61,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
max_limit:10,
|
||||
time:0,
|
||||
cd:10,
|
||||
ref_cost:0,
|
||||
},
|
||||
shuaxin: {
|
||||
min: 0,
|
||||
|
||||
@@ -17,10 +17,11 @@ export enum BoxSet {
|
||||
BOX_WIDTH = 64,
|
||||
BOX_HEIGHT = 64,
|
||||
//地图边界
|
||||
LETF_END = -400,
|
||||
RIGHT_END = 400,
|
||||
HERO_START = -500,
|
||||
MONSTER_START = 500,
|
||||
LETF_END = -420,
|
||||
RIGHT_END = 420,
|
||||
HERO_START = -360,
|
||||
MONSTER_START = 360,
|
||||
END_POINT = 360,
|
||||
//游戏地平线
|
||||
GAME_LINE = 30,
|
||||
GAME_LINE = 0,
|
||||
}
|
||||
@@ -39,6 +39,11 @@ export class CardControllerComp extends CCComp {
|
||||
if (this.in_load) {
|
||||
return
|
||||
}
|
||||
if (smc.vm_data.gold.min < smc.vm_data.gold.ref_cost) {
|
||||
oops.gui.toast("金币不足")
|
||||
return
|
||||
}
|
||||
smc.vm_data.gold.min -= smc.vm_data.gold.ref_cost;
|
||||
this.load_cards()
|
||||
|
||||
}
|
||||
@@ -47,7 +52,9 @@ export class CardControllerComp extends CCComp {
|
||||
let old_cards = ecs.query(ecs.allOf(HeroCardViewComp))
|
||||
if (old_cards.length > 0) {
|
||||
old_cards.forEach(element => {
|
||||
element.destroy();
|
||||
if (!element.get(HeroCardViewComp).in_destroy) {
|
||||
element.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
// console.log(old_cards)
|
||||
|
||||
@@ -60,6 +60,7 @@ export class Hero extends ecs.Entity {
|
||||
|
||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(MonsterViewComp)!;
|
||||
mv.hero_uuid=uuid;
|
||||
mv.speed =mv.ospeed = CardSet[uuid].speed;
|
||||
mv.hero_name= CardSet[uuid].name;
|
||||
mv.hp= mv.hp_max = CardSet[uuid].hp;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator ,Vec2,NodeEventType,EventTouch} from "cc";
|
||||
import { _decorator ,Label} 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 { data } from "../data/data";
|
||||
@@ -15,7 +15,7 @@ export class HeroCardViewComp extends CCComp {
|
||||
card_name:string = "hero_card";
|
||||
card_type:string = "hero";
|
||||
card_uid:number = 1000;
|
||||
|
||||
in_destroy:boolean = false;
|
||||
|
||||
protected onLoad(): void {
|
||||
// this.node.on(NodeEventType.TOUCH_START, this.onTouch, this);
|
||||
@@ -65,6 +65,7 @@ export class HeroCardViewComp extends CCComp {
|
||||
|
||||
use_card(){
|
||||
if(smc.vm_data.gold.min >= CardSet[this.card_uid].level){
|
||||
this.in_destroy = true;
|
||||
oops.message.dispatchEvent("do_add_hero",{uuid:this.card_uid})
|
||||
this.ent.destroy();
|
||||
smc.vm_data.gold.min -= CardSet[this.card_uid].level;
|
||||
@@ -74,7 +75,8 @@ export class HeroCardViewComp extends CCComp {
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
|
||||
|
||||
this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = CardSet[this.card_uid].level.toString();
|
||||
|
||||
}
|
||||
|
||||
@@ -88,6 +90,7 @@ export class HeroCardViewComp extends CCComp {
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.in_destroy = false;
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ const { ccclass, property } = _decorator;
|
||||
export class MonsterViewComp extends CCComp {
|
||||
/** 角色动画 */
|
||||
as: MonsterSpine = null!;
|
||||
hero_uuid:number = 1001;
|
||||
hero_name : string = "hero";
|
||||
level:number =1;
|
||||
camp: number = 1; /** 角色阵营 1:hero -1 :monster */
|
||||
@@ -75,6 +76,7 @@ export class MonsterViewComp extends CCComp {
|
||||
// collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
}
|
||||
console.log(' hero_uuid:',this.hero_uuid);
|
||||
|
||||
|
||||
}
|
||||
@@ -176,6 +178,10 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
move(dt: number){
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.camp, this.node.position.y, this.node.position.z);
|
||||
if(Math.abs(this.node.position.x) >= BoxSet.END_POINT){
|
||||
this.node.setPosition(v3(this.camp*-BoxSet.END_POINT,BoxSet.GAME_LINE,this.node.position.z))
|
||||
// console.log("speed:"+this.speed+" | stop_cd:"+this.stop_cd);
|
||||
}
|
||||
}
|
||||
power_change(power: number){
|
||||
this.power += power;
|
||||
@@ -224,18 +230,18 @@ export class MonsterViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
in_destroy(){
|
||||
switch (this.camp) {
|
||||
case -1:
|
||||
if(this.node.position.x < BoxSet.LETF_END){
|
||||
this.toDestroy();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(this.node.position.x > BoxSet.RIGHT_END){
|
||||
this.toDestroy();
|
||||
}
|
||||
break;
|
||||
}
|
||||
// switch (this.camp) {
|
||||
// case -1:
|
||||
// if(this.node.position.x < BoxSet.LETF_END){
|
||||
// this.toDestroy();
|
||||
// }
|
||||
// break;
|
||||
// case 1:
|
||||
// if(this.node.position.x > BoxSet.RIGHT_END){
|
||||
// this.toDestroy();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
update_pos(){
|
||||
smc.monsters_in.forEach((element,index) => {
|
||||
@@ -247,7 +253,7 @@ export class MonsterViewComp extends CCComp {
|
||||
load_skill(skill_name){
|
||||
// console.log("load_skill");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let pos = v3(0,30)
|
||||
let pos = v3(0,0)
|
||||
let speed =150
|
||||
let scale = this.camp
|
||||
let range = 80
|
||||
@@ -257,7 +263,7 @@ export class MonsterViewComp extends CCComp {
|
||||
var path = "game/skills/atked";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let pos = v3(0,0)
|
||||
let pos = v3(0,30)
|
||||
node.setPosition(pos)
|
||||
node.parent = this.node;
|
||||
}
|
||||
@@ -265,7 +271,7 @@ export class MonsterViewComp extends CCComp {
|
||||
var path = "game/skills/dead";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.setPosition(this.node.position)
|
||||
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
|
||||
node.parent = this.node.parent;
|
||||
}
|
||||
toDestroy(){
|
||||
|
||||
Reference in New Issue
Block a user