逐步 去掉 主英雄设定
This commit is contained in:
@@ -2,7 +2,7 @@ import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/mod
|
|||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { Initialize } from "../initialize/Initialize";
|
import { Initialize } from "../initialize/Initialize";
|
||||||
import { GameMap } from "../map/GameMap";
|
import { GameMap } from "../map/GameMap";
|
||||||
import { MissionData, VmInfo } from "./config/Mission";
|
import { HeroUI, MissionData, VmInfo } from "./config/Mission";
|
||||||
|
|
||||||
|
|
||||||
// import { Role } from "../role/Role";
|
// import { Role } from "../role/Role";
|
||||||
@@ -37,21 +37,20 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
vmdata: any = {
|
vmdata: any = {
|
||||||
game_over:false,
|
game_over:false,
|
||||||
game_pause:false,
|
game_pause:false,
|
||||||
mission_data:{
|
mission_data:{ },
|
||||||
|
hero:{ },
|
||||||
},
|
hero1:{},
|
||||||
hero:{
|
hero2:{},
|
||||||
|
hero3:{},
|
||||||
},
|
boss:{ },
|
||||||
|
|
||||||
boss:{
|
|
||||||
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
vmAdd() {
|
vmAdd() {
|
||||||
this.vmdata.mission_data=JSON.parse(JSON.stringify(MissionData))
|
this.vmdata.mission_data=JSON.parse(JSON.stringify(MissionData))
|
||||||
this.vmdata.hero=JSON.parse(JSON.stringify(VmInfo))
|
this.vmdata.hero=JSON.parse(JSON.stringify(VmInfo))
|
||||||
this.vmdata.boss=JSON.parse(JSON.stringify(VmInfo))
|
this.vmdata.boss=JSON.parse(JSON.stringify(VmInfo))
|
||||||
|
this.vmdata.hero1=JSON.parse(JSON.stringify(HeroUI))
|
||||||
|
this.vmdata.hero2=JSON.parse(JSON.stringify(HeroUI))
|
||||||
|
this.vmdata.hero3=JSON.parse(JSON.stringify(HeroUI))
|
||||||
VM.add(this.vmdata, "data");
|
VM.add(this.vmdata, "data");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,15 @@ export const MissionData = {
|
|||||||
skill_stone_max:10,//技能石最大数量
|
skill_stone_max:10,//技能石最大数量
|
||||||
refresh_count:5,//刷新次
|
refresh_count:5,//刷新次
|
||||||
}
|
}
|
||||||
|
export const HeroUI = {
|
||||||
|
uuid:0,
|
||||||
|
name:"",
|
||||||
|
count:0,
|
||||||
|
hp:0,
|
||||||
|
hp_max:0,
|
||||||
|
cd:0,
|
||||||
|
cd_max:0,
|
||||||
|
}
|
||||||
export const VmInfo = {
|
export const VmInfo = {
|
||||||
hp:0,
|
hp:0,
|
||||||
hp_max:0,
|
hp_max:0,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class Hero extends ecs.Entity {
|
|||||||
HeroModel!: HeroModelComp;
|
HeroModel!: HeroModelComp;
|
||||||
HeroView!: HeroViewComp;
|
HeroView!: HeroViewComp;
|
||||||
BattleMove!: BattleMoveComp;
|
BattleMove!: BattleMoveComp;
|
||||||
|
vmHero:any={}
|
||||||
protected init() {
|
protected init() {
|
||||||
this.addComponents<ecs.Comp>(
|
this.addComponents<ecs.Comp>(
|
||||||
BattleMoveComp,
|
BattleMoveComp,
|
||||||
@@ -38,29 +38,26 @@ export class Hero extends ecs.Entity {
|
|||||||
}
|
}
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
hart_load(uuid:number=5004) {
|
|
||||||
console.log("主体加载")
|
|
||||||
var path = "game/heros/"+HeroInfo[uuid].path;
|
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
var node = instantiate(prefab);
|
|
||||||
var scene = smc.map.MapView.scene;
|
|
||||||
node.parent = scene.entityLayer!.node!
|
|
||||||
let pos=HeroPos[0].pos
|
|
||||||
// if(HeroInfo[uuid].type==HType.warrior) pos=HeroPos[1].pos
|
|
||||||
node.setPosition(pos)
|
|
||||||
var hv = this.hero_init(uuid,node)
|
|
||||||
hv.scale = 1;
|
|
||||||
hv.is_master=true;
|
|
||||||
hv.lv=1
|
|
||||||
this.add(hv);
|
|
||||||
this.addComponents<ecs.Comp>(MasterModelComp)
|
|
||||||
oops.message.dispatchEvent(GameEvent.MasterCalled,{uuid:uuid})
|
|
||||||
|
|
||||||
}
|
|
||||||
/** 加载角色 */
|
/** 加载角色 */
|
||||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false},fight_pos:number=1) {
|
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false},fight_pos:number=1) {
|
||||||
// console.log("英雄加载:",uuid,pos,scale,info)
|
// console.log("英雄加载:",uuid,pos,scale,info)
|
||||||
scale = 1
|
scale = 1
|
||||||
|
if(smc.vmdata.hero1.uuid==0){
|
||||||
|
this.vmHero=smc.vmdata.hero1
|
||||||
|
|
||||||
|
}else if(smc.vmdata.hero2.uuid==0){
|
||||||
|
this.vmHero=smc.vmdata.hero2
|
||||||
|
|
||||||
|
}else if(smc.vmdata.hero3.uuid==0){
|
||||||
|
this.vmHero=smc.vmdata.hero3
|
||||||
|
|
||||||
|
}else{
|
||||||
|
console.log("[Hero] 英雄已满")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.vmHero.uuid=uuid
|
||||||
|
this.vmHero.count=1
|
||||||
var path = "game/heros/"+HeroInfo[uuid].path;
|
var path = "game/heros/"+HeroInfo[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);
|
||||||
@@ -69,18 +66,21 @@ export class Hero extends ecs.Entity {
|
|||||||
node.setPosition(pos)
|
node.setPosition(pos)
|
||||||
// console.log("hero load",pos)
|
// console.log("hero load",pos)
|
||||||
var hv = this.hero_init(uuid,node,info)
|
var hv = this.hero_init(uuid,node,info)
|
||||||
hv.fight_pos=fight_pos
|
|
||||||
hv.is_friend=true
|
|
||||||
this.add(hv);
|
this.add(hv);
|
||||||
this.addComponents<ecs.Comp>(FriendModelComp);
|
this.addComponents<ecs.Comp>(MasterModelComp)
|
||||||
// const move = this.get(BattleMoveComp);
|
oops.message.dispatchEvent(GameEvent.MasterCalled,{uuid:uuid})
|
||||||
// move.direction = 1; // 向右移动
|
const move = this.get(BattleMoveComp);
|
||||||
// move.targetX = 800; // 右边界'
|
move.direction = 1; // 向右移动
|
||||||
|
move.targetX = 800; // 右边界'
|
||||||
}
|
}
|
||||||
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false}) {
|
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false}) {
|
||||||
var hv = node.getComponent(HeroViewComp)!;
|
var hv = node.getComponent(HeroViewComp)!;
|
||||||
let hero= HeroInfo[uuid] // 共用英雄数据
|
let hero= HeroInfo[uuid] // 共用英雄数据
|
||||||
|
hv.vmHero=this.vmHero
|
||||||
|
this.vmHero.name=hero.name
|
||||||
hv.scale = 1;
|
hv.scale = 1;
|
||||||
|
hv.is_master=true;
|
||||||
|
hv.lv=1
|
||||||
hv.lv=info.lv
|
hv.lv=info.lv
|
||||||
hv.fac = FacSet.HERO;
|
hv.fac = FacSet.HERO;
|
||||||
hv.type = hero.type;
|
hv.type = hero.type;
|
||||||
@@ -89,8 +89,8 @@ export class Hero extends ecs.Entity {
|
|||||||
hv.hero_name= hero.name;
|
hv.hero_name= hero.name;
|
||||||
hv.speed =hv.ospeed = hero.speed;
|
hv.speed =hv.ospeed = hero.speed;
|
||||||
hv.dis = hero.dis;
|
hv.dis = hero.dis;
|
||||||
hv.cd = hv.cd_base = hero.cd
|
this.vmHero.cd_max=hv.cd = hv.cd_base = hero.cd
|
||||||
hv.hp= hv.hp_max = hv.hp_base=hero.hp+info.hp
|
this.vmHero.hp=this.vmHero.hp_max= hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
|
||||||
hv.ap = hv.ap_base=hero.ap+info.ap;
|
hv.ap = hv.ap_base=hero.ap+info.ap;
|
||||||
hero.buff.forEach((buff:any)=>{
|
hero.buff.forEach((buff:any)=>{
|
||||||
switch(buff.buff_type){
|
switch(buff.buff_type){
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
||||||
fac:number=0; //阵营 0:hero 1:monster
|
fac:number=0; //阵营 0:hero 1:monster
|
||||||
|
|
||||||
|
vmHero:any={}
|
||||||
|
|
||||||
box_group:number = BoxSet.HERO;
|
box_group:number = BoxSet.HERO;
|
||||||
|
|
||||||
is_dead:boolean = false; //是否摧毁
|
is_dead:boolean = false; //是否摧毁
|
||||||
@@ -152,7 +154,6 @@ export class HeroViewComp extends CCComp {
|
|||||||
onLoad() {
|
onLoad() {
|
||||||
this.as = this.getComponent(HeroSpine);
|
this.as = this.getComponent(HeroSpine);
|
||||||
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
|
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
|
||||||
this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_atk,this)
|
|
||||||
this.on(GameEvent.EXPUP,this.exp_up,this)
|
this.on(GameEvent.EXPUP,this.exp_up,this)
|
||||||
const collider = this.node.getComponent(BoxCollider2D);
|
const collider = this.node.getComponent(BoxCollider2D);
|
||||||
this.scheduleOnce(()=>{
|
this.scheduleOnce(()=>{
|
||||||
@@ -165,7 +166,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
start () {
|
start () {
|
||||||
this.as.idle()
|
this.as.idle()
|
||||||
this.BUFFCOMP=this.node.getComponent(BuffComp);
|
this.BUFFCOMP=this.node.getComponent(BuffComp);
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
/** 方向 */
|
/** 方向 */
|
||||||
this.node.setScale(this.scale,1);
|
this.node.setScale(this.scale,1);
|
||||||
this.node.getChildByName("top").setScale(this.scale,1);
|
this.node.getChildByName("top").setScale(this.scale,1);
|
||||||
@@ -201,10 +202,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.processDamageQueue();
|
this.processDamageQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
change_atk(e:GameEvent,data:any){
|
|
||||||
if(!this.is_master) return
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
get isActive() {
|
get isActive() {
|
||||||
return this.ent.has(HeroViewComp) && this.node?.isValid;
|
return this.ent.has(HeroViewComp) && this.node?.isValid;
|
||||||
@@ -236,70 +234,70 @@ export class HeroViewComp extends CCComp {
|
|||||||
change_wfuny(wfuny: number){
|
change_wfuny(wfuny: number){
|
||||||
this.wfuny+=wfuny
|
this.wfuny+=wfuny
|
||||||
if(this.wfuny<0) this.wfuny=0
|
if(this.wfuny<0) this.wfuny=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
change_puncture(puncture: number){
|
change_puncture(puncture: number){
|
||||||
this.puncture+=puncture
|
this.puncture+=puncture
|
||||||
if(this.puncture<1) this.puncture=1
|
if(this.puncture<1) this.puncture=1
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
change_puncture_damage(puncture_damage: number){
|
change_puncture_damage(puncture_damage: number){
|
||||||
this.puncture_damage+=puncture_damage
|
this.puncture_damage+=puncture_damage
|
||||||
if(this.puncture_damage<0) this.puncture_damage=0
|
if(this.puncture_damage<0) this.puncture_damage=0
|
||||||
if(this.puncture_damage>80) this.puncture_damage=80
|
if(this.puncture_damage>80) this.puncture_damage=80
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
change_dodge(dodge: number){
|
change_dodge(dodge: number){
|
||||||
this.dod+=dodge
|
this.dod+=dodge
|
||||||
if(this.dod<0) this.dod=0
|
if(this.dod<0) this.dod=0
|
||||||
if(this.dod>90) this.dod=90
|
if(this.dod>90) this.dod=90
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
change_frost_ratto(frost_ratto: number){
|
change_frost_ratto(frost_ratto: number){
|
||||||
this.frost_ratto+=frost_ratto
|
this.frost_ratto+=frost_ratto
|
||||||
if(this.frost_ratto<0) this.frost_ratto=0
|
if(this.frost_ratto<0) this.frost_ratto=0
|
||||||
if(this.frost_ratto>90) this.frost_ratto=90
|
if(this.frost_ratto>90) this.frost_ratto=90
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
|
|
||||||
change_knockback(knockback: number){
|
change_knockback(knockback: number){
|
||||||
this.knockback+=knockback
|
this.knockback+=knockback
|
||||||
if(this.knockback<0) this.knockback=0
|
if(this.knockback<0) this.knockback=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
|
|
||||||
change_stun_ratto(stun_ratto: number){
|
change_stun_ratto(stun_ratto: number){
|
||||||
this.stun_ratto+=stun_ratto
|
this.stun_ratto+=stun_ratto
|
||||||
if(this.stun_ratto<0) this.stun_ratto=0
|
if(this.stun_ratto<0) this.stun_ratto=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
|
|
||||||
change_def(def: number){
|
change_def(def: number){
|
||||||
this.def+=def
|
this.def+=def
|
||||||
if(this.def>90) this.def=90
|
if(this.def>90) this.def=90
|
||||||
if(this.def<0) this.def=0
|
if(this.def<0) this.def=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
// this.BUFFCOMP.tooltip(TooltipTypes.defup,def.toFixed(0));
|
// this.BUFFCOMP.tooltip(TooltipTypes.defup,def.toFixed(0));
|
||||||
}
|
}
|
||||||
change_crit(crit: number){
|
change_crit(crit: number){
|
||||||
this.crit+=crit
|
this.crit+=crit
|
||||||
if(this.crit<0) this.crit=0
|
if(this.crit<0) this.crit=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
change_crit_d(crit_d: number){
|
change_crit_d(crit_d: number){
|
||||||
this.crit_d+=crit_d
|
this.crit_d+=crit_d
|
||||||
if(this.crit_d<0) this.crit_d=0
|
if(this.crit_d<0) this.crit_d=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
change_reflect(reflect: number){
|
change_reflect(reflect: number){
|
||||||
this.reflect+=reflect
|
this.reflect+=reflect
|
||||||
if(this.reflect<0) this.reflect=0
|
if(this.reflect<0) this.reflect=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
change_lifesteal(lifesteal: number){
|
change_lifesteal(lifesteal: number){
|
||||||
this.lifesteal+=lifesteal
|
this.lifesteal+=lifesteal
|
||||||
if(this.lifesteal<0) this.lifesteal=0
|
if(this.lifesteal<0) this.lifesteal=0
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
}
|
}
|
||||||
|
|
||||||
check_atrr(buff:BuffAttr){
|
check_atrr(buff:BuffAttr){
|
||||||
@@ -318,20 +316,19 @@ export class HeroViewComp extends CCComp {
|
|||||||
switch(buff){
|
switch(buff){
|
||||||
case BuffAttr.ATK:
|
case BuffAttr.ATK:
|
||||||
this.ap=this.check_atrr(BuffAttr.ATK)
|
this.ap=this.check_atrr(BuffAttr.ATK)
|
||||||
if(this.is_master) {
|
// if(this.is_master) {
|
||||||
this.BUFFCOMP.vmdata_update();
|
// // this.BUFFCOMP.vmdata_update();
|
||||||
oops.message.dispatchEvent(GameEvent.APChange,{is_master:this.is_master,fac:this.fac})
|
// }
|
||||||
}
|
|
||||||
break
|
break
|
||||||
case BuffAttr.ATK_CD:
|
case BuffAttr.ATK_CD:
|
||||||
this.cd=this.check_atrr(BuffAttr.ATK_CD)
|
this.cd=this.check_atrr(BuffAttr.ATK_CD)
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
// if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
break
|
break
|
||||||
case BuffAttr.HP:
|
case BuffAttr.HP:
|
||||||
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
|
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
|
||||||
this.hp_max=this.check_atrr(BuffAttr.HP)
|
this.hp_max=this.check_atrr(BuffAttr.HP)
|
||||||
this.hp+=diff
|
this.hp+=diff
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,7 +376,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
|
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
|
||||||
this.hp_base -= Math.floor(hp) ;
|
this.hp_base -= Math.floor(hp) ;
|
||||||
this.count_atrr(BuffAttr.HP)
|
this.count_atrr(BuffAttr.HP)
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
add_hp(hp: number = 0,is_num:boolean=true) {
|
add_hp(hp: number = 0,is_num:boolean=true) {
|
||||||
@@ -404,7 +401,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.hp+=real_hp;
|
this.hp+=real_hp;
|
||||||
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
|
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
|
||||||
}
|
}
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -418,24 +415,9 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count_atk_count(){ //主将攻击次数 主要有装备加成,需要单独处理
|
count_atk_count(){ //主将攻击
|
||||||
if(!this.is_master) return
|
if(this.fac==FacSet.MON) return
|
||||||
this.atk_count+=1
|
this.atk_count+=1
|
||||||
if(this.atk_count< FightSet.ATK_ADD_COUNT) return
|
|
||||||
|
|
||||||
|
|
||||||
let master=ecs.query(ecs.allOf(MasterModelComp))
|
|
||||||
master.forEach(master=>{
|
|
||||||
let master_view=master.get(HeroViewComp)
|
|
||||||
if(this.atk_add_master_atk>0) {
|
|
||||||
master_view.add_ap(this.atk_add_master_atk,true)
|
|
||||||
}
|
|
||||||
if(this.atk_add_master_hp>0) {
|
|
||||||
master_view.add_hp_max(this.atk_add_master_hp,true)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
this.atk_count=0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -451,14 +433,13 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.is_count_dead=true
|
this.is_count_dead=true
|
||||||
this.scheduleOnce(()=>{
|
this.scheduleOnce(()=>{
|
||||||
oops.message.dispatchEvent(GameEvent.MonDead)
|
oops.message.dispatchEvent(GameEvent.MonDead)
|
||||||
|
|
||||||
},0.1)
|
},0.1)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.fac==FacSet.HERO){
|
if(this.fac==FacSet.HERO){
|
||||||
//console.log("[HeroViewComp]:英雄死亡")
|
//console.log("[HeroViewComp]:英雄死亡")
|
||||||
oops.message.dispatchEvent(GameEvent.FightEnd,{victory:false})
|
// oops.message.dispatchEvent(GameEvent.FightEnd,{victory:false})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -645,7 +626,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.ent.destroy();
|
this.ent.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||||
this.showDamage(damage, is_crit);
|
this.showDamage(damage, is_crit);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -719,14 +700,14 @@ export class HeroViewComp extends CCComp {
|
|||||||
// this.to_drop()
|
// this.to_drop()
|
||||||
|
|
||||||
// }
|
// }
|
||||||
do_dead_trigger(){
|
do_dead_trigger(){ //双倍死亡设定
|
||||||
if(this.is_dead||this.fac==FacSet.MON||this.is_master) return
|
if(this.is_dead||this.fac==FacSet.MON) return
|
||||||
let count = 1
|
let count = 1
|
||||||
for(let i=0;i<count;i++){
|
for(let i=0;i<count;i++){
|
||||||
//console.log("[HeroViewComp]:dead"+i+"次")
|
//console.log("[HeroViewComp]:dead"+i+"次")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
do_atked_trigger(){
|
do_atked_trigger(){ //双倍攻击设定
|
||||||
if(this.is_dead||this.fac==FacSet.MON) return
|
if(this.is_dead||this.fac==FacSet.MON) return
|
||||||
let count = 1
|
let count = 1
|
||||||
if(this.double_atked) {
|
if(this.double_atked) {
|
||||||
@@ -801,11 +782,11 @@ export class HeroViewComp extends CCComp {
|
|||||||
|
|
||||||
to_update(){
|
to_update(){
|
||||||
// console.log("[HeroViewComp]:to_update",this.is_master)
|
// console.log("[HeroViewComp]:to_update",this.is_master)
|
||||||
if(!this.is_master) return
|
// if(!this.is_master) return
|
||||||
smc.vmdata.hero.exp = smc.vmdata.hero.exp-smc.vmdata.hero.next_exp
|
// smc.vmdata.hero.exp = smc.vmdata.hero.exp-smc.vmdata.hero.next_exp
|
||||||
smc.vmdata.hero.lv = smc.vmdata.hero.lv+1
|
// smc.vmdata.hero.lv = smc.vmdata.hero.lv+1
|
||||||
smc.vmdata.hero.next_exp=getUpExp(smc.vmdata.hero.lv)
|
// smc.vmdata.hero.next_exp=getUpExp(smc.vmdata.hero.lv)
|
||||||
oops.message.dispatchEvent(GameEvent.HeroLvUp,{lv:smc.vmdata.hero.lv})
|
// oops.message.dispatchEvent(GameEvent.HeroLvUp,{lv:smc.vmdata.hero.lv})
|
||||||
this.BUFFCOMP.lv_up()
|
this.BUFFCOMP.lv_up()
|
||||||
// this.BUFFCOMP.tooltip(TooltipTypes.lvup)
|
// this.BUFFCOMP.tooltip(TooltipTypes.lvup)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export class MissionComp extends CCComp {
|
|||||||
wave_time_num:number = 0;
|
wave_time_num:number = 0;
|
||||||
wave_time_cd:Timer=new Timer(1);
|
wave_time_cd:Timer=new Timer(1);
|
||||||
is_in_wave:boolean = false;
|
is_in_wave:boolean = false;
|
||||||
tals:{
|
tals:any={
|
||||||
0:false,
|
0:false,
|
||||||
1:false,
|
1:false,
|
||||||
2:false,
|
2:false,
|
||||||
@@ -47,7 +47,11 @@ export class MissionComp extends CCComp {
|
|||||||
4:false,
|
4:false,
|
||||||
5:false,
|
5:false,
|
||||||
}
|
}
|
||||||
|
heros:any={
|
||||||
|
0:{uuid:0,count:0},
|
||||||
|
1:{uuid:0,count:0},
|
||||||
|
2:{uuid:0,count:0},
|
||||||
|
}
|
||||||
onLoad(){
|
onLoad(){
|
||||||
this.on(GameEvent.MissionStart,this.mission_start,this)
|
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||||
this.on(GameEvent.MasterCalled,this.ready_to_fight,this)
|
this.on(GameEvent.MasterCalled,this.ready_to_fight,this)
|
||||||
@@ -58,7 +62,7 @@ export class MissionComp extends CCComp {
|
|||||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||||
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
||||||
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
|
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
|
||||||
// this.on(GameEvent.UseEnhancement,this.hide_uplv_button,this)
|
this.on(GameEvent.UseHeroCard,this.hero_called,this)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +96,52 @@ export class MissionComp extends CCComp {
|
|||||||
do_reward(){
|
do_reward(){
|
||||||
// 奖励发放
|
// 奖励发放
|
||||||
}
|
}
|
||||||
|
hero_called(event: any, data: any) {
|
||||||
|
// 查找空位或已存在的英雄
|
||||||
|
const heroIndex = this.findHeroSlot(data.uuid);
|
||||||
|
|
||||||
|
if (heroIndex !== -1) {
|
||||||
|
// 找到英雄位置,增加数量
|
||||||
|
this.heros[heroIndex].count += 1;
|
||||||
|
} else {
|
||||||
|
// 查找空位
|
||||||
|
const emptySlot = this.findEmptySlot();
|
||||||
|
if (emptySlot !== -1) {
|
||||||
|
// 有空位,添加新英雄
|
||||||
|
this.heros[emptySlot].uuid = data.uuid;
|
||||||
|
this.heros[emptySlot].count = 1;
|
||||||
|
} else {
|
||||||
|
console.log("[MissionComp] 英雄已满");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找英雄位置
|
||||||
|
* @param uuid 英雄UUID
|
||||||
|
* @returns 英雄索引,未找到返回-1
|
||||||
|
*/
|
||||||
|
private findHeroSlot(uuid: number): number {
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
if (this.heros[i].uuid === uuid) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找空位
|
||||||
|
* @returns 空位索引,无空位返回-1
|
||||||
|
*/
|
||||||
|
private findEmptySlot(): number {
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
if (this.heros[i].uuid === 0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
count_tal(){
|
count_tal(){
|
||||||
let count=0
|
let count=0
|
||||||
@@ -186,7 +236,6 @@ export class MissionComp extends CCComp {
|
|||||||
oops.message.dispatchEvent(GameEvent.FightReady)
|
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||||
this.node.active=true
|
this.node.active=true
|
||||||
this.data_init()
|
this.data_init()
|
||||||
// this.hart_hero_load()
|
|
||||||
let loading=this.node.parent.getChildByName("loading")
|
let loading=this.node.parent.getChildByName("loading")
|
||||||
loading.active=true
|
loading.active=true
|
||||||
this.scheduleOnce(()=>{
|
this.scheduleOnce(()=>{
|
||||||
@@ -270,11 +319,6 @@ export class MissionComp extends CCComp {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//角色初始化
|
|
||||||
hart_hero_load(){
|
|
||||||
let hero = ecs.getEntity<Hero>(Hero);
|
|
||||||
hero.hart_load()
|
|
||||||
}
|
|
||||||
|
|
||||||
card_init(){
|
card_init(){
|
||||||
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
||||||
|
|||||||
@@ -46,32 +46,6 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
this.addHero(args.uuid,false,true)
|
this.addHero(args.uuid,false,true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private call_friend(event: string, args: any,is_master:boolean=false){
|
|
||||||
console.log("[MissionHeroComp]:call_hero addHero",args.uuid,is_master)
|
|
||||||
let hero_pos=1
|
|
||||||
if(is_master){
|
|
||||||
hero_pos=0
|
|
||||||
}
|
|
||||||
let info:any={ap:0,hp:0,lv:0}
|
|
||||||
let hero = ecs.getEntity<Hero>(Hero);
|
|
||||||
let scale = 1
|
|
||||||
let heros=ecs.query(ecs.allOf(HeroViewComp))
|
|
||||||
for(let hero of heros){
|
|
||||||
let hv = hero.get(HeroViewComp)
|
|
||||||
if(hv.fight_pos==hero_pos){
|
|
||||||
hero_pos=2
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log("[MissionHeroComp]:call_friend",heros)
|
|
||||||
let pos:Vec3 = HeroPos[hero_pos].pos;
|
|
||||||
if(is_master){
|
|
||||||
hero.hart_load(args.uuid)
|
|
||||||
}else{
|
|
||||||
hero.load(pos,scale,args.uuid,info,hero_pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +57,7 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
// let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
// let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||||
// // let uuid=args.uuid
|
// // let uuid=args.uuid
|
||||||
// // console.log("call_hero",uuid)
|
// // console.log("call_hero",uuid)
|
||||||
this.addHero(args.uuid,args.is_master)
|
this.addHero(args.uuid,args.is_master,false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 添加英雄 */
|
/** 添加英雄 */
|
||||||
@@ -95,16 +69,11 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
if(is_zhaohuan){
|
if(is_zhaohuan){
|
||||||
hero_pos=2
|
hero_pos=2
|
||||||
}
|
}
|
||||||
let info:any=this.get_info_and_remove(hero_pos,uuid)
|
|
||||||
// let info:any={ap:0,hp:0,lv:0}
|
|
||||||
let hero = ecs.getEntity<Hero>(Hero);
|
let hero = ecs.getEntity<Hero>(Hero);
|
||||||
let scale = 1
|
let scale = 1
|
||||||
let pos:Vec3 = HeroPos[hero_pos].pos;
|
let pos:Vec3 = HeroPos[hero_pos].pos;
|
||||||
if(is_master){
|
hero.load(pos,scale,uuid);
|
||||||
hero.hart_load(uuid)
|
|
||||||
}else{
|
|
||||||
hero.load(pos,scale,uuid,info,hero_pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_info_and_remove(fight_pos:number,uuid:number){
|
get_info_and_remove(fight_pos:number,uuid:number){
|
||||||
|
|||||||
Reference in New Issue
Block a user