添加了几个英雄
This commit is contained in:
95
assets/script/game/hero/Hero.ts
Normal file
95
assets/script/game/hero/Hero.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
/*
|
||||
* @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 { HeroBuffComp } from "./HeroBuffComp";
|
||||
import { HeroSet } from "../common/config/heroSet";
|
||||
import { MonSet } from "../common/config/MonSet";
|
||||
/** 角色实体 */
|
||||
@ecs.register(`Hero`)
|
||||
export class Hero extends ecs.Entity {
|
||||
// 数据层
|
||||
HeroModel!: HeroModelComp;
|
||||
// 视图层
|
||||
HeroView!: HeroViewComp;
|
||||
HeroBuff!: HeroBuffComp; // 移动
|
||||
|
||||
protected init() {
|
||||
this.addComponents<ecs.Comp>( HeroModelComp);
|
||||
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.remove(HeroViewComp);
|
||||
this.remove(HeroBuffComp);
|
||||
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(HeroSpine);
|
||||
// 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(HeroViewComp)!;
|
||||
var buff =node.getComponent(HeroBuffComp)!;
|
||||
// console.log("hero_init",buff)
|
||||
mv.speed =mv.ospeed = smc.monsters[uuid].speed;
|
||||
mv.hero_name= smc.monsters[uuid].name;
|
||||
buff.group=mv.box_group= BoxSet.MONSTER;
|
||||
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.power = smc.monsters[uuid].power;
|
||||
mv.type = smc.monsters[uuid].type;
|
||||
mv.skill_uuid = 9001;
|
||||
mv.max_skill_uuid = smc.monsters[uuid].max_skill_uuid;
|
||||
mv.scale = -1;
|
||||
mv.Tpos = v3(0,0,0);
|
||||
this.add(mv);
|
||||
this.add(buff);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user