局内技能 初步
This commit is contained in:
@@ -64,7 +64,9 @@ export const SkillSet={
|
||||
8001:{uuid: 8001,path: "8001",type: 1,tg:3,angle:true,level: 1,name: "飞刀",sp_name:"sword1",info:"释放一个魔法球攻击敌人",
|
||||
dis:1,count:1,in:0,run:0,ap:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:8001,sk_count:0,speed:600,},
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
export const CSkills={
|
||||
1001:{uuid: 1001,path: "1001",type: 1,tg:3,angle:true,level: 1,name: "火球术",sp_name:"fire",info:"释放一个火球术攻击敌人",
|
||||
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:3,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import { BossList, MissionNum, MonsetList } from "../common/config/MissionSet";
|
||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||
import { HCard } from "./HCard";
|
||||
import { HCardComp } from "./HCardComp";
|
||||
import { MSkill } from "../skills/MSkill";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -97,6 +98,7 @@ export class MissionComp extends CCComp {
|
||||
// this.shuaxin(dt)
|
||||
}
|
||||
mission_start(){
|
||||
/* todo 关卡设定完善*/
|
||||
this.total=smc.vm_data.mission.m_less=smc.vm_data.mission.m_alive=smc.vm_data.mission.total;
|
||||
this.hero_total=2
|
||||
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
|
||||
@@ -116,6 +118,12 @@ export class MissionComp extends CCComp {
|
||||
smc.vm_data.mission.mb_exp=0 //敌方远程经验石
|
||||
smc.vm_data.mission.mc_exp=0 //敌方辅助经验石
|
||||
smc.vm_data.mission.md_exp=0 //敌方特殊经验石
|
||||
this.call_mskill()
|
||||
}
|
||||
call_mskill(){
|
||||
let msk=ecs.getEntity<MSkill>(MSkill)
|
||||
let praent = this.node.getChildByName("exp").getChildByName("a_exp").getChildByName("skill")
|
||||
msk.load(1001,1,praent)
|
||||
}
|
||||
mission_end(){
|
||||
smc.vm_data.mission.play=false
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
import { Prefab,instantiate,Vec3,v3 ,SpriteAtlas,resources,Sprite,Node} from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CSkillComp } from "./CSkillComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||
|
||||
/** CSkill 模块 */
|
||||
@ecs.register(`CSkill`)
|
||||
export class CSkill extends ecs.Entity {
|
||||
CSkillView!: CSkillComp;
|
||||
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
|
||||
}
|
||||
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
this.remove(CSkillComp);
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
super.destroy();
|
||||
}
|
||||
start(){
|
||||
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001) {
|
||||
// var path = "game/monster/"+prefab_path;
|
||||
// console.log("load skill",this)
|
||||
var path = "game/heros/cskill";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
node.getChildByName("skill").setScale(node.getChildByName("skill").scale.x*scale, node.getChildByName("skill").scale.y, node.getChildByName("skill").scale.z);
|
||||
// let cskills = ecs.query(ecs.allOf(CSkillComp))
|
||||
if(SkillSet[uuid].type >= 90){
|
||||
pos = this.add_buff()
|
||||
}else{
|
||||
pos = this.add_skill()
|
||||
}
|
||||
|
||||
// console.log("load skill",pos,smc.player_buffs)
|
||||
node.setPosition(pos.x*scale,pos.y,pos.z)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
const url = 'game/heros/skill';
|
||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = node.getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(smc.skills[uuid].path);
|
||||
});
|
||||
this.skill_init(uuid,node,pos)
|
||||
oops.message.dispatchEvent("cskill_load",this)
|
||||
|
||||
}
|
||||
add_buff(){
|
||||
let pos = v3(0,0,0)
|
||||
for (let index = 0; index < 4; index++) {
|
||||
if(smc.player_buffs[index].eid == 0){
|
||||
pos.x=smc.player_buffs[index].x
|
||||
pos.y=smc.player_buffs[index].y
|
||||
smc.player_buffs[index].eid=this.eid
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
return pos
|
||||
}
|
||||
add_skill(){
|
||||
let pos = v3(0,0,0)
|
||||
for (let index = 4; index < 8; index++) {
|
||||
if(smc.player_buffs[index].eid == 0){
|
||||
pos.x=smc.player_buffs[index].x
|
||||
pos.y=smc.player_buffs[index].y
|
||||
smc.player_buffs[index].eid=this.eid
|
||||
break
|
||||
}
|
||||
}
|
||||
return pos
|
||||
}
|
||||
skill_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(CSkillComp)
|
||||
mv.scale = 1;
|
||||
mv.skill_uuid = uuid;
|
||||
mv.atk=smc.skills[uuid].atk;
|
||||
this.add(mv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** CSkill 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
|
||||
export class EcsCSkillSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// this.add(new ecs.ComblockSystem());
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
import { _decorator,v3,Vec3 ,Label} 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 { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||
import { Skill } from "../skills/Skill";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { BoxSet, GameSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
import { MonModelComp } from "../mon/MonModelComp";
|
||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('CSkillComp')
|
||||
@ecs.register('CSkill', false)
|
||||
export class CSkillComp extends CCComp {
|
||||
//持续时间
|
||||
private sd:Timer = new Timer(5)
|
||||
private cd:Timer = new Timer(1)
|
||||
private is_destroy:boolean = false;
|
||||
time:number = 0;
|
||||
scale:number = 1;
|
||||
speed:number = 0;
|
||||
dis:number = 0;
|
||||
atk:number = 0;
|
||||
skill_uuid:number = 1001;
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
this.sd =new Timer(smc.skills[this.skill_uuid].sd)
|
||||
this.cd = new Timer(smc.skills[this.skill_uuid].cd)
|
||||
this.time =smc.skills[this.skill_uuid].sd
|
||||
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if (this.sd.update(dt)) {
|
||||
if (this.is_destroy) {
|
||||
return
|
||||
}
|
||||
this.to_destroy()
|
||||
}
|
||||
if (this.cd.update(dt)) {
|
||||
this.time -=1
|
||||
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
|
||||
if(smc.skills[this.skill_uuid].type == 1){
|
||||
this.shoot()
|
||||
}
|
||||
if(smc.skills[this.skill_uuid].type > 90){
|
||||
this.add_buff()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
shoot() {
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let pos = v3(0,0)
|
||||
let t_pos = v3(0,0)
|
||||
let angle = 0
|
||||
let m_pos=v3(0,0)
|
||||
let monsters:any = ecs.query(ecs.allOf(MonModelComp));
|
||||
if (monsters.length > 0) {
|
||||
m_pos = monsters[0].MonView.node.position
|
||||
}else{
|
||||
m_pos = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
|
||||
}
|
||||
t_pos = v3(m_pos.x-this.node.position.x,m_pos.y-this.node.position.y) // 目标增量
|
||||
let dx=m_pos.x-this.node.position.x
|
||||
let dy=m_pos.y-this.node.position.y
|
||||
let dir=v3(dx,dy,0)
|
||||
let randian=Math.atan2(dir.y,dir.x)
|
||||
angle = randian * (180 / Math.PI);
|
||||
let scale = this.scale
|
||||
let atk = smc.skills[this.skill_uuid].atk+this.atk;
|
||||
skill.load(pos,scale,this.node,this.skill_uuid,atk,t_pos);
|
||||
}
|
||||
add_buff(){
|
||||
// 1: 远距离攻击,碰撞后 结束
|
||||
// 2: 远距离攻击,碰撞后 持续,直到技能结束
|
||||
// 3: 远距离攻击,碰撞后 持续,带击退功能
|
||||
// 4: 双技能技能,1技能结束后,触发2技能
|
||||
// 5: 特殊技能,触发特殊弹窗选项
|
||||
// 9: buff物品,
|
||||
// 91: 单体buff物品,加最少血,临时
|
||||
// 92:单体buff物品,随机,临时
|
||||
// 93: 群体buff物品
|
||||
// 94:role 临时buff
|
||||
// 95:role 永久buff
|
||||
let uuid= this.skill_uuid;
|
||||
let atk:number=0
|
||||
let args:any = {
|
||||
atk:atk*GameSet.ATK_TO_ATK_RATIO,
|
||||
hp:atk*GameSet.ATK_TO_HP_RATIO,
|
||||
shield:atk*GameSet.ATK_TO_SHIELD_RATIO,
|
||||
}
|
||||
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
|
||||
let least_hp:number=999999
|
||||
let t_hero:any= null
|
||||
if (heros.length > 0) {
|
||||
if(SkillSet[uuid].type==92){ //随机添加buff
|
||||
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
|
||||
this.do_add_buff(heros[i],uuid,args)
|
||||
}else{
|
||||
for (let i = 0; i < heros.length; i++) {
|
||||
let hero = heros[i];
|
||||
if(SkillSet[uuid].type==91){ //血量最少单体
|
||||
if(hero.HeroView.hp < least_hp){
|
||||
least_hp = hero.HeroView.hp
|
||||
t_hero = hero
|
||||
}
|
||||
}else{ //群体
|
||||
this.do_add_buff(hero,uuid,args)
|
||||
}
|
||||
|
||||
}
|
||||
if(t_hero){ //血量最少单体
|
||||
this.do_add_buff(t_hero,uuid,args)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// oops.message.dispatchEvent("add_buff",{uuid:this.skill_uuid,eid:0,group:BoxSet.HERO})
|
||||
}
|
||||
do_add_buff(target:any,uuid:number,args:any) {
|
||||
let buff = SkillSet[uuid]
|
||||
if(buff.hp > 0 ){
|
||||
target.HeroView.add_hp(buff.hp+args.hp)
|
||||
}
|
||||
if(buff.atk > 0 ){
|
||||
target.HeroView.add_atk(buff.atk+args.atk,buff.bsd)
|
||||
}
|
||||
if(buff.shield > 0 ){
|
||||
target.HeroView.add_shield(buff.shield+args.shield,buff.bsd)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
to_destroy() {
|
||||
this.is_destroy = true
|
||||
this.remove_buff()
|
||||
if (this.node.isValid) {
|
||||
this.ent.destroy()
|
||||
}
|
||||
}
|
||||
remove_buff(){
|
||||
for (let index = 0; index < 8; index++) {
|
||||
if(smc.player_buffs[index].eid == this.ent.eid){
|
||||
smc.player_buffs[index].eid=0
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.sd.reset()
|
||||
this.cd.reset()
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
30
assets/script/game/skills/MSkill.ts
Normal file
30
assets/script/game/skills/MSkill.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { instantiate, Prefab } 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";
|
||||
|
||||
/** MSkill 模块 */
|
||||
@ecs.register(`MSkill`)
|
||||
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";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = parent
|
||||
var msc = node.getComponent(MSkillComp)!;
|
||||
this.add(msc)
|
||||
}
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "80aaeefe-a9d9-42da-8086-62a77b582046",
|
||||
"uuid": "10489fd2-88db-4945-a7b2-b9f26aaceab2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
24
assets/script/game/skills/MSkillComp.ts
Normal file
24
assets/script/game/skills/MSkillComp.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { _decorator } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('MSkillComp')
|
||||
@ecs.register('MSkillComp', false)
|
||||
export class MSkillComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
console.log("MSkillComp start");
|
||||
}
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b8d6919d-0a2d-41eb-8c10-5ea684508f48",
|
||||
"uuid": "87082774-5f64-4312-ad72-ea125b4a5826",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
Reference in New Issue
Block a user