mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交上阵
This commit is contained in:
@@ -4,6 +4,7 @@ import BaseData from "./data/BaseData";
|
||||
import ChatData from "./data/ChatData";
|
||||
import PlayerData from "./data/PlayerData";
|
||||
import PlayerPetData from "./data/PlayerPetData";
|
||||
import PlayerTacticalData from "./data/PlayerTacticalData";
|
||||
|
||||
//数据类 (用于初始化游戏信息)
|
||||
export class AppData extends SystemBase{
|
||||
@@ -14,6 +15,7 @@ export class AppData extends SystemBase{
|
||||
PlayerData.getIns(), //玩家信息
|
||||
PlayerPetData.getIns(), //玩家宠物信息
|
||||
ChatData.getIns(), //聊天
|
||||
PlayerTacticalData.getIns(), //阵法
|
||||
];
|
||||
|
||||
async onInit(): Promise<any> {
|
||||
|
@@ -6,6 +6,7 @@ import { Node } from "cc";
|
||||
import { instantiate } from "cc";
|
||||
import { app } from "../App";
|
||||
import { JNFrameInfo, JNSyncFrameEvent } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
import { CCObject } from "cc";
|
||||
|
||||
export enum BattleMode{
|
||||
//无尽模式
|
||||
@@ -60,8 +61,6 @@ export default class GBattleModeManager extends Singleton {
|
||||
//打开指定模式
|
||||
async Open(mode:BattleMode,isAuto:boolean = false){
|
||||
|
||||
await this.Close();
|
||||
|
||||
this.current = mode;
|
||||
this.setAuto(isAuto);
|
||||
|
||||
@@ -75,7 +74,6 @@ export default class GBattleModeManager extends Singleton {
|
||||
|
||||
//主动调用场景销毁
|
||||
app.sync.onReset();
|
||||
this.clear();
|
||||
this.current = null;
|
||||
|
||||
}
|
||||
@@ -94,6 +92,7 @@ export default class GBattleModeManager extends Singleton {
|
||||
|
||||
//创建当前模式
|
||||
private create(){
|
||||
|
||||
if(!this.isInit || this.current == null) return;
|
||||
let mode = instantiate(this.modes[this.current]);
|
||||
mode.getComponent(GBaseMode).camera = this.camera;
|
||||
|
@@ -34,9 +34,9 @@ export class GTactical{
|
||||
//获取阵法
|
||||
static getTactical(isReversed:boolean = false): GTactical{
|
||||
let tactical = [
|
||||
[0,4,3],
|
||||
[6,0,1],
|
||||
[0,5,2],
|
||||
[7,4,1],
|
||||
[8,5,2],
|
||||
[9,6,3],
|
||||
];
|
||||
if(isReversed){
|
||||
tactical = this.getTacticalFlipX(tactical);
|
||||
|
@@ -40,7 +40,7 @@ export interface GOnHookInfo{
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂机模式 无限出现小怪
|
||||
* 挂机模式 无限出现小怪 (不是联机模式 该模式支持使用本地数据)
|
||||
*/
|
||||
@ccclass('GOnHookMode')
|
||||
export default class GOnHookMode extends GBaseMode<{}>{
|
||||
|
@@ -13,20 +13,29 @@ const RData = (data:any,isTips:boolean = true) => {
|
||||
}
|
||||
}
|
||||
|
||||
/************** 请求类 *******************/
|
||||
export interface NewsContext{
|
||||
state:number,
|
||||
msg:string,
|
||||
data:any,
|
||||
}
|
||||
//玩家登录返回
|
||||
export interface UserLoginVO{
|
||||
token:string, //token
|
||||
user:UserVO, //玩家信息
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************** 实体类 **************************/
|
||||
|
||||
//玩家信息
|
||||
export interface UserVO{
|
||||
userId:number, //玩家Id
|
||||
userName:string, //玩家名称
|
||||
userPass:string, //玩家密码
|
||||
}
|
||||
export interface UserLoginVO{
|
||||
token:string, //token
|
||||
user:UserVO, //玩家信息
|
||||
}
|
||||
//游戏玩家信息
|
||||
export interface PlayerInfoOV{
|
||||
playerId:number, //玩家Id
|
||||
userId: number, //用户Id
|
||||
@@ -34,12 +43,18 @@ export interface PlayerInfoOV{
|
||||
playerCreateTime:number, //玩家创建时间
|
||||
novice: false, //是否过引导
|
||||
}
|
||||
//玩家宠物信息
|
||||
export interface PlayerPetOV{
|
||||
petId:number, //宠物唯一Id
|
||||
petPlayerId:number; //宠物的玩家Id
|
||||
petTbId:number; //宠物配置表Id
|
||||
petGrade:number; //宠物等级
|
||||
}
|
||||
//玩家阵法信息
|
||||
export interface PlayerTacticalOV{
|
||||
playerId:number, //玩家Id
|
||||
tacticalData:string, //阵法数据
|
||||
}
|
||||
|
||||
export const API = {
|
||||
|
||||
@@ -54,5 +69,9 @@ export const API = {
|
||||
|
||||
/********** 宠物接口 ******************/
|
||||
GetPlayerPets: async () => RData(await app.api.get(`/game/pet/list`),false) as PlayerPetOV[], //获取玩家全部宠物
|
||||
|
||||
/********** 阵法接口 ******************/
|
||||
GetPlayerTactical: async () => RData(await app.api.get(`/game/tactical/get`),false) as PlayerTacticalOV, //获取玩家阵法
|
||||
SetPlayerTactical: async (data:PlayerTacticalOV) => RData(await app.api.post(`/game/tactical/set`,data),false) as PlayerTacticalOV, //更新玩家阵法
|
||||
}
|
||||
|
||||
|
@@ -7,12 +7,11 @@ import BaseData from "./BaseData";
|
||||
//聊天数据
|
||||
export default class ChatData extends BaseData{
|
||||
|
||||
static Event = "ChatData_Event_Message";
|
||||
|
||||
//世界消息列表
|
||||
datas:string[] = [];
|
||||
|
||||
//接受消息事件
|
||||
receives:Function[] = [];
|
||||
|
||||
onInit() {
|
||||
//监听聊天消息
|
||||
app.socket.on(GAction.CHAT_RECEIVE_MESSAGE,this.onChatReceiveMessage,this,GActionType.GUIChatMessage);
|
||||
@@ -23,7 +22,7 @@ export default class ChatData extends BaseData{
|
||||
onChatReceiveMessage(info:GUIChatMessage){
|
||||
console.log(`ChatData - onChatReceiveMessage`,info.message);
|
||||
this.datas.push(info.message);
|
||||
this.receives.forEach(fun => fun(info))
|
||||
app.event.emit(ChatData.Event,info);
|
||||
}
|
||||
|
||||
//发送消息
|
||||
@@ -32,14 +31,12 @@ export default class ChatData extends BaseData{
|
||||
}
|
||||
|
||||
//监听接受消息
|
||||
on(receive:Function){
|
||||
this.receives.push(receive);
|
||||
on(receive:Function,target?: any){
|
||||
app.event.on(ChatData.Event,receive,target)
|
||||
}
|
||||
//取消
|
||||
off(receive:Function){
|
||||
let index = this.receives.indexOf(receive);
|
||||
if(index != -1)
|
||||
this.receives.splice(index,1);
|
||||
off(receive:Function,target?: any){
|
||||
app.event.off(ChatData.Event,receive,target)
|
||||
}
|
||||
|
||||
}
|
||||
|
50
JisolGameCocos/assets/script/data/PlayerTacticalData.ts
Normal file
50
JisolGameCocos/assets/script/data/PlayerTacticalData.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { API, PlayerTacticalOV } from "../consts/API";
|
||||
import BaseData from "./BaseData";
|
||||
|
||||
interface PlayerTacticalInfo extends PlayerTacticalOV{
|
||||
roles:number[], //上阵的宠物顺序
|
||||
}
|
||||
|
||||
//玩家阵法数据 (玩家最多上阵 9 个宠物)
|
||||
export default class PlayerTacticalData extends BaseData{
|
||||
|
||||
//阵法信息
|
||||
info:PlayerTacticalInfo;
|
||||
|
||||
async onInit() {
|
||||
|
||||
await this.onUpdateInfo();
|
||||
|
||||
}
|
||||
|
||||
//更新阵法信息
|
||||
async onUpdateInfo(){
|
||||
let ov = await API.GetPlayerTactical();
|
||||
if(!ov.tacticalData){
|
||||
ov.tacticalData = JSON.stringify(this.getTacticalInfo());
|
||||
}
|
||||
this.info = {
|
||||
...ov,
|
||||
roles: JSON.parse(ov.tacticalData),
|
||||
}
|
||||
}
|
||||
|
||||
//更新上阵
|
||||
async UpdateTactical(roles:number[]){
|
||||
this.info.roles = roles;
|
||||
this.info.tacticalData = JSON.stringify(this.info.roles);
|
||||
//上传到服务器
|
||||
await API.SetPlayerTactical(this.info);
|
||||
}
|
||||
|
||||
//获取指定位置
|
||||
getItem(index:number){
|
||||
return this.info.roles[index];
|
||||
}
|
||||
|
||||
//获取初始化上阵信息
|
||||
getTacticalInfo():number[]{
|
||||
return [0,0,0,0,0,0,0,0,0]
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d2425352-add6-461a-ab20-32515cf9eb1e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
9
JisolGameCocos/assets/script/ui/Consts.meta
Normal file
9
JisolGameCocos/assets/script/ui/Consts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "0c3951ab-4554-4998-ad31-2acc45233dbd",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
9
JisolGameCocos/assets/script/ui/Consts/Tactical.meta
Normal file
9
JisolGameCocos/assets/script/ui/Consts/Tactical.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "231e3614-8fc2-4590-bc9f-57ff63343f85",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import PlayerTacticalData from '../../../data/PlayerTacticalData';
|
||||
import { app } from '../../../App';
|
||||
import { GUI } from '../../UIConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PlayerTacticalItem')
|
||||
export class PlayerTacticalItem extends Component {
|
||||
|
||||
//阵法的Index;
|
||||
index:number;
|
||||
|
||||
//初始化阵法
|
||||
onInit(index:number){
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
//更新信息
|
||||
onUpdateView(){
|
||||
PlayerTacticalData.getIns().getItem(this.index);
|
||||
}
|
||||
|
||||
//点击
|
||||
onClick(){
|
||||
app.layer.Open(GUI.IntoBattleView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "78c30f1a-d1d0-4210-9fc4-f7067364f26a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { PlayerTacticalItem } from './PlayerTacticalItem';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 玩家阵法
|
||||
*/
|
||||
@ccclass('PlayerTacticalView')
|
||||
export class PlayerTacticalView extends Component {
|
||||
|
||||
|
||||
//阵法子节点列表
|
||||
items:PlayerTacticalItem[] = [];
|
||||
|
||||
// onLoad(){
|
||||
|
||||
// //阵法
|
||||
// this.items = this.node.getComponentsInChildren(PlayerTacticalItem);
|
||||
// this.items.forEach((item,index) => item.onInit(index));
|
||||
|
||||
// this.onUpdateView();
|
||||
|
||||
// }
|
||||
|
||||
// //更新阵法显示
|
||||
// onUpdateView(){
|
||||
// this.items.forEach(item => {
|
||||
// item.onUpdateView();
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a9372de8-9c71-492e-af72-cee66fd5e045",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -30,13 +30,13 @@ export class MainChatView extends JNGLayerBase {
|
||||
this.onInitUpdate();
|
||||
|
||||
//监听消息
|
||||
ChatData.getIns().on(this.onMessage.bind(this));
|
||||
ChatData.getIns().on(this.onMessage.bind(this),this);
|
||||
|
||||
}
|
||||
|
||||
onJNClose(): void {
|
||||
super.onJNClose();
|
||||
ChatData.getIns().off(this.onMessage.bind(this));
|
||||
ChatData.getIns().off(this.onMessage.bind(this),this);
|
||||
}
|
||||
|
||||
//初始化聊天显示
|
||||
|
9
JisolGameCocos/assets/script/ui/Tactical.meta
Normal file
9
JisolGameCocos/assets/script/ui/Tactical.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "01b33bd2-2568-49ba-a042-ba4178c96227",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
14
JisolGameCocos/assets/script/ui/Tactical/IntoBattleView.ts
Normal file
14
JisolGameCocos/assets/script/ui/Tactical/IntoBattleView.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//上阵页面
|
||||
@ccclass('IntoBattleView')
|
||||
export class IntoBattleView extends JNLayerBase {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "00e5f8b0-939e-4e16-aed9-2199a4b17189",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -13,13 +13,15 @@ export enum GUI{
|
||||
Loading = "Loading", //加载页面
|
||||
Tips = "Tips", //提示
|
||||
|
||||
/** 主页页面 */
|
||||
MainChat = "MainChat", //主页聊天页面
|
||||
|
||||
/** 新手引导 */
|
||||
NoviceNamingView = "NoviceNamingView", //新手引导页面 - 取名
|
||||
NoviceSelectPetView = "NoviceSelectPetView", //新手引导页面 - 选择宠物
|
||||
|
||||
/** 主页页面 */
|
||||
MainChat = "MainChat", //主页聊天页面
|
||||
|
||||
IntoBattleView = "IntoBattleView", //上阵页面
|
||||
|
||||
Home = "Home", //主页面
|
||||
Main = "Main", //主页面2
|
||||
}
|
||||
@@ -110,6 +112,14 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
|
||||
},
|
||||
},
|
||||
[GUI.IntoBattleView]:{
|
||||
layer:GLayer.View,
|
||||
uri: "prefab/ui/阵法/IntoBattleView",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
},
|
||||
},
|
||||
...UISystemConfig, //系统页面
|
||||
...UINoviceConfig, //新手引导页面
|
||||
...UIMainConfig, //主页面
|
||||
|
Reference in New Issue
Block a user