diff --git a/DataTables/Datas/~$__tables__.xlsx b/DataTables/Datas/~$__tables__.xlsx new file mode 100644 index 00000000..1002ebeb Binary files /dev/null and b/DataTables/Datas/~$__tables__.xlsx differ diff --git a/DataTables/Datas/战斗/地图.xlsx b/DataTables/Datas/战斗/地图.xlsx index 59c198a6..58148355 100644 Binary files a/DataTables/Datas/战斗/地图.xlsx and b/DataTables/Datas/战斗/地图.xlsx differ diff --git a/DataTables/Datas/战斗/角色/角色战斗素材.xlsx b/DataTables/Datas/战斗/角色/角色战斗素材.xlsx index 6f2feb97..4cc162c0 100644 Binary files a/DataTables/Datas/战斗/角色/角色战斗素材.xlsx and b/DataTables/Datas/战斗/角色/角色战斗素材.xlsx differ diff --git a/DataTables/Datas/战斗/角色/角色技能.xlsx b/DataTables/Datas/战斗/角色/角色技能.xlsx index b7c797f2..4a887ecb 100644 Binary files a/DataTables/Datas/战斗/角色/角色技能.xlsx and b/DataTables/Datas/战斗/角色/角色技能.xlsx differ diff --git a/DataTables/Datas/战斗/角色/角色攻击.xlsx b/DataTables/Datas/战斗/角色/角色攻击.xlsx index 9a0c78cf..ca756f5c 100644 Binary files a/DataTables/Datas/战斗/角色/角色攻击.xlsx and b/DataTables/Datas/战斗/角色/角色攻击.xlsx differ diff --git a/DataTables/Datas/战斗/角色/角色表.xlsx b/DataTables/Datas/战斗/角色/角色表.xlsx index 52e2d4f5..ddd31373 100644 Binary files a/DataTables/Datas/战斗/角色/角色表.xlsx and b/DataTables/Datas/战斗/角色/角色表.xlsx differ diff --git a/JisolGameCocos/assets/battle.meta b/JisolGameCocos/assets/battle.meta index 5fffdc5e..cb38e4f0 100644 --- a/JisolGameCocos/assets/battle.meta +++ b/JisolGameCocos/assets/battle.meta @@ -6,6 +6,7 @@ "files": [], "subMetas": {}, "userData": { - "isBundle": true + "isBundle": true, + "bundleConfigID": "514cB4o1lDLr4YHgRwsEVt" } } diff --git a/JisolGameCocos/assets/resources.meta b/JisolGameCocos/assets/resources.meta index 0d35ca7b..63c21a3d 100644 --- a/JisolGameCocos/assets/resources.meta +++ b/JisolGameCocos/assets/resources.meta @@ -7,7 +7,7 @@ "subMetas": {}, "userData": { "isBundle": true, - "bundleConfigID": "default", + "bundleConfigID": "514cB4o1lDLr4YHgRwsEVt", "bundleName": "resources", "priority": 8, "compressionType": {}, diff --git a/JisolGameCocos/assets/resources/prefab/ui/Home/HomeView.prefab b/JisolGameCocos/assets/resources/prefab/ui/Home/HomeView.prefab index c0134c50..7b86b51f 100644 --- a/JisolGameCocos/assets/resources/prefab/ui/Home/HomeView.prefab +++ b/JisolGameCocos/assets/resources/prefab/ui/Home/HomeView.prefab @@ -47,22 +47,34 @@ }, { "__id__": 128 + }, + { + "__id__": 143 + }, + { + "__id__": 149 + }, + { + "__id__": 155 + }, + { + "__id__": 161 } ], "_active": true, "_components": [ { - "__id__": 143 + "__id__": 167 }, { - "__id__": 145 + "__id__": 169 }, { - "__id__": 147 + "__id__": 171 } ], "_prefab": { - "__id__": 149 + "__id__": 173 }, "_lpos": { "__type__": "cc.Vec3", @@ -3419,6 +3431,554 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, + { + "__type__": "cc.Node", + "_name": "001妙蛙种子", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 144 + }, + { + "__id__": 146 + } + ], + "_prefab": { + "__id__": 148 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -271.702, + "y": -580.56, + "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": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 143 + }, + "_enabled": true, + "__prefab": { + "__id__": 145 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 643.989990234375, + "height": 385.94000244140625 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.6291246759115515, + "y": 0.7755350460309831 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "24mjCxtbJAIYhkSGJS2XGL" + }, + { + "__type__": "sp.Skeleton", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 143 + }, + "_enabled": true, + "__prefab": { + "__id__": 147 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_skeletonData": { + "__uuid__": "29e1c6dc-6549-4f30-ad94-fe92d3cead0c", + "__expectedType__": "sp.SkeletonData" + }, + "defaultSkin": "default", + "defaultAnimation": "atk", + "_premultipliedAlpha": true, + "_timeScale": 1, + "_preCacheMode": 0, + "_cacheMode": 0, + "_defaultCacheMode": 0, + "_sockets": [], + "_useTint": false, + "_debugMesh": false, + "_debugBones": false, + "_debugSlots": false, + "_enableBatch": false, + "loop": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "02mvi2yPpIvajNGIKqQDxP" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "03QOgvM5ZPaLJxWwx9tYtd", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.Node", + "_name": "guaiA1a", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 150 + }, + { + "__id__": 152 + } + ], + "_prefab": { + "__id__": 154 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -123.079, + "y": -580.56, + "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": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 149 + }, + "_enabled": true, + "__prefab": { + "__id__": 151 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 84.5999984741211, + "height": 116.54000091552734 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.4938534223742009, + "y": 0.024026084866309822 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "8dVNo47axGpJRFT8NW+dax" + }, + { + "__type__": "sp.Skeleton", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 149 + }, + "_enabled": true, + "__prefab": { + "__id__": 153 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_skeletonData": { + "__uuid__": "14d2a9b1-50ad-4051-a96a-b1c194651259", + "__expectedType__": "sp.SkeletonData" + }, + "defaultSkin": "default", + "defaultAnimation": "atk", + "_premultipliedAlpha": true, + "_timeScale": 1, + "_preCacheMode": 0, + "_cacheMode": 0, + "_defaultCacheMode": 0, + "_sockets": [], + "_useTint": false, + "_debugMesh": false, + "_debugBones": false, + "_debugSlots": false, + "_enableBatch": false, + "loop": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "63+7zF/35IIatyyta5jw8G" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "9cYPe89alNLpO1Qn8AI3Y5", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.Node", + "_name": "guaiA1a", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 156 + }, + { + "__id__": 158 + } + ], + "_prefab": { + "__id__": 160 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 11.611, + "y": -580.56, + "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": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 155 + }, + "_enabled": true, + "__prefab": { + "__id__": 157 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100.08000183105469, + "height": 113.76000213623047 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5040967210222901, + "y": 0.07770745417182541 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "fdXo7ORJpDv6JVChYlXVuX" + }, + { + "__type__": "sp.Skeleton", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 155 + }, + "_enabled": true, + "__prefab": { + "__id__": 159 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_skeletonData": { + "__uuid__": "42029fae-0ee0-48c1-b7c5-850c03664ae4", + "__expectedType__": "sp.SkeletonData" + }, + "defaultSkin": "default", + "defaultAnimation": "atk", + "_premultipliedAlpha": true, + "_timeScale": 1, + "_preCacheMode": 0, + "_cacheMode": 0, + "_defaultCacheMode": 0, + "_sockets": [], + "_useTint": false, + "_debugMesh": false, + "_debugBones": false, + "_debugSlots": false, + "_enableBatch": false, + "loop": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "d8a1mv3UxMQI8rwba1ICfW" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "87tzkjpopJ6YTEDK3Fvt9k", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.Node", + "_name": "guaiA4e", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 162 + }, + { + "__id__": 164 + } + ], + "_prefab": { + "__id__": 166 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 171.846, + "y": -589.848, + "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": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 161 + }, + "_enabled": true, + "__prefab": { + "__id__": 163 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 162.3699951171875, + "height": 188.55999755859375 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5011394050227984, + "y": 0.04884387016013313 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "27Mc3b9O5A9b5AOEEyyaCO" + }, + { + "__type__": "sp.Skeleton", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 161 + }, + "_enabled": true, + "__prefab": { + "__id__": 165 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_skeletonData": { + "__uuid__": "51104c05-e5db-4274-a66e-1de9ab511e4f", + "__expectedType__": "sp.SkeletonData" + }, + "defaultSkin": "default", + "defaultAnimation": "atk", + "_premultipliedAlpha": true, + "_timeScale": 1, + "_preCacheMode": 0, + "_cacheMode": 0, + "_defaultCacheMode": 0, + "_sockets": [], + "_useTint": false, + "_debugMesh": false, + "_debugBones": false, + "_debugSlots": false, + "_enableBatch": false, + "loop": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "89C5gFHAdBlJbIYn4ncYCm" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ff9s+mSCdOhIPYSW36LMEs", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.UITransform", "_name": "", @@ -3429,7 +3989,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 144 + "__id__": 168 }, "_contentSize": { "__type__": "cc.Size", @@ -3457,7 +4017,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 146 + "__id__": 170 }, "_alignFlags": 45, "_target": null, @@ -3493,7 +4053,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 148 + "__id__": 172 }, "frameText": { "__id__": 19 diff --git a/JisolGameCocos/assets/resources/prefab/ui/System/LoginView.prefab b/JisolGameCocos/assets/resources/prefab/ui/System/LoginView.prefab index 1aa52477..e39b078a 100644 --- a/JisolGameCocos/assets/resources/prefab/ui/System/LoginView.prefab +++ b/JisolGameCocos/assets/resources/prefab/ui/System/LoginView.prefab @@ -1201,7 +1201,7 @@ "b": 255, "a": 255 }, - "_string": "注册", + "_string": "快速注册", "_horizontalAlign": 1, "_verticalAlign": 1, "_actualFontSize": 24, diff --git a/JisolGameCocos/assets/script/App.ts b/JisolGameCocos/assets/script/App.ts index 17f5bfef..b0e6994b 100644 --- a/JisolGameCocos/assets/script/App.ts +++ b/JisolGameCocos/assets/script/App.ts @@ -12,7 +12,6 @@ import JNLayerBase from "../../extensions/ngame/assets/ngame/ui/base/JNLayerBase import { EventDispatcher } from "../../extensions/ngame/assets/ngame/util/EventDispatcher"; import { JsonLoad, JsonUtil } from "../../extensions/ngame/assets/ngame/util/JsonUtil"; import NGameMessage from "../../extensions/ngame/assets/ngame/util/NGameMessage"; -import axios from "../../extensions/ngame/assets/plugins/axios.js"; import GBattleModeManager from "./battle/GBattleModeManager"; import { GLayer, GUI, UIConfig } from "./ui/UIConfig"; import JLoaderSystem from "../../extensions/ngame/assets/ngame/system/JLoaderSystem"; @@ -23,8 +22,12 @@ import { TB, Tables } from "../resources/config/data/schema"; import { JsonAsset } from "cc"; import { GAction } from "./consts/GActionEnum"; import { StorageData, StorageEnum } from "./consts/GData"; +import { Axios, Env, JNGame } from "../../extensions/ngame/assets/ngame/JNGame"; -let IP = "kyu.jisol.cn"; +//设置微信环境 +JNGame.setEnv(Env.WX); + +let IP = "localhost"; //重写UI class JNGLayer extends JNLayer{ @@ -231,9 +234,10 @@ export const app = { sync : new JNGSyncFrame(), //同步 event : EventDispatcher.getIns(), //通知 proto : NGameMessage.getIns(), //消息 - api : axios.create({ - baseURL: `http://${IP}:8080`, - }), //请求 + // api : Axios.create({ + // baseURL: `http://${IP}:8080`, + // }), //请求 + // api : {}, //请求 battle : GBattleModeManager.getIns(), //战斗 config : new JNGConfig(), //配置文件 battleRes : new JLoaderBattle("battle"), //battle包 @@ -242,4 +246,10 @@ export const app = { [JLoaderBattle.loading]:{title:"加载战斗资源"}, [JLoaderBattle.loadingInit]:{title:"初始化战斗资源"}, }), -} \ No newline at end of file +} + +// app.api.interceptors.request.use(function(config){ +// //设置Token +// config.headers.set("Token",StorageData.get(StorageEnum.Token)); +// return config; +// }) \ No newline at end of file diff --git a/JisolGameCocos/assets/script/Main.ts b/JisolGameCocos/assets/script/Main.ts index 92fd8e1f..d6f1ae64 100644 --- a/JisolGameCocos/assets/script/Main.ts +++ b/JisolGameCocos/assets/script/Main.ts @@ -1,6 +1,6 @@ import { _decorator, Component, director, instantiate, Node, Prefab } from 'cc'; import { app } from './App'; -import { JNGame } from '../../extensions/ngame/assets/ngame/JNGame'; +import { Env, JNGame } from '../../extensions/ngame/assets/ngame/JNGame'; import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction'; const { ccclass, property } = _decorator; diff --git a/JisolGameCocos/assets/script/consts/API.ts b/JisolGameCocos/assets/script/consts/API.ts index bdcfd840..b35048bf 100644 --- a/JisolGameCocos/assets/script/consts/API.ts +++ b/JisolGameCocos/assets/script/consts/API.ts @@ -13,6 +13,11 @@ const RData = (data:any) => { } } +export interface NewsContext{ + state:number, + msg:string, + data:any, +} export interface UserVO{ userId:number, //玩家Id userName:string, //玩家名称 @@ -25,8 +30,9 @@ export interface UserLoginVO{ export const API = { - UserRegister : async () => RData(await http.post(`/user/register`)) as UserVO, - UserLogin : async (account:string,password:string) => RData(await http.post(`/user/login`,{userId:account,userPass:password})) as UserLoginVO, + UserRegister : async () => RData(await http.post(`/user/register`)) as UserVO, //玩家注册 + UserLogin : async (account:string,password:string) => RData(await http.post(`/user/login`,{userId:account,userPass:password})) as UserLoginVO, //玩家登录 + GetPlayerInfo : async () => (await http.get(`/game/player/info`)).data as NewsContext, //获取玩家信息 } diff --git a/JisolGameCocos/assets/script/ui/Home/HomeView.ts b/JisolGameCocos/assets/script/ui/Home/HomeView.ts index fe3fda08..0faa7c03 100644 --- a/JisolGameCocos/assets/script/ui/Home/HomeView.ts +++ b/JisolGameCocos/assets/script/ui/Home/HomeView.ts @@ -6,6 +6,7 @@ import { director } from 'cc'; import { WorldCanvas } from '../../WorldCanvas'; import { StorageData, StorageEnum } from '../../consts/GData'; import { GUI } from '../UIConfig'; +import { API } from '../../consts/API'; const { ccclass, property } = _decorator; @ccclass('HomeView') @@ -14,6 +15,10 @@ export class HomeView extends JNGLayerBase { @property(Label) frameText:Label; + async onLoad(){ + app.layer.Open(GUI.Tips,{text:(await API.GetPlayerInfo()).msg}); + } + update(){ this.frameText.string = `当前帧数: ${app.sync.frame}`; } diff --git a/JisolGameCocos/extensions/ngame b/JisolGameCocos/extensions/ngame index 20392fca..eed71d58 160000 --- a/JisolGameCocos/extensions/ngame +++ b/JisolGameCocos/extensions/ngame @@ -1 +1 @@ -Subproject commit 20392fca1c6b8b903d2c517fbab15cde450cc9f9 +Subproject commit eed71d5820b3a313f6daf848e4d91abdcb55b367 diff --git a/JisolGameCocos/settings/v2/packages/builder.json b/JisolGameCocos/settings/v2/packages/builder.json index effd6aff..cd07ece9 100644 --- a/JisolGameCocos/settings/v2/packages/builder.json +++ b/JisolGameCocos/settings/v2/packages/builder.json @@ -1,6 +1,82 @@ { "__version__": "1.3.7", "bundleConfig": { - "custom": {} + "custom": { + "514cB4o1lDLr4YHgRwsEVt": { + "displayName": "远程", + "configs": { + "native": { + "preferredOptions": { + "isRemote": true, + "compressionType": "merge_dep" + } + }, + "web": { + "preferredOptions": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "fallbackOptions": { + "compressionType": "merge_dep" + } + }, + "miniGame": { + "fallbackOptions": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "configMode": "fallback", + "overwriteSettings": { + "alipay-mini-game": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "bytedance-mini-game": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "fb-instant-games": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "huawei-quick-game": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "oppo-mini-game": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "taobao-creative-app": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "taobao-mini-game": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "vivo-mini-game": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "wechatgame": { + "isRemote": true, + "compressionType": "merge_dep" + }, + "xiaomi-quick-game": { + "isRemote": true, + "compressionType": "merge_dep" + } + } + } + } + } + } + }, + "splash-setting": { + "logo": { + "type": "default" + }, + "totalTime": 500 } } diff --git a/JisolGameCocos/settings/v2/packages/information.json b/JisolGameCocos/settings/v2/packages/information.json index 1f29b4f0..2031e5f9 100644 --- a/JisolGameCocos/settings/v2/packages/information.json +++ b/JisolGameCocos/settings/v2/packages/information.json @@ -6,7 +6,7 @@ "label": "customSplash", "enable": true, "customSplash": { - "complete": false, + "complete": true, "form": "https://creator-api.cocos.com/api/form/show?sid=1b8a08a3e3a81e84a39b39c967858a15" } }, diff --git a/JisolGameServer/JNGame b/JisolGameServer/JNGame index b2141048..f3a45363 160000 --- a/JisolGameServer/JNGame +++ b/JisolGameServer/JNGame @@ -1 +1 @@ -Subproject commit b2141048e531cd2d44bea27887b570d0a2f300cd +Subproject commit f3a45363cab5962aed80e50d2f01827b3e7b9704 diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/config/CorsConfig.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/config/CorsConfig.java index b52857f5..9819d1fd 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/config/CorsConfig.java +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/config/CorsConfig.java @@ -1,17 +1,24 @@ package cn.jisol.game.config; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -class CorsConfig implements WebMvcConfigurer { - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("*") - .allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS") - .allowCredentials(true) - .maxAge(3600) - .allowedHeaders("*"); +class CorsConfig { + @Bean + public CorsFilter corsFilter() { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.addAllowedOrigin("*"); + corsConfiguration.addAllowedHeader("*"); + corsConfiguration.addAllowedMethod("*"); + corsConfiguration.setAllowCredentials(true); + + UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); + urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); + return new CorsFilter(urlBasedCorsConfigurationSource); } } diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/config/WebConfig.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/config/WebConfig.java new file mode 100644 index 00000000..38982978 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/config/WebConfig.java @@ -0,0 +1,30 @@ +package cn.jisol.game.config; + +import cn.jisol.game.controller.argsresolver.UserMethodArgumentResolver; +import cn.jisol.game.interceptor.LoginInterceptor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.List; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + /** + * 添加登录拦截器 + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + WebMvcConfigurer.super.addInterceptors(registry); + registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/game/**"); + } + + @Override + public void addArgumentResolvers(List resolvers) { + WebMvcConfigurer.super.addArgumentResolvers(resolvers); + resolvers.add(new UserMethodArgumentResolver()); + } +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/HttpCode.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/HttpCode.java new file mode 100644 index 00000000..38fe7316 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/HttpCode.java @@ -0,0 +1,9 @@ +package cn.jisol.game.controller; + +public interface HttpCode { + + //没有创建用户 + int NOT_CREATE_PLAYER_INFO = 2001; + + +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/argsresolver/CurrentUser.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/argsresolver/CurrentUser.java new file mode 100644 index 00000000..3e9176df --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/argsresolver/CurrentUser.java @@ -0,0 +1,10 @@ +package cn.jisol.game.controller.argsresolver; + +import java.lang.annotation.*; + +@Target({ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface CurrentUser { + +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/argsresolver/UserMethodArgumentResolver.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/argsresolver/UserMethodArgumentResolver.java new file mode 100644 index 00000000..a9a27b74 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/argsresolver/UserMethodArgumentResolver.java @@ -0,0 +1,41 @@ +package cn.jisol.game.controller.argsresolver; + +import cn.jisol.game.controller.exception.TokenException; +import cn.jisol.game.data.Cache; +import cn.jisol.game.entity.User; +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +import java.util.Objects; + +@Component +public class UserMethodArgumentResolver implements HandlerMethodArgumentResolver { + + @Override + public boolean supportsParameter(MethodParameter parameter) { + if (parameter.hasParameterAnnotation(CurrentUser.class)) { + return true; + } + return false; + } + + @Override + public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception { + + //获取Token + String token = nativeWebRequest.getHeader(Cache.KEY_TOKEN); + User user; + if(Objects.isNull(token) || Objects.isNull(user = Cache.TOKEN.get(token))){ + //抛出Token异常 + throw new TokenException(); + } + + return user; + + } + +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/ExceptionEnum.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/ExceptionEnum.java new file mode 100644 index 00000000..938d8815 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/ExceptionEnum.java @@ -0,0 +1,8 @@ +package cn.jisol.game.controller.exception; + +public interface ExceptionEnum { + + //Token 失效 + Integer LOGIN_TOKEN = 1001; + +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/HTTPExceptionHandler.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/HTTPExceptionHandler.java new file mode 100644 index 00000000..39155bab --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/HTTPExceptionHandler.java @@ -0,0 +1,27 @@ +package cn.jisol.game.controller.exception; + +import cn.jisol.ngame.util.NewsContext; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; + +import static cn.jisol.game.controller.exception.ExceptionEnum.LOGIN_TOKEN; + +@ControllerAdvice +public class HTTPExceptionHandler { + + //登录异常 + @ExceptionHandler(value = TokenException.class) + @ResponseBody + public NewsContext loginExceptionHandler(TokenException e){ + return NewsContext.onMessage("Token 失效",null,LOGIN_TOKEN); + } + + //全局异常 + @ExceptionHandler(value = Exception.class) + @ResponseBody + public NewsContext exceptionHandler(Exception e){ + e.printStackTrace(); + return NewsContext.onFail("异常错误:"+e.getMessage()); + } +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/TokenException.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/TokenException.java new file mode 100644 index 00000000..959f2dd5 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/exception/TokenException.java @@ -0,0 +1,4 @@ +package cn.jisol.game.controller.exception; + +public class TokenException extends Exception{ +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/game/PlayerController.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/game/PlayerController.java new file mode 100644 index 00000000..07d2f6af --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/game/PlayerController.java @@ -0,0 +1,45 @@ +package cn.jisol.game.controller.game; + +import cn.jisol.game.controller.HttpCode; +import cn.jisol.game.controller.argsresolver.CurrentUser; +import cn.jisol.game.entity.User; +import cn.jisol.game.entity.game.Player; +import cn.jisol.game.service.PlayerService; +import cn.jisol.game.service.impl.PlayerServiceImpl; +import cn.jisol.ngame.util.NewsContext; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Objects; + +/** + * 新手API + */ +@RestController +@RequestMapping("/game/player") +@ResponseBody +public class PlayerController { + + @Autowired + PlayerServiceImpl playerService; + + //获取玩家信息 + @GetMapping("/info") + public NewsContext getPlayerInfo(@CurrentUser User user){ + + Player info = playerService.getOne(Wrappers.lambdaQuery(Player.class).eq(Player::getUserId,user.getUserId())); + + if (Objects.isNull(info)){ + //玩家没有进入过游戏 前往 新手引导 + return NewsContext.onMessage("前往新手引导",null, HttpCode.NOT_CREATE_PLAYER_INFO); + }else{ + return NewsContext.onSuccess("获取成功",info); + } + + } + +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/data/Cache.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/data/Cache.java index 356d784f..fe5c9231 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/data/Cache.java +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/data/Cache.java @@ -10,6 +10,7 @@ import java.util.Map; */ public class Cache { + public static String KEY_TOKEN = "Token"; public static Map TOKEN = new HashMap<>(); } diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/entity/game/Player.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/entity/game/Player.java new file mode 100644 index 00000000..8e93e3f1 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/entity/game/Player.java @@ -0,0 +1,18 @@ +package cn.jisol.game.entity.game; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Builder; +import lombok.Data; + +@Builder +@Data +@TableName("`player`") +public class Player { + @TableId(type = IdType.AUTO) + private Long playerId; //游戏玩家Id + private String userId; //玩家Id + private String playerName; //游戏玩家名称 + private Long playerCreateTime; //玩家创建时间 +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/entity/game/PlayerPet.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/entity/game/PlayerPet.java new file mode 100644 index 00000000..d10a23d9 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/entity/game/PlayerPet.java @@ -0,0 +1,20 @@ +package cn.jisol.game.entity.game; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Builder; +import lombok.Data; + +/** + * 玩家宠物 + */ +@Builder +@Data +@TableName("`player_pet`") +public class PlayerPet { + @TableId(type = IdType.AUTO) + private Long petId; //宠物唯一Id + private String petTbId; //宠物配置表Id + private String petGrade; //宠物等级 +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/interceptor/LoginInterceptor.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/interceptor/LoginInterceptor.java new file mode 100644 index 00000000..c5078a16 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/interceptor/LoginInterceptor.java @@ -0,0 +1,30 @@ +package cn.jisol.game.interceptor; + +import cn.jisol.game.controller.exception.TokenException; +import cn.jisol.game.data.Cache; +import cn.jisol.game.entity.User; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Objects; + +/** + * 游戏登录拦截器 + */ +@Component +public class LoginInterceptor implements HandlerInterceptor { + + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + //获取Token + String token = request.getHeader(Cache.KEY_TOKEN); + if(Objects.isNull(token) || Objects.isNull(Cache.TOKEN.get(token))) { + //抛出Token异常 + throw new TokenException(); + } + return true; + } +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/mapper/PlayerMapper.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/mapper/PlayerMapper.java new file mode 100644 index 00000000..fc4cc11d --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/mapper/PlayerMapper.java @@ -0,0 +1,10 @@ +package cn.jisol.game.mapper; + +import cn.jisol.game.entity.game.Player; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Component; + +@Component +public interface PlayerMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/service/PlayerService.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/service/PlayerService.java new file mode 100644 index 00000000..87ff3c15 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/service/PlayerService.java @@ -0,0 +1,9 @@ +package cn.jisol.game.service; + +import cn.jisol.game.entity.User; +import cn.jisol.game.entity.game.Player; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface PlayerService extends IService { + +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/service/impl/PlayerServiceImpl.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/service/impl/PlayerServiceImpl.java new file mode 100644 index 00000000..a8802863 --- /dev/null +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/service/impl/PlayerServiceImpl.java @@ -0,0 +1,15 @@ +package cn.jisol.game.service.impl; + +import cn.jisol.game.entity.User; +import cn.jisol.game.entity.game.Player; +import cn.jisol.game.mapper.PlayerMapper; +import cn.jisol.game.mapper.UserMapper; +import cn.jisol.game.service.PlayerService; +import cn.jisol.game.service.UserService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class PlayerServiceImpl extends ServiceImpl implements PlayerService { + +}