mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-11-08 07:16:08 +00:00
提交代码
This commit is contained in:
@@ -1,105 +1,75 @@
|
||||
import { _decorator } from "cc";
|
||||
import GBaseMode from "../GBaseMode";
|
||||
import { TB, TbGEntity } from "../../config/data/schema";
|
||||
import GNormalModeBase, { GNormalModePlayerEnum } from "./default/GNormalModeBase";
|
||||
import { TD, app } from "../../App";
|
||||
import GOnHookData from "../../data/GOnHookData";
|
||||
import PlayerTacticalData from "../../data/PlayerTacticalData";
|
||||
import PlayerPetData from "../../data/PlayerPetData";
|
||||
import { TD, app } from "../../App";
|
||||
import { GUI } from "../../ui/UIConfig";
|
||||
import { GOnHookModePlayerEnum } from "./GOnHookMode";
|
||||
import GRoleDefault from "../base/role/GRoleDefault";
|
||||
import GBattleData from "../../data/GBattleData";
|
||||
import GAttributeData from "../base/values/GAttributeData";
|
||||
import JNFrameTime from "../../../../extensions/ngame/assets/ngame/sync/frame/game/time/JNFrameTime";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
//角色
|
||||
export enum GDungeonModeEnum{
|
||||
PLAYER, //玩家
|
||||
ENEMY, //怪物
|
||||
}
|
||||
|
||||
/**
|
||||
* 副本(默认) 模式
|
||||
*/
|
||||
@ccclass('GDungeonMode')
|
||||
export default class GDungeonMode extends GBaseMode<{},TbGEntity.TDungeon>{
|
||||
export default class GDungeonMode extends GNormalModeBase<{},TbGEntity.TDungeon>{
|
||||
|
||||
onSyncInitSuccess(){
|
||||
if(!this.data) return;
|
||||
|
||||
//生成玩家宠物
|
||||
onGenPlayerPet(index:number,petId:number){
|
||||
console.log("初始化 GDungeonMode 模式",this.data);
|
||||
super.onSyncInitSuccess();
|
||||
this.onUpdateWorld();
|
||||
|
||||
//生成玩家宠物
|
||||
this.onGenPlayerPet();
|
||||
//生成Boss
|
||||
this.onGenBoss();
|
||||
}
|
||||
|
||||
//更新地图
|
||||
onUpdateWorld(){
|
||||
let info = TD.TbGOnHookMaps.get(GOnHookData.getIns().info.onHookMap);
|
||||
this.setWorldMap(info.mapId);
|
||||
}
|
||||
|
||||
onGenPlayerPet(){
|
||||
//获取玩家阵容
|
||||
let infos = PlayerTacticalData.getIns().getTacticalInfo();
|
||||
|
||||
infos.forEach(petId => {
|
||||
infos.forEach((petId,index) => {
|
||||
if(!petId) return;
|
||||
|
||||
//获取要生成的宠物
|
||||
let info = PlayerPetData.getIns().petIdQueryPetInfo(petId);
|
||||
|
||||
if(!info){
|
||||
app.layer.Open(GUI.Tips,{text:"未拥有当前上阵的宠物"});
|
||||
return;
|
||||
}
|
||||
|
||||
let role = this.onGenRole(GOnHookModePlayerEnum.PLAYER,index,TD.TbGRole.get(info.petTbId));
|
||||
let role = this.onGenRole(GNormalModePlayerEnum.PLAYER,index + 1,TD.TbGRole.get(info.petTbId));
|
||||
|
||||
//添加宠物属性
|
||||
role.onEffectiveValue(GBattleData.getIns().data.getPetAttribute(petId));
|
||||
|
||||
})
|
||||
|
||||
//如果场上有这个宠物则更新阵法位置
|
||||
let passRole:GRoleDefault;
|
||||
this.playerRoles.forEach(role => {
|
||||
if(role.getComponent(GRoleOnHookPlayerExpand).petId == petId)
|
||||
passRole = role;
|
||||
})
|
||||
if(passRole){
|
||||
//更新宠物阵法位置
|
||||
passRole.tacticalIndex = index;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!info){
|
||||
app.layer.Open(GUI.Tips,{text:"未拥有当前上阵的宠物"});
|
||||
return;
|
||||
}
|
||||
let role = this.onGenRole(GOnHookModePlayerEnum.PLAYER,index,TD.TbGRole.get(info.petTbId));
|
||||
//向宠物添加 OnHook 扩展
|
||||
let expand = role.node.addComponent(GRoleOnHookPlayerExpand);
|
||||
expand.petId = petId;
|
||||
|
||||
//添加宠物属性
|
||||
role.onEffectiveValue(GBattleData.getIns().data.getPetAttribute(petId));
|
||||
|
||||
}
|
||||
|
||||
//生成宠物
|
||||
onGenRole(type: GOnHookModePlayerEnum,index:number,info:TB.TbGRole):GRoleDefault {
|
||||
|
||||
let tactical = this.getInfo(type).tactical;
|
||||
let pos:Vec2 = this.getInfo(type).tactical.getPosition(index);
|
||||
if(!pos) return;
|
||||
let role = instantiate(this.rolePrefab);
|
||||
|
||||
let entity = role.getComponent(GRoleDefault);
|
||||
//初始化
|
||||
entity.onInit(type,info,tactical,index);
|
||||
|
||||
//绑定寻敌
|
||||
entity.onQueryEunmy = () => {
|
||||
return this.getEnumy(entity,type);
|
||||
}
|
||||
|
||||
//绑定死亡回调
|
||||
entity.addKillBackEvent(this.onRoleKillBack.bind(this))
|
||||
//绑定受击回调
|
||||
entity.addHitCallback(this.onHitBack.bind(this));
|
||||
|
||||
this.addGObject(entity,tactical.getPosition(index));
|
||||
|
||||
this.getOnesRole(type).push(entity);
|
||||
|
||||
return entity;
|
||||
|
||||
onGenBoss(){
|
||||
let enemy = this.onGenRole(GNormalModePlayerEnum.ENEMY,5,TD.TbGRole.get(this.data.boss));
|
||||
enemy.onEffectiveValue(GAttributeData.TAttributeValue(this.data.attributes))
|
||||
}
|
||||
|
||||
//战斗结束
|
||||
onBattleEnd(win:GNormalModePlayerEnum){
|
||||
//结束游戏
|
||||
JNFrameTime.getInstance().setTimeout(() => {
|
||||
this.Close();
|
||||
},3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user