简单PVP

This commit is contained in:
PC-20230316NUNE\Administrator
2023-11-20 18:25:50 +08:00
parent 98b7a52b45
commit 74aabac454
36 changed files with 2972 additions and 261 deletions

View File

@@ -147,7 +147,7 @@
},
"_depth": 1,
"_stencil": 0,
"_clearFlags": 7,
"_clearFlags": 6,
"_rect": {
"__type__": "cc.Rect",
"x": 0,

View File

@@ -81,7 +81,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 720,
"x": 0,
"y": 0,
"z": 0
},
@@ -4387,8 +4387,8 @@
},
"_alignFlags": 45,
"_target": null,
"_left": 720,
"_right": -720,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "80f8f41e-26fe-455a-873a-da26dfd9a169",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "394ad8cd-f975-4785-a104-d76c781c17b8",
"files": [],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.49",
"importer": "prefab",
"imported": true,
"uuid": "d1bca093-45af-4ae2-a896-11ed7c6f9bda",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "PVP匹配页面"
}
}

View File

@@ -2091,10 +2091,6 @@
"views": {
"__id__": 37
},
"petIconPrefab": {
"__uuid__": "fc8eb7b6-f756-49f4-9102-ac3cca3a20ae",
"__expectedType__": "cc.Prefab"
},
"spine": {
"__id__": 8
},

View File

@@ -24,11 +24,12 @@ import { GAction } from "./consts/GAction";
import { StorageData, StorageEnum } from "./consts/GData";
import { JAPI, JAPIConfig } from "../../extensions/ngame/assets/ngame/util/JAPI";
import { AppData } from "./AppData";
import AppAction from "./AppAction";
let APIPath = `http://localhost:8080`
let WsPath = `ws://localhost:8080/websocket`
// let APIPath = `http://192.168.0.123:8080`
// let WsPath = `ws://192.168.0.123:8080/websocket`
// let APIPath = `http://localhost:8080`
// let WsPath = `ws://localhost:8080/websocket`
let APIPath = `http://192.168.0.123:8080`
let WsPath = `ws://192.168.0.123:8080/websocket`
// let APIPath = `https://api.pet.jisol.cn`
// let WsPath = `wss://api.pet.jisol.cn/websocket`
@@ -218,12 +219,13 @@ export const app = {
config : new JNGConfig(), //配置文件
battleRes : new JLoaderBattle("battle"), //battle包
data : new AppData(), //游戏基础信息
loading: new Loading({
action : new AppAction(), //游戏行为
loading : new Loading({
[JNGConfig.loading]:{title:"加载配置文件"},
[JLoaderBattle.loading]:{title:"加载战斗资源"},
[JLoaderBattle.loadingInit]:{title:"初始化战斗资源"},
[AppData.loading]:{title:"初始化信息"},
}),
})
}
app.api.addRequestInterceptors((config:JAPIConfig) => {

View File

@@ -0,0 +1,23 @@
import SystemBase from "../../extensions/ngame/assets/ngame/system/SystemBase";
import BaseAction from "./action/BaseAction";
import PVPAction from "./action/PVPAction";
export default class AppAction extends SystemBase{
loadings:BaseAction[] = [
PVPAction.getIns(), //PVP Action
];
async onInit(): Promise<any> {
//初始化所有数据类
for (let index = 0; index < this.loadings.length; index++) {
const data = this.loadings[index];
await data.onInit();
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b112702e-09c0-40a6-8887-ea797195488e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "df61d197-2845-4513-88af-2c4ae6cdc33f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,8 @@
import Singleton from "../../../extensions/ngame/assets/ngame/util/Singleton";
export default abstract class BaseAction extends Singleton {
//初始化
abstract onInit();
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "60baf66e-7156-4234-847b-ea520c1e0cc1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,41 @@
import { app } from "../App";
import GBattleModeManager, { BattleMode } from "../battle/GBattleModeManager";
import { GAction } from "../consts/GAction";
import { GActionType } from "../consts/GActionType";
import { GUI } from "../ui/UIConfig";
import BaseAction from "./BaseAction";
export interface GPVPStart{
leftTactical:string;
rightTactical:string;
}
export default class PVPAction extends BaseAction {
onInit(){
app.socket.on(GAction.C_MODE_PVP_START_WAIT,this.onModePVPStartWait,this);
app.socket.on(GAction.C_MODE_PVP_END_WAIT,this.onModePVPEndWait,this);
app.socket.on(GAction.C_MODE_PVP_START,this.onModePVPStart,this,GActionType.GPVPStart);
}
//PVP开始等待
onModePVPStartWait(){
//PVP 匹配页面
app.layer.Open(GUI.PVPModeMatchView);
}
//PVP结束等待
onModePVPEndWait(){
//PVP 匹配页面
app.layer.Close(GUI.PVPModeMatchView);
}
//开始PVP
onModePVPStart(info:GPVPStart){
console.log("开始PVP",info);
GBattleModeManager.getIns().Open(BattleMode.PVP,true);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "20d83911-fbc5-40d3-b970-b48ab4a529bf",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -64,7 +64,7 @@ export default class GPVPMode extends GBaseMode<{}>{
//调整相机
let camreaPos = this.camera.node.worldPosition;
this.camera.node.worldPosition = v3(0,100,camreaPos.z)
this.camera.node.worldPosition = v3(0,800,camreaPos.z)
//初始化战斗
console.log("GPVPMode 模式初始化");

View File

@@ -11,6 +11,6 @@ export const GAPI = {
//捕捉野怪
GOnHookCatchCreeps : async (creepId) => RData(await app.api.post(`/game/mode/onHook/onCatchCreeps/${creepId}`)) as PlayerPetOV,
//出售野怪
GOnHookSellCreeps : async (creepId) => RData(await app.api.post(`/game/mode/onHook/onSellCreeps/${creepId}`)),
GOnHookSellCreeps : async (creepId) => RData(await app.api.post(`/game/mode/onHook/onSellCreeps/${creepId}`)) as boolean,
}

View File

@@ -6,7 +6,14 @@ export enum GAction {
CHAT_MESSAGE = 2001, //发送聊天消息
CHAT_RECEIVE_MESSAGE = 2002, //接受聊天消息
/*************** 游戏模式 : 无尽模式(OnHook) **************/
/*************** 游戏模式 : PVP模式 **************/
S_MODE_PVP_JOIN = 3001, //加入PVP
S_MODE_PVP_LEAVE = 3002, //离开PVP
C_MODE_PVP_WAIT = 3003, //等待PVP开始
C_MODE_PVP_START = 3004, //PVP开始
C_MODE_PVP_END = 3005, //PVP结束
C_MODE_PVP_START_WAIT = 3006, //开始等待PVP开始
C_MODE_PVP_END_WAIT = 3007, //结束等待PVP开始
}

View File

@@ -8,7 +8,10 @@ export enum GActionType {
/*************** 游戏模式 : 无尽模式(OnHook) **************/
GOnHookPet = "GOnHookPet", //野怪
GOnHookPets = "GOnHookPets", //野怪列表
GOnHookPet = "GOnHookPet", //野怪
GOnHookPets = "GOnHookPets", //野怪列表
/*************** 游戏模式 : PVP **************/
GPVPStart = "GPVPStart", //PVP 开始
}

View File

@@ -5,6 +5,7 @@ import PlayerData from '../../data/PlayerData';
import GBattleModeManager, { BattleMode } from '../../battle/GBattleModeManager';
import { JNGLayerBase } from '../../components/JNComponent';
import { app } from '../../App';
import { GAction } from '../../consts/GAction';
const { ccclass, property } = _decorator;
@ccclass('MainView')
@@ -47,6 +48,11 @@ export class MainView extends JNGLayerBase {
GBattleModeManager.getIns().Open(BattleMode.OnHook,true);
}
//点击PVP模式
onOpenPVP(){
app.socket.Send(GAction.S_MODE_PVP_JOIN);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "7767a760-8e96-4bf8-8289-030e5a8c91c5",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "37638c81-4459-4c8d-8054-e5789bce2590",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,37 @@
import { _decorator, Component, Node } from 'cc';
import { JNGLayerBase } from '../../../components/JNComponent';
import { tween } from 'cc';
import { v3 } from 'cc';
import { app } from '../../../App';
import { GAction } from '../../../consts/GAction';
const { ccclass, property } = _decorator;
/**
* 游戏匹配页面
*/
@ccclass('PVPMatchView')
export class PVPMatchView extends JNGLayerBase {
@property(Node)
content:Node;
onJNLoad(data?: any): void {
super.onJNLoad(data);
tween(this.content)
.repeatForever(
tween()
.to(.5,{scale:v3(.8,.8,.8)})
.to(.5,{scale:v3(1,1,1)})
)
.start();
}
//取消匹配
onClickCancel(){
app.socket.Send(GAction.S_MODE_PVP_LEAVE)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "9979d56d-f754-44c3-8e29-c764eaeb0aaf",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -23,6 +23,9 @@ export enum GUI{
IntoBattleView = "IntoBattleView", //上阵页面
/**游戏模式页面 */
PVPModeMatchView = "PVPModeMatchView", //PVP模式匹配页面
Home = "Home", //主页面
Main = "Main", //主页面2
}
@@ -97,6 +100,17 @@ const UINoviceConfig:{ [key: string]: JNLayerInfo; } = {
}
//游戏模式页面
const UIGModeConfig:{ [key: string]: JNLayerInfo; } = {
[GUI.PVPModeMatchView]:{
layer:GLayer.Popup,
uri: "prefab/ui/模式/PVP/PVP匹配页面",
anims:BackOutScale
},
}
export const UIConfig:{ [key: string]: JNLayerInfo; } = {
[GUI.Home]:{
layer:GLayer.View,
@@ -121,5 +135,6 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
...UISystemConfig, //系统页面
...UINoviceConfig, //新手引导页面
...UIMainConfig, //主页面
...UIGModeConfig, //游戏模式页面
}