删掉了role 场景技能 基本完成
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { _decorator } from "cc";
|
||||
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;
|
||||
|
||||
@@ -8,12 +12,74 @@ 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
|
||||
console.log("MSkillComp start");
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
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
|
||||
this.shoot_enemy()
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
||||
console.log("mskill 获取自己坐标:"+ this.node.position );
|
||||
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)
|
||||
console.log("mskill 获取目标坐标:"+t_pos,pos);
|
||||
return {pos,t_pos}
|
||||
}
|
||||
/** 全局消息逻辑处理 */
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
Reference in New Issue
Block a user