- 补充游戏核心逻辑
- 完成 TodOList P0
- 添加游戏内控制台便于调试
- 增加敌人互斥机制提高运算负载
- 优化互斥算法将游戏性能基准线拉到 1k 敌人
This commit is contained in:
@@ -13,7 +13,7 @@ using Scene;
|
||||
using StarForce;
|
||||
using UnityGameFramework.Runtime;
|
||||
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
|
||||
using Game.Utility;
|
||||
using CustomUtility;
|
||||
|
||||
namespace Procedure
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Collections.Generic;
|
||||
using DataTable;
|
||||
using Definition;
|
||||
using Scene;
|
||||
using Game.Utility;
|
||||
using CustomUtility;
|
||||
using TMPro;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
@@ -25,20 +25,20 @@ namespace Procedure
|
||||
{
|
||||
public static readonly string[] DataTableNames = new string[]
|
||||
{
|
||||
"Enemy",
|
||||
"Entity",
|
||||
"Enemy",
|
||||
"Weapon",
|
||||
"Music",
|
||||
"Scene",
|
||||
"Sound",
|
||||
"UIForm",
|
||||
"UISound",
|
||||
"Goods",
|
||||
"Weapon",
|
||||
"Prop",
|
||||
"Role",
|
||||
"Level",
|
||||
"LevelUpReward",
|
||||
"LevelRarity"
|
||||
"LevelRarity",
|
||||
};
|
||||
|
||||
private Dictionary<string, bool> _loadedFlag = new Dictionary<string, bool>();
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CustomComponent;
|
||||
using CustomEvent;
|
||||
using DataTable;
|
||||
using Entity;
|
||||
using GameFramework.Fsm;
|
||||
using GameFramework.Procedure;
|
||||
@@ -11,19 +14,19 @@ namespace Procedure
|
||||
public override GameStateType GameStateType => GameStateType.Battle;
|
||||
|
||||
private EnemyManagerComponent _enemyManager = null;
|
||||
|
||||
|
||||
private int _currentLevel = 0;
|
||||
|
||||
private bool _levelOver;
|
||||
|
||||
private float _levelTimeLeft = 0;
|
||||
|
||||
private Player Player => _procedureGame.Player;
|
||||
|
||||
|
||||
private ProcedureGame _procedureGame = null;
|
||||
|
||||
public void LevelOver()
|
||||
public void AddBattleDuration(float seconds)
|
||||
{
|
||||
if (_levelOver) return;
|
||||
_levelOver = true;
|
||||
if (seconds <= 0f) return;
|
||||
_levelTimeLeft += seconds;
|
||||
}
|
||||
|
||||
#region FSM
|
||||
@@ -37,21 +40,33 @@ namespace Procedure
|
||||
public override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
_currentLevel = _procedureGame.CurrentLevel;
|
||||
_levelOver = false;
|
||||
_enemyManager.OnInit(_currentLevel, this);
|
||||
|
||||
|
||||
var drLevel = GameEntry.DataTable.GetDataTableRow<DRLevel>(_currentLevel);
|
||||
|
||||
if (drLevel == null)
|
||||
{
|
||||
throw new Exception($"GameStateBattle.OnEnter: {_currentLevel} is not found.");
|
||||
}
|
||||
|
||||
_levelTimeLeft = drLevel.Duration;
|
||||
_enemyManager.OnInit(drLevel);
|
||||
|
||||
if (Player != null) Player.Enable = true;
|
||||
}
|
||||
|
||||
public override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
|
||||
float realElapseSeconds)
|
||||
{
|
||||
_enemyManager.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
if (_levelOver)
|
||||
if (_levelTimeLeft < 0)
|
||||
{
|
||||
_procedureGame.BattleToShopOrLevelUp();
|
||||
return;
|
||||
}
|
||||
|
||||
_enemyManager.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
_levelTimeLeft -= elapseSeconds;
|
||||
GameEntry.Event.Fire(this, LevelProcessEventArgs.Create((int)_levelTimeLeft));
|
||||
}
|
||||
|
||||
public override void OnLeave(IFsm<IProcedureManager> procedureOwner)
|
||||
@@ -78,4 +93,4 @@ namespace Procedure
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,8 @@ namespace Procedure
|
||||
private Dictionary<GameStateType, GameStateBase> _gameStates;
|
||||
public Player Player;
|
||||
|
||||
public GameStateBase CurrentGameState => _gameStates[_currentGameState];
|
||||
|
||||
private void InitGameState()
|
||||
{
|
||||
_gameStates = new Dictionary<GameStateType, GameStateBase>
|
||||
@@ -93,7 +95,7 @@ namespace Procedure
|
||||
CurrentLevel = 1;
|
||||
_currentPlayerData = new PlayerData(-1, 1001);
|
||||
GameEntry.Entity.ShowPlayer(_currentPlayerData);
|
||||
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.HudForm);
|
||||
}
|
||||
|
||||
@@ -127,11 +129,11 @@ namespace Procedure
|
||||
_gameStates.Clear();
|
||||
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.HudForm);
|
||||
|
||||
|
||||
_hudForm = null;
|
||||
|
||||
|
||||
Player = null;
|
||||
|
||||
|
||||
_procedureOwner = null;
|
||||
|
||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Definition.Enum;
|
||||
using Scene;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityGameFramework.Runtime;
|
||||
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
|
||||
|
||||
@@ -30,6 +32,9 @@ namespace Procedure
|
||||
|
||||
var useCase2 = new SelectRoleFormUseCase(this);
|
||||
GameEntry.UIRouter.BindUIUseCase(UIFormType.SelectRoleForm, useCase2);
|
||||
|
||||
QualitySettings.vSyncCount = 0;
|
||||
Application.targetFrameRate = 120;
|
||||
}
|
||||
|
||||
protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown)
|
||||
|
||||
Reference in New Issue
Block a user