This commit is contained in:
2024-09-12 13:46:42 +08:00
parent 1c9aa38385
commit 5f1b081374
16 changed files with 186 additions and 215 deletions

View File

@@ -1,9 +0,0 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "f6a556e5-ddfa-414b-bb82-ea1da78872f3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -734,13 +734,13 @@
<key>premultiplyAlpha</key> <key>premultiplyAlpha</key>
<false/> <false/>
<key>realTextureFileName</key> <key>realTextureFileName</key>
<string>a6.png</string> <string>f2.png</string>
<key>size</key> <key>size</key>
<string>{938,670}</string> <string>{938,670}</string>
<key>smartupdate</key> <key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:d5d04c5fb788754a234a6c1c70e6a228:016e0863eb806096731b730bbe711037:0cab8998cdf7df9be777c4b42a91fbe6$</string> <string>$TexturePacker:SmartUpdate:d5d04c5fb788754a234a6c1c70e6a228:016e0863eb806096731b730bbe711037:0cab8998cdf7df9be777c4b42a91fbe6$</string>
<key>textureFileName</key> <key>textureFileName</key>
<string>a6.png</string> <string>f2.png</string>
</dict> </dict>
</dict> </dict>
</plist> </plist>

View File

@@ -2217,7 +2217,7 @@
} }
}, },
"userData": { "userData": {
"atlasTextureName": "a6.png", "atlasTextureName": "f2.png",
"format": 3, "format": 3,
"uuid": "3447240f-ac71-4e7b-93d2-9de5907a4cf7", "uuid": "3447240f-ac71-4e7b-93d2-9de5907a4cf7",
"textureUuid": "59fbc5be-4950-4b13-aa5d-76f8ca465187@6c48a" "textureUuid": "59fbc5be-4950-4b13-aa5d-76f8ca465187@6c48a"

View File

@@ -644,12 +644,12 @@
"_restitution": 0, "_restitution": 0,
"_offset": { "_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 400,
"y": 40 "y": 40
}, },
"_size": { "_size": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 1000, "width": 800,
"height": 500 "height": 500
}, },
"_id": "" "_id": ""

View File

@@ -21,6 +21,7 @@ import { MoveToComp } from "../common/ecs/position/MoveTo";
import { RoleBuffComp } from "./RoleBuffComp"; import { RoleBuffComp } from "./RoleBuffComp";
import { RoleRangComp } from "./RoleRangComp"; import { RoleRangComp } from "./RoleRangComp";
import { Tooltip } from "../skills/Tooltip"; import { Tooltip } from "../skills/Tooltip";
import { MonViewComp } from "../mon/MonViewComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** 角色显示组件 */ /** 角色显示组件 */
@@ -180,8 +181,8 @@ export class RoleViewComp extends CCComp {
} }
power_change(power: number){ power_change(power: number){
this.power += power; this.power += power;
if(this.power >= this.power_max){ if(this.power >= this.power_max&&this.check_enemy_alive()){
// this.as.maxSkill() this.as.atk()
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.do_max_skill(); this.do_max_skill();
},0.5) },0.5)
@@ -191,18 +192,37 @@ export class RoleViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress; this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
} }
shoot(skill_uuid:number){ shoot(skill_uuid:number){
// console.log("monster shoot"); // console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill); let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,50)
let scale = this.scale let scale = this.scale
let speed =smc.skills[skill_uuid].speed; let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis; let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk; let atk = smc.skills[skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
let angle=0 let angle=0
let t_pos:Vec3 = v3(0,0) let t_pos:Vec3 = v3(0,0)
if(this.enemy){ if(this.enemy){
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y) if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-(this.node.position.x+pos.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; angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){ if(this.scale == -1){
angle = angle +180 angle = angle +180
@@ -210,27 +230,23 @@ export class RoleViewComp extends CCComp {
}else{ }else{
t_pos=null t_pos=null
} }
skill.load(this.enemy,pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos); return {pos,t_pos,angle}
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid); }
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
}
return true
}else{
return false
} }
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(this.enemy,pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
} }
in_atk(dt: number) { in_atk(dt: number) {
if(this.atk_time >= this.atk_cd){ if(this.atk_time >= this.atk_cd){
if(this.is_atking){ if(this.is_atking&&this.check_enemy_alive()){
this.atk_time = 0; this.atk_time = 0;
// console.log("atk_cd:",this.as); // console.log("atk_cd:"+this.atk_cd);
this.as.atk(); this.as.atk();
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.shoot(this.skill_uuid); this.shoot(this.skill_uuid);

View File

@@ -72,7 +72,7 @@ export class SingletonModuleComp extends ecs.Comp {
g_time:0, g_time:0,
}, },
role:{ role:{
hp:300, hp:30000,
atk:10, atk:10,
lv:1, lv:1,
exp:0, exp:0,

View File

@@ -36,6 +36,7 @@ export enum BoxSet {
MOVE_RANGE_X = 20, MOVE_RANGE_X = 20,
MAX_SKILL_SY = 50, MAX_SKILL_SY = 50,
MAX_SKILL_BY = 80, MAX_SKILL_BY = 80,
ATK_Y = 20,
} }
export enum GameSet { export enum GameSet {
ATK_TO_ATK_RATIO=0.1, ATK_TO_ATK_RATIO=0.1,

View File

@@ -1,33 +1,33 @@
export const MonSet={ export const MonSet={
1001:{uuid: 1001,path: "ge1",type: 1,level: 1,name: "战斗哥",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1001:{uuid: 1001,path: "ge1",type: 1,level: 1,name: "战斗哥",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1002:{uuid: 1002,path: "ge2",type: 1,level: 1,name: "墨西哥",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1002:{uuid: 1002,path: "ge2",type: 1,level: 1,name: "墨西哥",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1003:{uuid: 1003,path: "ge3",type: 1,level: 1,name: "铁头哥",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1003:{uuid: 1003,path: "ge3",type: 1,level: 1,name: "铁头哥",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1011:{uuid: 1011,path: "orc1",type: 1,level: 1,name: "森林兽人",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1011:{uuid: 1011,path: "orc1",type: 1,level: 1,name: "森林兽人",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1012:{uuid: 1012,path: "orc2",type: 1,level: 1,name: "荒野兽人",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1012:{uuid: 1012,path: "orc2",type: 1,level: 1,name: "荒野兽人",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1013:{uuid: 1013,path: "orc3",type: 1,level: 1,name: "兽人战士",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1013:{uuid: 1013,path: "orc3",type: 1,level: 1,name: "兽人战士",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1021:{uuid: 1021,path: "gou1",type: 1,level: 1,name: "黄皮豺狼",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1021:{uuid: 1021,path: "gou1",type: 1,level: 1,name: "黄皮豺狼",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"},
1022:{uuid: 1022,path: "gou2",type: 1,level: 1,name: "白皮豺狼",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1022:{uuid: 1022,path: "gou2",type: 1,level: 1,name: "白皮豺狼",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"},
1023:{uuid: 1023,path: "gou3",type: 1,level: 1,name: "灰皮豺狼",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1023:{uuid: 1023,path: "gou3",type: 1,level: 1,name: "灰皮豺狼",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"},
1031:{uuid: 1031,path: "gou1",type: 1,level: 1,name: "独眼巨人",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1031:{uuid: 1031,path: "gou1",type: 1,level: 1,name: "独眼巨人",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"},
1032:{uuid: 1032,path: "gou2",type: 1,level: 1,name: "狂暴独眼",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1032:{uuid: 1032,path: "gou2",type: 1,level: 1,name: "狂暴独眼",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"},
1033:{uuid: 1033,path: "gou3",type: 1,level: 1,name: "独眼首领",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30, 1033:{uuid: 1033,path: "gou3",type: 1,level: 1,name: "独眼首领",atk: 4,hp: 30,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"},
1041:{uuid: 1041,path: "ys1",type: 1,level: 1,name: "火元素",atk: 4,hp: 24,atk_dis:400,atk_cd: 2,power: 50,speed: 30, 1041:{uuid: 1041,path: "ys1",type: 1,level: 1,name: "火元素",atk: 4,hp: 30,atk_dis:400,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "gou"},
1042:{uuid: 1042,path: "ys2",type: 1,level: 1,name: "冰元素",atk: 4,hp: 24,atk_dis:400,atk_cd: 2,power: 50,speed: 30, 1042:{uuid: 1042,path: "ys2",type: 1,level: 1,name: "冰元素",atk: 4,hp: 30,atk_dis:400,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "ys"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "ys"},
1043:{uuid: 1043,path: "ys3",type: 1,level: 1,name: "气元素",atk: 4,hp: 24,atk_dis:400,atk_cd: 2,power: 50,speed: 30, 1043:{uuid: 1043,path: "ys3",type: 1,level: 1,name: "气元素",atk: 4,hp: 30,atk_dis:400,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "ys"}, skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "ys"},
} }

View File

@@ -17,5 +17,4 @@ export const HeroSet={
skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: 2}, skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: 2},
} }

View File

@@ -152,7 +152,7 @@ export class HeroViewComp extends CCComp {
this.in_destroy(); this.in_destroy();
this.in_shield(dt); this.in_shield(dt);
this.in_stop(dt); this.in_stop(dt);
this.in_act(dt); this.in_atk(dt);
this.move(dt); this.move(dt);
// if(this.m_timer.update(dt)){ // if(this.m_timer.update(dt)){
// this.move_to() // this.move_to()
@@ -214,7 +214,7 @@ export class HeroViewComp extends CCComp {
} }
power_change(power: number){ power_change(power: number){
this.power += power; this.power += power;
if(this.power >= this.power_max){ if(this.power >= this.power_max&&this.check_enemy_alive()){
this.as.atk() this.as.atk()
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.do_max_skill(); this.do_max_skill();
@@ -225,26 +225,37 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress; this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
} }
shoot(skill_uuid:number){ shoot(skill_uuid:number){
console.log("hero shoot"); // console.log("mon shoot");
console.log(this.enemy)
console.log("hero box",this.enemy.getComponent(MonViewComp))
let skill = ecs.getEntity<Skill>(Skill); let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,50)
let scale = this.scale let scale = this.scale
let speed =smc.skills[skill_uuid].speed; let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis; let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk; let atk = smc.skills[skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
let angle=0 let angle=0
let t_pos:Vec3 = v3(0,0) let t_pos:Vec3 = v3(0,0)
let eid = 0
if(this.enemy){ if(this.enemy){
if(!this.enemy.isValid){ if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid); console.log("move_to",this.enemy.isValid);
return return
} }
eid = this.enemy.getComponent(MonViewComp).ent.eid t_pos = v3(this.enemy.position.x-(this.node.position.x+pos.x),this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI; angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){ if(this.scale == -1){
angle = angle +180 angle = angle +180
@@ -252,31 +263,21 @@ export class HeroViewComp extends CCComp {
}else{ }else{
t_pos=null t_pos=null
} }
return {pos,t_pos,angle}
skill.load(eid,this.enemy,pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
} }
//使用max_skill check_enemy_alive(){
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
let eid = 0
if(this.enemy){ if(this.enemy){
if(this.enemy.isValid){ if(!this.enemy.isValid){
eid = this.enemy.getComponent(MonViewComp).ent.eid return false
}
return true
}else{
return false
} }
} }
skill.load(eid,this.enemy,pos,speed,dis,scale,this.node,this.max_skill_uuid,atk); in_atk(dt: number) {
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid,100);
}
in_act(dt: number) {
if(this.atk_time >= this.atk_cd){ if(this.atk_time >= this.atk_cd){
if(this.is_atking){ if(this.is_atking&&this.check_enemy_alive()){
this.atk_time = 0; this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd); // console.log("atk_cd:"+this.atk_cd);
this.as.atk(); this.as.atk();

View File

@@ -68,8 +68,8 @@ export class Initialize extends ecs.Entity {
} }
// 设置语言包路径 // 设置语言包路径
oops.language.pack.json = oops.config.game.languagePathJson; // oops.language.pack.json = oops.config.game.languagePathJson;
oops.language.pack.texture = oops.config.game.languagePathTexture; // oops.language.pack.texture = oops.config.game.languagePathTexture;
// 加载语言包资源 // 加载语言包资源
oops.language.setLanguage(lan, next); oops.language.setLanguage(lan, next);

View File

@@ -156,8 +156,8 @@ export class MapMonsterComp extends CCComp {
let monster_layer = scene.entityLayer!.node! let monster_layer = scene.entityLayer!.node!
let monster_layer1 = scene.entityLayer1!.node!; let monster_layer1 = scene.entityLayer1!.node!;
let monster_layer2 = scene.entityLayer2!.node!; let monster_layer2 = scene.entityLayer2!.node!;
this.addMonster(m[0],monster_layer,pos2) this.addMonster(m[0],monster_layer,pos)
this.addMonster(m1[0],monster_layer1,pos2) this.addMonster(m1[0],monster_layer1,pos1)
this.addMonster(m2[0],monster_layer2,pos2) this.addMonster(m2[0],monster_layer2,pos2)
this.setp_num -= 1 this.setp_num -= 1
} }

View File

@@ -172,7 +172,7 @@ export class MonViewComp extends CCComp {
this.in_destroy(); this.in_destroy();
this.in_shield(); this.in_shield();
this.in_stop(dt); this.in_stop(dt);
this.in_act(dt); this.in_atk(dt);
this.move(dt); this.move(dt);
// if(this.m_timer.update(dt)){ // if(this.m_timer.update(dt)){
// this.move_to() // this.move_to()
@@ -234,7 +234,7 @@ export class MonViewComp extends CCComp {
} }
power_change(power: number){ power_change(power: number){
this.power += power; this.power += power;
if(this.power >= this.power_max){ if(this.power >= this.power_max&&this.check_enemy_alive()){
this.as.atk() this.as.atk()
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.do_max_skill(); this.do_max_skill();
@@ -247,12 +247,27 @@ export class MonViewComp extends CCComp {
shoot(skill_uuid:number){ shoot(skill_uuid:number){
// console.log("mon shoot"); // console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill); let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,50)
let scale = this.scale let scale = this.scale
let speed =smc.skills[skill_uuid].speed; let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis; let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk; let atk = smc.skills[skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
let angle=0 let angle=0
let t_pos:Vec3 = v3(0,0) let t_pos:Vec3 = v3(0,0)
if(this.enemy){ if(this.enemy){
@@ -260,7 +275,7 @@ export class MonViewComp extends CCComp {
console.log("move_to",this.enemy.isValid); console.log("move_to",this.enemy.isValid);
return return
} }
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y) t_pos = v3(this.enemy.position.x-(this.node.position.x+pos.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; angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){ if(this.scale == -1){
angle = angle +180 angle = angle +180
@@ -268,25 +283,21 @@ export class MonViewComp extends CCComp {
}else{ }else{
t_pos=null t_pos=null
} }
skill.load(this.enemy,pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos); return {pos,t_pos,angle}
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
} }
//使用max_skill check_enemy_alive(){
do_max_skill(){ if(this.enemy){
let skill = ecs.getEntity<Skill>(Skill); if(!this.enemy.isValid){
let x=32 return false
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(this.enemy,pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
} }
in_act(dt: number) { return true
}else{
return false
}
}
in_atk(dt: number) {
if(this.atk_time >= this.atk_cd){ if(this.atk_time >= this.atk_cd){
if(this.is_atking){ if(this.is_atking&&this.check_enemy_alive()){
this.atk_time = 0; this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd); // console.log("atk_cd:"+this.atk_cd);
this.as.atk(); this.as.atk();

View File

@@ -60,16 +60,10 @@ export class CSkillComp extends CCComp {
let t_pos = v3(0,0) let t_pos = v3(0,0)
let angle = 0 let angle = 0
let m_pos=v3(0,0) let m_pos=v3(0,0)
let target:any = null
let eid=0
let monsters:any = ecs.query(ecs.allOf(MonModelComp)); let monsters:any = ecs.query(ecs.allOf(MonModelComp));
if (monsters.length > 0) { if (monsters.length > 0) {
m_pos = monsters[0].MonView.node.position m_pos = monsters[0].MonView.node.position
target= monsters[0].MonView.node
eid = monsters[0].MonView.eid
}else{ }else{
return
m_pos = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE) m_pos = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
} }
t_pos = v3(m_pos.x-this.node.position.x,m_pos.y-this.node.position.y) // 目标增量 t_pos = v3(m_pos.x-this.node.position.x,m_pos.y-this.node.position.y) // 目标增量
@@ -82,7 +76,7 @@ export class CSkillComp extends CCComp {
let dis = smc.skills[this.skill_uuid].dis+this.dis; let dis = smc.skills[this.skill_uuid].dis+this.dis;
let atk = smc.skills[this.skill_uuid].atk+this.atk; let atk = smc.skills[this.skill_uuid].atk+this.atk;
let speed = smc.skills[this.skill_uuid].speed+this.speed; let speed = smc.skills[this.skill_uuid].speed+this.speed;
skill.load(eid,target,pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos); skill.load(pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos);
} }
add_buff(){ add_buff(){
// 1 远距离攻击,碰撞后 结束 // 1 远距离攻击,碰撞后 结束

View File

@@ -29,7 +29,7 @@ export class Skill extends ecs.Entity {
this.remove(SkillCom); this.remove(SkillCom);
super.destroy(); super.destroy();
} }
load(target_eid:number,target:any,pos: Vec3 = Vec3.ZERO,speed:number = 100, load(pos: Vec3 = Vec3.ZERO,speed:number = 100,
dis:number = 50,scale:number = 1,parent:Node, dis:number = 50,scale:number = 1,parent:Node,
uuid:number=1001,atk:number =10,angle = 0, uuid:number=1001,atk:number =10,angle = 0,
t_pos:Vec3 = null,run_type:number=0,) t_pos:Vec3 = null,run_type:number=0,)
@@ -53,8 +53,6 @@ export class Skill extends ecs.Entity {
sv.type = smc.skills[uuid].type; sv.type = smc.skills[uuid].type;
sv.box_tag= BoxSet.SKILL_TAG; sv.box_tag= BoxSet.SKILL_TAG;
sv.run_type== run_type; sv.run_type== run_type;
sv.target=target;
sv.target_eid=target_eid
if(scale == 1){ if(scale == 1){
sv.box_group=BoxSet.HERO sv.box_group=BoxSet.HERO
}else{ }else{

View File

@@ -28,8 +28,6 @@ export class SkillCom extends CCComp {
atk_count:number = 0; atk_count:number = 0;
angle:number = 0; angle:number = 0;
t_pos:Vec3 = null; // 目标增量 t_pos:Vec3 = null; // 目标增量
target:any =null
target_eid:number = 0;
is_destroy:boolean = false; is_destroy:boolean = false;
box_group:number = 0; box_group:number = 0;
box_tag:number=0; box_tag:number=0;
@@ -53,63 +51,63 @@ export class SkillCom extends CCComp {
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this); // collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this); collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
} }
// if(this.t_pos){ if(this.t_pos){
// this.x_speed=Math.cos(this.angle * Math.PI / 180) * this.speed-30*this.scale; this.x_speed=Math.cos(this.angle * Math.PI / 180) * this.speed-30*this.scale;
// this.y_speed=Math.sin(this.angle * Math.PI / 180) * this.speed; this.y_speed=Math.sin(this.angle * Math.PI / 180) * this.speed;
// }else{ }else{
// this.x_speed=this.speed this.x_speed=this.speed
// this.y_speed=0 this.y_speed=0
// } }
// if(this.run_type == 1){ if(this.run_type == 1){
// let s_pos = v3(this.node.position.x,this.node.position.y) let s_pos = v3(this.node.position.x,this.node.position.y)
// let c_pos = v3(this.node.position.x,this.node.position.y) let c_pos = v3(this.node.position.x,this.node.position.y)
// let e_pos = v3(this.node.position.x+this.dis*this.scale,BoxSet.GAME_LINE-50) let e_pos = v3(this.node.position.x+this.dis*this.scale,BoxSet.GAME_LINE-50)
// SkillCom.bezierTo(this.node,2,s_pos,c_pos,e_pos,{onUpdate: (target: Vec3, ratio: number) => { SkillCom.bezierTo(this.node,2,s_pos,c_pos,e_pos,{onUpdate: (target: Vec3, ratio: number) => {
// } }
// }).start(); }).start();
// } }
// if(this.run_type == 2){ if(this.run_type == 2){
// tween(this.node).to( this.in_time, tween(this.node).to( this.in_time,
// { position: new Vec3(this.node.position.x,this.node.position.y) }, { position: new Vec3(this.node.position.x,this.node.position.y) },
// { {
// onComplete: (target?: object) => { onComplete: (target?: object) => {
// this.is_destroy=true this.is_destroy=true
// }, },
// } }
// ).start(); ).start();
// } }
// if(this.run_type == 0){ if(this.run_type == 0){
// if(this.t_pos){ if(this.t_pos){
// let l_x=Math.cos(this.angle * Math.PI / 180) * 50; let l_x=Math.cos(this.angle * Math.PI / 180) * 50;
// let l_y=Math.sin(this.angle * Math.PI / 180) * 50; let l_y=Math.sin(this.angle * Math.PI / 180) * 50;
// let squaredDistance = this.t_pos.x * this.t_pos.x + this.t_pos.y * this.t_pos.y; let squaredDistance = this.t_pos.x * this.t_pos.x + this.t_pos.y * this.t_pos.y;
// let distance = Math.sqrt(squaredDistance); let distance = Math.sqrt(squaredDistance);
// let time = distance / this.speed-0.2; let time = distance / this.speed-0.2;
// //通过欧拉角 延长 目标点 增量 //通过欧拉角 延长 目标点 增量
// // this.t_pos.x=Math.cos(this.angle * Math.PI / 180) * this.dis; // this.t_pos.x=Math.cos(this.angle * Math.PI / 180) * this.dis;
// // this.t_pos.y=Math.sin(this.angle * Math.PI / 180) * this.dis; // this.t_pos.y=Math.sin(this.angle * Math.PI / 180) * this.dis;
// let e_pos=v3(this.node.position.x+l_x+this.t_pos.x,this.node.position.y+this.t_pos.y) let e_pos=v3(this.node.position.x+l_x+this.t_pos.x,this.node.position.y+this.t_pos.y)
// tween(this.node).to( 0.7,{ angle:this.angle,position: e_pos}, tween(this.node).to( 0.7,{ angle:this.angle,position: e_pos},
// { {
// onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度 onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
// // 将缓动系统计算出的结果赋予 node 的位置 // 将缓动系统计算出的结果赋予 node 的位置
// }, },
// onComplete: (target?: object) => { onComplete: (target?: object) => {
// this.is_destroy=true this.is_destroy=true
// }, },
// } }
// ).start(); ).start();
// }else{ }else{
// tween(this.node).to( this.dis/this.speed, tween(this.node).to( this.dis/this.speed,
// { position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) }, { position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) },
// { {
// onComplete: (target?: object) => { onComplete: (target?: object) => {
// this.is_destroy=true this.is_destroy=true
// }, },
// } }
// ).start(); ).start();
// } }
// } }
} }
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) { onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
@@ -152,50 +150,12 @@ export class SkillCom extends CCComp {
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z)) // this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
// this.move(deltaTime) // this.move(deltaTime)
this.toDestroy() this.toDestroy()
let enemy_is_alive=false
if(this.box_group==BoxSet.HERO){
let mons =ecs.query(ecs.allOf(MonModelComp));
for(let i=0;i<mons.length;i++){
if(mons[i].eid == this.target_eid){
enemy_is_alive=true
}
}
}
if(this.box_group==BoxSet.MONSTER){
let heros =ecs.query(ecs.allOf(HeroViewComp));
for(let i=0;i<heros.length;i++){
if(heros[i].eid == this.target_eid){
enemy_is_alive=true
}
}
}
if(enemy_is_alive){
this.move_to(this.target)
}else{
this.ent.destroy()
}
// this.t_move(deltaTime) // this.t_move(deltaTime)
if (this.node.position.x > 400||this.node.position.x < -400||this.node.position.y > 1000||this.node.position.y < -100) { if (this.node.position.x > 400||this.node.position.x < -400||this.node.position.y > 1000||this.node.position.y < -100) {
this.is_destroy=true this.is_destroy=true
} }
} }
move_to(target:any){
if(target.x > this.node.position.x){
this.node.setScale(v3(1,1,1))
}else{
this.node.setScale(v3(-1,1,1))
}
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(target.x,target.y);
move.node = this.node;
move.speed = this.speed;
}
t_move(dt: number){ t_move(dt: number){
if( this.run_type!=0){ if( this.run_type!=0){
return return