This commit is contained in:
2024-08-01 10:57:39 +08:00
parent 9aa9806b62
commit 6c5d417ad1
13 changed files with 119 additions and 330 deletions

View File

@@ -5,7 +5,7 @@
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, Vec3 ,tween, v3,Collider2D,Contact2DType,PhysicsSystem2D,IPhysics2DContact} from "cc";
import { instantiate, Node, Prefab, Vec3 ,tween, v3,Collider2D,Contact2DType,PhysicsSystem2D,IPhysics2DContact, animation,Label} from "cc";
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -36,23 +36,33 @@ export class Monster extends ecs.Entity {
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,speed:number = 100) {
var path = "game/monster/monster";
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,camp:number = 1,prefab_path:string = "monster",name:string="hero") {
var path = "game/monster/"+prefab_path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!;
var as = node.getComponent(MonsterSpine);
node.setPosition(pos)
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
node.setPosition(pos)
var mv = node.getComponent(MonsterViewComp)!;
mv.speed = speed;
mv.ospeed = speed;
console.log('speed:'+speed)
mv.speed =mv.ospeed = speed;
mv.hero_name= name;
mv.camp = camp;
mv.Tpos = v3(0,0,0);
mv.change_name(name)
this.add(mv);
smc.monsters_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0}),
// node.setScale(-1, 1, 1);
oops.message.dispatchEvent("monster_load",this)
if(camp == 1){
smc.heros_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0})
oops.message.dispatchEvent("hero_load",this)
}else{
smc.monsters_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0})
oops.message.dispatchEvent("monster_load",this)
}
}
/** 移动ECS System处理逻辑分享功能独立的业务代码 */