技能继续
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import { instantiate, Prefab, v3 } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { MSkillComp } from "./MSkillComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
|
||||
/** MSkill 模块 */
|
||||
@ecs.register(`MSkill`)
|
||||
export class MSkill extends ecs.Entity {
|
||||
|
||||
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
// this.addComponents<ecs.Comp>();
|
||||
}
|
||||
load(box_group:number=0,uuid:number=1001) {
|
||||
var path = "game/heros/mskill";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let entityLayer =smc.map.MapView.scene.entityLayer!.node!
|
||||
node.parent = entityLayer
|
||||
let pos=v3(-300,245)
|
||||
if(box_group==BoxSet.MONSTER){
|
||||
pos.x=300
|
||||
// node.setScale(-1,1)
|
||||
}
|
||||
node.setPosition(pos)
|
||||
var msc = node.getComponent(MSkillComp)!;
|
||||
msc.msk_uuid = uuid
|
||||
msc.box_group = box_group
|
||||
this.add(msc)
|
||||
}
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "10489fd2-88db-4945-a7b2-b9f26aaceab2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import { _decorator, ProgressBar, UITransform, v3, Vec3 } 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 { MSkills } from "../common/config/SkillSet";
|
||||
import { Skill } from "./Skill";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('MSkillComp')
|
||||
@ecs.register('MSkillComp', false)
|
||||
export class MSkillComp extends CCComp {
|
||||
msk_uuid: number = 0;
|
||||
ap: number = 0;
|
||||
cd: number = 0;
|
||||
cdt: number = 0;
|
||||
lv: number = 0;
|
||||
skill:any=null
|
||||
box_group:number=0
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
this.skill=MSkills[this.msk_uuid]
|
||||
this.ap=this.skill.ap
|
||||
this.cd=this.cdt=this.skill.cd
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(!smc.vmdata.mission.play||smc.vmdata.mission.pause){
|
||||
return
|
||||
}
|
||||
this.check_cd(dt)
|
||||
}
|
||||
check_cd(dt:number){
|
||||
this.cdt-=dt
|
||||
this.node.getComponent(ProgressBar).progress=this.cdt/this.cd
|
||||
if(this.cdt<=0){
|
||||
this.cdt=this.cd
|
||||
if(this.skill.shoot){
|
||||
this.shoot_enemy()
|
||||
}else if(this.skill.buff){
|
||||
this.add_buff()
|
||||
}else{
|
||||
this.to_mission()
|
||||
}
|
||||
}
|
||||
}
|
||||
to_mission(){
|
||||
//特殊技能,如 增加一次免死, 复活等
|
||||
}
|
||||
add_buff(){
|
||||
//buff 技能,如 加血 加攻 加生命值最大值
|
||||
}
|
||||
shoot_enemy(){
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let {pos,t_pos}=this.get_enemy_pos()
|
||||
pos.y=pos.y
|
||||
pos.x=pos.x
|
||||
skill.load(pos,this.box_group,this.node,this.skill.ssk,this.ap,t_pos,false,0);
|
||||
console.log("mskill 使用技能:"+this.skill.ssk);
|
||||
}
|
||||
get_enemy_pos(){
|
||||
let pos =v3(0,0)
|
||||
let t_pos:Vec3 = v3(0,0)
|
||||
let dir = 720
|
||||
let enemy = v3(720,BoxSet.GAME_LINE)
|
||||
if(this.box_group == BoxSet.MONSTER){
|
||||
let t_pos:Vec3 = v3(-720,0)
|
||||
for (let i = 0; i < smc.hero_pos.length; i++) {
|
||||
let ho:any = smc.hero_pos[i];
|
||||
let x=Math.abs(ho.x-this.node.position.x)
|
||||
if(x < dir){
|
||||
dir = x
|
||||
enemy = ho
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.box_group == BoxSet.HERO){
|
||||
let t_pos:Vec3 = v3(720,0)
|
||||
for (let i = 0; i < smc.enemy_pos.length; i++) {
|
||||
let mon:any = smc.enemy_pos[i];
|
||||
let x=Math.abs(mon.x-this.node.position.x)
|
||||
if(x < dir){
|
||||
dir = x
|
||||
enemy = mon
|
||||
}
|
||||
}
|
||||
}
|
||||
t_pos = v3(enemy.x-this.node.position.x,enemy.y-this.node.position.y)
|
||||
return {pos,t_pos}
|
||||
}
|
||||
/** 全局消息逻辑处理 */
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "87082774-5f64-4312-ad72-ea125b4a5826",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user