添加了 英雄专门处理 装备加成的文件,接下来 去掉原先的光环类文件 FightCon
This commit is contained in:
82
assets/script/game/hero/HeroConComp.ts
Normal file
82
assets/script/game/hero/HeroConComp.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { _decorator } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { EquipAttrTarget, EquipInfo } from "../common/config/Equips";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
import { BuffAttr } from "../common/config/SkillSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('HeroConCompComp')
|
||||
@ecs.register('HeroConComp', false)
|
||||
export class HeroConCompComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
heroView:HeroViewComp=null
|
||||
protected onLoad(): void {
|
||||
oops.message.on(GameEvent.EquipAdd,this.equip_add,this)
|
||||
oops.message.on(GameEvent.EquipChange,this.equip_change,this)
|
||||
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
oops.message.on(GameEvent.UseSpecialCard,this.use_special_card,this)
|
||||
}
|
||||
start() {
|
||||
this.heroView=this.node.getComponent(HeroViewComp)
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
}
|
||||
equip_add(e:GameEvent,data:any){
|
||||
console.log("[HeroConCompComp]:equip_add",data)
|
||||
let equip=EquipInfo[data.uuid]
|
||||
let buffs=equip.buff
|
||||
let special_attr=equip.special_attr
|
||||
for(let i=0;i<buffs.length;i++){
|
||||
let buff=buffs[i]
|
||||
if(buff.target==EquipAttrTarget.HERO){
|
||||
switch(buff.type){
|
||||
case BuffAttr.AP:
|
||||
this.heroView.add_ap(buff.value,true)
|
||||
break
|
||||
case BuffAttr.ATK:
|
||||
this.heroView.add_ap(buff.value,false)
|
||||
break
|
||||
case BuffAttr.ATK_CD:
|
||||
this.heroView.add_speed(buff.value)
|
||||
break
|
||||
case BuffAttr.DEF:
|
||||
this.heroView.add_def(buff.value)
|
||||
break
|
||||
case BuffAttr.HP:
|
||||
this.heroView.add_hp_max(buff.value,false)
|
||||
break
|
||||
case BuffAttr.HP_MAX:
|
||||
this.heroView.add_hp_max(buff.value,true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
equip_change(e:GameEvent,data:any){
|
||||
console.log("[HeroConCompComp]:equip_change",data)
|
||||
}
|
||||
fight_ready(e:GameEvent,data:any){
|
||||
console.log("[HeroConCompComp]:fight_ready",data)
|
||||
}
|
||||
use_special_card(e:GameEvent,data:any){
|
||||
console.log("[HeroConCompComp]:use_special_card",data)
|
||||
}
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/hero/HeroConComp.ts.meta
Normal file
9
assets/script/game/hero/HeroConComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "846e0307-e55e-4bc3-a9db-b387c89ad671",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -53,10 +53,12 @@ export class HeroViewComp extends CCComp {
|
||||
hp: number = 100; /** 血量 */
|
||||
hp_max: number = 100; /** 最大血量 */
|
||||
buff_hp:number=0;
|
||||
hp_base:number=0;
|
||||
|
||||
pwt:Timer = new Timer(1); //计时器
|
||||
ap: number = 10; /**攻击力 */
|
||||
buff_ap:number=0;
|
||||
ap_base:number=0;
|
||||
// atk_speed: number = 1;
|
||||
cd: number = 1.3; /**攻击速度 攻击间隔 */
|
||||
dis: number = 80;
|
||||
@@ -118,7 +120,6 @@ export class HeroViewComp extends CCComp {
|
||||
this.FIGHTCON=this.node.parent.getComponent(FightConComp);
|
||||
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
|
||||
this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_atk,this)
|
||||
this.on(GameEvent.UpdateHP,this.update_hp,this)
|
||||
this.on(GameEvent.EXPUP,this.exp_up,this)
|
||||
this.on(GameEvent.UseEnhancement,this.use_enhancement,this)
|
||||
const collider = this.node.getComponent(BoxCollider2D);
|
||||
@@ -218,11 +219,14 @@ export class HeroViewComp extends CCComp {
|
||||
add_ap(ap: number,is_num:boolean=true){
|
||||
//console.log("[HeroViewComp]:add_ap add:",ap,this.ap)
|
||||
if(is_num){
|
||||
this.ap += Math.floor(ap);
|
||||
this.ap_base += Math.floor(ap);
|
||||
}else{
|
||||
this.ap += Math.floor(ap/100*this.ap);
|
||||
this.buff_ap += Math.floor(ap/100*this.ap);
|
||||
}
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.apup,ap.toFixed(0));
|
||||
let diff=Math.floor(this.ap_base*(100+this.buff_ap)/100)-this.ap
|
||||
this.ap = Math.floor(this.ap_base*(100+this.buff_ap)/100)
|
||||
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.apup,diff.toFixed(0));
|
||||
|
||||
if(this.is_master) {
|
||||
this.BUFFCOMP.vmdata_update();
|
||||
@@ -233,35 +237,37 @@ export class HeroViewComp extends CCComp {
|
||||
de_ap(ap: number,is_num:boolean=true){
|
||||
//console.log("[HeroViewComp]:de_ap de:",ap,this.ap)
|
||||
if(is_num){
|
||||
this.ap -= Math.floor(ap);
|
||||
this.ap_base -= Math.floor(ap);
|
||||
}else{
|
||||
this.ap -= Math.floor(ap/100*this.ap);
|
||||
this.buff_ap -= Math.floor(ap/100*this.ap);
|
||||
}
|
||||
let diff=Math.floor(this.ap_base*(100+this.buff_ap)/100)-this.ap
|
||||
this.ap = Math.floor(this.ap_base*(100+this.buff_ap)/100)
|
||||
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.apup,diff.toFixed(0));
|
||||
|
||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||
}
|
||||
update_hp(e:GameEvent,data:any){
|
||||
//console.log("[HeroViewComp]:update_hp",data)
|
||||
if(this.is_master===data.is_master&&this.fac===FacSet.HERO){
|
||||
this.buff_hp += data.hp
|
||||
if(data.hp > 0){
|
||||
this.hp += this.hp_max*data.hp/100
|
||||
if(this.hp > this.hp_max*(100+this.buff_hp)/100){
|
||||
this.hp=this.hp_max*(100+this.buff_hp)/100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_hp_max(hp: number=0,is_num:boolean=true){
|
||||
this.hp_max += Math.floor(hp) ;
|
||||
this.hp += Math.floor(hp*(100+this.buff_hp)/100) ;
|
||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.hpup,hp.toFixed(0));
|
||||
|
||||
add_hp_max(hp: number=0,is_num:boolean=false){
|
||||
if(is_num){
|
||||
this.hp_base += Math.floor(hp) ;
|
||||
}else{
|
||||
this.buff_hp+=hp
|
||||
}
|
||||
let diff=Math.floor(this.hp_base*(100+this.buff_hp)/100)-this.hp_max
|
||||
this.hp_max =Math.floor(this.hp_base*(100+this.buff_hp)/100)
|
||||
this.hp+=diff
|
||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.hpup,diff.toFixed(0));
|
||||
}
|
||||
|
||||
de_hp_max(hp: number=0,is_num:boolean=true){ //最大值 只存在数值添加, 比例通过buff_hp处理
|
||||
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
|
||||
this.hp_max -= Math.floor(hp) ;
|
||||
this.hp_base -= Math.floor(hp) ;
|
||||
let diff=Math.floor(this.hp_base*(100+this.buff_hp)/100)-this.hp_max
|
||||
this.hp_max =Math.floor(this.hp_base*(100+this.buff_hp)/100)
|
||||
this.hp+=diff
|
||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||
}
|
||||
|
||||
@@ -332,13 +338,8 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
if(this.fac==FacSet.MON){
|
||||
let exp=getExpDrops(HeroInfo[this.hero_uuid].quality,this.lv)
|
||||
let stone=getStoneDrops(HeroInfo[this.hero_uuid].quality,this.lv)
|
||||
oops.message.dispatchEvent(GameEvent.EXPUP,{exp:exp})
|
||||
if(stone.type=="equip"){
|
||||
oops.message.dispatchEvent(GameEvent.EQUIP_STONE_UP,stone.count)
|
||||
}else{
|
||||
oops.message.dispatchEvent(GameEvent.SKILL_STONE_UP,stone.count)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(this.fac==FacSet.HERO){
|
||||
@@ -659,12 +660,12 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
to_update(){
|
||||
if(!this.is_master) return
|
||||
// oops.message.dispatchEvent(GameEvent.HeroLvUp,{lv:this.lv})
|
||||
|
||||
|
||||
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)
|
||||
//@todo 需要添加 升级动画
|
||||
|
||||
Reference in New Issue
Block a user