mon 和hero 统一
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
export const MissionNum = [1]
|
export const MissionNum = [1]
|
||||||
export const MonsetList = {
|
export const MonsetList = {
|
||||||
1:{
|
1:{
|
||||||
1:[1031,1032,1033,1011,1012,1013],
|
1:[9001,9011,9031,9021],
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,38 @@ export const HeroSet = {
|
|||||||
uuid: 9009, path: "arc1", type: 2, level: 1,cost:2, name: "弓箭手", atk: 15, hp: 50, atk_dis: 200, atk_cd: 1.5, power: 0, power_max: 20, speed: 30,
|
uuid: 9009, path: "arc1", type: 2, level: 1,cost:2, name: "弓箭手", atk: 15, hp: 50, atk_dis: 200, atk_cd: 1.5, power: 0, power_max: 20, speed: 30,
|
||||||
skill_uuid: 9003, max_skill_uuid: 1003, atktype: 2
|
skill_uuid: 9003, max_skill_uuid: 1003, atktype: 2
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
1011: {
|
||||||
|
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, atktype: 1
|
||||||
|
},
|
||||||
|
1012: {
|
||||||
|
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, atktype: 1
|
||||||
|
},
|
||||||
|
1013: {
|
||||||
|
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, atktype: 1
|
||||||
|
},
|
||||||
|
|
||||||
|
1031: {
|
||||||
|
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, atktype: 1
|
||||||
|
},
|
||||||
|
1032: {
|
||||||
|
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, atktype: 1
|
||||||
|
},
|
||||||
|
1033: {
|
||||||
|
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, atktype: 1
|
||||||
|
},
|
||||||
|
5001: {
|
||||||
|
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, atktype: 1
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MonSet = {
|
export const MonSet = {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { HeroSet,MonSet } from "../common/config/heroSet";
|
|||||||
import { Role } from "../Role/Role";
|
import { Role } from "../Role/Role";
|
||||||
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
||||||
import { Talents } from "../common/config/TalentSet";
|
import { Talents } from "../common/config/TalentSet";
|
||||||
|
import { MonModelComp } from "../mon/MonModelComp";
|
||||||
/** 角色实体 */
|
/** 角色实体 */
|
||||||
@ecs.register(`Hero`)
|
@ecs.register(`Hero`)
|
||||||
export class Hero extends ecs.Entity {
|
export class Hero extends ecs.Entity {
|
||||||
@@ -30,7 +31,7 @@ export class Hero extends ecs.Entity {
|
|||||||
|
|
||||||
|
|
||||||
protected init() {
|
protected init() {
|
||||||
this.addComponents<ecs.Comp>( HeroModelComp);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +42,19 @@ export class Hero extends ecs.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 加载角色 */
|
/** 加载角色 */
|
||||||
load(pos: Vec3 = Vec3.ZERO,scale:number = -1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!,index:number=-1) {
|
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!,index:number=-1,is_hero:boolean=true) {
|
||||||
|
let box_group= 0
|
||||||
|
|
||||||
|
if (is_hero) {
|
||||||
|
scale = 1
|
||||||
|
box_group=BoxSet.HERO
|
||||||
|
this.addComponents<ecs.Comp>( HeroModelComp);
|
||||||
|
}else{
|
||||||
|
scale=-1
|
||||||
|
box_group=BoxSet.MONSTER
|
||||||
|
this.addComponents<ecs.Comp>( MonModelComp);
|
||||||
|
}
|
||||||
|
|
||||||
var path = "game/hero/"+smc.heros[uuid].path;
|
var path = "game/hero/"+smc.heros[uuid].path;
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||||
var node = instantiate(prefab);
|
var node = instantiate(prefab);
|
||||||
@@ -52,17 +65,18 @@ export class Hero extends ecs.Entity {
|
|||||||
// pos.x=smc.Role.RoleView.node.position.x+pos.x;
|
// pos.x=smc.Role.RoleView.node.position.x+pos.x;
|
||||||
// pos.y=smc.Role.RoleView.node.position.y+pos.y;
|
// pos.y=smc.Role.RoleView.node.position.y+pos.y;
|
||||||
node.setPosition(pos)
|
node.setPosition(pos)
|
||||||
this.hero_init(uuid,node,index)
|
this.hero_init(uuid,node,index,scale,box_group)
|
||||||
oops.message.dispatchEvent("hero_load",this)
|
oops.message.dispatchEvent("hero_load",this)
|
||||||
}
|
}
|
||||||
|
|
||||||
hero_init(uuid:number=1001,node:Node,index:number=-1){
|
hero_init(uuid:number=1001,node:Node,index:number=-1,scale:number=1,box_group=BoxSet.HERO){
|
||||||
var hv = node.getComponent(HeroViewComp)!;
|
var hv = node.getComponent(HeroViewComp)!;
|
||||||
// console.log("hero_init",buff)
|
// console.log("hero_init",buff)
|
||||||
let hero_set= smc.heros[uuid]
|
let hero_set= smc.heros[uuid]
|
||||||
let role_talent= smc.vm_data.talent
|
let role_talent= smc.vm_data.talent
|
||||||
let talents=Talents;
|
let talents=Talents;
|
||||||
hv.scale = 1;
|
hv.scale = scale;
|
||||||
|
hv.box_group = box_group;
|
||||||
hv.speed =hv.ospeed = hero_set.speed;
|
hv.speed =hv.ospeed = hero_set.speed;
|
||||||
hv.hero_uuid= uuid;
|
hv.hero_uuid= uuid;
|
||||||
hv.hero_name= hero_set.name;
|
hv.hero_name= hero_set.name;
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.as.move()
|
this.as.move()
|
||||||
this.node.getChildByName("top").getChildByName("hp").active = false;
|
this.node.getChildByName("top").getChildByName("hp").active = false;
|
||||||
this.sprite = this.node.getChildByName("anm").getComponent(Sprite);
|
this.sprite = this.node.getChildByName("anm").getComponent(Sprite);
|
||||||
|
this.node.setScale(this.scale,1);
|
||||||
// this.node.getChildByName("top").getChildByName("shield").active = false;
|
// this.node.getChildByName("top").getChildByName("shield").active = false;
|
||||||
// this.node.getChildByName("top").setScale(this.scale,1);
|
// this.node.getChildByName("top").setScale(this.scale,1);
|
||||||
// this.node.getChildByName("atk").setScale(this.scale,1);
|
// this.node.getChildByName("atk").setScale(this.scale,1);
|
||||||
@@ -124,6 +125,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 注册单个碰撞体的回调函数
|
// 注册单个碰撞体的回调函数
|
||||||
let collider = this.getComponent(Collider2D);
|
let collider = this.getComponent(Collider2D);
|
||||||
collider.group = this.box_group;
|
collider.group = this.box_group;
|
||||||
|
console.log("hero collider ",this.scale,collider);
|
||||||
if (collider) {
|
if (collider) {
|
||||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||||
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
||||||
@@ -154,22 +156,22 @@ export class HeroViewComp extends CCComp {
|
|||||||
|
|
||||||
}
|
}
|
||||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||||
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
// if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
||||||
if(otherCollider.node.name=="role") return
|
// if(otherCollider.node.name=="role") return
|
||||||
let self_x = selfCollider.node.position.x;
|
// let self_x = selfCollider.node.position.x;
|
||||||
let other_x = otherCollider.node.position.x;
|
// let other_x = otherCollider.node.position.x;
|
||||||
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 15 ){
|
// if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 15 ){
|
||||||
this.stop_cd = 0.1;
|
// this.stop_cd = 0.1;
|
||||||
}
|
// }
|
||||||
// if(selfCollider.node.position.y < otherCollider.node.position.y){
|
// // if(selfCollider.node.position.y < otherCollider.node.position.y){
|
||||||
// if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
|
// // if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
|
||||||
|
|
||||||
// selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
// // selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
||||||
// // console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
// // // console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// }
|
// // }
|
||||||
}
|
// }
|
||||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
||||||
this.stop_cd = 0.1;
|
this.stop_cd = 0.1;
|
||||||
this.is_atking=true
|
this.is_atking=true
|
||||||
@@ -230,7 +232,10 @@ export class HeroViewComp extends CCComp {
|
|||||||
if(this.stop_cd > 0){
|
if(this.stop_cd > 0){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.node.position.x >= 250-this.atk_dis/2) {
|
if (this.node.position.x >= 360 && this.scale==1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(this.scale===-1&&this.node.position.x <= -360){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if(this.enemy){
|
// if(this.enemy){
|
||||||
@@ -301,14 +306,14 @@ export class HeroViewComp extends CCComp {
|
|||||||
|
|
||||||
pos.y=pos.y + y
|
pos.y=pos.y + y
|
||||||
pos.x=pos.x + x
|
pos.x=pos.x + x
|
||||||
skill.load(pos,BoxSet.HERO,this.node,skill_uuid,atk,t_pos);
|
skill.load(pos,this.box_group,this.node,skill_uuid,atk,t_pos);
|
||||||
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
|
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
|
||||||
}
|
}
|
||||||
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.atk;
|
let atk = smc.skills[s_uuid].atk+this.atk;
|
||||||
let {pos,t_pos}=this.get_hero_pos(hero)
|
let {pos,t_pos}=this.get_hero_pos(hero)
|
||||||
skill.load(pos,BoxSet.HERO,this.node,this.max_skill_uuid,atk,t_pos);
|
skill.load(pos,this.box_group,this.node,this.max_skill_uuid,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.atk*this.s_boncus*smc.vm_data.mission.hero.atk)
|
let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.atk*this.s_boncus*smc.vm_data.mission.hero.atk)
|
||||||
hero.add_hp(increase_hp)
|
hero.add_hp(increase_hp)
|
||||||
|
|||||||
@@ -171,11 +171,6 @@ export class MapMonsterComp extends CCComp {
|
|||||||
console.log("do_reward")
|
console.log("do_reward")
|
||||||
oops.message.dispatchEvent("do_reward");
|
oops.message.dispatchEvent("do_reward");
|
||||||
}
|
}
|
||||||
private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) {
|
|
||||||
let monster = ecs.getEntity<Mon>(Mon);
|
|
||||||
let scale = -1
|
|
||||||
monster.load(pos,scale,uuid,layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private on_other_add_monster(event: string, args: any) {
|
private on_other_add_monster(event: string, args: any) {
|
||||||
var scene = smc.map.MapView.scene;
|
var scene = smc.map.MapView.scene;
|
||||||
@@ -262,6 +257,12 @@ export class MapMonsterComp extends CCComp {
|
|||||||
hero.load(pos,scale,uuid,monster_layer);
|
hero.load(pos,scale,uuid,monster_layer);
|
||||||
this.set_start_point()
|
this.set_start_point()
|
||||||
}
|
}
|
||||||
|
private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) {
|
||||||
|
let monster = ecs.getEntity<Hero>(Hero);
|
||||||
|
let scale = -1
|
||||||
|
let index = -1
|
||||||
|
monster.load(pos,scale,uuid,layer,index,false);
|
||||||
|
}
|
||||||
|
|
||||||
load_boss(){
|
load_boss(){
|
||||||
let bs:any = RandomManager.instance.getRandomByObjectList(this.boss_list[this.monster_level],1)
|
let bs:any = RandomManager.instance.getRandomByObjectList(this.boss_list[this.monster_level],1)
|
||||||
|
|||||||
Reference in New Issue
Block a user