暂时解决 受伤触发技能 出错问题
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @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 { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { HeroSpine } from "./HeroSpine";
|
||||
@@ -33,7 +33,7 @@ export class HeroViewComp extends CCComp {
|
||||
enemy:any=null!;
|
||||
|
||||
as: HeroSpine = null!;
|
||||
anm_timer:Timer = new Timer(2);
|
||||
anm_timer:Timer = new Timer(0.3);
|
||||
anm_name="idle"
|
||||
status:String = "idle"
|
||||
|
||||
@@ -67,6 +67,7 @@ export class HeroViewComp extends CCComp {
|
||||
sk4:number = 1001;
|
||||
sk5:number = 1001;
|
||||
skr:any=[0,0,0,0,0,0];
|
||||
uar:any=[0,0,0,0,0,0];
|
||||
ap: number = 10; /**攻击力 */
|
||||
ap_buff: number = 0;
|
||||
ap_buffs:any = [];
|
||||
@@ -86,7 +87,8 @@ export class HeroViewComp extends CCComp {
|
||||
speed: number = 100; /** 角色移动速度 */
|
||||
ospeed: number = 100; /** 角色初始速度 */
|
||||
|
||||
Tpos: Vec3 = v3(0,-60,0);
|
||||
atk_count: number = 0;
|
||||
atked_count: number = 0;
|
||||
stop_cd: number = 0.5; /*停止倒计时*/
|
||||
|
||||
dir_y:number = 0;
|
||||
@@ -204,20 +206,21 @@ export class HeroViewComp extends CCComp {
|
||||
this.node.setPosition(pos)
|
||||
return
|
||||
}
|
||||
|
||||
// if (this.timer.update(dt)) {
|
||||
// this.power_change(this.power_speed)
|
||||
// }
|
||||
// if(this.anm_timer.update(dt)) {
|
||||
// this.change_anm()
|
||||
// this.handle_skill(this.sk2)
|
||||
// }
|
||||
this.check_atk_buffs(dt)
|
||||
this.check_atk_counts()
|
||||
this.in_stop(dt);
|
||||
this.at += dt;
|
||||
this.check_enemy_alive()
|
||||
this.in_atk(dt);
|
||||
// this.hp_show()
|
||||
this.move(dt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -329,34 +332,51 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
return {pos,t_pos}
|
||||
}
|
||||
|
||||
in_atk(dt: number) {
|
||||
if(this.at >= this.cd){
|
||||
if(this.is_atking){
|
||||
this.at = 0;
|
||||
// console.log("cd:"+this.cd);
|
||||
this.as.atk();
|
||||
let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
console.log("大招触发判断: i="+i+":skr="+this.skr[this.lv]);
|
||||
check_atk_counts(){
|
||||
if(this.atk_count >= 1){
|
||||
this.atk_count = 0
|
||||
console.log("atk_count 清零:"+this.atk_count);
|
||||
// let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
// console.log("大招判断: i="+i+":skr="+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.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]){
|
||||
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)
|
||||
|
||||
return
|
||||
this.handle_skill(this.sk2)
|
||||
}
|
||||
}
|
||||
}
|
||||
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.shoot_enemy(this.sk1)
|
||||
},0.3)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//使用max_skill
|
||||
handle_skill(skill:number){
|
||||
|
||||
this.as.atk()
|
||||
switch (smc.skills[skill].tg) {
|
||||
case 0: //自己
|
||||
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);
|
||||
}
|
||||
to_add_buff(hero:any,s_uuid:number){
|
||||
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let atk = smc.skills[s_uuid].atk+this.ap;
|
||||
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);
|
||||
|
||||
if(smc.skills[s_uuid].hp > 0){ //buff加血
|
||||
let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.ap)
|
||||
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)
|
||||
hero.add_atk(increase_atk,smc.skills[s_uuid].bsd)
|
||||
}
|
||||
|
||||
if(smc.skills[s_uuid].shield > 0){ //buff护盾
|
||||
hero.add_shield(smc.skills[s_uuid].shield)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
push_least_buff(skill:number){
|
||||
@@ -543,6 +568,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
add_shield(shield:number){
|
||||
this.shield =shield
|
||||
console.log("shield:",shield);
|
||||
if(this.shield > 0){
|
||||
this.node.getChildByName("shielded").active=true
|
||||
}
|
||||
@@ -573,7 +599,8 @@ export class HeroViewComp extends CCComp {
|
||||
var node = instantiate(prefab);
|
||||
let pos =v3(0,30);
|
||||
node.setPosition(pos)
|
||||
node.parent = this.node;
|
||||
node.parent = this.node;
|
||||
this.atked_count++;
|
||||
}
|
||||
dead(){
|
||||
var path = "game/skills/dead";
|
||||
|
||||
Reference in New Issue
Block a user