导入敌人模型素材,统一经验和金币掉落物
This commit is contained in:
@@ -12,21 +12,23 @@ namespace SepCore.Procedure
|
||||
{
|
||||
public class GameStateBattle : GameStateBase
|
||||
{
|
||||
private const float VacuumMaxDuration = 0.8f;
|
||||
private const float VacuumAbsorbSpeed = 30f;
|
||||
|
||||
public override GameStateType GameStateType => GameStateType.Battle;
|
||||
|
||||
private EnemyManagerComponent _enemyManager;
|
||||
|
||||
private int _currentLevel;
|
||||
|
||||
private TimerHandle _levelTimerHandle;
|
||||
private bool _isWaveEnding;
|
||||
private float _vacuumTimer;
|
||||
|
||||
private Player Player => _procedureGame.Player;
|
||||
|
||||
private ProcedureGame _procedureGame;
|
||||
|
||||
public void AddBattleDuration(float seconds)
|
||||
{
|
||||
if (seconds <= 0f) return;
|
||||
if (_isWaveEnding || seconds <= 0f) return;
|
||||
|
||||
float remaining = GameEntry.Timer.GetRemainingTime(_levelTimerHandle);
|
||||
if (remaining < 0f) return;
|
||||
@@ -45,6 +47,8 @@ namespace SepCore.Procedure
|
||||
public override void OnEnter()
|
||||
{
|
||||
_currentLevel = _procedureGame.CurrentLevel;
|
||||
_isWaveEnding = false;
|
||||
_vacuumTimer = 0f;
|
||||
|
||||
var levelConfig = GameEntry.Luban.Get<LevelConfig>(_currentLevel);
|
||||
_levelTimerHandle = GameEntry.Timer.ScheduleOnce(levelConfig.Duration, OnLevelTimeUp, this);
|
||||
@@ -60,6 +64,21 @@ namespace SepCore.Procedure
|
||||
|
||||
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
if (_isWaveEnding)
|
||||
{
|
||||
Vector3 currentPos = Player.CachedTransform.position;
|
||||
GameEntry.SimulationWorld.Tick(new SimulationTickContext(elapseSeconds, currentPos));
|
||||
|
||||
_vacuumTimer -= elapseSeconds;
|
||||
if (GameEntry.SimulationWorld.PickupCount == 0 || _vacuumTimer <= 0f)
|
||||
{
|
||||
CollectAllRemainingDrops(Player);
|
||||
_isWaveEnding = false;
|
||||
_procedureGame.BattleToShopOrLevelUp();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_enemyManager.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
Vector3 playerPosition = Player.CachedTransform.position;
|
||||
@@ -71,15 +90,36 @@ namespace SepCore.Procedure
|
||||
|
||||
private void OnLevelTimeUp()
|
||||
{
|
||||
_procedureGame.BattleToShopOrLevelUp();
|
||||
if (_isWaveEnding) return;
|
||||
|
||||
_isWaveEnding = true;
|
||||
_vacuumTimer = VacuumMaxDuration;
|
||||
|
||||
// 1. 停止玩家移动与射击
|
||||
Player.Enable = false;
|
||||
|
||||
// 2. 清退所有敌人并停止刷怪
|
||||
_enemyManager.OnReset();
|
||||
|
||||
// 3. 隐藏所有投射物
|
||||
HideEntityGroup(GameEntry.Luban.Global.ProjectileGroupName);
|
||||
|
||||
// 4. 触发全图磁铁,并提高吸附速度
|
||||
GameEntry.SimulationWorld.TriggerFullMapMagnet();
|
||||
GameEntry.SimulationWorld.SyncPlayerAbsorbSettings(999f, VacuumAbsorbSpeed, GameEntry.Luban.Global.CollectDistance);
|
||||
}
|
||||
|
||||
public override void OnLeave()
|
||||
{
|
||||
GameEntry.UIRouter.CloseUIAsync(UIFormType.JoystickForm).Forget();
|
||||
|
||||
GameEntry.Timer.Cancel(_levelTimerHandle);
|
||||
_levelTimerHandle = TimerHandle.Invalid;
|
||||
if (_levelTimerHandle.IsValid)
|
||||
{
|
||||
GameEntry.Timer.Cancel(_levelTimerHandle);
|
||||
_levelTimerHandle = TimerHandle.Invalid;
|
||||
}
|
||||
|
||||
_isWaveEnding = false;
|
||||
|
||||
// 隐藏所有敌人实体
|
||||
_enemyManager.OnReset();
|
||||
@@ -98,6 +138,24 @@ namespace SepCore.Procedure
|
||||
_procedureGame = null;
|
||||
}
|
||||
|
||||
private static void CollectAllRemainingDrops(Player player)
|
||||
{
|
||||
if (player == null || !GameEntry.Entity.HasEntityGroup(GameEntry.Luban.Global.DropGroupName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var entityGroup = GameEntry.Entity.GetEntityGroup(GameEntry.Luban.Global.DropGroupName);
|
||||
var entities = entityGroup.GetAllEntities();
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (entity is UnityGameFramework.Runtime.Entity runtimeEntity && runtimeEntity.Logic is DropEntity drop)
|
||||
{
|
||||
drop.TryCollect(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void HideEntityGroup(string groupName)
|
||||
{
|
||||
if (!GameEntry.Entity.HasEntityGroup(groupName))
|
||||
|
||||
Reference in New Issue
Block a user