mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
update 添加松鼠角色
This commit is contained in:
@@ -17,14 +17,15 @@ import GBattleModeManager from "./battle/GBattleModeManager";
|
||||
import { GLayer, UIConfig } from "./ui/UIConfig";
|
||||
import JLoaderSystem from "../../extensions/ngame/assets/ngame/system/JLoaderSystem";
|
||||
import { TableGRole } from "../resources/config/ts/TableGRole";
|
||||
import loader from "../../extensions/ngame/assets/ngame/util/loader";
|
||||
import { Prefab } from "cc";
|
||||
import { sp } from "cc";
|
||||
import { TableGRoleAttack } from "../resources/config/ts/TableGRoleAttack";
|
||||
import { SpriteFrame } from "cc";
|
||||
import { TableGRoleAttackBullet } from "../resources/config/ts/TableGRoleAttackBullet";
|
||||
import { TableGRoleAttackEffect } from "../resources/config/ts/TableGRoleAttackEffect";
|
||||
import { TableGRoleSkill } from "../resources/config/ts/TableGRoleSkill";
|
||||
import { TableGRoleSkillEffect } from "../resources/config/ts/TableGRoleSkillEffect";
|
||||
|
||||
let IP = "192.168.0.126";
|
||||
let IP = "192.168.1.23";
|
||||
|
||||
//重写UI
|
||||
class JNGLayer extends JNLayer{
|
||||
@@ -109,6 +110,9 @@ export class JNGConfig extends SystemBase{
|
||||
{name:TableGRole.TableName}, //角色
|
||||
{name:TableGRoleAttack.TableName}, //角色攻击
|
||||
{name:TableGRoleAttackBullet.TableName}, //角色攻击子弹
|
||||
{name:TableGRoleAttackEffect.TableName}, //角色攻击特效
|
||||
{name:TableGRoleSkill.TableName}, //角色技能
|
||||
{name:TableGRoleSkillEffect.TableName}, //角色技能特效
|
||||
].map((table) => {
|
||||
return {
|
||||
name:table.name,
|
||||
@@ -131,8 +135,11 @@ export class JLoaderRole extends JLoaderSystem{
|
||||
|
||||
skData:{[id:number]:sp.SkeletonData} = {};
|
||||
bullets:{[id:number]:SpriteFrame} = {};
|
||||
effects:{[id:number]:sp.SkeletonData} = {};
|
||||
|
||||
async onInit(): Promise<any> {
|
||||
await super.onInit();
|
||||
|
||||
//将配置表的角色都读取出来
|
||||
for (const info of Object.values(TableGRole.getAllConfig())) {
|
||||
this.skData[info.id] = await (new Promise(r => {
|
||||
@@ -141,6 +148,7 @@ export class JLoaderRole extends JLoaderSystem{
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
//将所有子弹读取出来
|
||||
for (const info of Object.values(TableGRoleAttackBullet.getAllConfig())) {
|
||||
this.bullets[info.id] = await (new Promise(r => {
|
||||
@@ -149,6 +157,24 @@ export class JLoaderRole extends JLoaderSystem{
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
//攻击特效读取
|
||||
for (const info of Object.values(TableGRoleAttackEffect.getAllConfig())) {
|
||||
this.effects[info.id] = await (new Promise(r => {
|
||||
this.bundle.load(info.spine,sp.SkeletonData,(err,data) => {
|
||||
r(data);
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
//技能特效读取
|
||||
for (const info of Object.values(TableGRoleSkillEffect.getAllConfig())) {
|
||||
this.effects[info.id] = await (new Promise(r => {
|
||||
this.bundle.load(info.spine,sp.SkeletonData,(err,data) => {
|
||||
r(data);
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
9
JisolGameCocos/assets/script/GData.ts
Normal file
9
JisolGameCocos/assets/script/GData.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
export const GData = {
|
||||
|
||||
layer: {
|
||||
World: 1,
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "13b542e0-5fa9-4b1d-bfef-8196b3b3ffd6",
|
||||
"uuid": "e04ba6b5-5d91-4424-969a-8faa3dacf167",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -3,6 +3,9 @@ import { app } from './App';
|
||||
import { JNGame } from '../../extensions/ngame/assets/ngame/JNGame';
|
||||
import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction';
|
||||
import { TableGRole } from '../resources/config/ts/TableGRole';
|
||||
import { PhysicsSystem2D } from 'cc';
|
||||
import { EPhysics2DDrawFlags } from 'cc';
|
||||
import { find } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('Main')
|
||||
|
@@ -2,12 +2,14 @@ import { Vec2 } from "cc";
|
||||
import GObject from "./base/GObject";
|
||||
import { v3 } from "cc";
|
||||
import { JNFrameInfo } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
import { Node } from "cc";
|
||||
import { Vec3 } from "cc";
|
||||
|
||||
|
||||
export default class GBaseMode<T> extends GObject<T> {
|
||||
|
||||
//添加对象到场景中
|
||||
addGObject(obj: GObject<{}>,pos?:Vec2){
|
||||
addGObject(obj: GObject<{}>,pos?:Vec2 | Vec3){
|
||||
obj.mode = this;
|
||||
this.node.addChild(obj.node);
|
||||
if(pos){
|
||||
@@ -15,6 +17,14 @@ export default class GBaseMode<T> extends GObject<T> {
|
||||
}
|
||||
}
|
||||
|
||||
//添加Node到场景中
|
||||
addGNode(obj:Node,pos?:Vec2 | Vec3){
|
||||
this.node.addChild(obj);
|
||||
if(pos){
|
||||
obj.setWorldPosition(v3(pos.x,pos.y,0));
|
||||
}
|
||||
}
|
||||
|
||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T) {
|
||||
|
||||
//重置 场景中的层级
|
||||
|
@@ -2,7 +2,7 @@ import { Node } from "cc";
|
||||
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
|
||||
import GRoleBase from "../role/GRoleBase";
|
||||
import GAttackNormal from "./GAttackNormal";
|
||||
import GAttackParabolicRemote from "./GAttackParabolicRemote";
|
||||
import GAttackParabolicBangRemote from "./GAttackParabolicBangRemote";
|
||||
import { UITransform } from "cc";
|
||||
import GButtleBase from "../bullet/GButtleBase";
|
||||
|
||||
@@ -21,13 +21,13 @@ export class GAttackBullet{
|
||||
}
|
||||
|
||||
//攻击方式基类
|
||||
export class GAttackBase{
|
||||
attack(role:GRoleBase<{}>,info:TableGRoleAttack){};
|
||||
export interface GAttackBase{
|
||||
attack(role:GRoleBase<{}>,info:TableGRoleAttack);
|
||||
}
|
||||
|
||||
//攻击方式
|
||||
export const GAttack:{[key:string]:(new () => GAttackBase)} = {
|
||||
["Normal"]:GAttackNormal,
|
||||
["ParabolicRemote"]:GAttackParabolicRemote,
|
||||
["ParabolicBangRemote"]:GAttackParabolicBangRemote,
|
||||
}
|
||||
|
||||
|
@@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
export default class GAttackBullet {
|
||||
|
||||
//创建子弹
|
||||
static create(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -8,20 +8,40 @@ import { v3 } from "cc";
|
||||
import { bezier } from "cc";
|
||||
import { v2 } from "cc";
|
||||
import { Vec2 } from "cc";
|
||||
import { sp } from "cc";
|
||||
import GEffectUtil from "../../effect/GEffectUtil";
|
||||
import { TableGRoleAttackEffect } from "../../../../resources/config/ts/TableGRoleAttackEffect";
|
||||
import GDetection from "../common/GDetection";
|
||||
import { rect } from "cc";
|
||||
import { UITransform } from "cc";
|
||||
import { BoxCollider2D } from "cc";
|
||||
/**
|
||||
* 抛物线普攻
|
||||
* 攻击子弹,子弹大小,龙骨-初始位置
|
||||
* 抛物线 爆炸普攻
|
||||
* 攻击子弹,爆炸特效,龙骨-初始位置,子弹大小
|
||||
*/
|
||||
export default class GAttackParabolicRemote implements GAttackBase{
|
||||
|
||||
attack(role: GRoleBase<{}>, info: TableGRoleAttack): void {
|
||||
|
||||
let enemy = role.fsm.enemy;
|
||||
if(!enemy) return;
|
||||
|
||||
//[子弹图片]
|
||||
let image:SpriteFrame = app.role.bullets[info.attackArgs[0]];
|
||||
let scale:number = info.attackArgs[1] as unknown as number;
|
||||
let bang = {
|
||||
ske: app.role.effects[info.attackArgs[1]],
|
||||
info: TableGRoleAttackEffect.getConfig(info.attackArgs[1])
|
||||
};
|
||||
let bone = role.spine.findBone(info.attackArgs[2]);
|
||||
let scale:number = parseFloat(info.attackArgs[3]);
|
||||
let aw = parseFloat(info.attackArgs[4]);
|
||||
let ah = parseFloat(info.attackArgs[5]);
|
||||
|
||||
if(!image || !bone || !scale || !bang|| !aw|| !ah) {
|
||||
console.warn("GAttackParabolicRemote ERROR",image,bone,scale,bang);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(role.spine,bone);
|
||||
let bullet = GAttackBullet.create(GButtleDefault,{
|
||||
image:image,
|
||||
@@ -48,8 +68,21 @@ export default class GAttackParabolicRemote implements GAttackBase{
|
||||
))
|
||||
})
|
||||
.onComplete(() => {
|
||||
enemy.onHit();
|
||||
bullet.node.removeFromParent();
|
||||
|
||||
//生成爆炸特效
|
||||
let effect = GEffectUtil.create(bang.ske);
|
||||
role.mode.addGNode(effect.node,bullet.node.worldPosition);
|
||||
//获取默认动画
|
||||
effect.setAnimation(0,bang.info.animation,false);
|
||||
//销毁
|
||||
bullet.node.destroy();
|
||||
|
||||
// enemy.getComponent(BoxCollider2D).apply();
|
||||
|
||||
// console.log(enemy.v2World,enemy.getComponent(BoxCollider2D).worldPoints,enemy.getComponent(UITransform).getBoundingBoxToWorld());
|
||||
GDetection.testAABBRole(rect(effect.node.worldPosition.x,effect.node.worldPosition.y,aw,ah)).forEach(role =>{
|
||||
role.onHit();
|
||||
});
|
||||
})
|
||||
.start();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "04262003-45a4-4d9d-a1d3-83c11146c891",
|
||||
"uuid": "f4c29cde-2ca3-452d-ad3e-3d6376f2bd6c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -7,6 +7,7 @@ import { size } from "cc";
|
||||
import { Size } from "cc";
|
||||
import { v3 } from "cc";
|
||||
import { Vec2 } from "cc";
|
||||
import { GData } from "../../../GData";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export interface GButtleDefaultInfo{
|
||||
@@ -19,7 +20,7 @@ export interface GButtleDefaultInfo{
|
||||
export default class GButtleDefault extends GButtleBase<GButtleDefaultInfo>{
|
||||
|
||||
setData(info:GButtleDefaultInfo){
|
||||
this.node.layer = 1;
|
||||
this.node.layer = GData.layer.World;
|
||||
this.node.addComponent(Sprite).spriteFrame = info.image;
|
||||
this.node.scale = v3(info.scale,info.scale,0);
|
||||
}
|
||||
|
9
JisolGameCocos/assets/script/battle/base/common.meta
Normal file
9
JisolGameCocos/assets/script/battle/base/common.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "651f7991-f580-4d09-a013-54c78bf46740",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
import { math } from "cc";
|
||||
import { PhysicsSystem2D } from "cc";
|
||||
import GRoleBase from "../role/GRoleBase";
|
||||
import { Vec2 } from "cc";
|
||||
|
||||
|
||||
//检测工具类
|
||||
export default class GDetection{
|
||||
|
||||
//检测角色
|
||||
static testAABBRole(rect:math.Rect):GRoleBase<{}>[]{
|
||||
//@ts-ignore
|
||||
return PhysicsSystem2D.instance.testAABB(rect).map(item => item.getComponent(GRoleBase<any>));
|
||||
}
|
||||
//检测角色
|
||||
static testPointRole(pos:Vec2){
|
||||
//@ts-ignore
|
||||
console.log(PhysicsSystem2D.instance.testPoint(pos));
|
||||
}
|
||||
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "8c684f5a-84b5-4ea1-92d3-c0b70461970c",
|
||||
"uuid": "a2cdfca5-479c-4e51-9245-29dd3626cbc2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
63
JisolGameCocos/assets/script/battle/base/common/GSpine.ts
Normal file
63
JisolGameCocos/assets/script/battle/base/common/GSpine.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { sp } from "cc";
|
||||
import GRoleBase from "../role/GRoleBase";
|
||||
import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
|
||||
import { Node } from "cc";
|
||||
import GBaseMode from "../../GBaseMode";
|
||||
import { Vec2 } from "cc";
|
||||
|
||||
|
||||
//Spine 工具
|
||||
export default class GSpine{
|
||||
|
||||
//保存当前Spine 播放新 Spine 结束后还原
|
||||
static onPlayAnotherSpine(role:GRoleBase<{}>,spine:sp.SkeletonData,play:string,fun:{
|
||||
start?:(ske:JNSkeleton) => void,
|
||||
end?:() => void,
|
||||
} = {}):JNSkeleton{
|
||||
|
||||
//关闭当前角色原本的Spine
|
||||
role.spine.enabled = false;
|
||||
//添加新的spine
|
||||
let spineNode = new Node();
|
||||
role.node.addChild(spineNode);
|
||||
let another = spineNode.addComponent(JNSkeleton);
|
||||
another.skeletonData = spine;
|
||||
fun.start && fun.start(another);
|
||||
another.setCompleteListener(() => {
|
||||
//还原
|
||||
role.spine.enabled = true;
|
||||
spineNode.destroy();
|
||||
fun.end && fun.end();
|
||||
});
|
||||
another.setAnimation(0,play,false);
|
||||
// another.setAnimation(0,play,false);
|
||||
return another;
|
||||
|
||||
}
|
||||
|
||||
//创建一个Spine
|
||||
static onCreateSpine(spine:sp.SkeletonData):JNSkeleton{
|
||||
|
||||
let spineNode = new Node();
|
||||
let another = spineNode.addComponent(JNSkeleton);
|
||||
another.premultipliedAlpha = false;
|
||||
another.skeletonData = spine;
|
||||
return another;
|
||||
|
||||
}
|
||||
|
||||
// 创建一个 Spine 并且 播放 销毁
|
||||
static onPlaySceneSpine(scene:GBaseMode<{}>,pos:Vec2,spine:sp.SkeletonData,play:string):JNSkeleton{
|
||||
|
||||
let create = this.onCreateSpine(spine);
|
||||
scene.addGNode(create.node,pos);
|
||||
create.setCompleteListener(() => {
|
||||
//销毁
|
||||
create.node.destroy();
|
||||
});
|
||||
create.setAnimation(0,play);
|
||||
return create;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ded09977-91f1-4932-aba7-c9c5d8489859",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -14,6 +14,8 @@ enum ProcessEnum {
|
||||
AttackEnemy = 2,
|
||||
//回阵型
|
||||
MoveToTactical = 3,
|
||||
//释放技能
|
||||
ReleaseSkills = 4,
|
||||
}
|
||||
|
||||
export default abstract class GFSMBattle extends GFSMBase{
|
||||
@@ -51,13 +53,19 @@ export default abstract class GFSMBattle extends GFSMBase{
|
||||
title:"攻击敌人",
|
||||
mode:GFSMProcessMode.WaitExecute,
|
||||
execute: this.onAttackProcess.bind(this),
|
||||
to:[ProcessEnum.SeekEnemy],//移动回阵型
|
||||
to:[ProcessEnum.SeekEnemy,ProcessEnum.ReleaseSkills],//移动回阵型 释放技能
|
||||
},
|
||||
[ProcessEnum.MoveToTactical]:{
|
||||
title:"移动回阵型",
|
||||
mode:GFSMProcessMode.WaitExecute,
|
||||
execute: this.onMoveToTacticalProcess.bind(this),
|
||||
to:[ProcessEnum.SeekEnemy],//移动回阵型
|
||||
},
|
||||
[ProcessEnum.ReleaseSkills]:{
|
||||
title:"释放技能",
|
||||
mode:GFSMProcessMode.WaitExecute,
|
||||
execute: this.onReleaseSkillsProcess.bind(this),
|
||||
to:[ProcessEnum.AttackEnemy],//继续攻击
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,12 +149,24 @@ export default abstract class GFSMBattle extends GFSMBase{
|
||||
this.player.fsmAnim.isAttack = true;
|
||||
//如果有敌人则攻击 没有 则 重置
|
||||
if(this.enemy){
|
||||
// if(){
|
||||
// //如果可以释放大招
|
||||
// }else{
|
||||
// //不可以则普攻
|
||||
//朝向敌人
|
||||
this.player.onTowardsTarget(this.enemy);
|
||||
return GFSMProcessEnum.Wait;
|
||||
// }
|
||||
}else{
|
||||
return ProcessEnum.SeekEnemy;
|
||||
}
|
||||
}
|
||||
|
||||
//释放技能
|
||||
onReleaseSkillsProcess(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -8,11 +8,13 @@ import { v3 } from "cc";
|
||||
import { GTactical } from "../../entity/GTactical";
|
||||
import { JEasing, JTween } from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/tween/JNFrameTween";
|
||||
import { v2 } from "cc";
|
||||
import GRole from "../../entity/GRole";
|
||||
import { app } from "../../../App";
|
||||
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
|
||||
import { GAttack, GAttackBase } from "../attack/GAttack";
|
||||
import { GRoleType } from "./GRoleType";
|
||||
import { TableGRole } from "../../../../resources/config/ts/TableGRole";
|
||||
import { TableGRoleSkill } from "../../../../resources/config/ts/TableGRoleSkill";
|
||||
import { GSkill, GSkillBase } from "../../skill/GSkill";
|
||||
import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum GRoleAnimEvent{
|
||||
@@ -22,14 +24,17 @@ export enum GRoleAnimEvent{
|
||||
//角色基类
|
||||
export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
@property(sp.Skeleton)
|
||||
spine:sp.Skeleton;
|
||||
@property(JNSkeleton)
|
||||
spine:JNSkeleton;
|
||||
|
||||
//角色
|
||||
role:GRole
|
||||
role:TableGRole
|
||||
|
||||
//角色技能
|
||||
skills:GSkillBase[] = [];
|
||||
|
||||
//角色类型
|
||||
type:GRoleType;
|
||||
type:number;
|
||||
|
||||
//状态机
|
||||
fsm:GFSMBattle;
|
||||
@@ -61,10 +66,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
blood:number = 100;
|
||||
fullBlood:number = 100;
|
||||
|
||||
//能量
|
||||
energy:number = 0;
|
||||
fullEnergy:number = 100;
|
||||
|
||||
//是否死亡
|
||||
_isDie:boolean = false;
|
||||
get isDie(){ return this._isDie}
|
||||
@@ -81,14 +82,14 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
onSyncLoad(){
|
||||
|
||||
if(!this.spine) this.spine = this.node.getComponent(sp.Skeleton);
|
||||
if(!this.spine) this.spine = this.node.getComponent(JNSkeleton);
|
||||
//如果没有生成则直接销毁
|
||||
if(!this.spine) {
|
||||
this.node.removeFromParent();
|
||||
this.node.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
this.spine.debugBones = true;
|
||||
// this.spine.debugBones = true;
|
||||
|
||||
this.bind(this.role);
|
||||
|
||||
@@ -105,11 +106,18 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
}
|
||||
|
||||
//设置角色
|
||||
bind(role:GRole){
|
||||
bind(role:TableGRole){
|
||||
if(this.spine)
|
||||
this.spine.skeletonData = app.role.skData[role.id];
|
||||
this.range = role.range; //设置攻击范围
|
||||
this.role = role;
|
||||
|
||||
this.range = role.roleAttackRange; //设置攻击范围
|
||||
this.role = role; //设置角色
|
||||
|
||||
// 设置技能
|
||||
this.skills = role.roleSkillIds.map(skillId => {
|
||||
let info = TableGRoleSkill.getConfig(skillId);
|
||||
return (new GSkill[info.skillController]()).bind(this,info);
|
||||
})
|
||||
}
|
||||
|
||||
//创建一个状态机
|
||||
@@ -123,6 +131,10 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
this.fsm && this.fsm.onUpdate(dt / 1000);
|
||||
this.fsmAnim && this.fsmAnim.onUpdate(dt / 1000);
|
||||
|
||||
if(frame.index == 100){
|
||||
this.skills[0] && this.skills[0].release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//向目标点移动
|
||||
@@ -153,18 +165,55 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
}
|
||||
|
||||
//朝向目标
|
||||
onTowardsTarget(role:GRoleBase<{}>){
|
||||
//获取两个坐标差值向量
|
||||
let normal = this.v2World.subtract(role.v2World).normalize();
|
||||
//设置朝向
|
||||
if(normal.x != 0){
|
||||
if(normal.x < 0){
|
||||
this.setTowards(GTowards.RIGHT)
|
||||
}else{
|
||||
this.setTowards(GTowards.LEFT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//攻击
|
||||
onAttack(){
|
||||
//敌人扣血
|
||||
let info = TableGRoleAttack.getConfig(this.role.id);
|
||||
(new GAttack[info.attackWay]()).attack(this,info);
|
||||
}
|
||||
|
||||
//释放技能 每一次只能释放一次
|
||||
onSkill():boolean{
|
||||
|
||||
for (const item of this.skills) {
|
||||
if(item.isRelease()){
|
||||
//如果可以释放则释放
|
||||
item.release();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
//每一次攻击 则 增加能量条
|
||||
this.energy += 10;
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(){
|
||||
// return;
|
||||
this.blood -= 10;
|
||||
//检测是否死亡
|
||||
if(this.blood <= 0){
|
||||
//关闭状态机
|
||||
this.fsm.close();
|
||||
//设置死亡
|
||||
this.isDie = true;
|
||||
}
|
||||
}
|
||||
|
||||
onDebugHit(){
|
||||
this.blood -= 10;
|
||||
//检测是否死亡
|
||||
if(this.blood <= 0){
|
||||
@@ -198,6 +247,11 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
this.setTowards(this.tactical.towards);
|
||||
}
|
||||
|
||||
//过滤敌人
|
||||
filterEnemy(roles:GRoleBase<{}>[] = []){
|
||||
return roles.filter(role => role.type != this.type);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,8 +0,0 @@
|
||||
|
||||
//角色类型
|
||||
export enum GRoleType{
|
||||
PLAYER = "PLAYER",
|
||||
ENMEY = "ENMEY",
|
||||
PVP1 = "PVP1",
|
||||
PVP2 = "PVP2",
|
||||
}
|
@@ -51,7 +51,6 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
|
||||
|
||||
//更新显示
|
||||
this.bloodVolume.progress = this.blood / this.fullBlood;
|
||||
this.energyVolume.progress = this.energy / this.fullBlood;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +75,6 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
|
||||
if(this.isDie){
|
||||
//销毁数据
|
||||
this.mode.killRole(this);
|
||||
// this.node.removeFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
|
9
JisolGameCocos/assets/script/battle/effect.meta
Normal file
9
JisolGameCocos/assets/script/battle/effect.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "82abb7d2-2e71-4d33-9853-644778b2abc3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
22
JisolGameCocos/assets/script/battle/effect/GEffectUtil.ts
Normal file
22
JisolGameCocos/assets/script/battle/effect/GEffectUtil.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { UITransform } from "cc";
|
||||
import { Node } from "cc";
|
||||
import { sp } from "cc";
|
||||
import JNSkeleton from "../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
|
||||
import { GData } from "../../GData";
|
||||
|
||||
export default class GEffectUtil {
|
||||
|
||||
//创建一个Spine特效
|
||||
static create(spine:sp.SkeletonData):JNSkeleton{
|
||||
let effectNode = new Node();
|
||||
effectNode.layer = GData.layer.World;
|
||||
effectNode.addComponent(UITransform);
|
||||
let ske = effectNode.addComponent(JNSkeleton);
|
||||
ske.skeletonData = spine;
|
||||
ske.premultipliedAlpha = false;
|
||||
return ske;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2935c359-6cdd-4449-adae-57fc390c9e45",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,12 +1,6 @@
|
||||
import { TableGRole } from "../../../resources/config/ts/TableGRole";
|
||||
import GRoleBase from "../base/role/GRoleBase";
|
||||
|
||||
//角色实体类
|
||||
export default interface GRole {
|
||||
id:number; //宠物Id
|
||||
range:number; //宠物攻击范围
|
||||
}
|
||||
|
||||
//角色工具类
|
||||
export class GRoleUtil{
|
||||
|
||||
@@ -21,16 +15,13 @@ export class GRoleUtil{
|
||||
}
|
||||
|
||||
//通过Id 获取 GRole
|
||||
static getGRole(id:number):GRole{
|
||||
static getGRole(id:number):TableGRole{
|
||||
let info:TableGRole;
|
||||
if(!(info = TableGRole.getConfig(id))) return null;
|
||||
return {
|
||||
id:info.id,
|
||||
range:info.roleAttackRange,
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
static getGRoles(ids:number[]):GRole[]{
|
||||
static getGRoles(ids:number[]):TableGRole[]{
|
||||
return ids.map(id => GRoleUtil.getGRole(id));
|
||||
}
|
||||
|
||||
|
@@ -5,11 +5,10 @@ import { Prefab } from "cc";
|
||||
import { instantiate } from "cc";
|
||||
import { Vec2 } from "cc";
|
||||
import GRolePVPEntity from "../base/role/PVP/GRolePVPEntity";
|
||||
import GRole, { GRoleUtil } from "../entity/GRole";
|
||||
import { GRoleUtil } from "../entity/GRole";
|
||||
import { TableGRole } from "../../../resources/config/ts/TableGRole";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
|
||||
//PVP 角色
|
||||
export enum GPVPModePlayerEnum{
|
||||
PLAYER, //玩家
|
||||
@@ -21,7 +20,7 @@ export interface GPVPModePlayerInfo{
|
||||
//阵法
|
||||
tactical: GTactical;
|
||||
//宠物列表
|
||||
roles: GRole[];
|
||||
roles: TableGRole[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,6 +53,7 @@ export default class GPVPMode extends GBaseMode<{}>{
|
||||
|
||||
|
||||
onSyncInitSuccess(): void {
|
||||
|
||||
|
||||
//初始化战斗
|
||||
console.log("GPVPMode 模式初始化");
|
||||
@@ -68,12 +68,14 @@ export default class GPVPMode extends GBaseMode<{}>{
|
||||
}
|
||||
|
||||
//生成角色
|
||||
onGenRole(type: GPVPModePlayerEnum,index:number,info:GRole) {
|
||||
onGenRole(type: GPVPModePlayerEnum,index:number,info:TableGRole) {
|
||||
|
||||
let pos:Vec2 = this.getInfo(type).tactical.getPosition(index);
|
||||
if(!pos) return;
|
||||
let role = instantiate(this.rolePrefab);
|
||||
let entity = role.getComponent(GRolePVPEntity)
|
||||
let entity = role.getComponent(GRolePVPEntity);
|
||||
//绑定角色
|
||||
entity.type = type;
|
||||
entity.bind(info);
|
||||
//赋值阵容
|
||||
entity.ones = type;
|
||||
|
9
JisolGameCocos/assets/script/battle/skill.meta
Normal file
9
JisolGameCocos/assets/script/battle/skill.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "b1c11eec-4d48-457d-a683-ab9ca5405212",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
34
JisolGameCocos/assets/script/battle/skill/GSkill.ts
Normal file
34
JisolGameCocos/assets/script/battle/skill/GSkill.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { TableGRoleSkill } from "../../../resources/config/ts/TableGRoleSkill";
|
||||
import GRoleBase from "../base/role/GRoleBase";
|
||||
import GSkillCrazySquirrel from "./RoleSkill/GSkillCrazySquirrel";
|
||||
|
||||
//技能状态
|
||||
export enum GSkillState{
|
||||
NoRelease,//不可释放
|
||||
Releasable,//可释放
|
||||
Releasing,//释放中
|
||||
}
|
||||
|
||||
//技能基类
|
||||
export interface GSkillBase {
|
||||
|
||||
//设置
|
||||
bind(role:GRoleBase<{}>,info:TableGRoleSkill):GSkillBase;
|
||||
|
||||
//是否允许释放
|
||||
isRelease():boolean;
|
||||
|
||||
//释放技能
|
||||
release():boolean;
|
||||
|
||||
//技能状态
|
||||
state():GSkillState;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//技能方式
|
||||
export const GSkill:{[key:string]:(new () => GSkillBase)} = {
|
||||
["GSkillCrazySquirrel"]:GSkillCrazySquirrel,
|
||||
}
|
||||
|
9
JisolGameCocos/assets/script/battle/skill/GSkill.ts.meta
Normal file
9
JisolGameCocos/assets/script/battle/skill/GSkill.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a6992aa4-aa31-41b3-aa5f-42487e417816",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
39
JisolGameCocos/assets/script/battle/skill/GSkillCDBase.ts
Normal file
39
JisolGameCocos/assets/script/battle/skill/GSkillCDBase.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { TableGRoleSkill } from "../../../resources/config/ts/TableGRoleSkill";
|
||||
import GRoleBase from "../base/role/GRoleBase";
|
||||
import { GSkillBase, GSkillState } from "./GSkill";
|
||||
|
||||
|
||||
//冷却技能基类 用于多长时间释放技能
|
||||
export default abstract class GSkillCDBase implements GSkillBase {
|
||||
|
||||
//冷却总时间
|
||||
cdTatal:number;
|
||||
//冷却时间
|
||||
cdTime:number;
|
||||
|
||||
bind(role:GRoleBase<{}>,info: TableGRoleSkill):GSkillCDBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
isRelease(): boolean {
|
||||
//冷却时间小于等于0可释放
|
||||
return this.cdTime <= 0;
|
||||
}
|
||||
|
||||
//释放技能
|
||||
release():boolean {
|
||||
// //是否可以释放技能
|
||||
// if(!this.isRelease()) return false;
|
||||
return this.onRelease();
|
||||
}
|
||||
|
||||
//子类实现释放
|
||||
abstract onRelease():boolean;
|
||||
|
||||
state(): GSkillState {
|
||||
if(this.isRelease())
|
||||
return GSkillState.Releasing
|
||||
else
|
||||
return GSkillState.NoRelease
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0f31e7c8-c018-4c3d-ab0c-ad0c759e4eb1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
9
JisolGameCocos/assets/script/battle/skill/RoleSkill.meta
Normal file
9
JisolGameCocos/assets/script/battle/skill/RoleSkill.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "74dac201-dfda-47ca-b0b1-414c217fa163",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
import { v2 } from "cc";
|
||||
import { JTween } from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/tween/JNFrameTween";
|
||||
import { TableGRoleSkill } from "../../../../resources/config/ts/TableGRoleSkill";
|
||||
import { app } from "../../../App";
|
||||
import GSpine from "../../base/common/GSpine";
|
||||
import GRoleBase from "../../base/role/GRoleBase";
|
||||
import GSkillCDBase from "../GSkillCDBase";
|
||||
import { v3 } from "cc";
|
||||
import GBaseMode from "../../GBaseMode";
|
||||
import GDetection from "../../base/common/GDetection";
|
||||
import { rect } from "cc";
|
||||
|
||||
/**
|
||||
* 疯狂松鼠技能
|
||||
* 参数:[技能冷却]
|
||||
*/
|
||||
export default class GSkillCrazySquirrel extends GSkillCDBase{
|
||||
|
||||
role:GRoleBase<{}>;
|
||||
info: TableGRoleSkill;
|
||||
|
||||
bind(role:GRoleBase<{}>,info: TableGRoleSkill):GSkillCrazySquirrel {
|
||||
|
||||
//技能冷却
|
||||
this.cdTatal = parseInt(info.skillArgs[0]);
|
||||
this.role = role;
|
||||
this.info = info;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
onRelease(): boolean {
|
||||
|
||||
//获取敌人位置
|
||||
let enemy = this.role.fsm.enemy;
|
||||
let scene:GBaseMode<{}> = this.role.mode;
|
||||
if(!enemy) return false;
|
||||
|
||||
let aw = parseInt(this.info.skillArgs[1]);
|
||||
let ah = parseInt(this.info.skillArgs[2]);
|
||||
|
||||
//出现松鼠丢炸弹
|
||||
GSpine.onPlayAnotherSpine(this.role,app.role.effects[50001],"skill",{
|
||||
end:() => {
|
||||
//从天而降
|
||||
let pos = enemy.v2World.add(v2(0,1000));
|
||||
let end = enemy.v2World;
|
||||
|
||||
//生成火球
|
||||
let spine = GSpine.onCreateSpine(app.role.effects[50002]);
|
||||
this.role.mode.addGNode(spine.node,pos);
|
||||
spine.setAnimation(0,"animation",true);
|
||||
spine.node.angle = 90;
|
||||
JTween(pos)
|
||||
.to(end,600)
|
||||
.onUpdate(pos => {
|
||||
spine.node.worldPosition = v3(pos.x,pos.y,0);
|
||||
})
|
||||
.onComplete(() => {
|
||||
let world = spine.node.worldPosition;
|
||||
spine.node.destroy();
|
||||
GSpine.onPlaySceneSpine(scene,v2(world.x,world.y),app.role.effects[50003],"animation");
|
||||
console.log(GDetection.testAABBRole(rect(world.x,world.y,aw,ah)).length)
|
||||
GDetection.testAABBRole(rect(world.x,world.y,aw,ah)).forEach(role =>{
|
||||
role.onHit();
|
||||
});
|
||||
})
|
||||
.start();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7d3fd1cc-d849-4139-8926-689129416a29",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user