逐步 去掉 主英雄设定
This commit is contained in:
@@ -19,7 +19,7 @@ export class Hero extends ecs.Entity {
|
||||
HeroModel!: HeroModelComp;
|
||||
HeroView!: HeroViewComp;
|
||||
BattleMove!: BattleMoveComp;
|
||||
|
||||
vmHero:any={}
|
||||
protected init() {
|
||||
this.addComponents<ecs.Comp>(
|
||||
BattleMoveComp,
|
||||
@@ -38,29 +38,26 @@ export class Hero extends ecs.Entity {
|
||||
}
|
||||
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) {
|
||||
// console.log("英雄加载:",uuid,pos,scale,info)
|
||||
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 prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
@@ -69,18 +66,21 @@ export class Hero extends ecs.Entity {
|
||||
node.setPosition(pos)
|
||||
// console.log("hero load",pos)
|
||||
var hv = this.hero_init(uuid,node,info)
|
||||
hv.fight_pos=fight_pos
|
||||
hv.is_friend=true
|
||||
this.add(hv);
|
||||
this.addComponents<ecs.Comp>(FriendModelComp);
|
||||
// const move = this.get(BattleMoveComp);
|
||||
// move.direction = 1; // 向右移动
|
||||
// move.targetX = 800; // 右边界'
|
||||
this.addComponents<ecs.Comp>(MasterModelComp)
|
||||
oops.message.dispatchEvent(GameEvent.MasterCalled,{uuid:uuid})
|
||||
const move = this.get(BattleMoveComp);
|
||||
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}) {
|
||||
var hv = node.getComponent(HeroViewComp)!;
|
||||
let hero= HeroInfo[uuid] // 共用英雄数据
|
||||
hv.vmHero=this.vmHero
|
||||
this.vmHero.name=hero.name
|
||||
hv.scale = 1;
|
||||
hv.is_master=true;
|
||||
hv.lv=1
|
||||
hv.lv=info.lv
|
||||
hv.fac = FacSet.HERO;
|
||||
hv.type = hero.type;
|
||||
@@ -89,8 +89,8 @@ export class Hero extends ecs.Entity {
|
||||
hv.hero_name= hero.name;
|
||||
hv.speed =hv.ospeed = hero.speed;
|
||||
hv.dis = hero.dis;
|
||||
hv.cd = hv.cd_base = hero.cd
|
||||
hv.hp= hv.hp_max = hv.hp_base=hero.hp+info.hp
|
||||
this.vmHero.cd_max=hv.cd = hv.cd_base = hero.cd
|
||||
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;
|
||||
hero.buff.forEach((buff:any)=>{
|
||||
switch(buff.buff_type){
|
||||
|
||||
@@ -36,6 +36,8 @@ export class HeroViewComp extends CCComp {
|
||||
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
||||
fac:number=0; //阵营 0:hero 1:monster
|
||||
|
||||
vmHero:any={}
|
||||
|
||||
box_group:number = BoxSet.HERO;
|
||||
|
||||
is_dead:boolean = false; //是否摧毁
|
||||
@@ -152,7 +154,6 @@ export class HeroViewComp extends CCComp {
|
||||
onLoad() {
|
||||
this.as = this.getComponent(HeroSpine);
|
||||
//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)
|
||||
const collider = this.node.getComponent(BoxCollider2D);
|
||||
this.scheduleOnce(()=>{
|
||||
@@ -165,7 +166,7 @@ export class HeroViewComp extends CCComp {
|
||||
start () {
|
||||
this.as.idle()
|
||||
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.getChildByName("top").setScale(this.scale,1);
|
||||
@@ -201,10 +202,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.processDamageQueue();
|
||||
}
|
||||
|
||||
change_atk(e:GameEvent,data:any){
|
||||
if(!this.is_master) return
|
||||
|
||||
}
|
||||
|
||||
|
||||
get isActive() {
|
||||
return this.ent.has(HeroViewComp) && this.node?.isValid;
|
||||
@@ -236,70 +234,70 @@ export class HeroViewComp extends CCComp {
|
||||
change_wfuny(wfuny: number){
|
||||
this.wfuny+=wfuny
|
||||
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){
|
||||
this.puncture+=puncture
|
||||
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){
|
||||
this.puncture_damage+=puncture_damage
|
||||
if(this.puncture_damage<0) this.puncture_damage=0
|
||||
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){
|
||||
this.dod+=dodge
|
||||
if(this.dod<0) this.dod=0
|
||||
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){
|
||||
this.frost_ratto+=frost_ratto
|
||||
if(this.frost_ratto<0) this.frost_ratto=0
|
||||
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){
|
||||
this.knockback+=knockback
|
||||
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){
|
||||
this.stun_ratto+=stun_ratto
|
||||
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){
|
||||
this.def+=def
|
||||
if(this.def>90) this.def=90
|
||||
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));
|
||||
}
|
||||
change_crit(crit: number){
|
||||
this.crit+=crit
|
||||
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){
|
||||
this.crit_d+=crit_d
|
||||
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){
|
||||
this.reflect+=reflect
|
||||
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){
|
||||
this.lifesteal+=lifesteal
|
||||
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){
|
||||
@@ -318,20 +316,19 @@ export class HeroViewComp extends CCComp {
|
||||
switch(buff){
|
||||
case BuffAttr.ATK:
|
||||
this.ap=this.check_atrr(BuffAttr.ATK)
|
||||
if(this.is_master) {
|
||||
this.BUFFCOMP.vmdata_update();
|
||||
oops.message.dispatchEvent(GameEvent.APChange,{is_master:this.is_master,fac:this.fac})
|
||||
}
|
||||
// if(this.is_master) {
|
||||
// // this.BUFFCOMP.vmdata_update();
|
||||
// }
|
||||
break
|
||||
case 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
|
||||
case BuffAttr.HP:
|
||||
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
|
||||
this.hp_max=this.check_atrr(BuffAttr.HP)
|
||||
this.hp+=diff
|
||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -379,7 +376,7 @@ export class HeroViewComp extends CCComp {
|
||||
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
|
||||
this.hp_base -= Math.floor(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) {
|
||||
@@ -404,7 +401,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.hp+=real_hp;
|
||||
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(){ //主将攻击次数 主要有装备加成,需要单独处理
|
||||
if(!this.is_master) return
|
||||
count_atk_count(){ //主将攻击
|
||||
if(this.fac==FacSet.MON) return
|
||||
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.scheduleOnce(()=>{
|
||||
oops.message.dispatchEvent(GameEvent.MonDead)
|
||||
|
||||
},0.1)
|
||||
|
||||
}
|
||||
|
||||
if(this.fac==FacSet.HERO){
|
||||
//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();
|
||||
}
|
||||
}
|
||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||
this.showDamage(damage, is_crit);
|
||||
|
||||
}
|
||||
@@ -719,14 +700,14 @@ export class HeroViewComp extends CCComp {
|
||||
// this.to_drop()
|
||||
|
||||
// }
|
||||
do_dead_trigger(){
|
||||
if(this.is_dead||this.fac==FacSet.MON||this.is_master) return
|
||||
do_dead_trigger(){ //双倍死亡设定
|
||||
if(this.is_dead||this.fac==FacSet.MON) return
|
||||
let count = 1
|
||||
for(let i=0;i<count;i++){
|
||||
//console.log("[HeroViewComp]:dead"+i+"次")
|
||||
}
|
||||
}
|
||||
do_atked_trigger(){
|
||||
do_atked_trigger(){ //双倍攻击设定
|
||||
if(this.is_dead||this.fac==FacSet.MON) return
|
||||
let count = 1
|
||||
if(this.double_atked) {
|
||||
@@ -801,11 +782,11 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
to_update(){
|
||||
// console.log("[HeroViewComp]:to_update",this.is_master)
|
||||
if(!this.is_master) return
|
||||
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.next_exp=getUpExp(smc.vmdata.hero.lv)
|
||||
oops.message.dispatchEvent(GameEvent.HeroLvUp,{lv:smc.vmdata.hero.lv})
|
||||
// if(!this.is_master) return
|
||||
// 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.next_exp=getUpExp(smc.vmdata.hero.lv)
|
||||
// oops.message.dispatchEvent(GameEvent.HeroLvUp,{lv:smc.vmdata.hero.lv})
|
||||
this.BUFFCOMP.lv_up()
|
||||
// this.BUFFCOMP.tooltip(TooltipTypes.lvup)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user