mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交地图选择
This commit is contained in:
@@ -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": {}
|
||||
}
|
Reference in New Issue
Block a user