加血技能完成 怪物动画减少

This commit is contained in:
2024-09-15 23:25:34 +08:00
parent 417b5d85be
commit 2095393757
317 changed files with 36222 additions and 60962 deletions

View File

@@ -22,6 +22,7 @@ import { Tooltip } from "../skills/Tooltip";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BoxRangComp } from "./BoxRangComp";
import { MonViewComp } from "../mon/MonViewComp";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -185,7 +186,7 @@ export class HeroViewComp extends CCComp {
if(this.enemy){
return
}
this.set_diry()
// this.set_diry()
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
}
set_diry(){
@@ -203,28 +204,104 @@ export class HeroViewComp extends CCComp {
this.as.atk()
this.to_speek(smc.skills[this.max_skill_uuid].name)
this.scheduleOnce(()=>{
this.do_max_skill();
this.handle_skill(this.max_skill_uuid);
},0.5)
this.power = 0
}
// let power_progress= this.power/this.power_max;
// this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
shoot(skill_uuid:number,y:number=0){
skill_pos(){
return v3(0,35)
}
get_enemy_pos(){
let pos =this.skill_pos()
let t_pos:Vec3 = v3(720,BoxSet.GAME_LINE)
if(this.enemy){
if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
}
return {pos,t_pos}
}
get_hero_pos(hero:any){
let pos =this.skill_pos()
let t_pos:Vec3 = v3(720,BoxSet.GAME_LINE)
if(!hero.HeroView.node.isValid){
console.log("hero.heroView.node.isValid",hero.HeroView);
return
}else{
t_pos = v3(hero.HeroView.node.position.x-this.node.position.x,hero.HeroView.node.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
}
return {pos,t_pos}
}
shoot(skill_uuid:number,y:number=0,x:number=0){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
let scale = this.scale
let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
let {pos,t_pos}=this.get_enemy_pos()
pos.y=pos.y + y
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
pos.x=pos.x + x
skill.load(pos,BoxSet.HERO,this.node,skill_uuid,atk,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
to_add_buff(hero:any,s_uuid:number){
let skill = ecs.getEntity<Skill>(Skill);
let atk = smc.skills[s_uuid].atk+this.atk;
let {pos,t_pos}=this.get_hero_pos(hero)
skill.load(pos,BoxSet.HERO,this.node,this.max_skill_uuid,atk,t_pos);
hero.HeroView.add_hp(smc.skills[s_uuid].atk)
}
push_least_buff(skill:number){
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
let least_hp:number=999999
let t_hero:any= null
if (heros.length > 0) {
if(smc.skills[skill].type==92){ //随机添加buff
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
}else{
for (let i = 0; i < heros.length; i++) {
let hero = heros[i];
if(smc.skills[skill].type==91){ //血量最少单体
if(hero.HeroView.hp < least_hp){
least_hp = hero.HeroView.hp
t_hero = hero
}
}else{ //群体
this.to_add_buff(hero,skill)
}
}
if(t_hero){ //血量最少单体
this.to_add_buff(t_hero,skill)
}
}
}
}
//使用max_skill
do_max_skill(){
this.shoot(this.max_skill_uuid)
handle_skill(skill:number){
switch (smc.skills[skill].tg) {
case 0: //自己
break;
case 1: //伙伴
this.push_least_buff(skill)
break;
case 2: //自己和伙伴
break;
case 3: //敌人
this.shoot(skill)
break;
case 4: //敌人和自己
this.shoot(skill)
break;
}
}
to_speek(words:string,time:number=0.5){
this.speek_time=0.5
@@ -242,31 +319,14 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("tooltip").active=false;
}
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
let angle=0
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-(this.node.position.x),this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
}else{
t_pos=null
}
return {pos,t_pos,angle}
}
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
}
return true
if(Math.abs(this.enemy.position.x-this.node.position.x) < this.atk_dis) return true;
return false
}else{
return false
}
@@ -278,7 +338,7 @@ export class HeroViewComp extends CCComp {
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill_uuid);
this.handle_skill(this.skill_uuid)
},0.4)
}
}else{
@@ -309,9 +369,11 @@ export class HeroViewComp extends CCComp {
}, 15);
}
}
heathed(){
this.node.getChildByName("heathed").active=true
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.heathed();
this.hp+=hp;
if(this.hp > this.hp_max){
this.hp = this.hp_max;