- 补充游戏核心逻辑
- 完成 TodOList P0
- 添加游戏内控制台便于调试
- 增加敌人互斥机制提高运算负载
- 优化互斥算法将游戏性能基准线拉到 1k 敌人
This commit is contained in:
@@ -12,7 +12,7 @@ using DataTable;
|
||||
using Definition;
|
||||
using Definition.Enum;
|
||||
using Procedure;
|
||||
using Game.Utility;
|
||||
using CustomUtility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace UI
|
||||
{
|
||||
public class DisplayItemInfoFormContext : UIContext
|
||||
{
|
||||
public int Index;
|
||||
public string IconAssetName;
|
||||
public string Title;
|
||||
public string TypeText;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Definition.Enum;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
@@ -6,6 +7,7 @@ namespace UI
|
||||
{
|
||||
public string Title;
|
||||
public Sprite Icon;
|
||||
public ItemRarity ItemRarity;
|
||||
public string Description;
|
||||
public string IconAssetName;
|
||||
}
|
||||
|
||||
@@ -10,5 +10,6 @@ namespace UI
|
||||
public List<GoodsItemContext> GoodsItems;
|
||||
public DisplayListAreaContext PropListContext;
|
||||
public DisplayListAreaContext WeaponListContext;
|
||||
public float WeaponRecycleRate = 0.3f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
using CustomEvent;
|
||||
using Definition.Enum;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class DisplayItemInfoFormController : UIFormControllerCommonBase<DisplayItemInfoFormContext, DisplayItemInfoForm>
|
||||
public class DisplayItemInfoFormController : UIFormControllerCommonBase<
|
||||
DisplayItemInfoFormContext, DisplayItemInfoForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.DisplayItemInfoForm;
|
||||
|
||||
private bool _locked = false;
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(DisplayItemInfoLockEventArgs.EventId, DisplayItemInfoLock);
|
||||
GameEntry.Event.Subscribe(DisplayItemInfoHideEventArgs.EventId, DisplayItemInfoHide);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(DisplayItemInfoLockEventArgs.EventId, DisplayItemInfoLock);
|
||||
GameEntry.Event.Unsubscribe(DisplayItemInfoHideEventArgs.EventId, DisplayItemInfoHide);
|
||||
}
|
||||
|
||||
protected override void RefreshUI(DisplayItemInfoForm form, DisplayItemInfoFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
@@ -26,6 +43,7 @@ namespace UI
|
||||
|
||||
return new DisplayItemInfoFormContext
|
||||
{
|
||||
Index = rawData.Index,
|
||||
IconAssetName = rawData.IconAssetName,
|
||||
Title = rawData.Title,
|
||||
Rarity = rawData.Rarity,
|
||||
@@ -39,12 +57,14 @@ namespace UI
|
||||
|
||||
public int? OpenUI(DisplayItemInfoFormRawData rawData)
|
||||
{
|
||||
_locked = false;
|
||||
DisplayItemInfoFormContext context = BuildContext(rawData);
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
_locked = false;
|
||||
if (userData is DisplayItemInfoFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
@@ -71,5 +91,26 @@ namespace UI
|
||||
Log.Error("DisplayItemInfoForm.BindUseCase() useCase is invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void DisplayItemInfoLock(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is DisplayItemInfoLockEventArgs)) return;
|
||||
|
||||
_locked = true;
|
||||
}
|
||||
|
||||
private void DisplayItemInfoHide(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is DisplayItemInfoHideEventArgs args)) return;
|
||||
|
||||
if (!args.Force && _locked && sender is not DisplayItemInfoForm) return;
|
||||
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.DisplayItemInfoForm);
|
||||
_locked = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using CustomEvent;
|
||||
using Definition.Enum;
|
||||
using Game.Utility;
|
||||
using CustomUtility;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace UI
|
||||
{
|
||||
Title = reward.Title,
|
||||
Icon = null,
|
||||
ItemRarity = reward.Rarity,
|
||||
Description = ItemDescUtility.CreatePropDescription(reward.Modifiers),
|
||||
IconAssetName = reward.IconAssetName
|
||||
});
|
||||
|
||||
@@ -3,8 +3,10 @@ using CustomEvent;
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
using Entity;
|
||||
using Game.Utility;
|
||||
using CustomUtility;
|
||||
using Entity.Weapon;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
@@ -25,18 +27,18 @@ namespace UI
|
||||
{
|
||||
GameEntry.Event.Subscribe(RefreshEventArgs.EventId, Refresh);
|
||||
GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
|
||||
GameEntry.Event.Subscribe(ShopWeaponRecycleEventArgs.EventId, WeaponRecycle);
|
||||
GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
|
||||
GameEntry.Event.Subscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
|
||||
GameEntry.Event.Subscribe(DisplayItemHideEventArgs.EventId, DisplayItemHide);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(RefreshEventArgs.EventId, Refresh);
|
||||
GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
|
||||
GameEntry.Event.Unsubscribe(ShopWeaponRecycleEventArgs.EventId, WeaponRecycle);
|
||||
GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
|
||||
GameEntry.Event.Unsubscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
|
||||
GameEntry.Event.Unsubscribe(DisplayItemHideEventArgs.EventId, DisplayItemHide);
|
||||
}
|
||||
|
||||
#region BuildContext
|
||||
@@ -56,12 +58,15 @@ namespace UI
|
||||
RefreshPrice = rawData.RefreshPrice,
|
||||
PlayerCoin = rawData.PlayerCoin,
|
||||
GoodsItems = rawData.GoodsItems,
|
||||
PropListContext = BuildDisplayListAreaContext(DisplayListAreaType.Prop, rawData.PropItems, rawData.PropMaxCount),
|
||||
WeaponListContext = BuildDisplayListAreaContext(DisplayListAreaType.Weapon, rawData.WeaponItems, rawData.WeaponMaxCount)
|
||||
PropListContext =
|
||||
BuildDisplayListAreaContext(DisplayListAreaType.Prop, rawData.PropItems, rawData.PropMaxCount),
|
||||
WeaponListContext = BuildDisplayListAreaContext(DisplayListAreaType.Weapon, rawData.WeaponItems,
|
||||
rawData.WeaponMaxCount)
|
||||
};
|
||||
}
|
||||
|
||||
private static DisplayListAreaContext BuildDisplayListAreaContext(DisplayListAreaType listType, IReadOnlyList<object> items,
|
||||
private static DisplayListAreaContext BuildDisplayListAreaContext(DisplayListAreaType listType,
|
||||
IReadOnlyList<object> items,
|
||||
int maxCount)
|
||||
{
|
||||
string title = GetDisplayListTitle(listType);
|
||||
@@ -89,6 +94,7 @@ namespace UI
|
||||
itemContexts[i] = BuildWeaponItem(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DisplayListAreaType.Prop:
|
||||
@@ -101,6 +107,7 @@ namespace UI
|
||||
itemContexts[i] = BuildPropItem(propItem);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -347,6 +354,7 @@ namespace UI
|
||||
|
||||
DisplayItemInfoFormRawData rawData = new();
|
||||
rawData.TargetPos = args.TargetPos;
|
||||
rawData.Index = args.Index;
|
||||
if (args.IsWeapon)
|
||||
{
|
||||
var weaponData = _rawData.WeaponItems[args.Index].WeaponData;
|
||||
@@ -355,7 +363,7 @@ namespace UI
|
||||
rawData.Rarity = weaponData.Rarity;
|
||||
rawData.TypeText = "武器";
|
||||
rawData.Description = ItemDescUtility.CreateWeaponDescription(weaponData);
|
||||
rawData.Price = 0;
|
||||
rawData.Price = Mathf.FloorToInt(weaponData.Price * Context.WeaponRecycleRate);
|
||||
rawData.IsWeapon = true;
|
||||
}
|
||||
else
|
||||
@@ -373,11 +381,29 @@ namespace UI
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.DisplayItemInfoForm, rawData);
|
||||
}
|
||||
|
||||
private void DisplayItemHide(object sender, GameEventArgs e)
|
||||
private void WeaponRecycle(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is DisplayItemHideEventArgs)) return;
|
||||
if (!(e is ShopWeaponRecycleEventArgs args)) return;
|
||||
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.DisplayItemInfoForm);
|
||||
if (_useCase == null || Context == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool success = _useCase.TryRecycleWeapon(args.Index, args.Price);
|
||||
if (!success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Context.WeaponListContext != null)
|
||||
{
|
||||
int currentCount = Mathf.Max(0, Context.WeaponListContext.CurrentCount - 1);
|
||||
Context.WeaponListContext.CurrentCount = currentCount;
|
||||
}
|
||||
|
||||
Form?.RemoveWeaponDisplayItem(args.Index);
|
||||
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace UI
|
||||
{
|
||||
public class DisplayItemInfoFormRawData
|
||||
{
|
||||
public int Index;
|
||||
public string IconAssetName;
|
||||
public string Title;
|
||||
public string TypeText;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Definition.DataStruct;
|
||||
using Entity;
|
||||
using Entity.Weapon;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Definition.DataStruct;
|
||||
using Entity;
|
||||
using Game.Utility;
|
||||
using CustomUtility;
|
||||
using Entity.Weapon;
|
||||
using Procedure;
|
||||
|
||||
namespace UI
|
||||
|
||||
@@ -7,7 +7,7 @@ using Entity;
|
||||
using Procedure;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Game.Utility;
|
||||
using CustomUtility;
|
||||
using GameFramework.DataTable;
|
||||
|
||||
namespace UI
|
||||
|
||||
@@ -4,7 +4,8 @@ using DataTable;
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
using Entity;
|
||||
using Game.Utility;
|
||||
using Entity.EntityData;
|
||||
using CustomUtility;
|
||||
using GameFramework.DataTable;
|
||||
using Procedure;
|
||||
using UnityEngine;
|
||||
@@ -127,8 +128,13 @@ namespace UI
|
||||
return null;
|
||||
}
|
||||
|
||||
player.Coin -= selection.Price;
|
||||
DisplayItemContext displayItem = ApplyGoodsPurchase(selection);
|
||||
if (displayItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
player.Coin -= selection.Price;
|
||||
_selections[goodsIndex] = null;
|
||||
|
||||
return new ShopPurchaseResult
|
||||
@@ -340,13 +346,97 @@ namespace UI
|
||||
|
||||
if (goods.GoodsType == GoodsType.Weapon)
|
||||
{
|
||||
// TODO: Weapon purchase apply flow depends on the upcoming weapon system integration.
|
||||
// Implement weapon creation/equip/add-to-inventory here when weapon runtime model is ready.
|
||||
Log.Warning("ShopFormUseCase::ApplyGoodsPurchase: Weapon purchase flow is not implemented yet.");
|
||||
return null;
|
||||
if (Player.Weapons != null && Player.Weapons.Count >= Player.WeaponCapacity)
|
||||
{
|
||||
Log.Warning("ShopFormUseCase::ApplyGoodsPurchase: Weapon capacity is full.");
|
||||
return null;
|
||||
}
|
||||
|
||||
DRWeapon drWeapon = _weaponDataTable != null ? _weaponDataTable.GetDataRow(goods.GoodsTypeId) : null;
|
||||
if (drWeapon == null)
|
||||
{
|
||||
Log.Warning($"ShopFormUseCase::ApplyGoodsPurchase: Missing DRWeapon, id = {goods.GoodsTypeId}");
|
||||
return null;
|
||||
}
|
||||
|
||||
var weaponData = CreateWeaponData(goods.GoodsTypeId);
|
||||
if (weaponData == null)
|
||||
{
|
||||
Log.Warning(
|
||||
$"ShopFormUseCase::ApplyGoodsPurchase: Unsupported weapon type id = {goods.GoodsTypeId}");
|
||||
return null;
|
||||
}
|
||||
|
||||
GameEntry.Entity.ShowWeapon(weaponData);
|
||||
|
||||
return new DisplayItemContext
|
||||
{
|
||||
IconAssetName = drWeapon.IconAssetName,
|
||||
Rarity = drWeapon.Rarity,
|
||||
IsWeapon = true
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private WeaponData CreateWeaponData(int weaponTypeId)
|
||||
{
|
||||
int entityId = GameEntry.Entity.GenerateSerialId();
|
||||
int ownerId = Player.Id;
|
||||
CampType ownerCamp = CampType.Player;
|
||||
|
||||
WeaponType weaponType = (WeaponType)weaponTypeId;
|
||||
switch (weaponType)
|
||||
{
|
||||
case WeaponType.WeaponKnife:
|
||||
return new WeaponKnifeData(entityId, ownerId, ownerCamp);
|
||||
case WeaponType.WeaponHandgun:
|
||||
return new WeaponHandgunData(entityId, ownerId, ownerCamp);
|
||||
case WeaponType.WeaponSlash:
|
||||
return new WeaponSlashData(entityId, ownerId, ownerCamp);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryRecycleWeapon(int argsIndex, int argsPrice)
|
||||
{
|
||||
Player player = Player;
|
||||
if (player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var weapons = player.Weapons;
|
||||
if (weapons == null || weapons.Count <= 1)
|
||||
{
|
||||
Log.Warning("ShopFormUseCase::TryRecycleWeapon: Can not recycle the last weapon.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (argsIndex < 0 || argsIndex >= weapons.Count)
|
||||
{
|
||||
Log.Warning($"ShopFormUseCase::TryRecycleWeapon: Invalid weapon index = {argsIndex}");
|
||||
return false;
|
||||
}
|
||||
|
||||
var weapon = weapons[argsIndex];
|
||||
if (weapon == null)
|
||||
{
|
||||
Log.Warning("ShopFormUseCase::TryRecycleWeapon: Weapon is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int recyclePrice = Mathf.Max(0, argsPrice);
|
||||
if (!player.RemoveWeapon(weapon))
|
||||
{
|
||||
Log.Warning("ShopFormUseCase::TryRecycleWeapon: Remove weapon failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.Coin += recyclePrice;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ namespace UI
|
||||
|
||||
private int _index = -1;
|
||||
|
||||
public void SetIndex(int index)
|
||||
{
|
||||
_index = index;
|
||||
}
|
||||
|
||||
public void OnInit(DisplayItemContext context, int index)
|
||||
{
|
||||
if (context == null) return;
|
||||
@@ -42,18 +47,25 @@ namespace UI
|
||||
public void OnItemInfoShow()
|
||||
{
|
||||
if (_index < 0) return;
|
||||
Vector3 targetPos = _itemRect.position + new Vector3(0, _itemRect.sizeDelta.y / 2, 0);
|
||||
if (_itemRect == null) return;
|
||||
|
||||
Rect rect = _itemRect.rect;
|
||||
Vector3 targetPos = _itemRect.TransformPoint(new Vector3(
|
||||
(rect.xMin + rect.xMax) / 2,
|
||||
rect.yMax,
|
||||
0f)
|
||||
);
|
||||
GameEntry.Event.Fire(this, DisplayItemShowEventArgs.Create(_index, _context.IsWeapon, targetPos));
|
||||
}
|
||||
|
||||
public void SetIndex(int index)
|
||||
public void OnItemInfoLock()
|
||||
{
|
||||
_index = index;
|
||||
GameEntry.Event.Fire(this, DisplayItemInfoLockEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnItemInfoHide()
|
||||
{
|
||||
GameEntry.Event.Fire(this, DisplayItemHideEventArgs.Create());
|
||||
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using CustomEvent;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
@@ -45,6 +45,7 @@ namespace UI
|
||||
_context = context;
|
||||
|
||||
_targetPos = ConvertWorldToAnchored(_context.TargetPos);
|
||||
Log.Info($"{_context.TargetPos}->{_targetPos}");
|
||||
|
||||
if (_content != null)
|
||||
{
|
||||
@@ -172,14 +173,16 @@ namespace UI
|
||||
}
|
||||
|
||||
Canvas canvas = _content.GetComponentInParent<Canvas>();
|
||||
Canvas rootCanvas = canvas != null ? canvas.rootCanvas : null;
|
||||
Camera uiCamera = null;
|
||||
if (canvas != null && canvas.renderMode != RenderMode.ScreenSpaceOverlay)
|
||||
if (rootCanvas != null && rootCanvas.renderMode != RenderMode.ScreenSpaceOverlay)
|
||||
{
|
||||
uiCamera = canvas.worldCamera;
|
||||
uiCamera = rootCanvas.worldCamera != null ? rootCanvas.worldCamera : Camera.main;
|
||||
}
|
||||
|
||||
Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(uiCamera, worldPos);
|
||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, screenPoint, uiCamera, out Vector2 localPoint))
|
||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, screenPoint, uiCamera,
|
||||
out Vector2 localPoint))
|
||||
{
|
||||
return worldPos;
|
||||
}
|
||||
@@ -187,5 +190,16 @@ namespace UI
|
||||
float z = _content.anchoredPosition3D.z;
|
||||
return new Vector3(localPoint.x, localPoint.y, z);
|
||||
}
|
||||
|
||||
public void OnRecycleButtonClick()
|
||||
{
|
||||
if (_context == null || !_context.IsWeapon) return;
|
||||
GameEntry.Event.Fire(this, ShopWeaponRecycleEventArgs.Create(_context.Index, _context.Price));
|
||||
}
|
||||
|
||||
public void OnCancelButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Components;
|
||||
using CustomComponent;
|
||||
using CustomEvent;
|
||||
using Entity;
|
||||
using GameFramework.Event;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -13,17 +12,17 @@ namespace UI
|
||||
[SerializeField] private float _sliderFadeDuration = 0.5f;
|
||||
|
||||
[SerializeField] private Slider _hpSlider;
|
||||
|
||||
|
||||
[SerializeField] private TMP_Text _hpText;
|
||||
|
||||
|
||||
private float _currentHpPercent = 0;
|
||||
private Coroutine _hpSliderFadeCoroutine;
|
||||
|
||||
[SerializeField] private Slider _expSlider;
|
||||
|
||||
|
||||
private float _currentExpPercent = 0;
|
||||
private Coroutine _expSliderFadeCoroutine;
|
||||
|
||||
|
||||
[SerializeField] private TMP_Text _expText;
|
||||
|
||||
private int _playerCurrentLevel = 1;
|
||||
@@ -31,11 +30,16 @@ namespace UI
|
||||
[SerializeField] private TMP_Text _coinText;
|
||||
private int _currentCoin = 0;
|
||||
|
||||
[SerializeField] private TMP_Text _levelTimeLeftText;
|
||||
private int _currentTimeLeft = 0;
|
||||
|
||||
[SerializeField] private TMP_Text _enemyCountText;
|
||||
private EnemyManagerComponent _enemy;
|
||||
|
||||
public void RefreshUI(HudFormContext hudFormContext)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region FSM
|
||||
|
||||
protected override void OnInit(object userData)
|
||||
@@ -46,6 +50,9 @@ namespace UI
|
||||
GameEntry.Event.Subscribe(PlayerExpChangeEventArgs.EventId, PlayerExpChange);
|
||||
GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, PlayerCoinChange);
|
||||
GameEntry.Event.Subscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
|
||||
GameEntry.Event.Subscribe(LevelProcessEventArgs.EventId, LevelProcess);
|
||||
|
||||
_enemy = GameEntry.EnemyManager;
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
@@ -54,9 +61,24 @@ namespace UI
|
||||
GameEntry.Event.Unsubscribe(PlayerHealthChangeEventArgs.EventId, PlayerHpChange);
|
||||
GameEntry.Event.Unsubscribe(PlayerExpChangeEventArgs.EventId, PlayerExpChange);
|
||||
GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, PlayerCoinChange);
|
||||
GameEntry.Event.Unsubscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
|
||||
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
|
||||
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
base.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
if (_enemy == null)
|
||||
{
|
||||
_enemy = GameEntry.EnemyManager;
|
||||
}
|
||||
|
||||
if (_enemy != null)
|
||||
{
|
||||
_enemyCountText.text = $"Enemy: {_enemy.CurrentEnemyCount}";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -67,7 +89,7 @@ namespace UI
|
||||
if (!(e is PlayerHealthChangeEventArgs args)) return;
|
||||
|
||||
_hpText.text = $"{args.CurrentHealth}/{args.MaxHealth}";
|
||||
|
||||
|
||||
float percent = (float)args.CurrentHealth / args.MaxHealth;
|
||||
if (Mathf.Approximately(_currentHpPercent, percent)) return;
|
||||
|
||||
@@ -96,7 +118,7 @@ namespace UI
|
||||
_playerCurrentLevel++;
|
||||
_expText.text = $"LV.{_playerCurrentLevel}";
|
||||
}
|
||||
|
||||
|
||||
private void PlayerCoinChange(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is PlayerCoinChangeEventArgs args)) return;
|
||||
@@ -106,24 +128,15 @@ namespace UI
|
||||
_currentCoin = args.CoinCount;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Test
|
||||
|
||||
private Player _player;
|
||||
|
||||
public void CauseDamageToPlayer()
|
||||
private void LevelProcess(object sender, GameEventArgs e)
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
_player = FindObjectOfType<Player>();
|
||||
}
|
||||
if (!(e is LevelProcessEventArgs args)) return;
|
||||
if (_currentTimeLeft == args.LevelTimeLeft) return;
|
||||
|
||||
if (_player == null) return;
|
||||
|
||||
_player.GetComponent<HealthComponent>().TakeDamage(2);
|
||||
_currentTimeLeft = args.LevelTimeLeft;
|
||||
_levelTimeLeftText.text = _currentTimeLeft.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace UI
|
||||
|
||||
if (_titleText != null) _titleText.text = context.Title;
|
||||
if (_descriptionText != null) _descriptionText.text = context.Description;
|
||||
if (_iconArea != null) _iconArea.SetIcon(context.Icon);
|
||||
if (_iconArea != null) _iconArea.OnInit(context.Icon, context.ItemRarity);
|
||||
|
||||
LoadIcon(_context.IconAssetName);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,12 @@ namespace UI
|
||||
_weaponListArea.AddItem(context);
|
||||
}
|
||||
|
||||
internal void RemoveWeaponDisplayItem(int index)
|
||||
{
|
||||
if (_weaponListArea == null) return;
|
||||
_weaponListArea.RemoveItemAt(index);
|
||||
}
|
||||
|
||||
#region ButtonClick
|
||||
|
||||
public void OnContinueButtonClick()
|
||||
|
||||
Reference in New Issue
Block a user