This commit is contained in:
2024-09-29 09:49:35 +08:00
parent 331b22da07
commit 81639781f9
7 changed files with 100 additions and 82 deletions

View File

@@ -9,7 +9,7 @@ import { Vec3, v3,_decorator ,Collider2D,Contact2DType,Label,Node,Prefab,instant
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { RoleSpine } from "./RoleSpine";
import {BoxSet} from "../common/config/BoxSet"
import {BoxSet, GameSet} from "../common/config/BoxSet"
import { smc } from "../common/SingletonModuleComp";
import { SkillCom } from "../skills/SkillCom";
import { Skill } from "../skills/Skill";
@@ -185,7 +185,7 @@ export class RoleViewComp extends CCComp {
this.in_atk();
this.skill_cds(dt);
this.move(dt);
this.check_enemys()
this.check_enemy_alive()
}
skill_cds(dt:number){
if(this.skill1.alive) this.skill1.cd -= dt;
@@ -195,27 +195,27 @@ export class RoleViewComp extends CCComp {
if(this.skill5.alive) this.skill5.cd -= dt;
if(this.skill1.cd <= 0){
this.shoot(this.skill1.uuid);
this.handle_skill(this.skill1.uuid);
this.skill1.cd=this.skill1.cd_max
console.log("shoot uuid :"+this.skill1.uuid);
}
if(this.skill2.cd <= 0){
this.shoot(this.skill2.uuid);
this.handle_skill(this.skill2.uuid);
this.skill2.cd=this.skill2.cd_max
console.log("shoot uuid :"+this.skill2.uuid);
}
if(this.skill3.cd <= 0){
this.shoot(this.skill3.uuid);
this.handle_skill(this.skill3.uuid);
this.skill3.cd=this.skill3.cd_max
console.log("shoot uuid :"+this.skill3.uuid);
}
if(this.skill4.cd <= 0){
this.shoot(this.skill4.uuid);
this.handle_skill(this.skill4.uuid);
this.skill4.cd=this.skill4.cd_max
console.log("shoot uuid :"+this.skill4.uuid);
}
if(this.skill5.cd <= 0){
this.shoot(this.skill5.uuid);
this.handle_skill(this.skill5.uuid);
this.skill5.cd=this.skill5.cd_max
console.log("shoot uuid :"+this.skill5.uuid);
}
@@ -231,25 +231,32 @@ export class RoleViewComp extends CCComp {
// });
// console.log(this.skills);
}
check_enemys(){
let enemys=ecs.query(ecs.allOf(MonViewComp));
if(enemys.length > 0){
let x= 720
for (let i = 0; i < enemys.length; i++) {
let enemy:any = enemys[i];
if(!enemy.MonView) continue
let node=enemy.MonView.node
if(node.isValid){
if(node.position.x < x){
x=node.position.x
this.enemy = node.position;
}
}
}
}else{
this.enemy = v3(720,this.node.position.y);
}
handle_skill(uuid:number){
// console.log("handle_skill uuid:"+uuid);
this.as.max();
this.scheduleOnce(()=>{
this.shoot(this.skill);
},0.3)
}
// check_enemys(){
// let enemys=ecs.query(ecs.allOf(MonViewComp));
// if(enemys.length > 0){
// let x= 720
// for (let i = 0; i < enemys.length; i++) {
// let enemy:any = enemys[i];
// if(!enemy.MonView) continue
// let node=enemy.MonView.node
// if(node.isValid){
// if(node.position.x < x){
// x=node.position.x
// this.enemy = node.position;
// }
// }
// }
// }else{
// this.enemy = v3(720,this.node.position.y);
// }
// }
move(dt:number){
if(this.stop_cd > 0){
this.as.idle()
@@ -287,30 +294,40 @@ export class RoleViewComp extends CCComp {
return {pos,t_pos}
}
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
let dir = 320
this.enemy = v3(720,this.node.position.y)
for (let i = 0; i < GameSet.ATK_LINES; i++) {
let mon:any = smc.enemy_pos[i];
let x=Math.abs(mon.x-this.node.position.x)
let y = Math.abs(mon.y-this.node.position.y)
let squaredDistance =x*x+y*y
let distance = Math.sqrt(squaredDistance);
if(distance < dir){
dir = distance
this.enemy = mon
}
return true
}
if(dir < this.atk_dis){
this.is_atking=true
}else{
return false
this.is_atking=false
}
}
in_atk() {
if(this.atk_time >= this.atk_cd){
// if(this.is_atking&&this.check_enemy_alive()){
// this.atk_time = 0;
// // console.log("atk_cd:"+this.atk_cd);
// this.as.atk();
// this.scheduleOnce(()=>{
// this.shoot(this.skill,-30);
// },0.4)
// }
this.atk_time = 0;
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill,-30,45);
},0.3)
if(this.is_atking){
this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill,-30);
},0.4)
}
// this.atk_time = 0;
// this.as.atk();
// this.scheduleOnce(()=>{
// this.shoot(this.skill,-30,45);
// },0.3)
}
}
@@ -337,7 +354,7 @@ export class RoleViewComp extends CCComp {
return;
}
this.hp += lhp;
this.tooltip(1,hp.toString());
// this.tooltip(1,hp.toString());
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
@@ -485,12 +502,12 @@ export class RoleViewComp extends CCComp {
in_atked() {
var path = "game/skills/atked";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let pos = v3(0,60)
node.setPosition(pos)
node.parent = this.node;
// var path = "game/skills/atked";
// var prefab: Prefab = oops.res.get(path, Prefab)!;
// var node = instantiate(prefab);
// let pos = v3(0,30)
// node.setPosition(pos)
// node.parent = this.node;
// this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);

View File

@@ -29,39 +29,38 @@ export const HeroSet = {
max_skill: "精准射击", skill_uuid: 9003, max_skill_uuid: 1003, word: "狂暴", info: "全体攻击", atktype: 2
},
}
export const MonSet = {
1011: {
uuid: 1011, path: "orc1", type: 1, level: 1,cost:2, name: "森林兽人", atk: 10, hp: 100, atk_dis: 100, atk_cd: 2, power: 0, power_max: 20, speed: 30,
uuid: 1011, path: "orc1", type: 1, level: 1,cost:2, name: "森林兽人", atk: 5, hp: 15, atk_dis: 100, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
1012: {
uuid: 1012, path: "orc2", type: 1, level: 1,cost:2, name: "荒野兽人", atk: 15, hp: 100, atk_dis: 100, atk_cd: 2, power: 0, power_max: 20, speed: 30,
uuid: 1012, path: "orc2", type: 1, level: 1,cost:2, name: "荒野兽人", atk: 10, hp: 15, atk_dis: 100, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
1013: {
uuid: 1013, path: "orc3", type: 1, level: 1,cost:2, name: "兽人战士", atk: 20, hp: 100, atk_dis: 100, atk_cd: 2, power: 0, power_max: 20, speed: 30,
uuid: 1013, path: "orc3", type: 1, level: 1,cost:2, name: "兽人战士", atk: 15, hp: 15, atk_dis: 100, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
1031: {
uuid: 1031, path: "du1", type: 1, level: 1,cost:2, name: "独眼巨人", atk: 10, hp: 100, atk_dis: 100, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 1031, path: "du1", type: 1, level: 1,cost:2, name: "独眼巨人", atk: 5, hp: 15, atk_dis: 100, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
1032: {
uuid: 1032, path: "du2", type: 1, level: 1,cost:2, name: "狂暴独眼", atk: 15, hp: 100, atk_dis: 100, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 1032, path: "du2", type: 1, level: 1,cost:2, name: "狂暴独眼", atk: 10, hp: 15, atk_dis: 100, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
1033: {
uuid: 1033, path: "du3", type: 1, level: 1,cost:2, name: "独眼首领", atk: 20, hp: 100, atk_dis: 100, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 1033, path: "du3", type: 1, level: 1,cost:2, name: "独眼首领", atk: 15, hp: 15, atk_dis: 100, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
5001: {
uuid: 5001, path: "boss1", type: 1, level: 1,cost:2, name: "骷髅王", atk: 30, hp: 1000, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 7,
uuid: 5001, path: "boss1", type: 1, level: 1,cost:2, name: "骷髅王", atk: 30, hp: 150, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 7,
max_skill: "精准打击", skill_uuid: 1001, max_skill_uuid: 1002, word: "守护", info: "自身护盾", atktype: 1
},

View File

@@ -277,7 +277,6 @@ export class HeroViewComp extends CCComp {
get_hero_pos(hero:any){
let pos =this.skill_pos()
let t_pos:Vec3 = v3(720,0)
console.log("hero.node.isValid",hero);
if(!hero.node.isValid){
return
}else{
@@ -347,10 +346,12 @@ export class HeroViewComp extends CCComp {
}
if(t_hero){ //血量最少单体
let role_hp=smc.Role.RoleView.hp_max-smc.Role.RoleView.hp
if(role_hp > least_hp){
least_hp = role_hp
t_hero = smc.Role.RoleView
if(smc.Role.RoleView){
let role_hp=smc.Role.RoleView.hp_max-smc.Role.RoleView.hp
if(role_hp > least_hp){
least_hp = role_hp
t_hero = smc.Role.RoleView
}
}
this.to_add_buff(t_hero,skill)
}
@@ -451,7 +452,7 @@ export class HeroViewComp extends CCComp {
return;
}
this.hp += lhp;
this.tooltip(1,hp.toString());
// this.tooltip(1,hp.toString());
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}

View File

@@ -33,7 +33,7 @@ export class TooltipCom extends CCComp {
this.node.getChildByName("loss_life").active=true;
tween(this.node).to(
this.alive_time,
{position:v3(this.node.position.x,this.node.position.y+10), },
{position:v3(this.node.position.x+30,this.node.position.y+20), },
{
onComplete:()=>{ this.ent.destroy()},
easing:"linear"
@@ -45,7 +45,7 @@ export class TooltipCom extends CCComp {
this.node.getChildByName("add_life").active=true;
tween(this.node).to(
this.alive_time,
{position:v3(this.node.position.x,this.node.position.y+10), },
{position:v3(this.node.position.x-30,this.node.position.y+20), },
{
onComplete:()=>{ this.ent.destroy()},
easing:"linear"