This commit is contained in:
DESKTOP-5RP3AKU\Jisol 2023-10-25 02:31:51 +08:00
parent ee259880b0
commit 08a486c828
18 changed files with 533 additions and 123 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "91200219-cf2f-4928-b01a-a3de1f556a1e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,62 +1,62 @@
guaiA1a.png guaiA1a.png
size: 512,128 size: 146,288
format: RGBA8888 format: RGBA8888
filter: Linear,Linear filter: Linear,Linear
repeat: none repeat: none
guaiA1a/beimian guaiA1a/beimian
rotate: false rotate: false
xy: 2, 2 xy: 2, 173
size: 125, 115 size: 123, 113
orig: 125, 115 orig: 125, 115
offset: 0, 0 offset: 1, 1
index: -1 index: -1
guaiA1a/jiao1 guaiA1a/jiao1
rotate: false rotate: true
xy: 161, 11 xy: 110, 3
size: 29, 34 size: 27, 32
orig: 29, 34 orig: 29, 34
offset: 0, 0 offset: 1, 1
index: -1 index: -1
guaiA1a/jiao2 guaiA1a/jiao2
rotate: false rotate: true
xy: 129, 8 xy: 73, 2
size: 30, 37 size: 28, 35
orig: 30, 37 orig: 30, 37
offset: 0, 0 offset: 1, 1
index: -1 index: -1
guaiA1a/jiao3 guaiA1a/jiao3
rotate: false rotate: true
xy: 358, 63 xy: 88, 32
size: 71, 54 size: 69, 51
orig: 71, 54 orig: 71, 54
offset: 0, 0 offset: 1, 1
index: -1 index: -1
guaiA1a/jiao4 guaiA1a/jiao4
rotate: false rotate: false
xy: 431, 63 xy: 2, 2
size: 71, 54 size: 69, 51
orig: 71, 54 orig: 71, 54
offset: 0, 0 offset: 1, 1
index: -1 index: -1
guaiA1a/shenti guaiA1a/shenti
rotate: false rotate: false
xy: 129, 47 xy: 2, 103
size: 139, 70 size: 137, 68
orig: 139, 70 orig: 139, 70
offset: 0, 0 offset: 1, 1
index: -1 index: -1
guaiA1a/yan guaiA1a/yan
rotate: false rotate: true
xy: 270, 48 xy: 127, 245
size: 43, 19 size: 41, 17
orig: 43, 19 orig: 43, 19
offset: 0, 0 offset: 1, 1
index: -1 index: -1
guaiA1a/ye guaiA1a/ye
rotate: false rotate: false
xy: 270, 69 xy: 2, 55
size: 86, 48 size: 84, 46
orig: 86, 48 orig: 86, 48
offset: 0, 0 offset: 1, 1
index: -1 index: -1

View File

@ -2,7 +2,7 @@
"ver": "1.0.1", "ver": "1.0.1",
"importer": "*", "importer": "*",
"imported": true, "imported": true,
"uuid": "73de6ac4-0559-42d0-b426-1f0c681fd5ab", "uuid": "9eb72656-748d-4794-8dac-4b7299e6cd39",
"files": [ "files": [
".atlas", ".atlas",
".json" ".json"

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
"ver": "1.2.6", "ver": "1.2.6",
"importer": "spine-data", "importer": "spine-data",
"imported": true, "imported": true,
"uuid": "c1cb94d4-afaf-4205-97ba-8896abcb7ec1", "uuid": "42029fae-0ee0-48c1-b7c5-850c03664ae4",
"files": [ "files": [
".json" ".json"
], ],

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -2,7 +2,7 @@
"ver": "1.0.26", "ver": "1.0.26",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "d749e084-5bd8-4c0c-877b-6e488137649d", "uuid": "2357c44f-3cf0-47eb-8f7a-0f303eaefe08",
"files": [ "files": [
".json", ".json",
".png" ".png"
@ -10,14 +10,14 @@
"subMetas": { "subMetas": {
"6c48a": { "6c48a": {
"importer": "texture", "importer": "texture",
"uuid": "d749e084-5bd8-4c0c-877b-6e488137649d@6c48a", "uuid": "2357c44f-3cf0-47eb-8f7a-0f303eaefe08@6c48a",
"displayName": "guaiA1a", "displayName": "guaiA1a",
"id": "6c48a", "id": "6c48a",
"name": "texture", "name": "texture",
"userData": { "userData": {
"wrapModeS": "clamp-to-edge", "wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge", "wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "d749e084-5bd8-4c0c-877b-6e488137649d", "imageUuidOrDatabaseUri": "2357c44f-3cf0-47eb-8f7a-0f303eaefe08",
"isUuid": true, "isUuid": true,
"visible": false, "visible": false,
"minfilter": "linear", "minfilter": "linear",
@ -34,7 +34,7 @@
}, },
"f9941": { "f9941": {
"importer": "sprite-frame", "importer": "sprite-frame",
"uuid": "d749e084-5bd8-4c0c-877b-6e488137649d@f9941", "uuid": "2357c44f-3cf0-47eb-8f7a-0f303eaefe08@f9941",
"displayName": "guaiA1a", "displayName": "guaiA1a",
"id": "f9941", "id": "f9941",
"name": "spriteFrame", "name": "spriteFrame",
@ -42,14 +42,14 @@
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
"offsetX": -4, "offsetX": 0,
"offsetY": 4.5, "offsetY": 0,
"trimX": 3, "trimX": 2,
"trimY": 3, "trimY": 2,
"width": 498, "width": 142,
"height": 113, "height": 284,
"rawWidth": 512, "rawWidth": 146,
"rawHeight": 128, "rawHeight": 288,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
@ -61,17 +61,17 @@
"meshType": 0, "meshType": 0,
"vertices": { "vertices": {
"rawPosition": [ "rawPosition": [
-249, -71,
-56.5, -142,
0, 0,
249, 71,
-56.5, -142,
0, 0,
-249, -71,
56.5, 142,
0, 0,
249, 71,
56.5, 142,
0 0
], ],
"indexes": [ "indexes": [
@ -83,38 +83,38 @@
3 3
], ],
"uv": [ "uv": [
3, 2,
125, 286,
501, 144,
125, 286,
3, 2,
12, 2,
501, 144,
12 2
], ],
"nuv": [ "nuv": [
0.005859375, 0.0136986301369863,
0.09375, 0.006944444444444444,
0.978515625, 0.9863013698630136,
0.09375, 0.006944444444444444,
0.005859375, 0.0136986301369863,
0.9765625, 0.9930555555555556,
0.978515625, 0.9863013698630136,
0.9765625 0.9930555555555556
], ],
"minPos": [ "minPos": [
-249, -71,
-56.5, -142,
0 0
], ],
"maxPos": [ "maxPos": [
249, 71,
56.5, 142,
0 0
] ]
}, },
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "d749e084-5bd8-4c0c-877b-6e488137649d@6c48a", "imageUuidOrDatabaseUri": "2357c44f-3cf0-47eb-8f7a-0f303eaefe08@6c48a",
"atlasUuid": "" "atlasUuid": ""
}, },
"ver": "1.0.12", "ver": "1.0.12",
@ -129,6 +129,6 @@
"type": "sprite-frame", "type": "sprite-frame",
"hasAlpha": true, "hasAlpha": true,
"fixAlphaTransparencyArtifacts": false, "fixAlphaTransparencyArtifacts": false,
"redirect": "d749e084-5bd8-4c0c-877b-6e488137649d@f9941" "redirect": "2357c44f-3cf0-47eb-8f7a-0f303eaefe08@f9941"
} }
} }

View File

@ -17,12 +17,123 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": null, "_parent": null,
"_children": [], "_children": [
{
"__id__": 2
}
],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 2 "__id__": 16
}, },
{
"__id__": 18
},
{
"__id__": 20
}
],
"_prefab": {
"__id__": 22
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "blood",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
}
],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 11
},
{
"__id__": 13
}
],
"_prefab": {
"__id__": 15
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -51.954,
"y": 126.253,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Bar",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{ {
"__id__": 4 "__id__": 4
}, },
@ -62,6 +173,203 @@
}, },
"_id": "" "_id": ""
}, },
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 15
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f6mlvX+zpDQKQyTNI8m1ge"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "24a704da-2867-446d-8d1a-5e920c75e09d@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ab2/RZSBpHM6hxBpsZcelP"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "d6plfNQY5CgK2nsYLzhuGq",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 10
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 15
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7eKZQXr4dA9ZZ1pNU9m4Id"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 12
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "9fd900dd-221b-4f89-8f2c-fba34243c835@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6dRnnmVKhM8KMkR+Ef0QZc"
},
{
"__type__": "cc.ProgressBar",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 14
},
"_barSprite": {
"__id__": 6
},
"_mode": 0,
"_totalLength": 100,
"_progress": 1,
"_reverse": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "13jsaXw0ZN24wtPkmda7Fc"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "4duWBgdflEeJnCTVFxBgL5",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
@ -72,7 +380,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 3 "__id__": 17
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -81,8 +389,8 @@
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0.5040967210222901,
"y": 0 "y": 0.07770745417182541
}, },
"_id": "" "_id": ""
}, },
@ -100,7 +408,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 5 "__id__": 19
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -113,11 +421,11 @@
"a": 255 "a": 255
}, },
"_skeletonData": { "_skeletonData": {
"__uuid__": "c1cb94d4-afaf-4205-97ba-8896abcb7ec1", "__uuid__": "42029fae-0ee0-48c1-b7c5-850c03664ae4",
"__expectedType__": "sp.SkeletonData" "__expectedType__": "sp.SkeletonData"
}, },
"defaultSkin": "default", "defaultSkin": "default",
"defaultAnimation": "walk", "defaultAnimation": "",
"_premultipliedAlpha": true, "_premultipliedAlpha": true,
"_timeScale": 1, "_timeScale": 1,
"_preCacheMode": 0, "_preCacheMode": 0,
@ -146,7 +454,10 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 7 "__id__": 21
},
"bloodVolume": {
"__id__": 13
}, },
"_id": "" "_id": ""
}, },

View File

@ -23,7 +23,7 @@ class JNGLayer extends JNLayer{
//重写Socket //重写Socket
class JNGSocket extends JNSocket{ class JNGSocket extends JNSocket{
public url() { public url() {
return "ws://192.168.0.127:8080/websocket"; return "ws://localhost:8080/websocket";
} }
} }
@ -96,7 +96,7 @@ export const app = {
event : EventDispatcher.getIns(), //通知 event : EventDispatcher.getIns(), //通知
proto : NGameMessage.getIns(), //消息 proto : NGameMessage.getIns(), //消息
api : axios.create({ api : axios.create({
baseURL: "http://192.168.0.127:8080", baseURL: "http://localhost:8080",
}), //请求 }), //请求
battle : GBattleModeManager.getIns(), //战斗 battle : GBattleModeManager.getIns(), //战斗
} }

View File

@ -2,7 +2,6 @@ import { _decorator, Component, director, instantiate, Node, Prefab } from 'cc';
import { app } from './App'; import { app } from './App';
import { JNGame } from '../../extensions/ngame/assets/ngame/JNGame'; import { JNGame } from '../../extensions/ngame/assets/ngame/JNGame';
import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction'; import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction';
import JNFrameTween, { JTween } from '../../extensions/ngame/assets/ngame/sync/frame/game/tween/JNFrameTween';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('Main') @ccclass('Main')
@ -16,8 +15,6 @@ export class Main extends Component {
async onLoad(){ async onLoad(){
JTween().start();
//加载 APP //加载 APP
await JNGame.Init(app,[ await JNGame.Init(app,[
{path:"proto/GDemo"} {path:"proto/GDemo"}

View File

@ -70,7 +70,8 @@ export default class GPVPMode extends GBaseMode{
entity.ones = type; entity.ones = type;
entity.tactical = this.getInfo(type).tactical; entity.tactical = this.getInfo(type).tactical;
entity.tacticalIndex = index; entity.tacticalIndex = index;
this.addGObject(entity,this.getInfo(type).tactical.getPosition(index,this.getTacticalPos(type))); entity.tacticalPos = this.getInfo(type).tactical.getPosition(index,this.getTacticalPos(type));
this.addGObject(entity,entity.tacticalPos);
this.getOnesRole(type).push(entity); this.getOnesRole(type).push(entity);
} }

View File

@ -25,25 +25,25 @@ export default abstract class GFSMBattle extends GFSMBase{
title:"寻找敌人", title:"寻找敌人",
execute: this.onSeekEnemyProcess.bind(this), execute: this.onSeekEnemyProcess.bind(this),
// to:[ProcessEnum.MoveToAttackRange], //移动到可攻击范围 // to:[ProcessEnum.MoveToAttackRange], //移动到可攻击范围
to:[ProcessEnum.AttackEnemy], //移动到可攻击范围 to:[ProcessEnum.MoveToAttackRange], //移动到可攻击范围
}, },
[ProcessEnum.MoveToAttackRange]:{ [ProcessEnum.MoveToAttackRange]:{
title:"移动到可攻击范围", title:"移动到可攻击范围",
mode:GFSMProcessMode.WaitExecute, mode:GFSMProcessMode.WaitExecute,
execute: this.onMoveToAttackRangeProcess.bind(this), execute: this.onMoveToAttackRangeProcess.bind(this),
to:[ProcessEnum.AttackEnemy,ProcessEnum.MoveToTactical] //攻击敌人 回阵型 to:[ProcessEnum.AttackEnemy] //攻击敌人 回阵型
}, },
[ProcessEnum.AttackEnemy]:{ [ProcessEnum.AttackEnemy]:{
title:"攻击敌人", title:"攻击敌人",
mode:GFSMProcessMode.WaitExecute, mode:GFSMProcessMode.WaitExecute,
execute: this.onAttackProcess.bind(this), execute: this.onAttackProcess.bind(this),
to:[ProcessEnum.MoveToTactical],//移动回阵型
}, },
[ProcessEnum.MoveToTactical]:{ // [ProcessEnum.MoveToTactical]:{
title:"移动回阵型", // title:"移动回阵型",
mode:GFSMProcessMode.WaitExecute, // mode:GFSMProcessMode.WaitExecute,
execute: this.onMoveToTacticalProcess.bind(this), // execute: this.onMoveToTacticalProcess.bind(this),
to:[ProcessEnum.SeekEnemy], //寻找敌人 // }
}
} }
//锁定的敌人 //锁定的敌人
@ -59,6 +59,10 @@ export default abstract class GFSMBattle extends GFSMBase{
//寻敌流程 //寻敌流程
onSeekEnemyProcess(dt:number):number{ onSeekEnemyProcess(dt:number):number{
//播放等待
this.player.fsmAnim.isMove = false;
this.player.fsmAnim.isAttack = false;
if(this.enemy){ if(this.enemy){
//如果有敌人 直接 攻击 //如果有敌人 直接 攻击
return ProcessEnum.MoveToAttackRange; return ProcessEnum.MoveToAttackRange;
@ -75,10 +79,14 @@ export default abstract class GFSMBattle extends GFSMBase{
} }
//移动可攻击范围 //移动可攻击范围
onMoveToAttackRangeProcess(){ onMoveToAttackRangeProcess(dt:number){
//如果没有敌人则回阵型 //播放移动
if(!this.enemy) return ProcessEnum.MoveToTactical; this.player.fsmAnim.isMove = true;
this.player.fsmAnim.isAttack = false;
//如果没有敌人则重置
if(!this.enemy) return GFSMProcessEnum.Reset;
let distance = Vec2.distance(this.player.v2World,this.enemy.v2World); let distance = Vec2.distance(this.player.v2World,this.enemy.v2World);
@ -87,24 +95,34 @@ export default abstract class GFSMBattle extends GFSMBase{
return ProcessEnum.AttackEnemy; return ProcessEnum.AttackEnemy;
}else{ }else{
//靠近目标 //靠近目标
// this.player. this.player.onMoveTarget(this.enemy.v2World,dt);
return GFSMProcessEnum.Wait;
} }
} }
//移动回阵型 //移动回阵型
onMoveToTacticalProcess(){ onMoveToTacticalProcess(dt:number){
//播放移动
this.player.fsmAnim.isMove = true;
this.player.fsmAnim.isAttack = false;
if(this.player.onMoveTarget(this.player.tacticalPos,dt)){
//回到阵容 重置
return GFSMProcessEnum.Reset;
}
return GFSMProcessEnum.Wait;
} }
onAttack(dt:number){
this.player.onAttackUpdate(dt);
}
//攻击敌人 //攻击敌人
onAttackProcess(dt:number){ onAttackProcess(dt:number){
this.onAttack(dt); //播放移动
return GFSMProcessEnum.Reset; this.player.fsmAnim.isMove = false;
this.player.fsmAnim.isAttack = true;
return GFSMProcessEnum.Wait;
} }

View File

@ -20,6 +20,7 @@ export interface GFSMProcessAnimInfo extends GFSMProcessInfo{
mixs?:number[]; mixs?:number[];
//播放的轨道 //播放的轨道
track?:sp.spine.TrackEntry; track?:sp.spine.TrackEntry;
//条件跳转
ifTo?:(() => boolean)[]; ifTo?:(() => boolean)[];
} }
@ -48,12 +49,31 @@ export class GFSMBattleAmin extends GFSMBase{
//动画Root //动画Root
spine:sp.Skeleton; spine:sp.Skeleton;
events:{event:string,fun:Function}[] = [];
constructor(spine:sp.Skeleton,trackIndex?:number){ constructor(spine:sp.Skeleton,trackIndex?:number){
super(); super();
this.spine = spine; this.spine = spine;
this.trackIndex = trackIndex || 0; this.trackIndex = trackIndex || 0;
//设置监听
this.spine.setEventListener(this.onEventListener.bind(this));
} }
//添加事件监听
addEventListener(event:string,fun:Function){
this.events.push({
event,
fun,
})
}
onEventListener(entry: sp.spine.TrackEntry, ev: sp.spine.Event){
this.events.forEach(item => {
if(item.event == ev.data.name){
item.fun();
}
});
}
// 流程图 // 流程图
process: { [key: number]: GFSMProcessAnimInfo; } = { process: { [key: number]: GFSMProcessAnimInfo; } = {
@ -130,6 +150,5 @@ export class GFSMBattleAmin extends GFSMBase{
} }
} }

View File

@ -6,8 +6,14 @@ import GFSMBattle from "../fsm/base/GFSMBattle/GFSMBattle";
import { GFSMBattleAmin } from "../fsm/base/GFSMBattle/GFSMBattleAmin"; import { GFSMBattleAmin } from "../fsm/base/GFSMBattle/GFSMBattleAmin";
import { Vec2 } from "cc"; import { Vec2 } from "cc";
import { v2 } from "cc"; import { v2 } from "cc";
import { v3 } from "cc";
import { GTactical } from "../../entity/GTactical";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
export enum GRoleAnimEvent{
Attack = "attack", //普通攻击
}
//角色基类 //角色基类
export default abstract class GRoleBase<T> extends GObject<T>{ export default abstract class GRoleBase<T> extends GObject<T>{
@ -24,7 +30,23 @@ export default abstract class GRoleBase<T> extends GObject<T>{
_isMirror:boolean = false; _isMirror:boolean = false;
//玩家攻击范围 //玩家攻击范围
range:number = 10; range:number = 100;
//移动速度
moveSpeed:number = 80;
//在阵容中的下标
tacticalIndex:number;
//阵容
tactical:GTactical;
//阵容位置
_tacticalPos:Vec2;
get tacticalPos(){ return this._tacticalPos}
set tacticalPos(value:Vec2){ this._tacticalPos = value}
//血量
blood:number = 100;
fullBlood:number = 100;
get isMirror(){ get isMirror(){
return this._isMirror; return this._isMirror;
@ -51,9 +73,24 @@ export default abstract class GRoleBase<T> extends GObject<T>{
this.fsm = this.fsmCreate(); this.fsm = this.fsmCreate();
//创建角色动画状态机 //创建角色动画状态机
this.fsmAnim = this.fsmAnimCreate(); this.fsmAnim = this.fsmAnimCreate();
//监听攻击
this.fsmAnim.addEventListener(GRoleAnimEvent.Attack,this.onAttack.bind(this));
} }
//攻击
onAttack(){
//敌人扣血
this.fsm.enemy.onHit();
}
//受击
onHit(){
this.blood--;
}
//创建一个状态机 //创建一个状态机
protected abstract fsmCreate():GFSMBattle; protected abstract fsmCreate():GFSMBattle;
//创建一个动画状态机 //创建一个动画状态机
@ -61,14 +98,26 @@ export default abstract class GRoleBase<T> extends GObject<T>{
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T){ onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T){
//更新状态机 //更新状态机
this.fsm && this.fsm.onUpdate(dt); this.fsm && this.fsm.onUpdate(dt / 1000);
this.fsmAnim && this.fsmAnim.onUpdate(dt); this.fsmAnim && this.fsmAnim.onUpdate(dt / 1000);
} }
//普攻更新 //向目标点移动
onAttackUpdate(dt:number){ onMoveTarget(target:Vec2,dt:number){
this.fsmAnim.isAttack = true; //获取两个坐标差值向量
let mins = this.v2World.subtract(target);
let normal = this.v2World.subtract(target).normalize();
if(Vec2.len(normal) >= Vec2.len(mins)){
this.node.setWorldPosition(Object.assign(v3(),target.clone()));
return true;
}else{
//移动
this.node.worldPosition = this.node.worldPosition.subtract(v3(normal.x*dt*this.moveSpeed,normal.y*dt*this.moveSpeed,0))
return false;
}
} }
} }

View File

@ -6,6 +6,9 @@ import GPVPMode, { GPVPModePlayerEnum } from "../../../PVP/GPVPMode";
import { GTactical } from "../../../entity/GTactical"; import { GTactical } from "../../../entity/GTactical";
import { GFSMBattleAmin } from "../../fsm/base/GFSMBattle/GFSMBattleAmin"; import { GFSMBattleAmin } from "../../fsm/base/GFSMBattle/GFSMBattleAmin";
import { JNFrameInfo } from "../../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame"; import { JNFrameInfo } from "../../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
import { Vec2 } from "cc";
import { v2 } from "cc";
import { ProgressBar } from "cc";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
export interface GDemoMessage{ export interface GDemoMessage{
@ -19,7 +22,6 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
//所属阵容 //所属阵容
_ones:GPVPModePlayerEnum; _ones:GPVPModePlayerEnum;
get ones():GPVPModePlayerEnum{ get ones():GPVPModePlayerEnum{
return this._ones; return this._ones;
} }
@ -33,11 +35,12 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
this._ones = value; this._ones = value;
} }
//攻击距离 @property(ProgressBar)
bloodVolume:ProgressBar;
//在阵容中的下标 onSyncLoad(){
tacticalIndex:number; super.onSyncLoad();
tactical:GTactical; }
getClassName():string{return "GDemoMessage"} getClassName():string{return "GDemoMessage"}
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: GDemoMessage) { onSyncUpdate(dt: number,frame:JNFrameInfo, input?: GDemoMessage) {
@ -50,6 +53,9 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
this.fsmAnim.isMove = input.isRun; this.fsmAnim.isMove = input.isRun;
} }
} }
//更新血量显示
this.bloodVolume.progress = this.blood / this.fullBlood;
} }
@ -61,7 +67,7 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
} }
protected fsmCreate(): GFSMPVP { protected fsmCreate(): GFSMPVP {
return null; // return null;
return new GFSMPVP(this); return new GFSMPVP(this);
} }
protected fsmAnimCreate(): GFSMBattleAmin { protected fsmAnimCreate(): GFSMBattleAmin {