88 lines
2.8 KiB
TypeScript
Raw Normal View History

2024-01-17 00:05:44 +08:00
import { _decorator } from "cc";
import { TB, TbGEntity } from "../../config/data/schema";
2024-01-17 18:36:59 +08:00
import GNormalModeBase, { GNormalModePlayerEnum } from "./default/GNormalModeBase";
import { TD, app } from "../../App";
import GOnHookData from "../../data/GOnHookData";
2024-01-17 00:05:44 +08:00
import PlayerTacticalData from "../../data/PlayerTacticalData";
import PlayerPetData from "../../data/PlayerPetData";
import { GUI } from "../../ui/UIConfig";
2024-01-17 18:36:59 +08:00
import GBattleData from "../../data/GBattleData";
import GAttributeData from "../base/values/GAttributeData";
import JNFrameTime from "../../../../extensions/ngame/assets/ngame/sync/frame/game/time/JNFrameTime";
2024-01-19 02:42:37 +08:00
import { GAPI } from "../../consts/GAPI";
2024-01-20 19:01:45 +08:00
import { Node } from "cc";
2024-01-22 18:33:24 +08:00
import DungeonData from "../../data/DungeonData";
2024-01-17 00:05:44 +08:00
const { ccclass, property } = _decorator;
2024-01-19 02:42:37 +08:00
export interface GDungeonModeData{
dungeonId:number, //副本Id
dungeonItemId:number, //副本关卡Id
data:TbGEntity.TDungeon //副本信息
}
2024-01-17 00:05:44 +08:00
/**
* ()
*/
@ccclass('GDungeonMode')
2024-01-19 02:42:37 +08:00
export default class GDungeonMode extends GNormalModeBase<{},GDungeonModeData>{
2024-01-17 18:36:59 +08:00
onSyncInitSuccess(){
if(!this.data) return;
2024-01-17 00:05:44 +08:00
2024-01-17 18:36:59 +08:00
console.log("初始化 GDungeonMode 模式",this.data);
super.onSyncInitSuccess();
this.onUpdateWorld();
2024-01-17 00:05:44 +08:00
2024-01-17 18:36:59 +08:00
//生成玩家宠物
this.onGenPlayerPet();
//生成Boss
this.onGenBoss();
}
//更新地图
onUpdateWorld(){
let info = TD.TbGOnHookMaps.get(GOnHookData.getIns().info.onHookMap);
this.setWorldMap(info.mapId);
}
2024-01-17 00:05:44 +08:00
2024-01-17 18:36:59 +08:00
onGenPlayerPet(){
2024-01-17 00:05:44 +08:00
//获取玩家阵容
let infos = PlayerTacticalData.getIns().getTacticalInfo();
2024-01-17 18:36:59 +08:00
infos.forEach((petId,index) => {
if(!petId) return;
2024-01-17 00:05:44 +08:00
//获取要生成的宠物
let info = PlayerPetData.getIns().petIdQueryPetInfo(petId);
if(!info){
app.layer.Open(GUI.Tips,{text:"未拥有当前上阵的宠物"});
return;
}
2024-01-17 18:36:59 +08:00
let role = this.onGenRole(GNormalModePlayerEnum.PLAYER,index + 1,TD.TbGRole.get(info.petTbId));
2024-01-17 00:05:44 +08:00
2024-01-17 18:36:59 +08:00
//添加宠物属性
role.onEffectiveValue(GBattleData.getIns().data.getPetAttribute(petId));
2024-01-17 00:05:44 +08:00
})
}
2024-01-17 18:36:59 +08:00
onGenBoss(){
2024-01-19 02:42:37 +08:00
let enemy = this.onGenRole(GNormalModePlayerEnum.ENEMY,5,TD.TbGRole.get(this.data.data.boss));
enemy.onEffectiveValue(GAttributeData.TAttributeValue(this.data.data.attributes))
2024-01-17 00:05:44 +08:00
}
2024-01-17 18:36:59 +08:00
//战斗结束
onBattleEnd(win:GNormalModePlayerEnum){
//结束游戏
2024-01-19 02:42:37 +08:00
JNFrameTime.getInstance().setTimeout(async () => {
2024-01-29 02:49:19 +08:00
if(win == GNormalModePlayerEnum.PLAYER){
await DungeonData.getIns().challenge(this.data.dungeonId,this.data.dungeonItemId);
}
2024-01-17 18:36:59 +08:00
this.Close();
},3000)
}
2024-01-17 00:05:44 +08:00
}