mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
生成野怪逻辑
This commit is contained in:
@@ -20,6 +20,8 @@ import PlayerTacticalData, { PlayerTacticalEvent } from "../../data/PlayerTactic
|
||||
import GRoleOnHookExpand from "../base/role/expand/OnHook/GRoleOnHookExpand";
|
||||
import PlayerPetData from "../../data/PlayerPetData";
|
||||
import { GUI } from "../../ui/UIConfig";
|
||||
import { GAction } from "../../consts/GAction";
|
||||
import { GActionType } from "../../consts/GActionType";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//挂机模式状态
|
||||
@@ -43,6 +45,16 @@ export interface GOnHookInfo{
|
||||
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;
|
||||
|
||||
//野怪列表
|
||||
_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(){
|
||||
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.onUpdateMap(0);
|
||||
|
||||
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([10004,10004,10004,10004,10003,10003]) };
|
||||
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([10002]) };
|
||||
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([]) };
|
||||
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([]) };
|
||||
|
||||
this.onUpdatePlayerPet();
|
||||
|
||||
//添加监听
|
||||
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))
|
||||
|
||||
@@ -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(){
|
||||
//获取玩家阵容
|
||||
@@ -318,7 +364,12 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
//生成敌人
|
||||
onResetGenerateEnemy(){
|
||||
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));
|
||||
}
|
||||
|
||||
//角色死亡回调
|
||||
|
Reference in New Issue
Block a user