修复已知问题
This commit is contained in:
@@ -110,7 +110,7 @@ namespace GeometryTD.UI
|
||||
return;
|
||||
}
|
||||
|
||||
RewardSelectFormRawData nextRawData = _useCase.TryRefresh();
|
||||
RewardSelectFormRawData nextRawData = _useCase.TryRotateSelection();
|
||||
if (nextRawData == null)
|
||||
{
|
||||
CloseUI();
|
||||
@@ -159,4 +159,4 @@ namespace GeometryTD.UI
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,17 +15,20 @@ namespace GeometryTD.UI
|
||||
|
||||
private int _displayCount = 3;
|
||||
private int _refreshCost;
|
||||
private bool _allowRefreshOnce = true;
|
||||
private bool _allowRotateOnce = true;
|
||||
private bool _allowGiveUp = true;
|
||||
private bool _hasRefreshed;
|
||||
private bool _hasRotated;
|
||||
private int _selectionOffset;
|
||||
private string _tipText = "Select one reward";
|
||||
|
||||
// RewardSelectForm keeps a fixed reward pool for the current node.
|
||||
// The "refresh" action only rotates which slice of that pool is shown so save/load
|
||||
// can reopen the same node with the exact same reward contents.
|
||||
public void ConfigureRewardPool(
|
||||
IReadOnlyList<RewardSelectItemRawData> rewardPool,
|
||||
int displayCount = 3,
|
||||
int refreshCost = 0,
|
||||
bool allowRefreshOnce = true,
|
||||
bool allowRotateOnce = true,
|
||||
bool allowGiveUp = true,
|
||||
string tipText = null)
|
||||
{
|
||||
@@ -45,10 +48,10 @@ namespace GeometryTD.UI
|
||||
|
||||
_displayCount = Mathf.Max(1, displayCount);
|
||||
_refreshCost = Mathf.Max(0, refreshCost);
|
||||
_allowRefreshOnce = allowRefreshOnce;
|
||||
_allowRotateOnce = allowRotateOnce;
|
||||
_allowGiveUp = allowGiveUp;
|
||||
_tipText = string.IsNullOrWhiteSpace(tipText) ? "Select one reward" : tipText;
|
||||
_hasRefreshed = false;
|
||||
_hasRotated = false;
|
||||
_selectionOffset = 0;
|
||||
_currentModel = null;
|
||||
}
|
||||
@@ -57,7 +60,7 @@ namespace GeometryTD.UI
|
||||
IReadOnlyList<TowerCompItemData> rewardCandidates,
|
||||
int displayCount = 3,
|
||||
int refreshCost = 0,
|
||||
bool allowRefreshOnce = true,
|
||||
bool allowRotateOnce = true,
|
||||
bool allowGiveUp = true,
|
||||
string tipText = null)
|
||||
{
|
||||
@@ -77,10 +80,10 @@ namespace GeometryTD.UI
|
||||
|
||||
_displayCount = Mathf.Max(1, displayCount);
|
||||
_refreshCost = Mathf.Max(0, refreshCost);
|
||||
_allowRefreshOnce = allowRefreshOnce;
|
||||
_allowRotateOnce = allowRotateOnce;
|
||||
_allowGiveUp = allowGiveUp;
|
||||
_tipText = string.IsNullOrWhiteSpace(tipText) ? "Select one reward" : tipText;
|
||||
_hasRefreshed = false;
|
||||
_hasRotated = false;
|
||||
_selectionOffset = 0;
|
||||
_currentModel = null;
|
||||
}
|
||||
@@ -93,30 +96,30 @@ namespace GeometryTD.UI
|
||||
|
||||
public RewardSelectFormRawData CreateInitialModel()
|
||||
{
|
||||
_hasRefreshed = false;
|
||||
_hasRotated = false;
|
||||
_currentModel = BuildModel();
|
||||
return _currentModel;
|
||||
}
|
||||
|
||||
public RewardSelectFormRawData TryRefresh()
|
||||
public RewardSelectFormRawData TryRotateSelection()
|
||||
{
|
||||
if (_currentModel == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!CanRefreshInternal())
|
||||
if (!CanRotateSelectionInternal())
|
||||
{
|
||||
return _currentModel;
|
||||
}
|
||||
|
||||
if (!TryConsumeRefreshCost())
|
||||
if (!TryConsumeRotateCost())
|
||||
{
|
||||
_currentModel.CanRefresh = false;
|
||||
return _currentModel;
|
||||
}
|
||||
|
||||
_hasRefreshed = true;
|
||||
_hasRotated = true;
|
||||
if (_rewardPool.Count > 0)
|
||||
{
|
||||
_selectionOffset = (_selectionOffset + _displayCount) % _rewardPool.Count;
|
||||
@@ -166,7 +169,7 @@ namespace GeometryTD.UI
|
||||
TipText = _tipText,
|
||||
RewardItems = selectedRewards,
|
||||
RefreshCost = _refreshCost,
|
||||
CanRefresh = selectedRewards.Length > 0 && CanRefreshInternal(),
|
||||
CanRefresh = selectedRewards.Length > 0 && CanRotateSelectionInternal(),
|
||||
CanGiveUp = _allowGiveUp
|
||||
};
|
||||
}
|
||||
@@ -190,17 +193,17 @@ namespace GeometryTD.UI
|
||||
return results;
|
||||
}
|
||||
|
||||
private bool CanRefreshInternal()
|
||||
private bool CanRotateSelectionInternal()
|
||||
{
|
||||
if (!_allowRefreshOnce || _hasRefreshed)
|
||||
if (!_allowRotateOnce || _hasRotated)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return CanPayRefreshCost();
|
||||
return CanPayRotateCost();
|
||||
}
|
||||
|
||||
private bool CanPayRefreshCost()
|
||||
private bool CanPayRotateCost()
|
||||
{
|
||||
if (_refreshCost <= 0)
|
||||
{
|
||||
@@ -215,7 +218,7 @@ namespace GeometryTD.UI
|
||||
return GameEntry.PlayerInventory.Gold >= _refreshCost;
|
||||
}
|
||||
|
||||
private bool TryConsumeRefreshCost()
|
||||
private bool TryConsumeRotateCost()
|
||||
{
|
||||
if (_refreshCost <= 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user