删掉了role 场景技能 基本完成
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
|
||||
|
||||
/** 数据层对象 */
|
||||
@ecs.register('CSkillModel')
|
||||
export class CSkillModelComp extends ecs.Comp {
|
||||
/** 提供 MVVM 组件使用的数据 */
|
||||
// private vm: any = {};
|
||||
|
||||
// /** 显示数据添加到 MVVM 框架中监视 */
|
||||
// vmAdd() {
|
||||
// VM.add(this.vm, "CSkillModel");
|
||||
// }
|
||||
|
||||
// /** 显示数据从 MVVM 框架中移除 */
|
||||
// vmRemove() {
|
||||
// VM.remove("CSkillModel");
|
||||
// }
|
||||
|
||||
/** 数据层组件移除时,重置所有数据为默认值 */
|
||||
reset() {
|
||||
// for (var key in this.vm) {
|
||||
// delete this.vm[key];
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d87fc680-dacd-4c20-9d19-08e941660d54",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import { instantiate, Prefab } from "cc";
|
||||
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`)
|
||||
@@ -12,13 +14,21 @@ export class MSkill extends ecs.Entity {
|
||||
protected init() {
|
||||
// this.addComponents<ecs.Comp>();
|
||||
}
|
||||
load(uuid:number=1001,index:number=-1,parent:any) {
|
||||
let box_group= 0
|
||||
var path = "game/skills/mskill";
|
||||
load(box_group:number=0,uuid:number=1001) {
|
||||
var path = "game/hero/mskill";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = parent
|
||||
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)
|
||||
}
|
||||
/** 模块资源释放 */
|
||||
|
||||
@@ -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) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
@@ -41,16 +41,10 @@ export class Skill extends ecs.Entity {
|
||||
//转换pos为世界坐标
|
||||
node.setPosition(pos)
|
||||
var sv = node.getComponent(SkillCom)!;
|
||||
let scale =1
|
||||
if(t_pos.x < pos.x){
|
||||
scale= - 1
|
||||
}
|
||||
let angle=0
|
||||
if(smc.skills[uuid].angle){
|
||||
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
|
||||
if(scale == -1){
|
||||
angle = angle +180
|
||||
}
|
||||
|
||||
}
|
||||
sv.angle = angle;
|
||||
// console.log(smc.skills[uuid].name+"angle:"+angle)
|
||||
|
||||
Reference in New Issue
Block a user