Files
heros/assets/script/game/Boss/Boss.ts
2024-09-23 08:14:39 +08:00

95 lines
3.1 KiB
TypeScript

/*
* @Author: dgflash
* @Date: 2021-11-18 17:47:56
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, tween, Vec3,Label,resources ,SpriteAtlas,Sprite,v3} 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 { BossModelComp } from "./BossModelComp";
import { BossSpine } from "./BossSpine";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BossViewComp } from "./BossViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { MonSet } from "../common/config/heroSet";
/** 角色实体 */
@ecs.register(`Boss`)
export class Boss extends ecs.Entity {
// 数据层
BossModel!: BossModelComp;
BossMoveTo!: MoveToComp; // 移动
// 视图层
BossView!: BossViewComp;
protected init() {
this.addComponents<ecs.Comp>(
BossModelComp);
}
destroy(): void {
this.remove(BossViewComp);
super.destroy();
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = -1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!) {
var path = "game/monster/"+MonSet[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent=layer
// var as = node.getComponent(MonSpine);
// let ratio=this.set_ratio(uuid);
// node.setScale(node.scale.x*scale*ratio, node.scale.y*ratio, 0);
node.setPosition(pos)
this.hero_init(uuid,node)
oops.message.dispatchEvent("mon_load",this)
}
set_ratio(uuid:number){
let ratio=1;
switch (MonSet[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;
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var bs = node.getComponent(BossViewComp)!;
// console.log("hero_init",buff)
bs.speed =bs.ospeed = smc.monsters[uuid].speed;
bs.boos_name= smc.monsters[uuid].name;
bs.hp= bs.hp_max = smc.monsters[uuid].hp;
bs.level = smc.monsters[uuid].level;
bs.atk = smc.monsters[uuid].atk;
bs.atk_cd = smc.monsters[uuid].atk_cd;
bs.atk_dis = smc.monsters[uuid].atk_dis;
bs.power = smc.monsters[uuid].power;
bs.power_max = smc.monsters[uuid].power_max;
bs.skill = smc.monsters[uuid].skill_uuid;
bs.type = smc.monsters[uuid].type;
bs.box_group = BoxSet.MONSTER;
bs.scale = -1;
bs.Tpos = v3(0,0,0);
this.add(bs);
}
}