133 lines
4.2 KiB
TypeScript
133 lines
4.2 KiB
TypeScript
|
|
/*
|
|
* @Author: dgflash
|
|
* @Date: 2021-11-18 17:47:56
|
|
* @LastEditors: dgflash
|
|
* @LastEditTime: 2022-08-04 15:43:04
|
|
*/
|
|
import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,SpriteAtlas} from "cc";
|
|
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { UIID } from "../common/config/GameUIConfig";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { HeroModelComp } from "./HeroModelComp";
|
|
import { HeroSpine } from "./HeroSpine";
|
|
import { HeroViewComp } from "./HeroViewComp";
|
|
import { BoxSet } from "../common/config/BoxSet";
|
|
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
|
import { HeroInfo,MonSet } from "../common/config/heroSet";
|
|
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
|
import { Talents } from "../common/config/TalentSet";
|
|
import { MonModelComp } from "../mon/MonModelComp";
|
|
/** 角色实体 */
|
|
@ecs.register(`Hero`)
|
|
export class Hero extends ecs.Entity {
|
|
// 数据层
|
|
HeroModel!: HeroModelComp;
|
|
// 视图层
|
|
HeroView!: HeroViewComp;
|
|
|
|
|
|
protected init() {
|
|
|
|
|
|
}
|
|
|
|
destroy(): void {
|
|
this.remove(HeroViewComp);
|
|
this.remove(MoveToComp);
|
|
super.destroy();
|
|
}
|
|
|
|
/** 加载角色 */
|
|
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,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 prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
|
|
var scene = smc.map.MapView.scene;
|
|
node.parent = scene.entityLayer!.node!
|
|
|
|
node.setPosition(pos)
|
|
this.hero_init(uuid,node,scale,box_group)
|
|
oops.message.dispatchEvent("hero_load",this)
|
|
}
|
|
|
|
hero_init(uuid:number=1001,node:Node,scale:number=1,box_group=BoxSet.HERO){
|
|
var hv = node.getComponent(HeroViewComp)!;
|
|
// console.log("hero_init",buff)
|
|
let HInf= smc.heros[uuid] // 角色数据
|
|
let talent= smc.vmdata.talent
|
|
let hero =smc.vmdata.heros[uuid]
|
|
let talents=Talents;
|
|
hv.scale = scale;
|
|
hv.box_group = box_group;
|
|
hv.hero_uuid= uuid;
|
|
hv.hero_name= HInf.name;
|
|
hv.hero_type= HInf.type;
|
|
hv.speed =hv.ospeed = HInf.speed;
|
|
hv.dis = HInf.dis;
|
|
hv.pw = HInf.pw;
|
|
hv.pwm= HInf.pwm;
|
|
hv.pws= HInf.pws
|
|
hv.lv = hero.lv;
|
|
hv.slv = hero.slv;
|
|
hv.type = HInf.type;
|
|
hv.sk1 = HInf.sk1[hero.slv];
|
|
hv.sk2 = HInf.sk2[hero.slv];
|
|
hv.akc = HInf.akc[hero.slv];
|
|
hv.uac = HInf.uac[hero.slv];
|
|
hv.crc = HInf.crc[hero.slv];
|
|
hv.dgc = HInf.dgc[hero.slv];
|
|
hv.akr = HInf.akr[hero.slv];
|
|
hv.uar = HInf.uar[hero.slv];
|
|
hv.crr = HInf.crr[hero.slv];
|
|
hv.dgr = HInf.dgr[hero.slv];
|
|
hv.type = HInf.type;
|
|
hv.hp= hv.hp_max =HInf.hp+HInf.hp_up*hero.lv ;
|
|
hv.ap = HInf.ap+HInf.ap_up*hero.lv ;
|
|
hv.def= HInf.def+HInf.def_up*hero.lv;
|
|
hv.cd = HInf.a_cd
|
|
hv.crit = HInf.crit; //暴击率
|
|
hv.crit_add = HInf.crit_add;//暴击伤害加成
|
|
hv.dodge = HInf.dodge; //闪避率
|
|
hv.aep=HInf.aep;
|
|
hv.uaep=HInf.uaep;
|
|
hv.dep=HInf.dep;
|
|
|
|
this.add(hv);
|
|
}
|
|
set_ratio(uuid:number){
|
|
let ratio=1;
|
|
switch (smc.heros[uuid].level) {
|
|
case 2:
|
|
ratio=1.05
|
|
break;
|
|
case 3:
|
|
ratio=1.1
|
|
break;
|
|
case 4:
|
|
ratio=1.15
|
|
break;
|
|
case 5:
|
|
ratio=1.2
|
|
break;
|
|
default:
|
|
ratio=1
|
|
}
|
|
return ratio;
|
|
}
|
|
} |