mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
生成野怪逻辑
This commit is contained in:
parent
c4437fef5e
commit
62b72bdcfc
Binary file not shown.
BIN
DataTables/Datas/战斗/模式/OnHook模式的全局表.xlsx
Normal file
BIN
DataTables/Datas/战斗/模式/OnHook模式的全局表.xlsx
Normal file
Binary file not shown.
@ -276,6 +276,39 @@ export class TbGMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export namespace TB {
|
||||||
|
export class TbGOnHookGlobal {
|
||||||
|
|
||||||
|
constructor(_json_: any) {
|
||||||
|
if (_json_.id === undefined) { throw new Error() }
|
||||||
|
this.id = _json_.id
|
||||||
|
if (_json_.args === undefined) { throw new Error() }
|
||||||
|
this.args = _json_.args
|
||||||
|
if (_json_.tig === undefined) { throw new Error() }
|
||||||
|
this.tig = _json_.tig
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
readonly id: number
|
||||||
|
/**
|
||||||
|
* 全局表参数
|
||||||
|
*/
|
||||||
|
readonly args: string
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
readonly tig: string
|
||||||
|
|
||||||
|
resolve(tables:Tables)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export class TbGGlobal{
|
export class TbGGlobal{
|
||||||
@ -470,6 +503,38 @@ export class TbGMap{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export class TbGOnHookGlobal{
|
||||||
|
private _dataMap: Map<number, TB.TbGOnHookGlobal>
|
||||||
|
private _dataList: TB.TbGOnHookGlobal[]
|
||||||
|
constructor(_json_: any) {
|
||||||
|
this._dataMap = new Map<number, TB.TbGOnHookGlobal>()
|
||||||
|
this._dataList = []
|
||||||
|
for(var _json2_ of _json_) {
|
||||||
|
let _v: TB.TbGOnHookGlobal
|
||||||
|
_v = new TB.TbGOnHookGlobal(_json2_)
|
||||||
|
this._dataList.push(_v)
|
||||||
|
this._dataMap.set(_v.id, _v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getDataMap(): Map<number, TB.TbGOnHookGlobal> { return this._dataMap; }
|
||||||
|
getDataList(): TB.TbGOnHookGlobal[] { return this._dataList; }
|
||||||
|
|
||||||
|
get(key: number): TB.TbGOnHookGlobal | undefined { return this._dataMap.get(key); }
|
||||||
|
|
||||||
|
resolve(tables:Tables)
|
||||||
|
{
|
||||||
|
for(let data of this._dataList)
|
||||||
|
{
|
||||||
|
data.resolve(tables)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type JsonLoader = (file: string) => any
|
type JsonLoader = (file: string) => any
|
||||||
|
|
||||||
export class Tables {
|
export class Tables {
|
||||||
@ -485,6 +550,8 @@ export class Tables {
|
|||||||
get TbGRoleSkill(): TbGRoleSkill { return this._TbGRoleSkill;}
|
get TbGRoleSkill(): TbGRoleSkill { return this._TbGRoleSkill;}
|
||||||
private _TbGMap: TbGMap
|
private _TbGMap: TbGMap
|
||||||
get TbGMap(): TbGMap { return this._TbGMap;}
|
get TbGMap(): TbGMap { return this._TbGMap;}
|
||||||
|
private _TbGOnHookGlobal: TbGOnHookGlobal
|
||||||
|
get TbGOnHookGlobal(): TbGOnHookGlobal { return this._TbGOnHookGlobal;}
|
||||||
|
|
||||||
constructor(loader: JsonLoader) {
|
constructor(loader: JsonLoader) {
|
||||||
this._TbGGlobal = new TbGGlobal(loader('tbgglobal'))
|
this._TbGGlobal = new TbGGlobal(loader('tbgglobal'))
|
||||||
@ -493,6 +560,7 @@ export class Tables {
|
|||||||
this._TbGRoleBattleRes = new TbGRoleBattleRes(loader('tbgrolebattleres'))
|
this._TbGRoleBattleRes = new TbGRoleBattleRes(loader('tbgrolebattleres'))
|
||||||
this._TbGRoleSkill = new TbGRoleSkill(loader('tbgroleskill'))
|
this._TbGRoleSkill = new TbGRoleSkill(loader('tbgroleskill'))
|
||||||
this._TbGMap = new TbGMap(loader('tbgmap'))
|
this._TbGMap = new TbGMap(loader('tbgmap'))
|
||||||
|
this._TbGOnHookGlobal = new TbGOnHookGlobal(loader('tbgonhookglobal'))
|
||||||
|
|
||||||
this._TbGGlobal.resolve(this)
|
this._TbGGlobal.resolve(this)
|
||||||
this._TbGRole.resolve(this)
|
this._TbGRole.resolve(this)
|
||||||
@ -500,5 +568,6 @@ export class Tables {
|
|||||||
this._TbGRoleBattleRes.resolve(this)
|
this._TbGRoleBattleRes.resolve(this)
|
||||||
this._TbGRoleSkill.resolve(this)
|
this._TbGRoleSkill.resolve(this)
|
||||||
this._TbGMap.resolve(this)
|
this._TbGMap.resolve(this)
|
||||||
|
this._TbGOnHookGlobal.resolve(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 80001,
|
||||||
|
"args": "100",
|
||||||
|
"tig": "预先生成的野外宠物数量"
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"ver": "2.0.1",
|
||||||
|
"importer": "json",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "0ccb44c9-b7bc-4fc6-b7d2-8a4335f806a5",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,8 @@ import PlayerTacticalData, { PlayerTacticalEvent } from "../../data/PlayerTactic
|
|||||||
import GRoleOnHookExpand from "../base/role/expand/OnHook/GRoleOnHookExpand";
|
import GRoleOnHookExpand from "../base/role/expand/OnHook/GRoleOnHookExpand";
|
||||||
import PlayerPetData from "../../data/PlayerPetData";
|
import PlayerPetData from "../../data/PlayerPetData";
|
||||||
import { GUI } from "../../ui/UIConfig";
|
import { GUI } from "../../ui/UIConfig";
|
||||||
|
import { GAction } from "../../consts/GAction";
|
||||||
|
import { GActionType } from "../../consts/GActionType";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
//挂机模式状态
|
//挂机模式状态
|
||||||
@ -43,6 +45,16 @@ export interface GOnHookInfo{
|
|||||||
roles: TB.TbGRole[];
|
roles: TB.TbGRole[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//野怪
|
||||||
|
interface GOnHookPet{
|
||||||
|
key:string; //野怪唯一Id
|
||||||
|
petTbId:number; //野怪配置表Id
|
||||||
|
}
|
||||||
|
//野怪列表
|
||||||
|
interface GOnHookPets{
|
||||||
|
pets:GOnHookPet[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 挂机模式 无限出现小怪 (不是联机模式 该模式支持使用本地数据)
|
* 挂机模式 无限出现小怪 (不是联机模式 该模式支持使用本地数据)
|
||||||
*/
|
*/
|
||||||
@ -103,6 +115,21 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
//是否允许攻击
|
//是否允许攻击
|
||||||
isAllowAttack:boolean = false;
|
isAllowAttack:boolean = false;
|
||||||
|
|
||||||
|
//野怪列表
|
||||||
|
_wildlifes:GOnHookPets;
|
||||||
|
get wildlifes(){
|
||||||
|
//如果没有野怪了 则 向服务器生成
|
||||||
|
if(!this._wildlifes || !(this._wildlifes.pets.length)){
|
||||||
|
//生成
|
||||||
|
this.onSpawnWildlife();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this._wildlifes;
|
||||||
|
}
|
||||||
|
set wildlifes(data:GOnHookPets){
|
||||||
|
this._wildlifes = data;
|
||||||
|
}
|
||||||
|
|
||||||
//添加监听事件
|
//添加监听事件
|
||||||
addEvent(){
|
addEvent(){
|
||||||
app.event.on(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
|
app.event.on(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
|
||||||
@ -135,14 +162,22 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
this.map3.init(app.battleRes.maps[60001][2],1,app.battleRes.maps[60001][1].width * scale,1048 * scale);
|
this.map3.init(app.battleRes.maps[60001][2],1,app.battleRes.maps[60001][1].width * scale,1048 * scale);
|
||||||
this.onUpdateMap(0);
|
this.onUpdateMap(0);
|
||||||
|
|
||||||
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([10004,10004,10004,10004,10003,10003]) };
|
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([]) };
|
||||||
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([10002]) };
|
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([]) };
|
||||||
|
|
||||||
this.onUpdatePlayerPet();
|
this.onUpdatePlayerPet();
|
||||||
|
|
||||||
//添加监听
|
//添加监听
|
||||||
this.addEvent();
|
this.addEvent();
|
||||||
|
|
||||||
|
// //模拟请求生成宠物
|
||||||
|
// app.socket.SendBack(GAction.MODE_ON_HOOK_SPAWN_PET,{
|
||||||
|
// type:GActionType.GOnHookPets,
|
||||||
|
// fun:(info:GOnHookPets) => {
|
||||||
|
// console.log("接受到野怪列表",info)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
//生成玩家
|
//生成玩家
|
||||||
// this.playerInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.PLAYER,index + 1,info))
|
// this.playerInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.PLAYER,index + 1,info))
|
||||||
|
|
||||||
@ -151,6 +186,17 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//生成野怪
|
||||||
|
onSpawnWildlife(){
|
||||||
|
//获取服务器野怪
|
||||||
|
app.socket.SendBack(GAction.MODE_ON_HOOK_SPAWN_PET,{
|
||||||
|
type:GActionType.GOnHookPets,
|
||||||
|
fun:(info:GOnHookPets) => {
|
||||||
|
this.wildlifes = info;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
//更新玩家宠物
|
//更新玩家宠物
|
||||||
onUpdatePlayerPet(){
|
onUpdatePlayerPet(){
|
||||||
//获取玩家阵容
|
//获取玩家阵容
|
||||||
@ -318,7 +364,12 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
//生成敌人
|
//生成敌人
|
||||||
onResetGenerateEnemy(){
|
onResetGenerateEnemy(){
|
||||||
this.enemyRoles = [];
|
this.enemyRoles = [];
|
||||||
this.enemyInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.ENEMY,index + 1,info))
|
if(!this.wildlifes) return;
|
||||||
|
|
||||||
|
//获取敌人
|
||||||
|
let wildlife = this.wildlifes.pets.shift();
|
||||||
|
this.onGenRole(GOnHookModePlayerEnum.ENEMY,2,GRoleUtil.getGRole(wildlife.petTbId));
|
||||||
|
// this.enemyInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.ENEMY,index + 1,info));
|
||||||
}
|
}
|
||||||
|
|
||||||
//角色死亡回调
|
//角色死亡回调
|
||||||
|
@ -2,8 +2,15 @@ export enum GAction {
|
|||||||
|
|
||||||
TOKEN_EXPIRED = 1001, //Token过期
|
TOKEN_EXPIRED = 1001, //Token过期
|
||||||
|
|
||||||
//聊天
|
/*************** 聊天 **************/
|
||||||
CHAT_MESSAGE = 2001, //发送聊天消息
|
CHAT_MESSAGE = 2001, //发送聊天消息
|
||||||
CHAT_RECEIVE_MESSAGE = 2002, //接受聊天消息
|
CHAT_RECEIVE_MESSAGE = 2002, //接受聊天消息
|
||||||
|
|
||||||
|
|
||||||
|
/*************** 游戏模式 : 无尽模式(OnHook) **************/
|
||||||
|
MODE_ON_HOOK_SPAWN_PET = 3001, //生成宠物
|
||||||
|
MODE_ON_HOOK_CAPTURE_PET = 3002, //捕捉宠物
|
||||||
|
MODE_ON_HOOK_SELL_PET = 3003, //卖出宠物
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -6,4 +6,9 @@ export enum GActionType {
|
|||||||
|
|
||||||
GUIChatMessage = "GUIChatMessage",//聊天信息
|
GUIChatMessage = "GUIChatMessage",//聊天信息
|
||||||
|
|
||||||
|
|
||||||
|
/*************** 游戏模式 : 无尽模式(OnHook) **************/
|
||||||
|
GOnHookPet = "GOnHookPet", //野怪
|
||||||
|
GOnHookPets = "GOnHookPets", //野怪列表
|
||||||
|
|
||||||
}
|
}
|
@ -44,11 +44,14 @@ export default class PlayerTacticalData extends BaseData{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新上阵
|
//更新上阵
|
||||||
async UpdateTactical(roles:number[]){
|
async UpdateTactical(roles:number[]):Promise<boolean>{
|
||||||
|
//如果阵法一样则不更新
|
||||||
|
if(this.info.tacticalData == JSON.stringify(roles)) return false;
|
||||||
this.info.roles = roles;
|
this.info.roles = roles;
|
||||||
this.info.tacticalData = JSON.stringify(this.info.roles);
|
this.info.tacticalData = JSON.stringify(this.info.roles);
|
||||||
//上传到服务器 并且保存
|
//上传到服务器 并且保存
|
||||||
this.onSaveTacticalInfo(await API.SetPlayerTactical(this.info));
|
this.onSaveTacticalInfo(await API.SetPlayerTactical(this.info));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//修改指定位置的上阵 上阵下标,上阵的宠物Id
|
//修改指定位置的上阵 上阵下标,上阵的宠物Id
|
||||||
|
@ -118,6 +118,12 @@ export class PlayerTacticalItem extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addMoveEndEvent(fun:Function){
|
||||||
|
this.drag.addMoveEndEvent((e) => {
|
||||||
|
fun(this,e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { _decorator, Component, Node } from 'cc';
|
import { _decorator, Component, Node } from 'cc';
|
||||||
import { PlayerTacticalItem } from './PlayerTacticalItem';
|
import { PlayerTacticalItem } from './PlayerTacticalItem';
|
||||||
import { app } from '../../../App';
|
import { app } from '../../../App';
|
||||||
import { PlayerTacticalEvent } from '../../../data/PlayerTacticalData';
|
import PlayerTacticalData, { PlayerTacticalEvent } from '../../../data/PlayerTacticalData';
|
||||||
import JNodeDrag from '../../../../../extensions/ngame/assets/ngame/util/components/JNodeDrag';
|
import JNodeDrag from '../../../../../extensions/ngame/assets/ngame/util/components/JNodeDrag';
|
||||||
import { EventTouch } from 'cc';
|
import { EventTouch } from 'cc';
|
||||||
import { UITransform } from 'cc';
|
import { UITransform } from 'cc';
|
||||||
|
import { GUI } from '../../UIConfig';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +24,10 @@ export class PlayerTacticalView extends Component {
|
|||||||
this.items = this.node.getComponentsInChildren(PlayerTacticalItem);
|
this.items = this.node.getComponentsInChildren(PlayerTacticalItem);
|
||||||
this.items.forEach((item,index) => {
|
this.items.forEach((item,index) => {
|
||||||
item.onInit(index); //初始化阵法下标
|
item.onInit(index); //初始化阵法下标
|
||||||
|
//添加移动事件
|
||||||
item.addMoveEvent(this.onMoveItem.bind(this));
|
item.addMoveEvent(this.onMoveItem.bind(this));
|
||||||
|
//添加移动结束事件
|
||||||
|
item.addMoveEndEvent(this.onMoveEndItem.bind(this));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.onUpdateView();
|
this.onUpdateView();
|
||||||
@ -53,6 +57,20 @@ export class PlayerTacticalView extends Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//子节点移动结束
|
||||||
|
async onMoveEndItem(){
|
||||||
|
|
||||||
|
//移动结束则保存阵法
|
||||||
|
let pets:number[] = PlayerTacticalData.getIns().getInitTacticalInfo();
|
||||||
|
this.items.forEach(item => {
|
||||||
|
pets[item.index] = item.petId || 0;
|
||||||
|
})
|
||||||
|
if(await PlayerTacticalData.getIns().UpdateTactical(pets)){
|
||||||
|
app.layer.Open(GUI.Tips,{text:"保存阵法成功"});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected onDestroy(): void {
|
protected onDestroy(): void {
|
||||||
this.offEvent();
|
this.offEvent();
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 01a31870c404967092e5c87fc91650bae868bbad
|
Subproject commit ea12e2c1097c07ed71baf59504455038e3b0b856
|
14
JisolGameCocos/proto/GOnHookMessage.proto
Normal file
14
JisolGameCocos/proto/GOnHookMessage.proto
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "cn.jisol.ngame.proto";
|
||||||
|
|
||||||
|
//生成宠物类
|
||||||
|
message GOnHookPet {
|
||||||
|
string key = 1; //生成宠物的key
|
||||||
|
int32 petTbId = 2; //生成宠物的配置表Id
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成的宠物类列表
|
||||||
|
message GOnHookPets {
|
||||||
|
repeated GOnHookPet pets = 1; //宠物列表
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
Subproject commit fe5330b622e0fb50a12808bc832eeb79202c4eb3
|
Subproject commit a57971eceadfcc80e06934e75a7dee7469fb10a1
|
@ -24,6 +24,7 @@ public final class TbGMap extends AbstractBean {
|
|||||||
map1OffsetY = _buf.get("map1OffsetY").getAsInt();
|
map1OffsetY = _buf.get("map1OffsetY").getAsInt();
|
||||||
map2OffsetY = _buf.get("map2OffsetY").getAsInt();
|
map2OffsetY = _buf.get("map2OffsetY").getAsInt();
|
||||||
map3OffsetY = _buf.get("map3OffsetY").getAsInt();
|
map3OffsetY = _buf.get("map3OffsetY").getAsInt();
|
||||||
|
scale = _buf.get("scale").getAsFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TbGMap deserialize(JsonObject _buf) {
|
public static TbGMap deserialize(JsonObject _buf) {
|
||||||
@ -62,6 +63,10 @@ public final class TbGMap extends AbstractBean {
|
|||||||
* 地图2(后) 偏移量Y
|
* 地图2(后) 偏移量Y
|
||||||
*/
|
*/
|
||||||
public final int map3OffsetY;
|
public final int map3OffsetY;
|
||||||
|
/**
|
||||||
|
* 地图缩放
|
||||||
|
*/
|
||||||
|
public final float scale;
|
||||||
|
|
||||||
public static final int __ID__ = -2067912029;
|
public static final int __ID__ = -2067912029;
|
||||||
|
|
||||||
@ -79,6 +84,7 @@ public final class TbGMap extends AbstractBean {
|
|||||||
+ "(format_field_name __code_style field.name):" + map1OffsetY + ","
|
+ "(format_field_name __code_style field.name):" + map1OffsetY + ","
|
||||||
+ "(format_field_name __code_style field.name):" + map2OffsetY + ","
|
+ "(format_field_name __code_style field.name):" + map2OffsetY + ","
|
||||||
+ "(format_field_name __code_style field.name):" + map3OffsetY + ","
|
+ "(format_field_name __code_style field.name):" + map3OffsetY + ","
|
||||||
|
+ "(format_field_name __code_style field.name):" + scale + ","
|
||||||
+ "}";
|
+ "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package cfg.TB;
|
||||||
|
|
||||||
|
import luban.*;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
|
||||||
|
public final class TbGOnHookGlobal extends AbstractBean {
|
||||||
|
public TbGOnHookGlobal(JsonObject _buf) {
|
||||||
|
id = _buf.get("id").getAsInt();
|
||||||
|
args = _buf.get("args").getAsString();
|
||||||
|
tig = _buf.get("tig").getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TbGOnHookGlobal deserialize(JsonObject _buf) {
|
||||||
|
return new cfg.TB.TbGOnHookGlobal(_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
public final int id;
|
||||||
|
/**
|
||||||
|
* 全局表参数
|
||||||
|
*/
|
||||||
|
public final String args;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public final String tig;
|
||||||
|
|
||||||
|
public static final int __ID__ = -340649858;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeId() { return __ID__; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "{ "
|
||||||
|
+ "(format_field_name __code_style field.name):" + id + ","
|
||||||
|
+ "(format_field_name __code_style field.name):" + args + ","
|
||||||
|
+ "(format_field_name __code_style field.name):" + tig + ","
|
||||||
|
+ "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -31,6 +31,8 @@ public final class Tables
|
|||||||
public cfg.TbGRoleSkill getTbGRoleSkill() { return _tbgroleskill; }
|
public cfg.TbGRoleSkill getTbGRoleSkill() { return _tbgroleskill; }
|
||||||
private final cfg.TbGMap _tbgmap;
|
private final cfg.TbGMap _tbgmap;
|
||||||
public cfg.TbGMap getTbGMap() { return _tbgmap; }
|
public cfg.TbGMap getTbGMap() { return _tbgmap; }
|
||||||
|
private final cfg.TbGOnHookGlobal _tbgonhookglobal;
|
||||||
|
public cfg.TbGOnHookGlobal getTbGOnHookGlobal() { return _tbgonhookglobal; }
|
||||||
|
|
||||||
public Tables(IJsonLoader loader) throws java.io.IOException {
|
public Tables(IJsonLoader loader) throws java.io.IOException {
|
||||||
_tbgglobal = new cfg.TbGGlobal(loader.load("tbgglobal"));
|
_tbgglobal = new cfg.TbGGlobal(loader.load("tbgglobal"));
|
||||||
@ -39,6 +41,7 @@ public final class Tables
|
|||||||
_tbgrolebattleres = new cfg.TbGRoleBattleRes(loader.load("tbgrolebattleres"));
|
_tbgrolebattleres = new cfg.TbGRoleBattleRes(loader.load("tbgrolebattleres"));
|
||||||
_tbgroleskill = new cfg.TbGRoleSkill(loader.load("tbgroleskill"));
|
_tbgroleskill = new cfg.TbGRoleSkill(loader.load("tbgroleskill"));
|
||||||
_tbgmap = new cfg.TbGMap(loader.load("tbgmap"));
|
_tbgmap = new cfg.TbGMap(loader.load("tbgmap"));
|
||||||
|
_tbgonhookglobal = new cfg.TbGOnHookGlobal(loader.load("tbgonhookglobal"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
JisolGameServer/Main/src/main/java/cfg/TbGOnHookGlobal.java
Normal file
37
JisolGameServer/Main/src/main/java/cfg/TbGOnHookGlobal.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package cfg;
|
||||||
|
|
||||||
|
import luban.*;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
|
|
||||||
|
public final class TbGOnHookGlobal {
|
||||||
|
private final java.util.HashMap<Integer, cfg.TB.TbGOnHookGlobal> _dataMap;
|
||||||
|
private final java.util.ArrayList<cfg.TB.TbGOnHookGlobal> _dataList;
|
||||||
|
|
||||||
|
public TbGOnHookGlobal(JsonElement _buf) {
|
||||||
|
_dataMap = new java.util.HashMap<Integer, cfg.TB.TbGOnHookGlobal>();
|
||||||
|
_dataList = new java.util.ArrayList<cfg.TB.TbGOnHookGlobal>();
|
||||||
|
|
||||||
|
for (com.google.gson.JsonElement _e_ : _buf.getAsJsonArray()) {
|
||||||
|
cfg.TB.TbGOnHookGlobal _v;
|
||||||
|
_v = cfg.TB.TbGOnHookGlobal.deserialize(_e_.getAsJsonObject());
|
||||||
|
_dataList.add(_v);
|
||||||
|
_dataMap.put(_v.id, _v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.util.HashMap<Integer, cfg.TB.TbGOnHookGlobal> getDataMap() { return _dataMap; }
|
||||||
|
public java.util.ArrayList<cfg.TB.TbGOnHookGlobal> getDataList() { return _dataList; }
|
||||||
|
|
||||||
|
public cfg.TB.TbGOnHookGlobal get(int key) { return _dataMap.get(key); }
|
||||||
|
|
||||||
|
}
|
@ -8,4 +8,9 @@ public interface GActionEnum {
|
|||||||
int CHAT_MESSAGE = 2001; //发送聊天消息
|
int CHAT_MESSAGE = 2001; //发送聊天消息
|
||||||
int CHAT_RECEIVE_MESSAGE = 2002; //接受聊天消息
|
int CHAT_RECEIVE_MESSAGE = 2002; //接受聊天消息
|
||||||
|
|
||||||
|
/*************** 游戏模式 : 无尽模式(OnHook) **************/
|
||||||
|
int MODE_ON_HOOK_SPAWN_PET = 3001; //生成宠物
|
||||||
|
int MODE_ON_HOOK_CAPTURE_PET = 3002; //捕捉宠物
|
||||||
|
int MODE_ON_HOOK_SELL_PET = 3003; //卖出宠物
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.jisol.game.actions.onhook;
|
||||||
|
|
||||||
|
import cfg.TB.TbGRole;
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.jisol.game.actions.GActionEnum;
|
||||||
|
import cn.jisol.game.data.GlobalIds;
|
||||||
|
import cn.jisol.game.data.TD;
|
||||||
|
import cn.jisol.game.network.client.GClient;
|
||||||
|
import cn.jisol.game.proto.GOnHookMessage;
|
||||||
|
import cn.jisol.ngame.actions.core.NAction;
|
||||||
|
import cn.jisol.ngame.actions.core.NActionMethod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
//无尽模式
|
||||||
|
@NAction
|
||||||
|
public class GOnHookAction {
|
||||||
|
|
||||||
|
//生成的宠物列表
|
||||||
|
public static Map<Long,Map<String, GOnHookMessage.GOnHookPet>> PETS = new HashMap<>();
|
||||||
|
|
||||||
|
//生成宠物 返回生成好的列表
|
||||||
|
@NActionMethod(GActionEnum.MODE_ON_HOOK_SPAWN_PET)
|
||||||
|
public static GOnHookMessage.GOnHookPets onSpawnPet(GClient client){
|
||||||
|
|
||||||
|
//获取玩家生成的宠物
|
||||||
|
Map<String, GOnHookMessage.GOnHookPet> pets = PETS.get(client.player.getPlayerId());
|
||||||
|
|
||||||
|
//如果没有则生成类
|
||||||
|
if(Objects.isNull(pets)){
|
||||||
|
PETS.put(client.player.getPlayerId(),pets = new HashMap<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取可生成的最大数量
|
||||||
|
int max = Integer.parseInt(TD.DATA.getTbGOnHookGlobal().get(GlobalIds.MODE_ON_HOOK_SPAWN_NUM).args);
|
||||||
|
|
||||||
|
//获取配置表全部宠物
|
||||||
|
ArrayList<TbGRole> tdPets = TD.DATA.getTbGRole().getDataList();
|
||||||
|
|
||||||
|
//如果小于最大数量则生成
|
||||||
|
while (pets.size() < max){
|
||||||
|
|
||||||
|
//目前随机生成宠物
|
||||||
|
GOnHookMessage.GOnHookPet hookPet = GOnHookMessage.GOnHookPet.newBuilder()
|
||||||
|
//生成唯一Id
|
||||||
|
.setKey(RandomUtil.randomString(8))
|
||||||
|
//随机取配置表宠物中的宠物
|
||||||
|
.setPetTbId(tdPets.get(RandomUtil.randomInt(0, tdPets.size() - 1)).id)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
//添加到宠物列表中
|
||||||
|
pets.put(hookPet.getKey(),hookPet);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//返回生成好的宠物
|
||||||
|
return GOnHookMessage.GOnHookPets.newBuilder().addAllPets(pets.values()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package cn.jisol.game.controller.game.mode;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Api(value = "JNGameDemo - API", tags = {"无尽模式 - API"})
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/game/mode/onhook")
|
||||||
|
@ResponseBody
|
||||||
|
public class GOnHookController {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -5,4 +5,8 @@ public interface GlobalIds {
|
|||||||
//选择宠物配置表Id
|
//选择宠物配置表Id
|
||||||
int SELECT_PET_ID = 70001;
|
int SELECT_PET_ID = 70001;
|
||||||
|
|
||||||
|
|
||||||
|
//OnHook模式 宠物生成数量
|
||||||
|
int MODE_ON_HOOK_SPAWN_NUM = 80001;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class WebSocket {
|
|||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(Session session, InputStream inputStream){
|
public void onMessage(Session session, InputStream inputStream){
|
||||||
GClient client = CLIENTS.get(session.getId());
|
GClient client = CLIENTS.get(session.getId());
|
||||||
JNetwork.onMessage(inputStream,client,CLIENTS,client.user,client.player);
|
JNetwork.onMessage(inputStream,client,client,CLIENTS,client.user,client.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClose
|
@OnClose
|
||||||
|
@ -13,8 +13,10 @@ public class GClient extends QueueNClient {
|
|||||||
|
|
||||||
public Session session;
|
public Session session;
|
||||||
|
|
||||||
|
//账号
|
||||||
public User user;
|
public User user;
|
||||||
|
|
||||||
|
//游戏玩家
|
||||||
public Player player;
|
public Player player;
|
||||||
|
|
||||||
public GClient(String token,Session session){
|
public GClient(String token,Session session){
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "cn.jisol.ngame.proto";
|
||||||
|
|
||||||
|
//生成宠物类
|
||||||
|
message GOnHookPet {
|
||||||
|
string key = 1; //生成宠物的key
|
||||||
|
int32 petTbId = 2; //生成宠物的配置表Id
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成的宠物类列表
|
||||||
|
message GOnHookPets {
|
||||||
|
repeated GOnHookPet pets = 1; //宠物列表
|
||||||
|
}
|
@ -5,8 +5,9 @@
|
|||||||
"map1": "map/MAP6/MAP6_1/spriteFrame",
|
"map1": "map/MAP6/MAP6_1/spriteFrame",
|
||||||
"map2": "map/MAP6/MAP6_2/spriteFrame",
|
"map2": "map/MAP6/MAP6_2/spriteFrame",
|
||||||
"map3": "map/MAP6/MAP6_3/spriteFrame",
|
"map3": "map/MAP6/MAP6_3/spriteFrame",
|
||||||
"map1OffsetY": 100,
|
"map1OffsetY": 80,
|
||||||
"map2OffsetY": 400,
|
"map2OffsetY": 520,
|
||||||
"map3OffsetY": 400
|
"map3OffsetY": 520,
|
||||||
|
"scale": 1.5
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 80001,
|
||||||
|
"args": "100",
|
||||||
|
"tig": "预先生成的野外宠物数量"
|
||||||
|
}
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user