添加角色 远程攻击逻辑

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-10-27 02:38:08 +08:00
parent 39dd60bb8d
commit 7e402432dd
199 changed files with 7059 additions and 5 deletions

View File

@@ -20,6 +20,9 @@ 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";
//重写UI
@@ -102,7 +105,9 @@ export class JNGConfig extends SystemBase{
//配置JSON加载
jsons:JsonLoad[] = [
{name:TableGRole.TableName},
{name:TableGRole.TableName}, //角色
{name:TableGRoleAttack.TableName}, //角色攻击
{name:TableGRoleAttackBullet.TableName}, //角色攻击子弹
].map((table) => {
return {
name:table.name,
@@ -124,6 +129,7 @@ export class JNGConfig extends SystemBase{
export class JLoaderRole extends JLoaderSystem{
skData:{[id:number]:sp.SkeletonData} = {};
bullets:{[id:number]:SpriteFrame} = {};
async onInit(): Promise<any> {
await super.onInit();
//将配置表的角色都读取出来
@@ -134,6 +140,15 @@ export class JLoaderRole extends JLoaderSystem{
})
}))
}
//将所有子弹读取出来
for (const info of Object.values(TableGRoleAttackBullet.getAllConfig())) {
this.bullets[info.id] = await (new Promise(r => {
this.bundle.load(info.bulletSrc,SpriteFrame,(err,data) => {
r(data);
})
}))
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "e15c838f-470f-4ed6-8594-6f83fda53554",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,19 @@
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
import GRoleBase from "../role/GRoleBase";
import GAttackNormal from "./GAttackNormal";
import GAttackRemote from "./GAttackRemote";
//攻击方式基类
export class GAttackBase{
attack(role:GRoleBase<{}>,info:TableGRoleAttack){};
}
//攻击方式
export const GAttack:{[key:string]:new () => GAttackBase} = {
["Normal"]:GAttackNormal,
["Remote"]:GAttackRemote,
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "27b49d92-b5a7-4972-9a72-856cbb2daaf3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,13 @@
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
import GRoleBase from "../role/GRoleBase";
import { GAttackBase } from "./GAttack";
//普通攻击
export default class GAttackNormal implements GAttackBase{
attack(role: GRoleBase<{}>, info: TableGRoleAttack) {
role.fsm.enemy.onHit();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "95040d38-b26e-4de8-97c8-9e1ec860843e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,15 @@
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
import { app } from "../../../App";
import GRoleBase from "../role/GRoleBase";
import { GAttackBase } from "./GAttack";
export default class GAttackRemote implements GAttackBase{
attack(role: GRoleBase<{}>, info: TableGRoleAttack): void {
console.log(app.role.bullets[info.attackArgs[0]]);
role.fsm.enemy.onHit();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "565d04ae-ff80-4b3c-ac82-97dfcce552c2",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -10,6 +10,8 @@ import { JEasing, JTween } from "../../../../../extensions/ngame/assets/ngame/sy
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";
const { ccclass, property } = _decorator;
export enum GRoleAnimEvent{
@@ -96,6 +98,7 @@ export default abstract class GRoleBase<T> extends GObject<T>{
bind(role:GRole){
if(this.spine)
this.spine.skeletonData = app.role.skData[role.id];
this.range = role.range; //设置攻击范围
this.role = role;
}
@@ -143,7 +146,8 @@ export default abstract class GRoleBase<T> extends GObject<T>{
//攻击
onAttack(){
//敌人扣血
this.fsm.enemy?.onHit();
let info = TableGRoleAttack.getConfig(this.role.id);
(new GAttack[info.attackWay]()).attack(this,info);
}
//受击

View File

@@ -4,6 +4,7 @@ import GRoleBase from "../base/role/GRoleBase";
//角色实体类
export default interface GRole {
id:number; //宠物Id
range:number; //宠物攻击范围
}
//角色工具类
@@ -24,7 +25,8 @@ export class GRoleUtil{
let info:TableGRole;
if(!(info = TableGRole.getConfig(id))) return null;
return {
id:info.id
id:info.id,
range:info.roleAttackRange,
}
}

View File

@@ -58,7 +58,7 @@ export default class GPVPMode extends GBaseMode<{}>{
//初始化战斗
console.log("GPVPMode 模式初始化");
this.playerInfo = { tactical: GTactical.getTactical(),roles: GRoleUtil.getGRoles([10001,10001,10001,10001,10001]) };
this.playerInfo = { tactical: GTactical.getTactical(),roles: GRoleUtil.getGRoles([10001,10001,10001,10001,10003]) };
this.enemyInfo = { tactical: GTactical.getTactical(true),roles: GRoleUtil.getGRoles([10002,10002,10002,10001,10001]) };
//生成玩家