This commit is contained in:
PC-20230316NUNE\Administrator 2023-10-28 18:50:06 +08:00
parent 324736a619
commit ca84f38096
11 changed files with 378 additions and 21 deletions

View File

@ -159,7 +159,7 @@
"_shutter": 7, "_shutter": 7,
"_iso": 0, "_iso": 0,
"_screenScale": 1, "_screenScale": 1,
"_visibility": 1108344832, "_visibility": 33554432,
"_targetTexture": null, "_targetTexture": null,
"_postProcess": null, "_postProcess": null,
"_usePostProcess": false, "_usePostProcess": false,

View File

@ -20,22 +20,25 @@
"_children": [ "_children": [
{ {
"__id__": 2 "__id__": 2
},
{
"__id__": 16
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 16 "__id__": 30
}, },
{ {
"__id__": 18 "__id__": 32
}, },
{ {
"__id__": 20 "__id__": 34
} }
], ],
"_prefab": { "_prefab": {
"__id__": 22 "__id__": 36
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -370,6 +373,310 @@
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": 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", "__type__": "cc.UITransform",
"_name": "", "_name": "",
@ -380,7 +687,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 17 "__id__": 31
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -408,7 +715,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 19 "__id__": 33
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -451,11 +758,14 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 21 "__id__": 35
}, },
"bloodVolume": { "bloodVolume": {
"__id__": 13 "__id__": 13
}, },
"energyVolume": {
"__id__": 27
},
"_id": "" "_id": ""
}, },
{ {

View File

@ -24,7 +24,7 @@ import { TableGRoleAttack } from "../resources/config/ts/TableGRoleAttack";
import { SpriteFrame } from "cc"; import { SpriteFrame } from "cc";
import { TableGRoleAttackBullet } from "../resources/config/ts/TableGRoleAttackBullet"; import { TableGRoleAttackBullet } from "../resources/config/ts/TableGRoleAttackBullet";
let IP = "localhost"; let IP = "192.168.0.126";
//重写UI //重写UI
class JNGLayer extends JNLayer{ class JNGLayer extends JNLayer{

View File

@ -64,5 +64,14 @@ export default class GObject<T> extends JNGSyncProtoBase<T>{
} }
} }
//镜像值处理
getMirrorValue(value:number){
if(this.isMirror){
return value * -1;
}else{
return value;
}
}
} }

View File

@ -15,6 +15,9 @@ import { Vec2 } from "cc";
export default class GAttackParabolicRemote implements GAttackBase{ export default class GAttackParabolicRemote implements GAttackBase{
attack(role: GRoleBase<{}>, info: TableGRoleAttack): void { attack(role: GRoleBase<{}>, info: TableGRoleAttack): void {
let enemy = role.fsm.enemy;
//[子弹图片] //[子弹图片]
let image:SpriteFrame = app.role.bullets[info.attackArgs[0]]; let image:SpriteFrame = app.role.bullets[info.attackArgs[0]];
let scale:number = info.attackArgs[1] as unknown as number; let scale:number = info.attackArgs[1] as unknown as number;
@ -25,27 +28,29 @@ export default class GAttackParabolicRemote implements GAttackBase{
scale:scale, scale:scale,
}); });
role.mode.addGObject(bullet); 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)) bullet.node.setWorldPosition(v3(world2.x,world2.y,world2.z))
//子弹移动 //子弹移动
let start = bullet.v2World; 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)); 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({}) bullet.JTween({})
.to({},Vec2.distance(start,end)*3) .to({},Vec2.distance(start,end)*3)
.onUpdate((data,elapsed) => { .onUpdate((data,elapsed) => {
// console.log(data,elapsed,bezier(0,6,12,1,elapsed),bezier(0,6,12,1,elapsed))
bullet.node.setWorldPosition(v3( bullet.node.setWorldPosition(v3(
bezier(start.x,center.x,center.x,end.x,elapsed), bezier(start.x,center.x,center.x,end.x,elapsed),
bezier(start.y,center.y,center.y,end.y,elapsed), bezier(start.y,center.y,center.y,end.y,elapsed),
0 0
)) ))
}) })
.onComplete(() => {
enemy.onHit();
bullet.node.removeFromParent();
})
.start(); .start();

View File

@ -12,6 +12,7 @@ import GRole from "../../entity/GRole";
import { app } from "../../../App"; import { app } from "../../../App";
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack"; import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
import { GAttack, GAttackBase } from "../attack/GAttack"; import { GAttack, GAttackBase } from "../attack/GAttack";
import { GRoleType } from "./GRoleType";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
export enum GRoleAnimEvent{ export enum GRoleAnimEvent{
@ -27,6 +28,9 @@ export default abstract class GRoleBase<T> extends GObject<T>{
//角色 //角色
role:GRole role:GRole
//角色类型
type:GRoleType;
//状态机 //状态机
fsm:GFSMBattle; fsm:GFSMBattle;
@ -57,6 +61,10 @@ export default abstract class GRoleBase<T> extends GObject<T>{
blood:number = 100; blood:number = 100;
fullBlood:number = 100; fullBlood:number = 100;
//能量
energy:number = 0;
fullEnergy:number = 100;
//是否死亡 //是否死亡
_isDie:boolean = false; _isDie:boolean = false;
get isDie(){ return this._isDie} get isDie(){ return this._isDie}
@ -150,11 +158,14 @@ export default abstract class GRoleBase<T> extends GObject<T>{
//敌人扣血 //敌人扣血
let info = TableGRoleAttack.getConfig(this.role.id); let info = TableGRoleAttack.getConfig(this.role.id);
(new GAttack[info.attackWay]()).attack(this,info); (new GAttack[info.attackWay]()).attack(this,info);
//每一次攻击 则 增加能量条
this.energy += 10;
} }
//受击 //受击
onHit(){ onHit(){
this.blood-=50; this.blood -= 10;
//检测是否死亡 //检测是否死亡
if(this.blood <= 0){ if(this.blood <= 0){
//关闭状态机 //关闭状态机
@ -169,13 +180,13 @@ export default abstract class GRoleBase<T> extends GObject<T>{
console.log("onFly"); console.log("onFly");
let vWorld = this.node.worldPosition; let vWorld = this.node.worldPosition;
let vEndWorld = this.getWorldBackLen(v2(800,500)); let vEndWorld = this.getWorldBackLen(v2(1000,500));
this.JTween(vWorld) this.JTween(vWorld)
.to({x:vEndWorld.x},600) .to({x:vEndWorld.x},800)
.onUpdate(pos => this.node.worldPosition = vWorld) .onUpdate(pos => this.node.worldPosition = vWorld)
.start(); .start();
this.JTween(vWorld) this.JTween(vWorld)
.to({y:vEndWorld.y},600) .to({y:vEndWorld.y},800)
.easing(JEasing.Circular.Out) .easing(JEasing.Circular.Out)
.onUpdate(pos => this.node.worldPosition = vWorld) .onUpdate(pos => this.node.worldPosition = vWorld)
.start(); .start();

View File

@ -0,0 +1,8 @@
//角色类型
export enum GRoleType{
PLAYER = "PLAYER",
ENMEY = "ENMEY",
PVP1 = "PVP1",
PVP2 = "PVP2",
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "04262003-45a4-4d9d-a1d3-83c11146c891",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -28,6 +28,10 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
@property(ProgressBar) @property(ProgressBar)
bloodVolume:ProgressBar; bloodVolume:ProgressBar;
//能量条
@property(ProgressBar)
energyVolume:ProgressBar;
onSyncLoad(){ onSyncLoad(){
super.onSyncLoad(); super.onSyncLoad();
} }
@ -45,8 +49,9 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
} }
} }
//更新血量显示 //更新显示
this.bloodVolume.progress = this.blood / this.fullBlood; this.bloodVolume.progress = this.blood / this.fullBlood;
this.energyVolume.progress = this.energy / this.fullBlood;
} }

View File

@ -26,7 +26,7 @@ export class GTactical{
static getTactical(isReversed:boolean = false): GTactical{ static getTactical(isReversed:boolean = false): GTactical{
let tactical = [ let tactical = [
[0,4,3], [0,4,3],
[0,0,1], [6,0,1],
[0,5,2], [0,5,2],
]; ];
if(isReversed){ if(isReversed){

View File

@ -58,8 +58,8 @@ export default class GPVPMode extends GBaseMode<{}>{
//初始化战斗 //初始化战斗
console.log("GPVPMode 模式初始化"); console.log("GPVPMode 模式初始化");
this.playerInfo = { tactical: GTactical.getTactical(),roles: GRoleUtil.getGRoles([10001,10001,10001,10001,10003]) }; 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]) }; 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)) this.playerInfo.roles.forEach((info,index) => this.onGenRole(GPVPModePlayerEnum.PLAYER,index+1,info))