91 lines
3.1 KiB
TypeScript
91 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, 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 { MonModelComp } from "./MonModelComp";
|
|
import { MonSpine } from "./MonSpine";
|
|
import { MonViewComp } from "./MonViewComp";
|
|
import { BoxSet } from "../common/config/BoxSet";
|
|
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
|
import { HeroSet,MonSet } from "../common/config/heroSet";
|
|
/** 角色实体 */
|
|
@ecs.register(`Mon`)
|
|
export class Mon extends ecs.Entity {
|
|
// 数据层
|
|
MonModel!: MonModelComp;
|
|
// 视图层
|
|
MonView!: MonViewComp;
|
|
|
|
protected init() {
|
|
this.addComponents<ecs.Comp>( MonModelComp);
|
|
|
|
}
|
|
|
|
destroy(): void {
|
|
this.remove(MonViewComp);
|
|
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 mv = node.getComponent(MonViewComp)!;
|
|
// console.log("hero_init",buff)
|
|
mv.speed =mv.ospeed = smc.monsters[uuid].speed;
|
|
mv.hero_name= smc.monsters[uuid].name;
|
|
mv.hp= mv.hp_max = smc.monsters[uuid].hp;
|
|
mv.level = smc.monsters[uuid].level;
|
|
mv.atk = smc.monsters[uuid].atk;
|
|
mv.atk_cd = smc.monsters[uuid].atk_cd;
|
|
mv.atk_dis = smc.monsters[uuid].atk_dis;
|
|
mv.power = smc.monsters[uuid].power;
|
|
mv.power_max = smc.monsters[uuid].power_max;
|
|
|
|
mv.type = smc.monsters[uuid].type;
|
|
mv.skill_uuid = smc.monsters[uuid].skill_uuid;
|
|
mv.max_skill_uuid = smc.monsters[uuid].max_skill_uuid;
|
|
mv.scale = -1;
|
|
mv.Tpos = v3(0,0,0);
|
|
this.add(mv);
|
|
}
|
|
} |