暂时解决 受伤触发技能 出错问题

This commit is contained in:
2024-11-17 08:59:35 +08:00
parent 227cfd26d4
commit 75d2dd5988
6 changed files with 57 additions and 29 deletions

View File

@@ -290,13 +290,13 @@
"_restitution": 0, "_restitution": 0,
"_offset": { "_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0.4,
"y": 0 "y": -0.7
}, },
"_size": { "_size": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 30, "width": 11.6,
"height": 30 "height": 12.3
}, },
"_id": "" "_id": ""
}, },

View File

@@ -4,7 +4,7 @@ export const HeroInfo = {
uuid: 9001, path: "k1", type: 1, lv: 1,name: "白骑士", wp:1001,arm:2001,ring:3001,shoes:4001, uuid: 9001, path: "k1", type: 1, lv: 1,name: "白骑士", wp:1001,arm:2001,ring:3001,shoes:4001,
exp_type:0,lv2:5,lv3:10,lv4:20,lv5:30,a_exp:1,ua_exp:1,d_exp:10,ed_exp:1,a_buff:8101,ua_buff:8201,d_buff:8301,ed_buff:8401, exp_type:0,lv2:5,lv3:10,lv4:20,lv5:30,a_exp:1,ua_exp:1,d_exp:10,ed_exp:1,a_buff:8101,ua_buff:8201,d_buff:8301,ed_buff:8401,
ap: 20, ap_rate:0.1, hp: 100, hp_rate:0.1, def:10,def_rate:0.1, dis: 100, a_cd: 1, power: 0, power_max: 15, speed: 40, ap: 20, ap_rate:0.1, hp: 100, hp_rate:0.1, def:10,def_rate:0.1, dis: 100, a_cd: 1, power: 0, power_max: 15, speed: 40,
sk1: 9001, sk2: 2002, sk3: 9003, sk4: 9004, sk5: 9005, sk6: 9006, atktype: 1,skr:[0,10,20,30,40,50] sk1: 9001, sk2: 2002, sk3: 9003, sk4: 9004, sk5: 9005, sk6: 9006, atktype: 1,skr:[0,10,20,30,40,50],uar:[0,10,20,30,40,50],
}, },

View File

@@ -89,9 +89,11 @@ export class Hero extends ecs.Entity {
hv.sk4 = HInf.sk4; hv.sk4 = HInf.sk4;
hv.sk5 = HInf.sk5; hv.sk5 = HInf.sk5;
hv.skr = HInf.skr; hv.skr = HInf.skr;
hv.uar = HInf.uar;
hv.type = HInf.type; hv.type = HInf.type;
hv.hp= hv.hp_max =HInf.hp; hv.hp= hv.hp_max =HInf.hp;
hv.ap = HInf.ap; hv.ap = HInf.ap;
hv.def= HInf.def;
hv.cd = HInf.a_cd hv.cd = HInf.a_cd
hv.power_max= HInf.power_max hv.power_max= HInf.power_max
this.add(hv); this.add(hv);

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18 * @LastEditTime: 2022-08-17 12:36:18
*/ */
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,RigidBody2D ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math} from "cc"; import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,RigidBody2D ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroSpine } from "./HeroSpine"; import { HeroSpine } from "./HeroSpine";
@@ -33,7 +33,7 @@ export class HeroViewComp extends CCComp {
enemy:any=null!; enemy:any=null!;
as: HeroSpine = null!; as: HeroSpine = null!;
anm_timer:Timer = new Timer(2); anm_timer:Timer = new Timer(0.3);
anm_name="idle" anm_name="idle"
status:String = "idle" status:String = "idle"
@@ -67,6 +67,7 @@ export class HeroViewComp extends CCComp {
sk4:number = 1001; sk4:number = 1001;
sk5:number = 1001; sk5:number = 1001;
skr:any=[0,0,0,0,0,0]; skr:any=[0,0,0,0,0,0];
uar:any=[0,0,0,0,0,0];
ap: number = 10; /**攻击力 */ ap: number = 10; /**攻击力 */
ap_buff: number = 0; ap_buff: number = 0;
ap_buffs:any = []; ap_buffs:any = [];
@@ -86,7 +87,8 @@ export class HeroViewComp extends CCComp {
speed: number = 100; /** 角色移动速度 */ speed: number = 100; /** 角色移动速度 */
ospeed: number = 100; /** 角色初始速度 */ ospeed: number = 100; /** 角色初始速度 */
Tpos: Vec3 = v3(0,-60,0); atk_count: number = 0;
atked_count: number = 0;
stop_cd: number = 0.5; /*停止倒计时*/ stop_cd: number = 0.5; /*停止倒计时*/
dir_y:number = 0; dir_y:number = 0;
@@ -204,20 +206,21 @@ export class HeroViewComp extends CCComp {
this.node.setPosition(pos) this.node.setPosition(pos)
return return
} }
// if (this.timer.update(dt)) { // if (this.timer.update(dt)) {
// this.power_change(this.power_speed) // this.power_change(this.power_speed)
// } // }
// if(this.anm_timer.update(dt)) { // if(this.anm_timer.update(dt)) {
// this.change_anm() // this.handle_skill(this.sk2)
// } // }
this.check_atk_buffs(dt) this.check_atk_buffs(dt)
this.check_atk_counts()
this.in_stop(dt); this.in_stop(dt);
this.at += dt; this.at += dt;
this.check_enemy_alive() this.check_enemy_alive()
this.in_atk(dt); this.in_atk(dt);
// this.hp_show() // this.hp_show()
this.move(dt); this.move(dt);
} }
@@ -329,34 +332,51 @@ export class HeroViewComp extends CCComp {
return {pos,t_pos} return {pos,t_pos}
} }
check_atk_counts(){
in_atk(dt: number) { if(this.atk_count >= 1){
if(this.at >= this.cd){ this.atk_count = 0
if(this.is_atking){ console.log("atk_count 清零:"+this.atk_count);
this.at = 0; // let i = RandomManager.instance.getRandomInt(0,100,3)
// console.log("cd:"+this.cd); // console.log("大招判断: i="+i+":skr="+this.skr[this.lv]);
this.as.atk(); // if(i < this.skr[this.lv]){
let i = RandomManager.instance.getRandomInt(0,100,3) // console.log("大招触发: i="+i+":skr="+this.skr[this.lv]);
console.log("大招触发判断: i="+i+":skr="+this.skr[this.lv]); // this.node.getChildByName("max").active=true
// this.scheduleOnce(()=>{
// this.node.getChildByName("max").active=false
// },0.8)
// this.handle_skill(this.sk2)
// }
}
if(this.atked_count >= 1){
this.atked_count = 0
let i = RandomManager.instance.getRandomInt(0,100,3)
console.log("受伤判断i="+i+":skr="+this.skr[this.lv]);
if(i < this.skr[this.lv]){ if(i < this.skr[this.lv]){
console.log("受伤触发: i="+i+":skr="+this.skr[this.lv]);
this.node.getChildByName("max").active=true this.node.getChildByName("max").active=true
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.node.getChildByName("max").active=false this.node.getChildByName("max").active=false
},0.8) },0.8)
this.handle_skill(this.sk2) this.handle_skill(this.sk2)
return
} }
}
}
in_atk(dt: number) {
if(this.at >= this.cd){
if(this.is_atking){
this.at = 0;
this.atk_count++
// console.log("cd:"+this.cd);
this.as.atk();
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.shoot_enemy(this.sk1) this.shoot_enemy(this.sk1)
},0.3) },0.3)
} }
} }
} }
//使用max_skill //使用max_skill
handle_skill(skill:number){ handle_skill(skill:number){
this.as.atk()
switch (smc.skills[skill].tg) { switch (smc.skills[skill].tg) {
case 0: //自己 case 0: //自己
this.to_add_buff(this.node.getComponent(HeroViewComp),skill) this.to_add_buff(this.node.getComponent(HeroViewComp),skill)
@@ -391,10 +411,13 @@ export class HeroViewComp extends CCComp {
// this.tooltip(3,smc.skills[sk1].name,this.sk1); // this.tooltip(3,smc.skills[sk1].name,this.sk1);
} }
to_add_buff(hero:any,s_uuid:number){ to_add_buff(hero:any,s_uuid:number){
let skill = ecs.getEntity<Skill>(Skill); let skill = ecs.getEntity<Skill>(Skill);
let atk = smc.skills[s_uuid].atk+this.ap; let atk = smc.skills[s_uuid].atk+this.ap;
let {pos,t_pos}=this.get_hero_pos(hero) let {pos,t_pos}=this.get_hero_pos(hero)
console.log("to_add_buff:"+hero.hero_name+" "+s_uuid);
skill.load(pos,this.box_group,this.node,this.sk2,atk,t_pos); skill.load(pos,this.box_group,this.node,this.sk2,atk,t_pos);
if(smc.skills[s_uuid].hp > 0){ //buff加血 if(smc.skills[s_uuid].hp > 0){ //buff加血
let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.ap) let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.ap)
hero.add_hp(increase_hp) hero.add_hp(increase_hp)
@@ -403,9 +426,11 @@ export class HeroViewComp extends CCComp {
let increase_atk=Math.floor(smc.skills[s_uuid].atk*this.ap) let increase_atk=Math.floor(smc.skills[s_uuid].atk*this.ap)
hero.add_atk(increase_atk,smc.skills[s_uuid].bsd) hero.add_atk(increase_atk,smc.skills[s_uuid].bsd)
} }
if(smc.skills[s_uuid].shield > 0){ //buff护盾 if(smc.skills[s_uuid].shield > 0){ //buff护盾
hero.add_shield(smc.skills[s_uuid].shield) hero.add_shield(smc.skills[s_uuid].shield)
} }
} }
push_least_buff(skill:number){ push_least_buff(skill:number){
@@ -543,6 +568,7 @@ export class HeroViewComp extends CCComp {
} }
add_shield(shield:number){ add_shield(shield:number){
this.shield =shield this.shield =shield
console.log("shield:",shield);
if(this.shield > 0){ if(this.shield > 0){
this.node.getChildByName("shielded").active=true this.node.getChildByName("shielded").active=true
} }
@@ -574,6 +600,7 @@ export class HeroViewComp extends CCComp {
let pos =v3(0,30); let pos =v3(0,30);
node.setPosition(pos) node.setPosition(pos)
node.parent = this.node; node.parent = this.node;
this.atked_count++;
} }
dead(){ dead(){
var path = "game/skills/dead"; var path = "game/skills/dead";

View File

@@ -38,7 +38,7 @@ export class SkillCom extends CCComp {
run_type:number = 0; // 0有目标 带方向1贝塞尔曲线 2 不动 ,3 直线 run_type:number = 0; // 0有目标 带方向1贝塞尔曲线 2 不动 ,3 直线
in_time:number = 0.3; // 不动技能持续时间 in_time:number = 0.3; // 不动技能持续时间
start() { start() {
console.log("skill start run_type",this.run_type) // console.log("skill start run_type",this.run_type)
if(this.node.parent.scale.x < 0){ if(this.node.parent.scale.x < 0){
this.t_pos.x=this.t_pos.x*-1 this.t_pos.x=this.t_pos.x*-1
} }
@@ -72,7 +72,7 @@ export class SkillCom extends CCComp {
let distance = Math.sqrt(squaredDistance); let distance = Math.sqrt(squaredDistance);
time = distance / this.speed; time = distance / this.speed;
let e_pos=v3(this.node.position.x+this.t_pos.x,this.node.position.y+this.t_pos.y) let e_pos=v3(this.node.position.x+this.t_pos.x,this.node.position.y+this.t_pos.y)
console.log("skill tx:"+e_pos.x+" node :"+this.node.position.x) // console.log("skill tx:"+e_pos.x+" node :"+this.node.position.x)
this.node.getChildByName("skill").setRotationFromEuler(0,0,this.angle) this.node.getChildByName("skill").setRotationFromEuler(0,0,this.angle)
// console.log("skill ",this.node.getRotation()) // console.log("skill ",this.node.getRotation())
tween(this.node).to( time,{ position: e_pos}, tween(this.node).to( time,{ position: e_pos},
@@ -149,7 +149,7 @@ export class SkillCom extends CCComp {
toDestroy() { toDestroy() {
if(this.is_destroy){ if(this.is_destroy){
if(this.node.parent) this.ent.destroy() this.ent.destroy()
} }
} }

View File

@@ -8,7 +8,6 @@ export class dead extends Component {
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this); anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
} }
onAnimationFinished(){ onAnimationFinished(){
console.log("动画结束");
this.node.destroy(); this.node.destroy();
} }
update(deltaTime: number) { update(deltaTime: number) {