血量更新 修改

This commit is contained in:
2024-12-26 15:49:07 +08:00
parent 13bec1e640
commit 295dcbda33
7 changed files with 51 additions and 55 deletions

View File

@@ -13,8 +13,8 @@ const { ccclass, property } = _decorator;
@ccclass('Main')
export class Main extends Root {
start() {
// if (DEBUG) profiler.showStats();
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
if (DEBUG) profiler.showStats();
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
// // | EPhysics2DDrawFlags.Pair
// |EPhysics2DDrawFlags.CenterOfMass
// |EPhysics2DDrawFlags.Joint

View File

@@ -34,9 +34,9 @@ export const MBSet = {
ap_exp:100,
def_exp:100,
hp_exp:100,
ap_add:10,
def_add:5,
hp_add:50,
ap_add:2,
def_add:1,
hp_add:5,
crit_add:1,
dodge_add:1,
ap_cost:1,

View File

@@ -29,22 +29,22 @@ run:number = 0; // 0有目标 带方向1贝塞尔曲线 2 不动 ,3 直线
*/
export const SkillSet={
6001:{uuid: 6001,path: "6001",type: 1,tg:3,angle:true,exp:30,upcost:2,level: 1,name: "火球术",sp_name:"fire",info:"释放一个火球术攻击敌人",
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:3,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:600, },
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:3,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:300, },
6002:{uuid: 6002,path: "6002",type: 1,tg:3,angle:true,exp:30,upcost:2,level: 3,name: "寒冰箭",sp_name:"ice",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:600, },
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:300, },
6003:{uuid: 6003,path: "6003",type: 1,tg:3,angle:true,exp:30,upcost:2,level: 3,name: "强效射击",sp_name:"b_arrow",info:"释放一个火球术攻击敌人",
dis:1,count:1,in:0,run:1,ap:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:600, },
dis:1,count:1,in:0,run:1,ap:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:300, },
6004:{uuid: 6004,path: "6004",type: 1,tg:3,angle:true,exp:30,upcost:2,level: 3,name: "奥术冲击",sp_name:"bm_ball",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:600, },
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:300, },
6005:{uuid: 6005,path: "6005",type: 1,tg:3,angle:true,exp:30,upcost:2,level: 1,name: "挥砍",sp_name:"patk",info:"蓄力释放剑气攻击敌人",
dis:1,count:1,in:0,run:0,ap:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:6000,},
dis:1,count:1,in:0,run:0,ap:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:300,},
6101:{uuid: 6101,path: "6101",type: 91,tg:1,angle:false,exp:30,upcost:2,level: 1,name: "治愈术",sp_name:"heath",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0,run:1,ap:0,hp:3,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:450, },
dis:1,count:1,in:0,run:1,ap:0,hp:3,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:6001,sk_count:0,speed:300, },
6102:{uuid: 6102,path: "6102",type: 91,tg:0,angle:false,exp:30,upcost:2,level: 1,name: "魔法盾",sp_name:"shield",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0.2,run:2,ap:0,hp:0,shield:1,sd:0,cd:0,bsd:8,bcd:0,sk_uuid:6001,sk_count:0,speed:450, },
dis:1,count:1,in:0.2,run:2,ap:0,hp:0,shield:1,sd:0,cd:0,bsd:8,bcd:0,sk_uuid:6001,sk_count:0,speed:300, },
6103:{uuid: 6103,path: "6103",type: 91,tg:0,angle:false,exp:30,upcost:2,level: 1,name: "狂暴",sp_name:"atkup",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0.2,run:2,ap:1,hp:0,shield:0,sd:0,cd:0,bsd:8,bcd:0,sk_uuid:6001,sk_count:0,speed:450, },
dis:1,count:1,in:0.2,run:2,ap:1,hp:0,shield:0,sd:0,cd:0,bsd:8,bcd:0,sk_uuid:6001,sk_count:0,speed:300, },
}

View File

@@ -109,7 +109,7 @@ export class Hero extends ecs.Entity {
hv.uar = hero.uar[slv];
hv.crr = hero.crr[slv];
hv.dgr = hero.dgr[slv];
hv.hp= hv.hp_max =hero.hp+hero.hp_up*hv.lv ;
hv.rhp_max=hv.hp= hv.hp_max =hero.hp+hero.hp_up*hv.lv ;
hv.ap = hero.ap+hero.ap_up*hv.lv ;
hv.def= hero.def+hero.def_up*hv.lv;
hv.cd = hero.a_cd

View File

@@ -53,6 +53,7 @@ export class HeroViewComp extends CCComp {
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
rhp_max: number = 100;
hp_speed: number = 0; //每秒回复量
pw: number = 0; /**能量**/
@@ -178,13 +179,16 @@ export class HeroViewComp extends CCComp {
let self_x = selfCollider.node.position.x;
let other_x = otherCollider.node.position.x;
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
if(selfCollider.group==BoxSet.HERO){
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 8 ){
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 20 ){
// this.node.setSiblingIndex(otherCollider.node.getSiblingIndex()-10)
this.stop_cd = 0.1;
}
}
if(selfCollider.group==BoxSet.MONSTER){
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x > other_x && Math.abs(other_x-self_x) < 8 ){
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x > other_x && Math.abs(other_x-self_x) < 20 ){
// this.node.setSiblingIndex(otherCollider.node.getSiblingIndex()-10)
this.stop_cd = 0.1;
}
}
@@ -214,7 +218,7 @@ export class HeroViewComp extends CCComp {
this.at += dt;
this.check_enemy_alive()
this.in_atk(dt);
// this.hp_show()
this.hp_show()
this.move(dt);
this.check_mission_buf()
}
@@ -223,41 +227,35 @@ export class HeroViewComp extends CCComp {
this.crit_max=(100+smc.vmdata.mission.crit)/100*this.crit
this.def_max=(100+smc.vmdata.mission.def)/100*this.def
this.dodge_max=(100+smc.vmdata.mission.dodge)/100*this.dodge
this.rhp_max=(100+smc.vmdata.mission.hp)/100*this.hp_max
if(this.box_group == BoxSet.MONSTER){
this.ap_max=(100+smc.vmdata.mission.map)/100*this.ap
this.crit_max=(100+smc.vmdata.mission.mcrit)/100*this.crit
this.def_max=(100+smc.vmdata.mission.mdef)/100*this.def
this.dodge_max=(100+smc.vmdata.mission.mdodge)/100*this.dodge
this.rhp_max=(100+smc.vmdata.mission.mhp)/100*this.hp_max
}
}
check_enemy_alive(){
let dir = 320
let enemys=smc.enemy_pos
this.enemy = v3(720,this.node.position.y)
if(this.box_group == BoxSet.MONSTER){
for (let i = 0; i < smc.hero_pos.length; i++) {
let ho:any = smc.hero_pos[i];
let x=Math.abs(ho.x-this.node.position.x)
if(x < dir){
dir = x
this.enemy = ho
}
}
enemys=smc.hero_pos
this.enemy=v3(-720,this.node.position.y)
}
if(this.box_group == BoxSet.HERO){
for (let i = 0; i < smc.enemy_pos.length; i++) {
let mon:any = smc.enemy_pos[i];
let x=Math.abs(mon.x-this.node.position.x)
if(x < dir){
dir = x
this.enemy = mon
}
}
for (let i = 0; i < enemys.length; i++) {
let ho:any = enemys[i];
let x=Math.abs(ho.x-this.node.position.x)
if(x < dir){
dir = x
this.enemy = ho
}
}
if(dir < this.dis){
this.is_atking=true
if(this.dis-dir > 45 ) this.stop_cd = 0.1
if(this.dis-dir > 80 &&this.type > 0 ) this.stop_cd = 0.1
}else{
this.is_atking=false
}
@@ -312,7 +310,9 @@ export class HeroViewComp extends CCComp {
}
hp_show(){
if(this.hp == this.hp_max){
let hp_progress= this.hp/this.rhp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp == this.rhp_max){
this.node.getChildByName("top").getChildByName("hp").active = false;
} else{
this.node.getChildByName("top").getChildByName("hp").active = true;
@@ -563,8 +563,8 @@ export class HeroViewComp extends CCComp {
if(!heros[i].HeroView) continue
let hero = heros[i].HeroView;
if(SkillSet[skill].type==91){ //血量最少单体
if((hero.hp_max-hero.hp) > least_hp){
least_hp = (hero.hp_max-hero.hp)
if((hero.rhp_max-hero.hp) > least_hp){
least_hp = (hero.rhp_max-hero.hp)
t_hero = hero
}
}else{ //群体
@@ -609,19 +609,14 @@ export class HeroViewComp extends CCComp {
add_hp(hp: number=0){
this.heathed();
this.hp+=hp;
if(this.hp > this.hp_max){
this.hp = this.hp_max;
if(this.hp > this.rhp_max){
this.hp = this.rhp_max;
}
this.tooltip(2,hp.toFixed(0));
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
}
add_hp_max(hp: number=0){
this.hp_max_add()
this.hp += hp;
this.hp_max += hp;
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
this.hp += hp/100*this.hp_max;
}
hp_change(hp: number,is_crit:boolean=false){
if(this.is_dead){
@@ -636,11 +631,10 @@ export class HeroViewComp extends CCComp {
this.tooltip(1,hp.toFixed(0),250);
}
if(this.hp > this.hp_max){
this.hp = this.hp_max;
if(this.hp > this.rhp_max){
this.hp = this.rhp_max;
}
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
this.dead();
this.to_grave()

View File

@@ -48,9 +48,9 @@ export class HCardComp extends CCComp {
this.node.getChildByName("bg").getComponent(Sprite).grayscale=false
this.is_dead=false
}
this.hp.string=this.heros[this.hi].HeroView.hp_max
this.hp.string=this.heros[this.hi].HeroView.rhp_max
this.ap.string=this.heros[this.hi].HeroView.ap*(smc.vmdata.mission.ap+100)/100
this.life.progress=this.heros[this.hi].HeroView.hp/this.heros[this.hi].HeroView.hp_max
this.life.progress=this.heros[this.hi].HeroView.hp/this.heros[this.hi].HeroView.rhp_max
this.pw.progress=this.heros[this.hi].HeroView.pw/this.heros[this.hi].HeroView.pwm
}

View File

@@ -36,10 +36,12 @@ export class Skill extends ecs.Entity {
let angle=0
if(SkillSet[uuid].angle){
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(t_pos.x<0){
angle+=180
}
}
sv.angle = angle;
// console.log(SkillSet[uuid].name+"angle:"+angle)
console.log(group+" "+SkillSet[uuid].name+"angle:"+angle)
sv.s_uuid = uuid;
sv.ap = ap;
sv.is_crit=is_crit