补充事件参数 + 完善 UI 设计
- 事件节点在 EventNodeComponent.cs 的 StartEvent/EndEvent 会携带 runId/nodeId/nodeType/sequenceIndex - 商店节点在 ShopNodeComponent.cs 也会带同一套字段 - 战斗节点通过 CombatNodeComponent.cs 把上下文传进 CombatScheduler,再由 CombatRunningPhaseState.cs 发 NodeEnterEventArgs、由 CombatSchedulerFlowCoordinator.cs 发 NodeCompleteEventArgs - NodeCompleteEventArgs.cs 现在新增了 SequenceIndex - 各种 UI 的覆盖问题
This commit is contained in:
@@ -3,6 +3,7 @@ using GameFramework.DataTable;
|
||||
using GeometryTD.CustomEvent;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.Procedure;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -174,7 +175,12 @@ namespace GeometryTD.CustomComponent
|
||||
EnsureCombatRuntimeInitialized();
|
||||
}
|
||||
|
||||
public void StartCombat(int levelId = 0)
|
||||
public void StartCombat(
|
||||
int levelId = 0,
|
||||
string runId = null,
|
||||
int nodeId = 0,
|
||||
RunNodeType nodeType = RunNodeType.None,
|
||||
int sequenceIndex = -1)
|
||||
{
|
||||
if (!EnsureCombatRuntimeInitialized())
|
||||
{
|
||||
@@ -221,7 +227,14 @@ namespace GeometryTD.CustomComponent
|
||||
LastDefeatedEnemyCount = 0;
|
||||
LastGainedCoin = 0;
|
||||
LastGainedGold = 0;
|
||||
if (!_combatScheduler.Start(selectedLevel, phaseList, _selectedSpawnEntriesByPhaseId))
|
||||
if (!_combatScheduler.Start(
|
||||
selectedLevel,
|
||||
phaseList,
|
||||
_selectedSpawnEntriesByPhaseId,
|
||||
runId,
|
||||
nodeId,
|
||||
nodeType,
|
||||
sequenceIndex))
|
||||
{
|
||||
CurrentLevel = null;
|
||||
return;
|
||||
|
||||
+10
-1
@@ -4,6 +4,7 @@ using GeometryTD.CustomEvent;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.Entity;
|
||||
using GeometryTD.Procedure;
|
||||
using GeometryTD.UI;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
@@ -67,7 +68,11 @@ namespace GeometryTD.CustomComponent
|
||||
public bool Start(
|
||||
DRLevel level,
|
||||
IReadOnlyList<DRLevelPhase> phases,
|
||||
IReadOnlyDictionary<int, IReadOnlyList<DRLevelSpawnEntry>> spawnEntriesByPhaseId)
|
||||
IReadOnlyDictionary<int, IReadOnlyList<DRLevelSpawnEntry>> spawnEntriesByPhaseId,
|
||||
string runId = null,
|
||||
int nodeId = 0,
|
||||
RunNodeType nodeType = RunNodeType.None,
|
||||
int sequenceIndex = -1)
|
||||
{
|
||||
if (!_initialized || _context.Entity == null)
|
||||
{
|
||||
@@ -89,6 +94,10 @@ namespace GeometryTD.CustomComponent
|
||||
_context.IsFinishAsVictory = true;
|
||||
|
||||
_context.CurrentLevel = level;
|
||||
_context.RunId = runId;
|
||||
_context.NodeId = nodeId;
|
||||
_context.NodeType = nodeType;
|
||||
_context.SequenceIndex = sequenceIndex;
|
||||
_context.CombatInRunResourceManager.InitializeForCombat(level);
|
||||
for (int i = 0; i < phases.Count; i++)
|
||||
{
|
||||
|
||||
+14
-1
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using GeometryTD.CustomEvent;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.Procedure;
|
||||
using GeometryTD.UI;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
@@ -55,6 +56,10 @@ namespace GeometryTD.CustomComponent
|
||||
_context.IsFinishAsVictory = true;
|
||||
_context.IsCompleted = false;
|
||||
_context.NodeEnterFired = false;
|
||||
_context.RunId = null;
|
||||
_context.NodeId = 0;
|
||||
_context.NodeType = RunNodeType.None;
|
||||
_context.SequenceIndex = -1;
|
||||
}
|
||||
|
||||
public void CleanupAllCombatEntities()
|
||||
@@ -196,7 +201,15 @@ namespace GeometryTD.CustomComponent
|
||||
public void CompleteNormalCombatAndNotify(bool succeeded)
|
||||
{
|
||||
CompleteCombat(succeeded);
|
||||
GameEntry.Event.Fire(this, NodeCompleteEventArgs.Create());
|
||||
GameEntry.Event.Fire(
|
||||
this,
|
||||
NodeCompleteEventArgs.Create(
|
||||
_context.RunId,
|
||||
_context.NodeId,
|
||||
_context.NodeType,
|
||||
_context.SequenceIndex,
|
||||
succeeded,
|
||||
GameEntry.PlayerInventory != null ? GameEntry.PlayerInventory.GetInventorySnapshot() : null));
|
||||
}
|
||||
|
||||
public void CompleteFailureCombatAndNotify()
|
||||
|
||||
+5
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Entity;
|
||||
using GeometryTD.Procedure;
|
||||
using GeometryTD.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -29,5 +30,9 @@ namespace GeometryTD.CustomComponent
|
||||
public bool IsCompleted { get; set; }
|
||||
public bool NodeEnterFired { get; set; }
|
||||
public CombatSettlementContext SettlementContext { get; set; }
|
||||
public string RunId { get; set; }
|
||||
public int NodeId { get; set; }
|
||||
public RunNodeType NodeType { get; set; }
|
||||
public int SequenceIndex { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -38,7 +38,13 @@ namespace GeometryTD.CustomComponent
|
||||
if (!Context.NodeEnterFired)
|
||||
{
|
||||
Context.NodeEnterFired = true;
|
||||
GameEntry.Event.Fire(Flow, NodeEnterEventArgs.Create());
|
||||
GameEntry.Event.Fire(
|
||||
Flow,
|
||||
NodeEnterEventArgs.Create(
|
||||
Context.RunId,
|
||||
Context.NodeId,
|
||||
Context.NodeType,
|
||||
Context.SequenceIndex));
|
||||
}
|
||||
|
||||
Log.Info(
|
||||
|
||||
@@ -3,6 +3,7 @@ using GameFramework.DataTable;
|
||||
using GeometryTD.CustomEvent;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.Procedure;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using GeometryTD.UI;
|
||||
using UnityEngine;
|
||||
@@ -12,6 +13,11 @@ namespace GeometryTD.CustomComponent
|
||||
{
|
||||
public class EventNodeComponent : GameFrameworkComponent
|
||||
{
|
||||
private string _activeRunId;
|
||||
private int _activeNodeId;
|
||||
private RunNodeType _activeNodeType = RunNodeType.None;
|
||||
private int _activeSequenceIndex = -1;
|
||||
|
||||
private readonly List<EventItem> _eventItems = new List<EventItem>();
|
||||
|
||||
private EventFormUseCase _eventFormUseCase;
|
||||
@@ -47,7 +53,7 @@ namespace GeometryTD.CustomComponent
|
||||
Log.Info("EventNodeComponent initialized with {0} events.", _eventItems.Count);
|
||||
}
|
||||
|
||||
public void StartEvent()
|
||||
public void StartEvent(string runId = null, int nodeId = 0, RunNodeType nodeType = RunNodeType.None, int sequenceIndex = -1)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
@@ -69,15 +75,36 @@ namespace GeometryTD.CustomComponent
|
||||
return;
|
||||
}
|
||||
|
||||
_activeRunId = runId;
|
||||
_activeNodeId = nodeId;
|
||||
_activeNodeType = nodeType;
|
||||
_activeSequenceIndex = sequenceIndex;
|
||||
_eventFormUseCase.SetCurrentEvent(randomEvent);
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.EventForm);
|
||||
GameEntry.Event.Fire(this, NodeEnterEventArgs.Create());
|
||||
GameEntry.Event.Fire(this, NodeEnterEventArgs.Create(runId, nodeId, nodeType, sequenceIndex));
|
||||
}
|
||||
|
||||
public void EndEvent()
|
||||
{
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.EventForm);
|
||||
GameEntry.Event.Fire(this, NodeCompleteEventArgs.Create());
|
||||
GameEntry.Event.Fire(
|
||||
this,
|
||||
NodeCompleteEventArgs.Create(
|
||||
_activeRunId,
|
||||
_activeNodeId,
|
||||
_activeNodeType,
|
||||
_activeSequenceIndex,
|
||||
true,
|
||||
GameEntry.PlayerInventory != null ? GameEntry.PlayerInventory.GetInventorySnapshot() : null));
|
||||
ClearActiveNodeContext();
|
||||
}
|
||||
|
||||
private void ClearActiveNodeContext()
|
||||
{
|
||||
_activeRunId = null;
|
||||
_activeNodeId = 0;
|
||||
_activeNodeType = RunNodeType.None;
|
||||
_activeSequenceIndex = -1;
|
||||
}
|
||||
|
||||
private static EventOption[] ParseOptions(string optionsRaw)
|
||||
|
||||
@@ -2,11 +2,17 @@ using GeometryTD.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
using GeometryTD.CustomEvent;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.Procedure;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
public class ShopNodeComponent : GameFrameworkComponent
|
||||
{
|
||||
private string _activeRunId;
|
||||
private int _activeNodeId;
|
||||
private RunNodeType _activeNodeType = RunNodeType.None;
|
||||
private int _activeSequenceIndex = -1;
|
||||
|
||||
private ShopFormUseCase _shopFormUseCase;
|
||||
private bool _initialized;
|
||||
|
||||
@@ -22,7 +28,7 @@ namespace GeometryTD.CustomComponent
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public void StartShop()
|
||||
public void StartShop(string runId = null, int nodeId = 0, RunNodeType nodeType = RunNodeType.None, int sequenceIndex = -1)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
@@ -35,14 +41,35 @@ namespace GeometryTD.CustomComponent
|
||||
return;
|
||||
}
|
||||
|
||||
_activeRunId = runId;
|
||||
_activeNodeId = nodeId;
|
||||
_activeNodeType = nodeType;
|
||||
_activeSequenceIndex = sequenceIndex;
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.ShopForm);
|
||||
GameEntry.Event.Fire(this, NodeEnterEventArgs.Create());
|
||||
GameEntry.Event.Fire(this, NodeEnterEventArgs.Create(runId, nodeId, nodeType, sequenceIndex));
|
||||
}
|
||||
|
||||
public void EndShop()
|
||||
{
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.ShopForm);
|
||||
GameEntry.Event.Fire(this, NodeCompleteEventArgs.Create());
|
||||
GameEntry.Event.Fire(
|
||||
this,
|
||||
NodeCompleteEventArgs.Create(
|
||||
_activeRunId,
|
||||
_activeNodeId,
|
||||
_activeNodeType,
|
||||
_activeSequenceIndex,
|
||||
true,
|
||||
GameEntry.PlayerInventory != null ? GameEntry.PlayerInventory.GetInventorySnapshot() : null));
|
||||
ClearActiveNodeContext();
|
||||
}
|
||||
|
||||
private void ClearActiveNodeContext()
|
||||
{
|
||||
_activeRunId = null;
|
||||
_activeNodeId = 0;
|
||||
_activeNodeType = RunNodeType.None;
|
||||
_activeSequenceIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user