You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.9 KiB
96 lines
3.9 KiB
using System.Collections.Generic;
|
|
using Sog;
|
|
using UnityEngine;
|
|
using xFrame;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public static class BattleSvc
|
|
{
|
|
public static void InitLevelCmpt(CombatContext context)
|
|
{
|
|
int chapterId = CoreUIBridge.BattleInfoParams.characterId;
|
|
int stageId = CoreUIBridge.BattleInfoParams.initStageId;
|
|
var chapterBattleDesc = ChapterBattleDescMgr.Instance.GetConfig(chapterId);
|
|
if (stageId == 0)
|
|
stageId = chapterBattleDesc.firstChapterBattleStageId;
|
|
List<WaveParam> waveParams = ListPool<WaveParam>.Pop();
|
|
|
|
while (stageId != 0)
|
|
{
|
|
var battleStageDesc = ChapterBattleStageDescMgr.Instance.GetConfig(stageId);
|
|
var waveParam = GetWaveParamByStageId(battleStageDesc);
|
|
waveParams.Add(waveParam);
|
|
stageId = battleStageDesc.nextStageId;
|
|
}
|
|
|
|
var dictionary = DictionaryPool<int, int>.Pop();
|
|
var levelWaveEnt = context.CreateEntity("LevelWaveEnt");
|
|
levelWaveEnt.AddLevelWave(dictionary, waveParams, LevelSpawnState.Start,
|
|
chapterBattleDesc.chapterBattleLimitedTime, chapterId);
|
|
levelWaveEnt.AddFaction(Faction.Player, SelectUseType.None, Faction.Enemy);
|
|
levelWaveEnt.AddTransformProxy(Vector2.zero, Vector2.zero, levelWaveEnt);
|
|
var commParamDesc = CommParamDescMgr.Instance.GetConfig("MonAngryGA");
|
|
if (commParamDesc != null)
|
|
{
|
|
AbilitySrv.AttachActiveAbility(levelWaveEnt, commParamDesc.int_val);
|
|
}
|
|
context.leveWaveEid = levelWaveEnt.creationIndex;
|
|
}
|
|
|
|
|
|
public static WaveParam GetWaveParamByStageId(ChapterBattleStageDesc battleStageDesc)
|
|
{
|
|
// 小波
|
|
var lastCnt = 0;
|
|
for (int i = 0; i < battleStageDesc.monster.Length; i++)
|
|
{
|
|
var waveConfig = battleStageDesc.monster[i];
|
|
// 用数量做的上线
|
|
if (((int)waveConfig.PositionType & 0b11110000) != 0)
|
|
{
|
|
for (int j = 0; j < waveConfig.Local.Length; j++)
|
|
{
|
|
lastCnt += waveConfig.Num[j];
|
|
}
|
|
continue;
|
|
}
|
|
for (int j = 0; j < waveConfig.Num.Length; j++)
|
|
{
|
|
lastCnt += waveConfig.Num[j];
|
|
}
|
|
}
|
|
var waveParam = new WaveParam
|
|
{
|
|
waveData = battleStageDesc,
|
|
state = WaveSpawnState.None,
|
|
lastSpawnCount = lastCnt,
|
|
spawnedIdx = new int[battleStageDesc.monster.Length],
|
|
newRuleTimeSpanAcc = new Fixed64[battleStageDesc.monster.Length],
|
|
eids = ListPool<int>.Pop()
|
|
};
|
|
return waveParam;
|
|
}
|
|
|
|
|
|
// 关卡压制Buff
|
|
// public static void AttachChapterSuppressBuffToHero()
|
|
// {
|
|
// var heroEnt = context.LocalPlayer;
|
|
// var heroPower = CoreUIBridge.BattleInfoParams.heroPower;
|
|
// heroEnt.property.SetProperty(PropertyDef.LocalHeroPower, heroPower, true);
|
|
//
|
|
// var levelWave = context.LevelWave.levelWave;
|
|
// var chapterId = levelWave.battleId;
|
|
// var chapterBattleDesc = ChapterBattleDescMgr.Instance.GetConfig(chapterId);
|
|
// var chapterPower = chapterBattleDesc.chapterPower;
|
|
// heroEnt.property.SetProperty(PropertyDef.ChapterSuppressPower, chapterPower, true);
|
|
// if (chapterPower <= 0) return;
|
|
// var commParamDesc = CommParamDescMgr.Instance.GetConfig("LevelPenaltyGA");
|
|
// if (commParamDesc != null)
|
|
// {
|
|
// AbilitySrv.AttachActiveAbility(heroEnt, commParamDesc.int_val);
|
|
// }
|
|
// }
|
|
}
|
|
}
|