ddd
This commit is contained in:
@@ -34,17 +34,16 @@ export class Role extends ecs.Entity {
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=101) {
|
||||
load(uuid:number=101) {
|
||||
// var path = "game/monster/"+prefab_path;
|
||||
var path = "game/heros/role";
|
||||
|
||||
let pos: Vec3 = Vec3.ZERO
|
||||
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.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
||||
node.setPosition(pos)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
const url = 'game/heros/player';
|
||||
@@ -59,7 +58,7 @@ export class Role extends ecs.Entity {
|
||||
|
||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var rv = node.getComponent(RoleViewComp)!;
|
||||
|
||||
|
||||
this.add(rv);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export class MapViewComp extends CCComp {
|
||||
}
|
||||
load_role(){
|
||||
let role = ecs.getEntity<Role>(Role);
|
||||
role.load()
|
||||
role.load(103)
|
||||
}
|
||||
load_data(){
|
||||
// let heros = oops.res.get("config/game/heros")
|
||||
|
||||
@@ -123,11 +123,9 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
}
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag != BoxSet.ATK_RANGE){
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag != BoxSet.ATK_RANGE&&otherCollider.tag != BoxSet.SKILL_TAG){
|
||||
this.is_atking = true;
|
||||
if(otherCollider.tag != BoxSet.SKILL_TAG&&selfCollider.tag != BoxSet.ATK_RANGE){
|
||||
this.stop_cd = 0.1;
|
||||
}
|
||||
this.stop_cd = 0.1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -213,8 +211,8 @@ export class MonsterViewComp extends CCComp {
|
||||
shoot(skill_uuid:number){
|
||||
// console.log("monster shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let x=0
|
||||
let pos = v3(x,40)
|
||||
let x=32
|
||||
let pos = v3(this.scale*32,30)
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let scale = this.scale
|
||||
let dis = SkillSet[skill_uuid].dis;
|
||||
|
||||
@@ -37,7 +37,8 @@ export class SkillCom extends CCComp {
|
||||
collider.tag = this.box_tag;
|
||||
collider.sensor = true;
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
}
|
||||
if(this.t_pos){
|
||||
@@ -66,9 +67,9 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
|
||||
}
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(otherCollider.group != selfCollider.group){
|
||||
// console.log("skill end contact",selfCollider.group,otherCollider.group)
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(otherCollider.group != selfCollider.group&&otherCollider.tag !=BoxSet.ATK_RANGE&&otherCollider.tag !=BoxSet.SKILL_TAG){
|
||||
// console.log("skill onBeginContact",selfCollider.group,otherCollider.group)
|
||||
this.is_destroy=true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user