角色动画 确定
This commit is contained in:
@@ -47,7 +47,7 @@ export class MonsterViewComp extends CCComp {
|
||||
hp_speed: number = 0; //每秒回复量
|
||||
|
||||
power: number = 0; /**能量**/
|
||||
power_max: number = 100; /** 能量最大值 */
|
||||
power_max: number = 600*3; /** 能量最大值 */
|
||||
power_speed: number = 1; //能量回复速度每0.1秒回复量
|
||||
|
||||
skill_name: string = "base"; //技能名称
|
||||
@@ -76,7 +76,7 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(MonsterSpine);
|
||||
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||
// | EPhysics2DDrawFlags.Pair
|
||||
// |EPhysics2DDrawFlags.CenterOfMass
|
||||
// |EPhysics2DDrawFlags.Joint
|
||||
@@ -89,7 +89,7 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
this.BoxRang = this.node.getChildByName("range_box");
|
||||
this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
|
||||
this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*SkillSet[this.skill_uuid].dis-30;
|
||||
this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*SkillSet[this.skill_uuid].dis;
|
||||
// console.log("monseter ",this.BoxRang);
|
||||
|
||||
// 注册单个碰撞体的回调函数
|
||||
@@ -123,7 +123,7 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
}
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag != BoxSet.ATK_RANGE&&otherCollider.tag != BoxSet.SKILL_TAG){
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
||||
this.is_atking = true;
|
||||
this.stop_cd = 0.1;
|
||||
}
|
||||
@@ -132,25 +132,21 @@ export class MonsterViewComp extends CCComp {
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
|
||||
if(selfCollider.group == otherCollider.group){
|
||||
if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
|
||||
let self_pos=selfCollider.node.getPosition();
|
||||
let other_pos=otherCollider.node.getPosition();
|
||||
// console.log('monster view group 相同');
|
||||
if(otherCollider.tag != BoxSet.SKILL_TAG){
|
||||
let self_pos=selfCollider.node.getPosition();
|
||||
let other_pos=otherCollider.node.getPosition();
|
||||
if(selfCollider.group == BoxSet.HERO){
|
||||
if(self_pos.x < other_pos.x&&Math.abs(self_pos.x-other_pos.x) <= 20&&self_pos.y==other_pos.y){
|
||||
this.stop_cd=0.1
|
||||
}
|
||||
switch (selfCollider.group) {
|
||||
case BoxSet.HERO:
|
||||
if(self_pos.x < other_pos.x&&Math.abs(self_pos.x-other_pos.x) <= BoxSet.MOVE_RANGE_X && self_pos.y==other_pos.y){
|
||||
this.stop_cd=0.1
|
||||
}
|
||||
break;
|
||||
case BoxSet.MONSTER:
|
||||
if(self_pos.x > other_pos.x&&Math.abs(self_pos.x-other_pos.x) <= BoxSet.MOVE_RANGE_X && self_pos.y==other_pos.y){
|
||||
this.stop_cd=0.1
|
||||
}
|
||||
}
|
||||
if(selfCollider.group == BoxSet.MONSTER){
|
||||
if(self_pos.x > other_pos.x&&Math.abs(self_pos.x-other_pos.x) <= 20&&self_pos.y==other_pos.y){
|
||||
this.stop_cd=0.1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
// console.log('monster onPostSolve'+selfCollider.group+"|"+otherCollider.group);
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +174,7 @@ export class MonsterViewComp extends CCComp {
|
||||
this.in_stop(dt);
|
||||
this.in_act(dt);
|
||||
this.move(dt);
|
||||
// this.update_pos();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -191,7 +187,7 @@ export class MonsterViewComp extends CCComp {
|
||||
* 如果角色属于正向阵营 (scale == 1) 且 x 轴位置大于等于 0,则直接返回。
|
||||
* 如果角色属于反向阵营 (scale != 1) 且 x 轴位置小于等于 0,则直接返回。
|
||||
*/
|
||||
if ((this.scale === 1 && this.node.position.x >= 120) || (this.scale !== 1 && this.node.position.x <= -180)) {
|
||||
if (this.scale === 1 && this.node.position.x >= 120) {
|
||||
return;
|
||||
}
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
|
||||
@@ -213,12 +209,11 @@ export class MonsterViewComp extends CCComp {
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let x=32
|
||||
let pos = v3(this.scale*32,30)
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let scale = this.scale
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let dis = SkillSet[skill_uuid].dis;
|
||||
let atk = SkillSet[skill_uuid].atk+this.atk;
|
||||
let sp_name = SkillSet[skill_uuid].sp_name;
|
||||
skill.load(pos,speed,dis,scale,this.node,sp_name,atk);
|
||||
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk);
|
||||
}
|
||||
in_act(dt: number) {
|
||||
|
||||
@@ -278,13 +273,6 @@ export class MonsterViewComp extends CCComp {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
update_pos(){
|
||||
smc.monsters_in.forEach((element,index) => {
|
||||
if(element.eid == this.ent.eid){
|
||||
element.pos_x = this.node.position.x;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
in_atked() {
|
||||
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
||||
|
||||
Reference in New Issue
Block a user