mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交地图选择
This commit is contained in:
@@ -26,10 +26,10 @@ 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.1.23:8080`
|
||||
// let WsPath = `ws://192.168.1.23:8080/websocket`
|
||||
// let APIPath = `http://localhost:8080`
|
||||
// let WsPath = `ws://localhost:8080/websocket`
|
||||
let APIPath = `http://192.168.1.23:8080`
|
||||
let WsPath = `ws://192.168.1.23:8080/websocket`
|
||||
// let APIPath = `http://192.168.0.113:8080`
|
||||
// let WsPath = `ws://192.168.0.113:8080/websocket`
|
||||
// let APIPath = `https://api.pet.jisol.cn`
|
||||
|
@@ -38,6 +38,8 @@ export class GMapLoop extends JNGSyncBase<{}> {
|
||||
this.repeat = repeat;
|
||||
this.mapWidth = width || this.map.width;
|
||||
this.mapHeight = height || this.map.height;
|
||||
this.node.destroyAllChildren();
|
||||
this.createMaps = new Map;
|
||||
}
|
||||
|
||||
//更新地图(世界坐标X)
|
||||
|
@@ -21,10 +21,12 @@ import GRoleOnHookPlayerExpand from "../base/role/expand/OnHook/GRoleOnHookPlaye
|
||||
import PlayerPetData from "../../data/PlayerPetData";
|
||||
import { GUI } from "../../ui/UIConfig";
|
||||
import { GOnHookPet, GOnHookPets } from "../../../../extensions/ngame/assets/ngame/message/proto";
|
||||
import GOnHookManager from "../../manager/battle/mode/GOnHookManager";
|
||||
import GOnHookManager, { GOnHookManagerEvent } from "../../manager/battle/mode/GOnHookManager";
|
||||
import GRoleOnHookCreepsExpand from "../base/role/expand/OnHook/GRoleOnHookCreepsExpand";
|
||||
import { ModeRenderEvent } from "../../ui/Consts/Game/ModeRender";
|
||||
import GPetAttribute from "../base/values/attribute/role/GPetAttribute";
|
||||
import GDefaultMode from "./default/GDefaultMode";
|
||||
import GOnHookData from "../../data/GOnHookData";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//挂机模式状态
|
||||
@@ -50,19 +52,11 @@ export interface GOnHookInfo{
|
||||
* 挂机模式 无限出现小怪 (不是联机模式 该模式支持使用本地数据 和 API)
|
||||
*/
|
||||
@ccclass('GOnHookMode')
|
||||
export default class GOnHookMode extends GBaseMode<{},{}>{
|
||||
export default class GOnHookMode extends GDefaultMode<{},{}>{
|
||||
|
||||
@property(Prefab)
|
||||
rolePrefab: Prefab = null;
|
||||
|
||||
//场景地图
|
||||
@property(GMapLoop)
|
||||
map1:GMapLoop;
|
||||
@property(GMapLoop)
|
||||
map2:GMapLoop;
|
||||
@property(GMapLoop)
|
||||
map3:GMapLoop;
|
||||
|
||||
@property(Node)
|
||||
objects: Node = null;
|
||||
|
||||
@@ -84,9 +78,6 @@ export default class GOnHookMode extends GBaseMode<{},{}>{
|
||||
playerRoles: GRoleDefault[] = [];
|
||||
//敌方宠物
|
||||
enemyRoles: GRoleDefault[] = [];
|
||||
|
||||
//地图信息
|
||||
mapInfo:TB.TbGMap;
|
||||
|
||||
//每一波怪的距离
|
||||
everyX:number = 600;
|
||||
@@ -109,11 +100,13 @@ export default class GOnHookMode extends GBaseMode<{},{}>{
|
||||
//添加监听事件
|
||||
addEvent(){
|
||||
app.event.on(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
|
||||
app.event.on(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this);
|
||||
}
|
||||
//移除监听事件
|
||||
onDestroy(){
|
||||
super.onDestroy();
|
||||
app.event.off(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
|
||||
app.event.off(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this);
|
||||
}
|
||||
|
||||
onSyncInitSuccess():void{
|
||||
@@ -128,15 +121,8 @@ export default class GOnHookMode extends GBaseMode<{},{}>{
|
||||
//初始化状态机
|
||||
this.fsm = new GFSMOnHookMode(this);
|
||||
|
||||
//初始化地图
|
||||
this.mapInfo = TD.TbGMap.get(60001);
|
||||
|
||||
let scale = this.mapInfo.scale;
|
||||
|
||||
this.map1.init(app.battleRes.maps[60001][0],1,app.battleRes.maps[60001][0].width * scale,app.battleRes.maps[60001][0].height * scale);
|
||||
this.map2.init(app.battleRes.maps[60001][1],1,app.battleRes.maps[60001][1].width * scale,app.battleRes.maps[60001][1].height * scale);
|
||||
this.map3.init(app.battleRes.maps[60001][2],1,app.battleRes.maps[60001][1].width * scale,1048 * scale);
|
||||
this.onUpdateMap(0);
|
||||
//更新场景
|
||||
this.onUpdateWorld();
|
||||
|
||||
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos) };
|
||||
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos) };
|
||||
@@ -161,6 +147,17 @@ export default class GOnHookMode extends GBaseMode<{},{}>{
|
||||
// this.onResetGenerateEnemy();
|
||||
|
||||
}
|
||||
|
||||
//更新地图
|
||||
onUpdateWorld(){
|
||||
let info = TD.TbGOnHookMaps.get(GOnHookData.getIns().info.onHookMap);
|
||||
this.setWorldMap(info.mapId)
|
||||
}
|
||||
|
||||
//更新页面
|
||||
onUpdateView(){
|
||||
|
||||
}
|
||||
|
||||
//更新玩家宠物
|
||||
onUpdatePlayerPet(){
|
||||
@@ -195,14 +192,6 @@ export default class GOnHookMode extends GBaseMode<{},{}>{
|
||||
this.fsm.onUpdate(dt,frame);
|
||||
}
|
||||
|
||||
//更新地图
|
||||
onUpdateMap(dt){
|
||||
let cameraX = this.camera.node.worldPosition.x;
|
||||
this.map1.UpdateMap(cameraX,0,this.mapInfo.map1OffsetY);
|
||||
this.map2.UpdateMap(cameraX,cameraX / 10,this.mapInfo.map2OffsetY);
|
||||
this.map3.UpdateMap(cameraX,0,this.mapInfo.map3OffsetY);
|
||||
}
|
||||
|
||||
//更新相机逻辑
|
||||
onUpdateCamera(dt:number){
|
||||
|
||||
|
9
JisolGameCocos/assets/script/battle/modes/default.meta
Normal file
9
JisolGameCocos/assets/script/battle/modes/default.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "9b681679-8251-4587-86de-226eb77202f3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
import { _decorator } from "cc";
|
||||
import GBaseMode from "../../GBaseMode";
|
||||
import { GMapLoop } from "../../base/common/map/GMapLoop";
|
||||
import { TD, app } from "../../../App";
|
||||
import { TB } from "../../../../resources/config/data/schema";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export default class GDefaultMode<T,DT> extends GBaseMode<T,DT>{
|
||||
|
||||
//场景地图
|
||||
@property(GMapLoop)
|
||||
map1:GMapLoop;
|
||||
@property(GMapLoop)
|
||||
map2:GMapLoop;
|
||||
@property(GMapLoop)
|
||||
map3:GMapLoop;
|
||||
|
||||
//地图信息
|
||||
mapInfo:TB.TbGMap;
|
||||
|
||||
//设置世界地图
|
||||
setWorldMap(mapId:number = 60001){
|
||||
|
||||
//初始化地图
|
||||
this.mapInfo = TD.TbGMap.get(mapId);
|
||||
|
||||
let scale = this.mapInfo.scale;
|
||||
this.map1.init(app.battleRes.maps[mapId][0],1,app.battleRes.maps[mapId][0].width * scale,app.battleRes.maps[mapId][0].height * scale);
|
||||
this.map2.init(app.battleRes.maps[mapId][1],1,app.battleRes.maps[mapId][1].width * scale,app.battleRes.maps[mapId][1].height * scale);
|
||||
this.map3.init(app.battleRes.maps[mapId][2],1,app.battleRes.maps[mapId][1].width * scale,1048 * scale);
|
||||
|
||||
//更新地图
|
||||
this.onUpdateMap(0);
|
||||
|
||||
}
|
||||
|
||||
//更新地图
|
||||
onUpdateMap(dt){
|
||||
let cameraX = this.camera.node.worldPosition.x;
|
||||
this.map1.UpdateMap(cameraX,0,this.mapInfo.map1OffsetY);
|
||||
this.map2.UpdateMap(cameraX,cameraX / 10,this.mapInfo.map2OffsetY);
|
||||
this.map3.UpdateMap(cameraX,0,this.mapInfo.map3OffsetY);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5dd657bf-b55d-410c-a850-36893d6c6369",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -15,6 +15,8 @@ export const GAPI = {
|
||||
/************** 无限模式接口 ********************/
|
||||
//获取模式信息
|
||||
GOnHookInfo : async () => RData(await app.api.get(`/game/mode/onHook/info`)) as ModeOnHookOV,
|
||||
//切换游戏
|
||||
GOnHookSetMap : async (mapId) => RData(await app.api.post(`/game/mode/onHook/setMapId/${mapId}`)) as ModeOnHookOV,
|
||||
//生成野怪
|
||||
GOnHookSpawnCreeps : async () => RProto(await app.api.get(`/game/mode/onHook/onSpawnCreeps`,{responseType:'arraybuffer'}),GActionType.GOnHookPets) as GOnHookPets,
|
||||
//捕捉野怪
|
||||
|
@@ -1,4 +1,7 @@
|
||||
import { app } from "../App";
|
||||
import { API } from "../consts/API";
|
||||
import { GAPI, ModeOnHookOV } from "../consts/GAPI";
|
||||
import { GUI } from "../ui/UIConfig";
|
||||
import BaseData from "./BaseData";
|
||||
|
||||
//无限模式数据类
|
||||
@@ -11,5 +14,13 @@ export default class GOnHookData extends BaseData{
|
||||
console.log("GOnHookData Info",this.info);
|
||||
}
|
||||
|
||||
//切换地图
|
||||
async setMap(mapId:number){
|
||||
|
||||
this.info = await GAPI.GOnHookSetMap(mapId);
|
||||
app.layer.Open(GUI.Tips,{text:"切换地图成功"});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ import Singleton from "../../../../../extensions/ngame/assets/ngame/util/Singlet
|
||||
import { app } from "../../../App";
|
||||
import { PlayerPetOV } from "../../../consts/API";
|
||||
import { GAPI } from "../../../consts/GAPI";
|
||||
import GOnHookData from "../../../data/GOnHookData";
|
||||
import PlayerPetData from "../../../data/PlayerPetData";
|
||||
import { GUI } from "../../../ui/UIConfig";
|
||||
|
||||
@@ -10,7 +11,9 @@ export enum GOnHookManagerEvent{
|
||||
//添加死亡野怪
|
||||
ADD_KILL_SREEP = "GOnHookManagerEvent_ADD_KILL_SREEP",
|
||||
//删除死亡野怪
|
||||
DEL_KILL_SREEP = "GOnHookManagerEvent_DEL_KILL_SREEP"
|
||||
DEL_KILL_SREEP = "GOnHookManagerEvent_DEL_KILL_SREEP",
|
||||
//删除死亡野怪
|
||||
UPDATE_MAP = "GOnHookManagerEvent_UPDATE_MAP"
|
||||
}
|
||||
|
||||
//游戏模式 OnHook 管理器
|
||||
@@ -116,6 +119,17 @@ export default class GOnHookManager extends Singleton{
|
||||
return await GAPI.GOnHookSellCreeps(creeps.key);
|
||||
}
|
||||
|
||||
//切换场景
|
||||
async setMap(mapId:number){
|
||||
|
||||
await GOnHookData.getIns().setMap(mapId);
|
||||
|
||||
//通知地图已切换
|
||||
app.event.emit(GOnHookManagerEvent.UPDATE_MAP);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -18,6 +18,12 @@ export class MapSelectShowItem extends JNScrollViewItem<TB.TbGOnHookMaps> {
|
||||
@property({type:Label,displayName:"地图介绍"})
|
||||
mapText:Label;
|
||||
|
||||
@property({type:Node,displayName:"选中图片"})
|
||||
selectNode:Node;
|
||||
|
||||
//是否选择
|
||||
isSelect:boolean = false;
|
||||
|
||||
onInit(data: TB.TbGOnHookMaps): void {
|
||||
|
||||
this.onUpdateView();
|
||||
@@ -29,10 +35,13 @@ export class MapSelectShowItem extends JNScrollViewItem<TB.TbGOnHookMaps> {
|
||||
|
||||
this.mapName.string = this.data.name;
|
||||
this.mapText.string = this.data.introduce;
|
||||
this.selectNode.active = !!this.isSelect;
|
||||
|
||||
//加载预览图
|
||||
TbResource.loadSpriteFrame(this.data.mapImage,this.mapImage,this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
|
||||
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import { TD } from '../../App';
|
||||
import { app, TD } from '../../App';
|
||||
import GOnHookData from '../../data/GOnHookData';
|
||||
import { TbGOnHookMaps } from '../../../resources/config/data/schema';
|
||||
import { MapSelectShowItem } from './MapSelectShowItem';
|
||||
import { NodeEventType } from 'cc';
|
||||
import GOnHookManager from '../../manager/battle/mode/GOnHookManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('MapSelectView')
|
||||
@@ -11,13 +16,53 @@ export class MapSelectView extends JNLayerBase {
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView;
|
||||
|
||||
//当前地图下标
|
||||
index:number = -1;
|
||||
|
||||
onJNLoad(data?: any): void {
|
||||
super.onJNLoad(data);
|
||||
|
||||
TD.TbGOnHookMaps.getDataList().forEach((item,index) => {
|
||||
if(GOnHookData.getIns().info.onHookMap == item.id){
|
||||
this.index = index;
|
||||
}
|
||||
})
|
||||
|
||||
this.views.refreshData(TD.TbGOnHookMaps.getDataList())
|
||||
|
||||
let items = this.views.getItems<MapSelectShowItem>();
|
||||
|
||||
//向子节点添加点击事件
|
||||
this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this));
|
||||
|
||||
items[this.index].isSelect = true;
|
||||
items[this.index].onUpdateView();
|
||||
|
||||
}
|
||||
|
||||
//点击地图
|
||||
onClickItem(index:number){
|
||||
let items = this.views.getItems<MapSelectShowItem>();
|
||||
|
||||
items.forEach(item => {
|
||||
item.isSelect = false;
|
||||
})
|
||||
this.index = index;
|
||||
items[this.index].isSelect = true;
|
||||
this.views.getItems<MapSelectShowItem>().forEach(item => item.onUpdateView())
|
||||
|
||||
}
|
||||
|
||||
//点击确认
|
||||
async onClickConfirm(){
|
||||
|
||||
await GOnHookManager.getIns().setMap(this.views.getItems<MapSelectShowItem>()[this.index].data.id);
|
||||
|
||||
//关闭页面
|
||||
app.layer.CloseNode(this.node);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user