生成野怪逻辑

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-17 02:57:46 +08:00
parent c4437fef5e
commit 62b72bdcfc
29 changed files with 2451 additions and 192 deletions

View File

@@ -24,6 +24,7 @@ public final class TbGMap extends AbstractBean {
map1OffsetY = _buf.get("map1OffsetY").getAsInt();
map2OffsetY = _buf.get("map2OffsetY").getAsInt();
map3OffsetY = _buf.get("map3OffsetY").getAsInt();
scale = _buf.get("scale").getAsFloat();
}
public static TbGMap deserialize(JsonObject _buf) {
@@ -62,6 +63,10 @@ public final class TbGMap extends AbstractBean {
* 地图2(后) 偏移量Y
*/
public final int map3OffsetY;
/**
* 地图缩放
*/
public final float scale;
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):" + map2OffsetY + ","
+ "(format_field_name __code_style field.name):" + map3OffsetY + ","
+ "(format_field_name __code_style field.name):" + scale + ","
+ "}";
}
}

View File

@@ -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 + ","
+ "}";
}
}

View File

@@ -31,6 +31,8 @@ public final class Tables
public cfg.TbGRoleSkill getTbGRoleSkill() { return _tbgroleskill; }
private final cfg.TbGMap _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 {
_tbgglobal = new cfg.TbGGlobal(loader.load("tbgglobal"));
@@ -39,6 +41,7 @@ public final class Tables
_tbgrolebattleres = new cfg.TbGRoleBattleRes(loader.load("tbgrolebattleres"));
_tbgroleskill = new cfg.TbGRoleSkill(loader.load("tbgroleskill"));
_tbgmap = new cfg.TbGMap(loader.load("tbgmap"));
_tbgonhookglobal = new cfg.TbGOnHookGlobal(loader.load("tbgonhookglobal"));
}
}

View 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); }
}

View File

@@ -8,4 +8,9 @@ public interface GActionEnum {
int CHAT_MESSAGE = 2001; //发送聊天消息
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; //卖出宠物
}

View File

@@ -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();
}
}

View File

@@ -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 {
}

View File

@@ -5,4 +5,8 @@ public interface GlobalIds {
//选择宠物配置表Id
int SELECT_PET_ID = 70001;
//OnHook模式 宠物生成数量
int MODE_ON_HOOK_SPAWN_NUM = 80001;
}

View File

@@ -55,7 +55,7 @@ public class WebSocket {
@OnMessage
public void onMessage(Session session, InputStream inputStream){
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

View File

@@ -13,8 +13,10 @@ public class GClient extends QueueNClient {
public Session session;
//账号
public User user;
//游戏玩家
public Player player;
public GClient(String token,Session session){

File diff suppressed because it is too large Load Diff

View 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; //宠物列表
}

View File

@@ -5,8 +5,9 @@
"map1": "map/MAP6/MAP6_1/spriteFrame",
"map2": "map/MAP6/MAP6_2/spriteFrame",
"map3": "map/MAP6/MAP6_3/spriteFrame",
"map1OffsetY": 100,
"map2OffsetY": 400,
"map3OffsetY": 400
"map1OffsetY": 80,
"map2OffsetY": 520,
"map3OffsetY": 520,
"scale": 1.5
}
]

View File

@@ -0,0 +1,7 @@
[
{
"id": 80001,
"args": "100",
"tig": "预先生成的野外宠物数量"
}
]