技能碰撞改回物理碰撞

This commit is contained in:
panfudan
2025-03-30 16:59:40 +08:00
parent 67704725b2
commit 798a831227
85 changed files with 13428 additions and 7394 deletions

View File

@@ -1,4 +1,4 @@
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp, Game, tween, Color, RigidBody, RigidBody2D} from "cc";
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp, Game, tween, Color} 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 { HeroSpine } from "./HeroSpine";
@@ -39,7 +39,6 @@ export class HeroViewComp extends CCComp {
atk_range:number = 150;
box_group:number = BoxSet.HERO;
rigid:RigidBody2D=null!;
is_dead:boolean = false; //是否摧毁
@@ -47,7 +46,8 @@ export class HeroViewComp extends CCComp {
is_atking:boolean = false;
is_boss:boolean = false;
is_big_boss:boolean = false;
rate:number=0;
r_up:number=0;
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_speed: number = 0; //每秒回复量
@@ -90,7 +90,7 @@ export class HeroViewComp extends CCComp {
onLoad() {
this.as = this.getComponent(HeroSpine);
let anm = this.node.getChildByName("anm")
anm.setScale(anm.scale.x*0.7,anm.scale.y*0.7);
anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8);
// 注册单个碰撞体的回调函数
// let collider = this.getComponent(Collider2D);
@@ -102,16 +102,10 @@ export class HeroViewComp extends CCComp {
// collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
// // collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
// }
// this.rigid = this.getComponent(RigidBody2D);
// if(this.rigid.sleep){
// console.log("hero rigid sleep ",this.scale,this.rigid);
// this.rigid.wakeUp();
// }
}
// onBeginContact (seCol: Collider2D, oCol: Collider2D) {
// console.log("碰撞开始 ",this.scale,seCol,oCol);
// }
// onEndContact (seCol: Collider2D, oCol: Collider2D) { console.log("碰撞结束 ",this.scale,seCol,oCol);}
// onPreSolve (seCol: Collider2D, oCol: Collider2D) {console.log("碰撞预处理 ",this.scale,seCol,oCol);}
@@ -133,10 +127,10 @@ export class HeroViewComp extends CCComp {
}
update(dt: number){
if(!smc.mission.play||smc.mission.pause) return
if(this.is_dead) {
if(!this.in_grave()) this.to_grave()
return
}
// if(this.is_dead) {
// this.ent.destroy();
// return
// }
this.hp_show()
if(this.ice_cd > 0){
this.ice_cd -=dt;
@@ -248,31 +242,23 @@ export class HeroViewComp extends CCComp {
}
//掉落物品
to_drop(){
let Drops = getMonsterDrops(1, MonsterType.Normal, 1.2);
if(this.is_boss) Drops =getMonsterDrops(1, MonsterType.Elite, 1.2);
if(this.is_big_boss) Drops =getMonsterDrops(1, MonsterType.Boss, 1.2);
// let Drops = getMonsterDrops(1, MonsterType.Normal, 1.2);
// if(this.is_boss) Drops =getMonsterDrops(1, MonsterType.Elite, 1.2);
// if(this.is_big_boss) Drops =getMonsterDrops(1, MonsterType.Boss, 1.2);
}
//进入墓地
to_grave(){
let pos =v3(-1000,this.node.position.y,this.node.position.z)
if(this.fac==1) pos.x=1000
this.node.setPosition(pos)
}
//是否在墓地
in_grave(){
return this.node.position.y <= -900;
}
to_alive(){
let pos =v3(HeroSet.Start_x[this.type],HeroSet.Start_y[this.type],this.node.position.z)
this.node.setPosition(pos)
this.revive()
}
to_console(value:any,value2:any=null,value3:any=null){
console.log("["+this.scale+this.hero_name+']'+value,value2,value3)
}
reset() {
this.is_dead = false;
this.node.destroy();
const collider = this.getComponent(Collider2D);
if (collider) {
collider.off(Contact2DType.BEGIN_CONTACT);
}
this.scheduleOnce(() => {
this.node.destroy();
}, 0.1);
}
playSkillEffect(skill_id:number) {
let skill = SkillSet[skill_id]