From 4335a8500b2f9a9ab8bb261f5880c6d4dfb97646 Mon Sep 17 00:00:00 2001 From: panfudan Date: Wed, 26 Mar 2025 13:49:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E8=83=BD=E7=B3=BB=E7=BB=9F=E8=BF=98?= =?UTF-8?q?=E8=A6=81,=E4=BC=A4=E5=AE=B3=E9=80=BB=E8=BE=91=E4=BA=A4?= =?UTF-8?q?=E7=BB=99=E7=A2=B0=E6=92=9E=E7=B3=BB=E7=BB=9F=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/hero/Hero.ts | 14 +--- assets/script/game/hero/HeroViewComp.ts | 85 ++------------------- assets/script/game/skill/HeroSkillSystem.ts | 2 +- assets/script/game/skills/SkillCom.ts | 55 ++++++------- 4 files changed, 35 insertions(+), 121 deletions(-) diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 6eb17554..2fe60f42 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -55,22 +55,10 @@ export class Hero extends ecs.Entity { hv.hero_name= hero.name; hv.speed =hv.ospeed = hero.speed; hv.dis = hero.dis; - hv.pw = hero.pw; - hv.pwm= hero.pwm; - hv.pws= hero.pws - hv.apw=hero.apw; - hv.uapw=hero.uapw; - hv.cpw=hero.cpw; - hv.dpw=hero.dpw; - hv.dopw=hero.dopw; - let slv= Math.floor(( hv.lv) / 5); hv.hp= hv.hp_max =hero.hp; hv.ap = hero.ap; - hv.def= hero.def; hv.cd = hero.a_cd - hv.crit = hero.crit; //暴击率 - hv.crit_add = hero.crit_add;//暴击伤害加成 - hv.dodge = hero.dodge; //闪避率 + hv.atk_skill=hero.skills[0] this.add(hv); // 初始化多个技能组件 diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 8169fcc3..8b31a5ff 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -51,45 +51,17 @@ export class HeroViewComp extends CCComp { hp: number = 100; /** 血量 */ hp_max: number = 100; /** 最大血量 */ hp_speed: number = 0; //每秒回复量 - - pw: number = 0; // 当前能量值 - pwm: number = 100; // 最大能量值 - pws: number = 1; //能量回复速度每0.1秒回复量 - apw:number=0; - uapw:number=0; - cpw:number=0; - dopw:number=0; - dpw:number=0; + pwt:Timer = new Timer(1); //计时器 - - akr:number=0; //攻击触发机率 - uar:number=0; //受伤触发机率 - dgr:number=0; //闪避触发机率 - crr:number=0; //暴击触发机率 - akc:number=0; //攻击次数触发 - uac:number=0; //受伤次数触发 - dgc:number=0; //闪避次数触发 - crc:number=0; //暴击次数触发 - - aexp:number=0; //攻击经验 - uaexp:number=0; //受伤经验 - cexp:number=0; //暴击经验 */ - doexp:number=0; //闪避经验 */ - dexp:number=0; //死亡经验 */ - ap: number = 10; /**攻击力 */ - ap_buff: number = 0; - ap_buffs:any = []; // atk_speed: number = 1; cd: number = 1.3; /**攻击速度 攻击间隔 */ dis: number = 80; at: number = 0; /** 冷却时间 */ - + atk_skill:number=0; def: number = 0; //防御 vun: number = 0; //易伤 - crit: number = 0; //暴击率 - crit_add: number = 0;//暴击伤害加成 dodge: number = 10; //闪避率 @@ -99,9 +71,6 @@ export class HeroViewComp extends CCComp { atk_count: number = 0; atked_count: number = 0; - dodge_count: number = 0; - crit_count: number = 0; - stop_cd: number = 0; /*停止倒计时*/ yun_cd: number = 0; //眩晕倒计时 @@ -139,18 +108,12 @@ export class HeroViewComp extends CCComp { } 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); - } - - onPostSolve (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);} + onPostSolve (seCol: Collider2D, oCol: Collider2D) {console.log("碰撞后处理 ",this.scale,seCol,oCol); } /** 视图层逻辑代码分离演示 */ start () { @@ -172,9 +135,6 @@ export class HeroViewComp extends CCComp { if(!this.in_grave()) this.to_grave() return } - if (this.pwt.update(dt)) { - this.pw+=this.pws - } this.hp_show() if(this.ice_cd > 0){ this.ice_cd -=dt; @@ -240,27 +200,6 @@ export class HeroViewComp extends CCComp { this.ap -= Math.floor(ap); this.BUFFCOMP.buff_get("deap") } - add_def(def: number){ - this.def += Math.floor(def); - this.BUFFCOMP.buff_get("def") - } - de_def(def: number){ - this.def -= Math.floor(def); - this.BUFFCOMP.buff_get("dedef") - } - /** - * 增加英雄的暴击率。 - * @param crit 要增加的暴击率。 - */ - - add_crit(critRate: number) { - this.crit += Math.floor(critRate); - this.BUFFCOMP.buff_get("crit"); - } - de_crit(critRate: number) { - this.crit += Math.floor(critRate); - this.BUFFCOMP.buff_get("decrit"); - } /** * 增加英雄的闪避率。 * @param dodge 要增加的闪避率。 @@ -293,8 +232,7 @@ export class HeroViewComp extends CCComp { add_hp2(hprate: number=0){ this.hp += Math.floor(hprate/100*this.hp_max) ; } - - + /** 静止时间 */ in_stop (dt: number) { if(this.stop_cd > 0){ @@ -315,9 +253,6 @@ export class HeroViewComp extends CCComp { 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(){ @@ -329,13 +264,11 @@ export class HeroViewComp extends CCComp { in_grave(){ return this.node.position.y <= -900; } - to_alive(){ let pos =v3(HeroSet.StartPos[this.type],this.node.position.y,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) } @@ -343,7 +276,6 @@ export class HeroViewComp extends CCComp { this.is_dead = false; this.node.destroy(); } - playSkillEffect(skill_id:number) { let skill = SkillSet[skill_id] switch(skill.act){ @@ -357,7 +289,6 @@ export class HeroViewComp extends CCComp { break } } - public revive() { this.hp = this.hp_max; const skills = this.ent.get(HeroSkillsComp); diff --git a/assets/script/game/skill/HeroSkillSystem.ts b/assets/script/game/skill/HeroSkillSystem.ts index 836cc5ab..d888abdc 100644 --- a/assets/script/game/skill/HeroSkillSystem.ts +++ b/assets/script/game/skill/HeroSkillSystem.ts @@ -28,7 +28,7 @@ export class HeroSkillSystem extends ecs.ComblockSystem implements ecs.ISystemUp update(e: ecs.Entity) { - return false + //return false // 处理伤害队列 this.processDamageQueue(); const view = e.get(HeroViewComp); diff --git a/assets/script/game/skills/SkillCom.ts b/assets/script/game/skills/SkillCom.ts index 82b31c3d..18783a57 100644 --- a/assets/script/game/skills/SkillCom.ts +++ b/assets/script/game/skills/SkillCom.ts @@ -1,4 +1,4 @@ -import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math} from "cc"; +import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math, RigidBody2D} 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 { smc } from "../common/SingletonModuleComp"; @@ -29,36 +29,31 @@ export class SkillCom extends CCComp { targetPos: Vec3 = v3(); // 目标位置 duration: number = 0; // 技能持续时间 prefabName: string = ""; // 预制体名称 - group:number = 0; //阵营 - animName: string = ""; // 动画名称 - box_group:number = 0; //碰撞组 + animName: string = ""; + group:number = 0; //阵营 + rigid:RigidBody2D=null!; // 动画名称 protected onLoad(): void { - - - let collider = this.getComponent(Collider2D); - collider.group = this.box_group; - // console.log("hero collider ",this.scale,collider); - if (collider) { - collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); - // collider.on(Contact2DType.END_CONTACT, this.onEndContact, this); - collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this); - // collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this); - } - - } - onBeginContact (seCol: Collider2D, oCol: Collider2D) { - - } - - onEndContact (seCol: Collider2D, oCol: Collider2D) { - - } - onPreSolve (seCol: Collider2D, oCol: Collider2D) { - - } - - onPostSolve (seCol: Collider2D, oCol: Collider2D) { - } + let collider = this.getComponent(Collider2D); + collider.group = this.group; + // console.log("hero collider ",this.scale,collider); + if (collider) { + collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); + // collider.on(Contact2DType.END_CONTACT, this.onEndContact, this); + 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);} + onPostSolve (seCol: Collider2D, oCol: Collider2D) {console.log("碰撞后处理 ",this.scale,seCol,oCol); } start() { oops.message.on(GameEvent.MissionEnd, this.doDestroy, this);