mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
添加角色 远程攻击逻辑
This commit is contained in:
9
JisolGameCocos/assets/script/battle/base/attack.meta
Normal file
9
JisolGameCocos/assets/script/battle/base/attack.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "e15c838f-470f-4ed6-8594-6f83fda53554",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
19
JisolGameCocos/assets/script/battle/base/attack/GAttack.ts
Normal file
19
JisolGameCocos/assets/script/battle/base/attack/GAttack.ts
Normal 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,
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "27b49d92-b5a7-4972-9a72-856cbb2daaf3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "95040d38-b26e-4de8-97c8-9e1ec860843e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "565d04ae-ff80-4b3c-ac82-97dfcce552c2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
//受击
|
||||
|
Reference in New Issue
Block a user