From ca84f38096362eb0944c6d231b907c66f3162574 Mon Sep 17 00:00:00 2001 From: "PC-20230316NUNE\\Administrator" <2858626794@qq.com> Date: Sat, 28 Oct 2023 18:50:06 +0800 Subject: [PATCH] update --- .../assets/resources/UICanvas.prefab | 2 +- .../prefab/battle/role/RolePVPEntity.prefab | 324 +++++++++++++++++- JisolGameCocos/assets/script/App.ts | 2 +- .../assets/script/battle/base/GObject.ts | 9 + .../base/attack/GAttackParabolicRemote.ts | 13 +- .../script/battle/base/role/GRoleBase.ts | 19 +- .../script/battle/base/role/GRoleType.ts | 8 + .../script/battle/base/role/GRoleType.ts.meta | 9 + .../battle/base/role/PVP/GRolePVPEntity.ts | 7 +- .../assets/script/battle/entity/GTactical.ts | 2 +- .../assets/script/battle/modes/GPVPMode.ts | 4 +- 11 files changed, 378 insertions(+), 21 deletions(-) create mode 100644 JisolGameCocos/assets/script/battle/base/role/GRoleType.ts create mode 100644 JisolGameCocos/assets/script/battle/base/role/GRoleType.ts.meta diff --git a/JisolGameCocos/assets/resources/UICanvas.prefab b/JisolGameCocos/assets/resources/UICanvas.prefab index fc992f2b..f9947064 100644 --- a/JisolGameCocos/assets/resources/UICanvas.prefab +++ b/JisolGameCocos/assets/resources/UICanvas.prefab @@ -159,7 +159,7 @@ "_shutter": 7, "_iso": 0, "_screenScale": 1, - "_visibility": 1108344832, + "_visibility": 33554432, "_targetTexture": null, "_postProcess": null, "_usePostProcess": false, diff --git a/JisolGameCocos/assets/resources/prefab/battle/role/RolePVPEntity.prefab b/JisolGameCocos/assets/resources/prefab/battle/role/RolePVPEntity.prefab index 40557fcd..9c4ff091 100644 --- a/JisolGameCocos/assets/resources/prefab/battle/role/RolePVPEntity.prefab +++ b/JisolGameCocos/assets/resources/prefab/battle/role/RolePVPEntity.prefab @@ -20,22 +20,25 @@ "_children": [ { "__id__": 2 + }, + { + "__id__": 16 } ], "_active": true, "_components": [ { - "__id__": 16 + "__id__": 30 }, { - "__id__": 18 + "__id__": 32 }, { - "__id__": 20 + "__id__": 34 } ], "_prefab": { - "__id__": 22 + "__id__": 36 }, "_lpos": { "__type__": "cc.Vec3", @@ -370,6 +373,310 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, + { + "__type__": "cc.Node", + "_name": "energy", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 17 + } + ], + "_active": true, + "_components": [ + { + "__id__": 23 + }, + { + "__id__": 25 + }, + { + "__id__": 27 + } + ], + "_prefab": { + "__id__": 29 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -51.954, + "y": 118.227, + "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__": 16 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__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.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 17 + }, + "_enabled": true, + "__prefab": { + "__id__": 19 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "33XDUgb7hE7Iae0ToFMuDl" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 17 + }, + "_enabled": true, + "__prefab": { + "__id__": 21 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 78, + "g": 156, + "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": "978QNpG8RAu5dOq5L5q74y" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "86H6XFlX5NF7gBNm1o/YQY", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 16 + }, + "_enabled": true, + "__prefab": { + "__id__": 24 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2fv65eXxBBLY9sDM8+GdTw" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 16 + }, + "_enabled": true, + "__prefab": { + "__id__": 26 + }, + "_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": "6eKAM0oQ5H1LcXpcqmeYoy" + }, + { + "__type__": "cc.ProgressBar", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 16 + }, + "_enabled": true, + "__prefab": { + "__id__": 28 + }, + "_barSprite": { + "__id__": 20 + }, + "_mode": 0, + "_totalLength": 100, + "_progress": 1, + "_reverse": false, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "96r31KcJFBA6JkO6JK9juG" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "eezHTmz/xEZ72deCl7tprY", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.UITransform", "_name": "", @@ -380,7 +687,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 17 + "__id__": 31 }, "_contentSize": { "__type__": "cc.Size", @@ -408,7 +715,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 19 + "__id__": 33 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -451,11 +758,14 @@ }, "_enabled": true, "__prefab": { - "__id__": 21 + "__id__": 35 }, "bloodVolume": { "__id__": 13 }, + "energyVolume": { + "__id__": 27 + }, "_id": "" }, { diff --git a/JisolGameCocos/assets/script/App.ts b/JisolGameCocos/assets/script/App.ts index 2570d5cb..c15752c1 100644 --- a/JisolGameCocos/assets/script/App.ts +++ b/JisolGameCocos/assets/script/App.ts @@ -24,7 +24,7 @@ import { TableGRoleAttack } from "../resources/config/ts/TableGRoleAttack"; import { SpriteFrame } from "cc"; import { TableGRoleAttackBullet } from "../resources/config/ts/TableGRoleAttackBullet"; -let IP = "localhost"; +let IP = "192.168.0.126"; //重写UI class JNGLayer extends JNLayer{ diff --git a/JisolGameCocos/assets/script/battle/base/GObject.ts b/JisolGameCocos/assets/script/battle/base/GObject.ts index 73eedc91..5ca89d5c 100644 --- a/JisolGameCocos/assets/script/battle/base/GObject.ts +++ b/JisolGameCocos/assets/script/battle/base/GObject.ts @@ -64,5 +64,14 @@ export default class GObject extends JNGSyncProtoBase{ } } + //镜像值处理 + getMirrorValue(value:number){ + if(this.isMirror){ + return value * -1; + }else{ + return value; + } + } + } diff --git a/JisolGameCocos/assets/script/battle/base/attack/GAttackParabolicRemote.ts b/JisolGameCocos/assets/script/battle/base/attack/GAttackParabolicRemote.ts index d7c3c5c3..2a8b1df3 100644 --- a/JisolGameCocos/assets/script/battle/base/attack/GAttackParabolicRemote.ts +++ b/JisolGameCocos/assets/script/battle/base/attack/GAttackParabolicRemote.ts @@ -15,6 +15,9 @@ import { Vec2 } from "cc"; export default class GAttackParabolicRemote implements GAttackBase{ attack(role: GRoleBase<{}>, info: TableGRoleAttack): void { + + let enemy = role.fsm.enemy; + //[子弹图片] let image:SpriteFrame = app.role.bullets[info.attackArgs[0]]; let scale:number = info.attackArgs[1] as unknown as number; @@ -25,27 +28,29 @@ export default class GAttackParabolicRemote implements GAttackBase{ scale:scale, }); role.mode.addGObject(bullet); - let world2 = role.node.worldPosition.clone().add(v3(bone.worldX,bone.worldY,0)) + let world2 = role.node.worldPosition.clone().add(v3(role.getMirrorValue(bone.worldX),bone.worldY,0)) //设置子弹位置 bullet.node.setWorldPosition(v3(world2.x,world2.y,world2.z)) //子弹移动 let start = bullet.v2World; - let end = role.fsm.enemy.v2World; + let end = enemy.v2World; let center = v2(((start.x + end.x) / 2),((start.y + end.y) / 2) + (Math.abs((start.x - end.x)) / 2)); - // start.rotate(90).normalize().multiplyScalar(50); bullet.JTween({}) .to({},Vec2.distance(start,end)*3) .onUpdate((data,elapsed) => { - // console.log(data,elapsed,bezier(0,6,12,1,elapsed),bezier(0,6,12,1,elapsed)) bullet.node.setWorldPosition(v3( bezier(start.x,center.x,center.x,end.x,elapsed), bezier(start.y,center.y,center.y,end.y,elapsed), 0 )) }) + .onComplete(() => { + enemy.onHit(); + bullet.node.removeFromParent(); + }) .start(); diff --git a/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts b/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts index e64c4e6e..68914a64 100644 --- a/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts +++ b/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts @@ -12,6 +12,7 @@ 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"; const { ccclass, property } = _decorator; export enum GRoleAnimEvent{ @@ -27,6 +28,9 @@ export default abstract class GRoleBase extends GObject{ //角色 role:GRole + //角色类型 + type:GRoleType; + //状态机 fsm:GFSMBattle; @@ -57,6 +61,10 @@ export default abstract class GRoleBase extends GObject{ blood:number = 100; fullBlood:number = 100; + //能量 + energy:number = 0; + fullEnergy:number = 100; + //是否死亡 _isDie:boolean = false; get isDie(){ return this._isDie} @@ -150,11 +158,14 @@ export default abstract class GRoleBase extends GObject{ //敌人扣血 let info = TableGRoleAttack.getConfig(this.role.id); (new GAttack[info.attackWay]()).attack(this,info); + + //每一次攻击 则 增加能量条 + this.energy += 10; } //受击 onHit(){ - this.blood-=50; + this.blood -= 10; //检测是否死亡 if(this.blood <= 0){ //关闭状态机 @@ -169,13 +180,13 @@ export default abstract class GRoleBase extends GObject{ console.log("onFly"); let vWorld = this.node.worldPosition; - let vEndWorld = this.getWorldBackLen(v2(800,500)); + let vEndWorld = this.getWorldBackLen(v2(1000,500)); this.JTween(vWorld) - .to({x:vEndWorld.x},600) + .to({x:vEndWorld.x},800) .onUpdate(pos => this.node.worldPosition = vWorld) .start(); this.JTween(vWorld) - .to({y:vEndWorld.y},600) + .to({y:vEndWorld.y},800) .easing(JEasing.Circular.Out) .onUpdate(pos => this.node.worldPosition = vWorld) .start(); diff --git a/JisolGameCocos/assets/script/battle/base/role/GRoleType.ts b/JisolGameCocos/assets/script/battle/base/role/GRoleType.ts new file mode 100644 index 00000000..ec68ff23 --- /dev/null +++ b/JisolGameCocos/assets/script/battle/base/role/GRoleType.ts @@ -0,0 +1,8 @@ + +//角色类型 +export enum GRoleType{ + PLAYER = "PLAYER", + ENMEY = "ENMEY", + PVP1 = "PVP1", + PVP2 = "PVP2", +} \ No newline at end of file diff --git a/JisolGameCocos/assets/script/battle/base/role/GRoleType.ts.meta b/JisolGameCocos/assets/script/battle/base/role/GRoleType.ts.meta new file mode 100644 index 00000000..2b2f065a --- /dev/null +++ b/JisolGameCocos/assets/script/battle/base/role/GRoleType.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "04262003-45a4-4d9d-a1d3-83c11146c891", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/JisolGameCocos/assets/script/battle/base/role/PVP/GRolePVPEntity.ts b/JisolGameCocos/assets/script/battle/base/role/PVP/GRolePVPEntity.ts index 565354c4..80b699fb 100644 --- a/JisolGameCocos/assets/script/battle/base/role/PVP/GRolePVPEntity.ts +++ b/JisolGameCocos/assets/script/battle/base/role/PVP/GRolePVPEntity.ts @@ -28,6 +28,10 @@ export default class GRolePVPEntity extends GRoleBase{ @property(ProgressBar) bloodVolume:ProgressBar; + //能量条 + @property(ProgressBar) + energyVolume:ProgressBar; + onSyncLoad(){ super.onSyncLoad(); } @@ -45,8 +49,9 @@ export default class GRolePVPEntity extends GRoleBase{ } } - //更新血量显示 + //更新显示 this.bloodVolume.progress = this.blood / this.fullBlood; + this.energyVolume.progress = this.energy / this.fullBlood; } diff --git a/JisolGameCocos/assets/script/battle/entity/GTactical.ts b/JisolGameCocos/assets/script/battle/entity/GTactical.ts index 00e2d4d9..6b438dc0 100644 --- a/JisolGameCocos/assets/script/battle/entity/GTactical.ts +++ b/JisolGameCocos/assets/script/battle/entity/GTactical.ts @@ -26,7 +26,7 @@ export class GTactical{ static getTactical(isReversed:boolean = false): GTactical{ let tactical = [ [0,4,3], - [0,0,1], + [6,0,1], [0,5,2], ]; if(isReversed){ diff --git a/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts b/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts index c51d225b..942af690 100644 --- a/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts +++ b/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts @@ -58,8 +58,8 @@ export default class GPVPMode extends GBaseMode<{}>{ //初始化战斗 console.log("GPVPMode 模式初始化"); - 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]) }; + this.playerInfo = { tactical: GTactical.getTactical(), roles: GRoleUtil.getGRoles([10001,10001,10001,10001,10003,10003]) }; + this.enemyInfo = { tactical: GTactical.getTactical(true), roles: GRoleUtil.getGRoles([10002,10002,10002,10001,10001,10003]) }; //生成玩家 this.playerInfo.roles.forEach((info,index) => this.onGenRole(GPVPModePlayerEnum.PLAYER,index+1,info))