init
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// using Definition.Enum;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayItemContext : UIContext
|
||||
// {
|
||||
// public string IconAssetName;
|
||||
// public ItemRarity Rarity;
|
||||
// public bool IsWeapon;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,18 @@
|
||||
// using Definition.Enum;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayItemInfoFormContext : UIContext
|
||||
// {
|
||||
// public int Index;
|
||||
// public string IconAssetName;
|
||||
// public string Title;
|
||||
// public string TypeText;
|
||||
// public ItemRarity Rarity;
|
||||
// public string Description;
|
||||
// public int Price;
|
||||
// public bool IsWeapon;
|
||||
// public Vector3 TargetPos;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,14 @@
|
||||
// using System.Collections;
|
||||
// using System.Collections.Generic;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayListAreaContext : UIContext
|
||||
// {
|
||||
// public string Title;
|
||||
// public int CurrentCount;
|
||||
// public int MaxCount = -1;
|
||||
// public DisplayItemContext[] ItemContexts;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,15 @@
|
||||
// using Definition.Enum;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class GoodsItemContext : UIContext
|
||||
// {
|
||||
// public string Title;
|
||||
// public ItemRarity Rarity;
|
||||
// public string Type;
|
||||
// public Sprite Icon;
|
||||
// public string Description;
|
||||
// public int Price;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,10 @@
|
||||
// using System.Collections;
|
||||
// using System.Collections.Generic;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class HudFormContext : UIContext
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,10 @@
|
||||
// using System.Collections.Generic;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class LevelUpFormContext : UIContext
|
||||
// {
|
||||
// public List<LevelUpRewardItemContext> Props;
|
||||
// public int RefreshPrice;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,14 @@
|
||||
// using Definition.Enum;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class LevelUpRewardItemContext : UIContext
|
||||
// {
|
||||
// public string Title;
|
||||
// public Sprite Icon;
|
||||
// public ItemRarity ItemRarity;
|
||||
// public string Description;
|
||||
// public string IconAssetName;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,15 @@
|
||||
// using System.Collections.Generic;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class ShopFormContext : UIContext
|
||||
// {
|
||||
// public int CurrentLevel;
|
||||
// public int RefreshPrice;
|
||||
// public int PlayerCoin;
|
||||
// public List<GoodsItemContext> GoodsItems;
|
||||
// public DisplayListAreaContext PropListContext;
|
||||
// public DisplayListAreaContext WeaponListContext;
|
||||
// public float WeaponRecycleRate = 0.3f;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,116 @@
|
||||
// using CustomEvent;
|
||||
// using Definition.Enum;
|
||||
// using GameFramework.Event;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// protected override void CloseLoadedFormDirect(DisplayItemInfoForm form)
|
||||
// {
|
||||
// GameEntry.UI.CloseUIForm(form);
|
||||
// }
|
||||
//
|
||||
// private static DisplayItemInfoFormContext BuildContext(DisplayItemInfoFormRawData rawData)
|
||||
// {
|
||||
// if (rawData == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return new DisplayItemInfoFormContext
|
||||
// {
|
||||
// Index = rawData.Index,
|
||||
// IconAssetName = rawData.IconAssetName,
|
||||
// Title = rawData.Title,
|
||||
// Rarity = rawData.Rarity,
|
||||
// TypeText = rawData.TypeText,
|
||||
// Description = rawData.Description,
|
||||
// Price = rawData.Price,
|
||||
// IsWeapon = rawData.IsWeapon,
|
||||
// TargetPos = rawData.TargetPos
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// if (userData is DisplayItemInfoFormRawData rawData)
|
||||
// {
|
||||
// return OpenUI(rawData);
|
||||
// }
|
||||
//
|
||||
// if (userData != null)
|
||||
// {
|
||||
// Log.Warning("DisplayItemInfoFormController.OpenUI() userData type is invalid.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return OpenUIInternal(Context);
|
||||
// }
|
||||
//
|
||||
// public override void BindUseCase(IUIUseCase useCase)
|
||||
// {
|
||||
// if (!(useCase is DisplayItemInfoFormUseCase))
|
||||
// {
|
||||
// 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
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,46 @@
|
||||
// using Definition.Enum;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class HudFormController : UIFormControllerCommonBase<HudFormContext, HudForm>
|
||||
// {
|
||||
// protected override UIFormType UIFormTypeId => UIFormType.HudForm;
|
||||
//
|
||||
// protected override void RefreshUI(HudForm form, HudFormContext context)
|
||||
// {
|
||||
// form.RefreshUI(context);
|
||||
// }
|
||||
//
|
||||
// private static HudFormContext BuildHudFormContext()
|
||||
// {
|
||||
// return new HudFormContext();
|
||||
// }
|
||||
//
|
||||
// public override int? OpenUI(object userData = null)
|
||||
// {
|
||||
// if (userData is HudFormContext context)
|
||||
// {
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// if (userData != null)
|
||||
// {
|
||||
// Log.Warning("HudFormController.OpenUI() userData type is invalid.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return OpenUIInternal(BuildHudFormContext());
|
||||
// }
|
||||
//
|
||||
// public int? OpenUI(HudFormContext context)
|
||||
// {
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// public override void BindUseCase(IUIUseCase useCase)
|
||||
// {
|
||||
// Log.Info("HudFormController doesn't need UseCase");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,169 @@
|
||||
// using System.Collections.Generic;
|
||||
// using CustomEvent;
|
||||
// using Definition.Enum;
|
||||
// using CustomUtility;
|
||||
// using GameFramework.Event;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class LevelUpFormController : UIFormControllerCommonBase<LevelUpFormContext, LevelUpForm>
|
||||
// {
|
||||
// private LevelUpFormUseCase _useCase;
|
||||
//
|
||||
// protected override UIFormType UIFormTypeId => UIFormType.LevelUpForm;
|
||||
//
|
||||
// protected override void RefreshUI(LevelUpForm form, LevelUpFormContext context)
|
||||
// {
|
||||
// form.RefreshUI(context);
|
||||
// }
|
||||
//
|
||||
// protected override void SubscribeCustomEvents()
|
||||
// {
|
||||
// GameEntry.Event.Subscribe(RefreshEventArgs.EventId, OnRefresh);
|
||||
// GameEntry.Event.Subscribe(LevelUpPropSelectedEventArgs.EventId, OnLevelUpPropSelected);
|
||||
// }
|
||||
//
|
||||
// protected override void UnsubscribeCustomEvents()
|
||||
// {
|
||||
// GameEntry.Event.Unsubscribe(RefreshEventArgs.EventId, OnRefresh);
|
||||
// GameEntry.Event.Unsubscribe(LevelUpPropSelectedEventArgs.EventId, OnLevelUpPropSelected);
|
||||
// }
|
||||
//
|
||||
// private static LevelUpFormContext BuildContext(LevelUpFormRawData rawData)
|
||||
// {
|
||||
// if (rawData == null || rawData.Rewards == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// List<LevelUpRewardItemContext> props = new List<LevelUpRewardItemContext>(rawData.Rewards.Count);
|
||||
// foreach (var reward in rawData.Rewards)
|
||||
// {
|
||||
// if (reward == null)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// props.Add(new LevelUpRewardItemContext
|
||||
// {
|
||||
// Title = reward.Title,
|
||||
// Icon = null,
|
||||
// ItemRarity = reward.Rarity,
|
||||
// Description = ItemDescUtility.CreatePropDescription(reward.Modifiers),
|
||||
// IconAssetName = reward.IconAssetName
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// return new LevelUpFormContext
|
||||
// {
|
||||
// RefreshPrice = rawData.RefreshPrice,
|
||||
// Props = props
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public override int? OpenUI(object userData = null)
|
||||
// {
|
||||
// if (userData is LevelUpFormContext context)
|
||||
// {
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// if (userData is LevelUpFormRawData rawDataFromUserData)
|
||||
// {
|
||||
// return OpenUI(rawDataFromUserData);
|
||||
// }
|
||||
//
|
||||
// if (userData != null)
|
||||
// {
|
||||
// Log.Warning("LevelUpFormController.OpenUI() userData type is invalid.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (_useCase == null)
|
||||
// {
|
||||
// Log.Error("LevelUpFormController.OpenUI() useCase is null.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// LevelUpFormRawData rawData = _useCase.CreateInitialModel();
|
||||
// return OpenUI(rawData);
|
||||
// }
|
||||
//
|
||||
// public int? OpenUI(LevelUpFormRawData rawData)
|
||||
// {
|
||||
// LevelUpFormContext context = BuildContext(rawData);
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// public override void BindUseCase(IUIUseCase useCase)
|
||||
// {
|
||||
// if (!(useCase is LevelUpFormUseCase levelUpFormUseCase))
|
||||
// {
|
||||
// Log.Error("LevelUpForm.BindUseCase() useCase is invalid.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _useCase = levelUpFormUseCase;
|
||||
// }
|
||||
//
|
||||
// private void SelectReward(int selectedIndex)
|
||||
// {
|
||||
// if (_useCase == null)
|
||||
// {
|
||||
// Log.Error("LevelUpFormController.OpenUI() useCase is null.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// LevelUpFormRawData rawData = _useCase.SelectReward(selectedIndex);
|
||||
// if (rawData == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// OpenUI(rawData);
|
||||
// }
|
||||
//
|
||||
// private void RefreshRewardList(int refreshCost)
|
||||
// {
|
||||
// if (_useCase == null)
|
||||
// {
|
||||
// Log.Error("LevelUpFormController.OpenUI() useCase is null.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// LevelUpFormRawData rawData = _useCase.TryRefresh(refreshCost);
|
||||
// if (rawData == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// OpenUI(rawData);
|
||||
// }
|
||||
//
|
||||
// private void OnRefresh(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is LevelUpForm))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!(e is RefreshEventArgs args))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// RefreshRewardList(args.Cost);
|
||||
// }
|
||||
//
|
||||
// private void OnLevelUpPropSelected(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is LevelUpPropSelectedEventArgs args))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// SelectReward(args.SelectedId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,411 @@
|
||||
// using System.Collections.Generic;
|
||||
// using CustomEvent;
|
||||
// using Definition.DataStruct;
|
||||
// using Definition.Enum;
|
||||
// using Entity;
|
||||
// using CustomUtility;
|
||||
// using Entity.Weapon;
|
||||
// using GameFramework.Event;
|
||||
// using UnityEngine;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class ShopFormController : UIFormControllerCommonBase<ShopFormContext, ShopForm>
|
||||
// {
|
||||
// private ShopFormUseCase _useCase;
|
||||
// private ShopFormRawData _rawData;
|
||||
//
|
||||
// protected override UIFormType UIFormTypeId => UIFormType.ShopForm;
|
||||
//
|
||||
// protected override void RefreshUI(ShopForm form, ShopFormContext context)
|
||||
// {
|
||||
// form.RefreshUI(context);
|
||||
// }
|
||||
//
|
||||
// protected override void SubscribeCustomEvents()
|
||||
// {
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// #region BuildContext
|
||||
//
|
||||
// private ShopFormContext BuildContext(ShopFormRawData rawData)
|
||||
// {
|
||||
// if (rawData == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// _rawData = rawData;
|
||||
//
|
||||
// return new ShopFormContext
|
||||
// {
|
||||
// CurrentLevel = rawData.CurrentLevel,
|
||||
// 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)
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// private static DisplayListAreaContext BuildDisplayListAreaContext(DisplayListAreaType listType,
|
||||
// IReadOnlyList<object> items,
|
||||
// int maxCount)
|
||||
// {
|
||||
// string title = GetDisplayListTitle(listType);
|
||||
// if (items == null)
|
||||
// {
|
||||
// return new DisplayListAreaContext
|
||||
// {
|
||||
// Title = title,
|
||||
// CurrentCount = 0,
|
||||
// MaxCount = maxCount,
|
||||
// ItemContexts = System.Array.Empty<DisplayItemContext>()
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// DisplayItemContext[] itemContexts = new DisplayItemContext[items.Count];
|
||||
// switch (listType)
|
||||
// {
|
||||
// case DisplayListAreaType.Weapon:
|
||||
// if (items is IReadOnlyList<WeaponBase> weapons)
|
||||
// {
|
||||
// for (int i = 0; i < weapons.Count; i++)
|
||||
// {
|
||||
// WeaponBase weapon = weapons[i];
|
||||
// if (weapon == null) break;
|
||||
// itemContexts[i] = BuildWeaponItem(weapon);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
//
|
||||
// case DisplayListAreaType.Prop:
|
||||
// if (items is IReadOnlyList<PropItem> propItems)
|
||||
// {
|
||||
// for (int i = 0; i < propItems.Count; i++)
|
||||
// {
|
||||
// PropItem propItem = propItems[i];
|
||||
// if (propItem == null) break;
|
||||
// itemContexts[i] = BuildPropItem(propItem);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// int currentCount = itemContexts.Length;
|
||||
// return new DisplayListAreaContext
|
||||
// {
|
||||
// Title = title,
|
||||
// CurrentCount = currentCount,
|
||||
// MaxCount = maxCount,
|
||||
// ItemContexts = itemContexts
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// private static string GetDisplayListTitle(DisplayListAreaType listType)
|
||||
// {
|
||||
// return listType switch
|
||||
// {
|
||||
// DisplayListAreaType.Weapon => "武器",
|
||||
// DisplayListAreaType.Prop => "道具",
|
||||
// _ => string.Empty
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// private static DisplayItemContext BuildPropItem(PropItem propItem)
|
||||
// {
|
||||
// string iconAssetName = null;
|
||||
// ItemRarity rarity = ItemRarity.None;
|
||||
//
|
||||
// if (propItem != null)
|
||||
// {
|
||||
// iconAssetName = propItem.IconAssetName;
|
||||
// rarity = propItem.Rarity;
|
||||
// }
|
||||
//
|
||||
// return new DisplayItemContext
|
||||
// {
|
||||
// IconAssetName = iconAssetName,
|
||||
// Rarity = rarity,
|
||||
// IsWeapon = false
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// private static DisplayItemContext BuildWeaponItem(WeaponBase weaponBase)
|
||||
// {
|
||||
// string iconAssetName = null;
|
||||
// ItemRarity rarity = ItemRarity.None;
|
||||
//
|
||||
// if (weaponBase != null && weaponBase.WeaponData != null)
|
||||
// {
|
||||
// iconAssetName = weaponBase.WeaponData.IconAssetName;
|
||||
// rarity = weaponBase.WeaponData.Rarity;
|
||||
// }
|
||||
//
|
||||
// return new DisplayItemContext
|
||||
// {
|
||||
// IconAssetName = iconAssetName,
|
||||
// Rarity = rarity,
|
||||
// IsWeapon = true
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// private static void AppendDisplayItemContext(DisplayListAreaContext listContext, DisplayItemContext newItem)
|
||||
// {
|
||||
// if (listContext == null || newItem == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int oldCount = listContext.ItemContexts != null ? listContext.ItemContexts.Length : 0;
|
||||
// DisplayItemContext[] newContexts = new DisplayItemContext[oldCount + 1];
|
||||
// if (oldCount > 0)
|
||||
// {
|
||||
// System.Array.Copy(listContext.ItemContexts, newContexts, oldCount);
|
||||
// }
|
||||
//
|
||||
// newContexts[oldCount] = newItem;
|
||||
// listContext.ItemContexts = newContexts;
|
||||
// listContext.CurrentCount = oldCount + 1;
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// #region UI Methods
|
||||
//
|
||||
// public int? OpenUI(ShopFormRawData rawData)
|
||||
// {
|
||||
// ShopFormContext context = BuildContext(rawData);
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// public override int? OpenUI(object userData = null)
|
||||
// {
|
||||
// if (userData is ShopFormContext context)
|
||||
// {
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// if (userData is ShopFormRawData rawDataFromUserData)
|
||||
// {
|
||||
// return OpenUI(rawDataFromUserData);
|
||||
// }
|
||||
//
|
||||
// if (userData != null)
|
||||
// {
|
||||
// Log.Warning("ShopFormController.OpenUI() userData type is invalid.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (_useCase == null)
|
||||
// {
|
||||
// Log.Error("ShopForm.OpenUI():: useCase is null.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// ShopFormRawData rawData = _useCase.CreateInitialModel();
|
||||
// return OpenUI(rawData);
|
||||
// }
|
||||
//
|
||||
// public override void BindUseCase(IUIUseCase useCase)
|
||||
// {
|
||||
// if (!(useCase is ShopFormUseCase shopFormUseCase))
|
||||
// {
|
||||
// Log.Error("LevelUpForm.BindUseCase() useCase is invalid.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _useCase = shopFormUseCase;
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// #region Service
|
||||
//
|
||||
// private void RefreshGoodsItems(ShopRefreshResult result)
|
||||
// {
|
||||
// if (Context == null || result == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Context.GoodsItems = result.GoodsItems;
|
||||
// Context.RefreshPrice = result.RefreshPrice;
|
||||
//
|
||||
// if (Form == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Form.RefreshGoodsItems(result.GoodsItems);
|
||||
// Form.RefreshRefreshPrice(result.RefreshPrice);
|
||||
// }
|
||||
//
|
||||
// private void ApplyGoodsPurchased(ShopPurchaseResult result)
|
||||
// {
|
||||
// if (Context == null || result == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (Context.GoodsItems != null && result.GoodsIndex >= 0 && result.GoodsIndex < Context.GoodsItems.Count)
|
||||
// {
|
||||
// Context.GoodsItems[result.GoodsIndex] = null;
|
||||
// }
|
||||
//
|
||||
// if (result.DisplayItem != null)
|
||||
// {
|
||||
// if (result.DisplayItem.IsWeapon)
|
||||
// {
|
||||
// AppendDisplayItemContext(Context.WeaponListContext, result.DisplayItem);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AppendDisplayItemContext(Context.PropListContext, result.DisplayItem);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Form?.ApplyGoodsPurchased(result.GoodsIndex, result.DisplayItem);
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// #region Event Handlers
|
||||
//
|
||||
// private void Refresh(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is ShopForm))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!(e is RefreshEventArgs args))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ShopRefreshResult result = _useCase.TryRefresh(args.Cost);
|
||||
// if (result == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// RefreshGoodsItems(result);
|
||||
// }
|
||||
//
|
||||
// private void ShopPurchase(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is ShopForm))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!(e is ShopPurchaseEventArgs args))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ShopPurchaseResult result = _useCase.TryPurchase(args.GoodsIndex);
|
||||
// if (result == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ApplyGoodsPurchased(result);
|
||||
// }
|
||||
//
|
||||
// private void ShopContinue(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is ShopForm))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!(e is ShopContinueEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _useCase?.Continue();
|
||||
// }
|
||||
//
|
||||
// private void DisplayItemShow(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is DisplayItemShowEventArgs args) || _rawData == null) return;
|
||||
//
|
||||
// DisplayItemInfoFormRawData rawData = new();
|
||||
// rawData.TargetPos = args.TargetPos;
|
||||
// rawData.Index = args.Index;
|
||||
// if (args.IsWeapon)
|
||||
// {
|
||||
// var weaponData = _rawData.WeaponItems[args.Index].WeaponData;
|
||||
// rawData.IconAssetName = weaponData.IconAssetName;
|
||||
// rawData.Title = weaponData.Title;
|
||||
// rawData.Rarity = weaponData.Rarity;
|
||||
// rawData.TypeText = "武器";
|
||||
// rawData.Description = ItemDescUtility.CreateWeaponDescription(weaponData);
|
||||
// rawData.Price = Mathf.FloorToInt(weaponData.Price * Context.WeaponRecycleRate);
|
||||
// rawData.IsWeapon = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var propItem = _rawData.PropItems[args.Index];
|
||||
// rawData.IconAssetName = propItem.IconAssetName;
|
||||
// rawData.Title = propItem.Title;
|
||||
// rawData.Rarity = propItem.Rarity;
|
||||
// rawData.TypeText = "道具";
|
||||
// rawData.Description = ItemDescUtility.CreatePropDescription(propItem);
|
||||
// rawData.Price = 0;
|
||||
// rawData.IsWeapon = false;
|
||||
// }
|
||||
//
|
||||
// GameEntry.UIRouter.OpenUI(UIFormType.DisplayItemInfoForm, rawData);
|
||||
// }
|
||||
//
|
||||
// private void WeaponRecycle(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is ShopWeaponRecycleEventArgs args)) return;
|
||||
//
|
||||
// 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
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,20 @@
|
||||
// using System.Collections;
|
||||
// using System.Collections.Generic;
|
||||
// using Definition.Enum;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayItemInfoFormRawData
|
||||
// {
|
||||
// public int Index;
|
||||
// public string IconAssetName;
|
||||
// public string Title;
|
||||
// public string TypeText;
|
||||
// public ItemRarity Rarity;
|
||||
// public string Description;
|
||||
// public int Price;
|
||||
// public bool IsWeapon;
|
||||
// public Vector3 TargetPos;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,11 @@
|
||||
// using System.Collections.Generic;
|
||||
// using DataTable;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class LevelUpFormRawData
|
||||
// {
|
||||
// public List<DRLevelUpReward> Rewards;
|
||||
// public int RefreshPrice;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,18 @@
|
||||
// using System.Collections.Generic;
|
||||
// using Definition.DataStruct;
|
||||
// using Entity.Weapon;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class ShopFormRawData
|
||||
// {
|
||||
// public int CurrentLevel;
|
||||
// public int RefreshPrice;
|
||||
// public int PlayerCoin;
|
||||
// public List<GoodsItemContext> GoodsItems;
|
||||
// public IReadOnlyList<PropItem> PropItems;
|
||||
// public int PropMaxCount = -1;
|
||||
// public IReadOnlyList<WeaponBase> WeaponItems;
|
||||
// public int WeaponMaxCount = -1;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,75 @@
|
||||
// using Definition.DataStruct;
|
||||
// using Entity;
|
||||
// using CustomUtility;
|
||||
// using Entity.Weapon;
|
||||
// using Procedure;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayItemInfoFormUseCase : IUIUseCase
|
||||
// {
|
||||
// private readonly ProcedureGame _procedureGame;
|
||||
//
|
||||
// private Player Player => _procedureGame != null ? _procedureGame.Player : null;
|
||||
//
|
||||
// public DisplayItemInfoFormUseCase(ProcedureGame procedureGame)
|
||||
// {
|
||||
// _procedureGame = procedureGame;
|
||||
// }
|
||||
//
|
||||
// public DisplayItemInfoFormRawData CreateModel(int index, bool isWeapon)
|
||||
// {
|
||||
// if (index < 0 || Player == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (isWeapon)
|
||||
// {
|
||||
// var weapons = Player.Weapons;
|
||||
// if (weapons == null || index >= weapons.Count)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// WeaponBase weapon = weapons[index];
|
||||
// if (weapon == null || weapon.WeaponData == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return new DisplayItemInfoFormRawData
|
||||
// {
|
||||
// IconAssetName = weapon.WeaponData.IconAssetName,
|
||||
// Title = weapon.WeaponData.Title,
|
||||
// TypeText = "Weapon",
|
||||
// Description = ItemDescUtility.CreateWeaponDescription(weapon),
|
||||
// Price = 0,
|
||||
// IsWeapon = true
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// var props = Player.Props;
|
||||
// if (props == null || index >= props.Count)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// PropItem prop = props[index];
|
||||
// if (prop == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return new DisplayItemInfoFormRawData
|
||||
// {
|
||||
// IconAssetName = prop.IconAssetName,
|
||||
// Title = prop.Title,
|
||||
// TypeText = "Prop",
|
||||
// Description = ItemDescUtility.CreatePropDescription(prop),
|
||||
// Price = 0,
|
||||
// IsWeapon = false
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,195 @@
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using DataTable;
|
||||
// using Definition.DataStruct;
|
||||
// using Definition.Enum;
|
||||
// using Entity;
|
||||
// using Procedure;
|
||||
// using UnityEngine;
|
||||
// using UnityGameFramework.Runtime;
|
||||
// using CustomUtility;
|
||||
// using GameFramework.DataTable;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// internal class LevelUpFormUseCase : IUIUseCase
|
||||
// {
|
||||
// private const int BaseRefreshPrice = 2;
|
||||
// private readonly GameStateLevelUp _gameStateLevelUp;
|
||||
// private readonly DRLevelUpReward[] _allRewards;
|
||||
// private readonly IDataTable<DRLevelRarity> _levelRarityTable;
|
||||
// private readonly Dictionary<ItemRarity, List<DRLevelUpReward>> _rewardsByRarity = new();
|
||||
// private readonly List<DRLevelUpReward> _validRewards = new();
|
||||
//
|
||||
// private int _refreshCount;
|
||||
// private LevelUpFormRawData _currentModel;
|
||||
//
|
||||
// private readonly Player _player;
|
||||
//
|
||||
// public LevelUpFormUseCase(Player player, GameStateLevelUp gameStateLevelUp)
|
||||
// {
|
||||
// _player = player;
|
||||
// _gameStateLevelUp = gameStateLevelUp;
|
||||
// _allRewards = GameEntry.DataTable.GetDataTable<DRLevelUpReward>().ToArray();
|
||||
// _levelRarityTable = GameEntry.DataTable.GetDataTable<DRLevelRarity>();
|
||||
//
|
||||
// BuildRewardRarityPools();
|
||||
// }
|
||||
//
|
||||
// public LevelUpFormRawData CreateInitialModel(int count = 4)
|
||||
// {
|
||||
// _refreshCount = 0;
|
||||
//
|
||||
// if (_gameStateLevelUp == null || _player.PendingLevelPoints <= 0)
|
||||
// {
|
||||
// _currentModel = null;
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// _currentModel = BuildModel(BaseRefreshPrice, count);
|
||||
// return _currentModel;
|
||||
// }
|
||||
//
|
||||
// public LevelUpFormRawData TryRefresh(int refreshCost, int count = 4)
|
||||
// {
|
||||
// if (_currentModel == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (_player == null || _player.Coin < refreshCost)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// _player.Coin -= refreshCost;
|
||||
//
|
||||
// _refreshCount++;
|
||||
// _currentModel = BuildModel((_refreshCount + 1) * BaseRefreshPrice, count);
|
||||
// return _currentModel;
|
||||
// }
|
||||
//
|
||||
// public LevelUpFormRawData SelectReward(int selectedIndex, int count = 4)
|
||||
// {
|
||||
// if (_currentModel?.Rewards == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (selectedIndex < 0 || selectedIndex >= _currentModel.Rewards.Count)
|
||||
// {
|
||||
// Log.Warning("LevelUpFormUseCase::SelectReward: Invalid index");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// ApplyReward(_currentModel.Rewards[selectedIndex]);
|
||||
//
|
||||
// if (--_player.PendingLevelPoints > 0)
|
||||
// {
|
||||
// _refreshCount = 0;
|
||||
// _currentModel = BuildModel(BaseRefreshPrice, count);
|
||||
// return _currentModel;
|
||||
// }
|
||||
//
|
||||
// _gameStateLevelUp.IsCompleted = true;
|
||||
// _currentModel = null;
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private LevelUpFormRawData BuildModel(int refreshPrice, int count)
|
||||
// {
|
||||
// if (_allRewards == null || _allRewards.Length == 0)
|
||||
// {
|
||||
// Log.Error("LevelUpFormUseCase::BuildModel(): _allRewards is empty");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// int finalCount = count > 0 ? System.Math.Min(count, _allRewards.Length) : _allRewards.Length;
|
||||
// List<DRLevelUpReward> selections = new List<DRLevelUpReward>(finalCount);
|
||||
//
|
||||
// int currentLevel = _player != null ? _player.CurrentLevel : 1;
|
||||
// for (int i = 0; i < finalCount; i++)
|
||||
// {
|
||||
// ItemRarity rarity = RarityUtility.SelectRarityForLevel(_levelRarityTable, currentLevel);
|
||||
// DRLevelUpReward reward = PickRewardByRarity(rarity);
|
||||
// if (reward == null)
|
||||
// {
|
||||
// Log.Warning("LevelUpFormUseCase::BuildModel(): No available reward for selection.");
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// selections.Add(reward);
|
||||
// }
|
||||
//
|
||||
// return new LevelUpFormRawData
|
||||
// {
|
||||
// Rewards = selections,
|
||||
// RefreshPrice = refreshPrice
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// private void ApplyReward(DRLevelUpReward reward)
|
||||
// {
|
||||
// if (reward == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (_player == null)
|
||||
// {
|
||||
// Log.Warning("LevelUpFormUseCase::ApplyReward: Player is null");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (reward.Modifiers == null || reward.Modifiers.Length == 0)
|
||||
// {
|
||||
// Log.Warning("LevelUpFormUseCase::ApplyReward: Reward modifiers are empty");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _player.AddProp(new PropItem(reward.Modifiers, reward.Rarity, reward.Title, reward.IconAssetName));
|
||||
// }
|
||||
//
|
||||
// private void BuildRewardRarityPools()
|
||||
// {
|
||||
// _rewardsByRarity.Clear();
|
||||
// _validRewards.Clear();
|
||||
//
|
||||
// if (_allRewards == null) return;
|
||||
//
|
||||
// foreach (DRLevelUpReward reward in _allRewards)
|
||||
// {
|
||||
// if (reward == null)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// ItemRarity rarity = reward.Rarity;
|
||||
// _validRewards.Add(reward);
|
||||
//
|
||||
// if (!_rewardsByRarity.TryGetValue(rarity, out List<DRLevelUpReward> list))
|
||||
// {
|
||||
// list = new List<DRLevelUpReward>();
|
||||
// _rewardsByRarity.Add(rarity, list);
|
||||
// }
|
||||
//
|
||||
// list.Add(reward);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private DRLevelUpReward PickRewardByRarity(ItemRarity rarity)
|
||||
// {
|
||||
// if (_rewardsByRarity.TryGetValue(rarity, out List<DRLevelUpReward> list) && list.Count > 0)
|
||||
// {
|
||||
// return list[Random.Range(0, list.Count)];
|
||||
// }
|
||||
//
|
||||
// if (_validRewards.Count > 0)
|
||||
// {
|
||||
// return _validRewards[Random.Range(0, _validRewards.Count)];
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,444 @@
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using DataTable;
|
||||
// using Definition.DataStruct;
|
||||
// using Definition.Enum;
|
||||
// using Entity;
|
||||
// using Entity.EntityData;
|
||||
// using CustomUtility;
|
||||
// using GameFramework.DataTable;
|
||||
// using Procedure;
|
||||
// using UnityEngine;
|
||||
// using UnityGameFramework.Runtime;
|
||||
// using Random = UnityEngine.Random;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// internal sealed class ShopRefreshResult
|
||||
// {
|
||||
// public List<GoodsItemContext> GoodsItems;
|
||||
// public int RefreshPrice;
|
||||
// }
|
||||
//
|
||||
// internal sealed class ShopPurchaseResult
|
||||
// {
|
||||
// public int GoodsIndex;
|
||||
// public DisplayItemContext DisplayItem;
|
||||
// }
|
||||
//
|
||||
// internal class ShopFormUseCase : IUIUseCase
|
||||
// {
|
||||
// private readonly ProcedureGame _procedureGame;
|
||||
// private readonly GameStateShop _gameStateShop;
|
||||
//
|
||||
// private readonly DRGoods[] _allGoods;
|
||||
// private readonly IDataTable<DRProp> _propDataTable;
|
||||
// private readonly IDataTable<DRWeapon> _weaponDataTable;
|
||||
// private readonly IDataTable<DRLevelRarity> _levelRarityTable;
|
||||
//
|
||||
// private readonly List<DRGoods> _validGoods = new();
|
||||
// private readonly Dictionary<ItemRarity, List<DRGoods>> _goodsByRarity = new();
|
||||
//
|
||||
// private readonly List<ShopGoodsSelection> _selections = new();
|
||||
// private int _refreshTime;
|
||||
//
|
||||
// private Player Player => _procedureGame.Player;
|
||||
//
|
||||
// private sealed class ShopGoodsSelection
|
||||
// {
|
||||
// public GoodsType GoodsType;
|
||||
// public int GoodsTypeId;
|
||||
// public int Price;
|
||||
// }
|
||||
//
|
||||
// public ShopFormUseCase(ProcedureGame procedureGame, GameStateShop gameStateShop)
|
||||
// {
|
||||
// _procedureGame = procedureGame;
|
||||
// _gameStateShop = gameStateShop;
|
||||
// _allGoods = GameEntry.DataTable.GetDataTable<DRGoods>().ToArray();
|
||||
// _propDataTable = GameEntry.DataTable.GetDataTable<DRProp>();
|
||||
// _weaponDataTable = GameEntry.DataTable.GetDataTable<DRWeapon>();
|
||||
// _levelRarityTable = GameEntry.DataTable.GetDataTable<DRLevelRarity>();
|
||||
//
|
||||
// BuildGoodsRarityPools();
|
||||
// }
|
||||
//
|
||||
// public ShopFormRawData CreateInitialModel()
|
||||
// {
|
||||
// _refreshTime = 0;
|
||||
//
|
||||
// Player player = Player;
|
||||
// if (_procedureGame == null || player == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// int currentLevel = _procedureGame.CurrentLevel;
|
||||
// return new ShopFormRawData
|
||||
// {
|
||||
// CurrentLevel = currentLevel,
|
||||
// RefreshPrice = currentLevel,
|
||||
// PlayerCoin = player.Coin,
|
||||
// GoodsItems = BuildRandomGoodsItems(4),
|
||||
// PropItems = player.Props,
|
||||
// PropMaxCount = -1,
|
||||
// WeaponItems = player.Weapons,
|
||||
// WeaponMaxCount = player.WeaponCapacity
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public ShopRefreshResult TryRefresh(int cost)
|
||||
// {
|
||||
// Player player = Player;
|
||||
// if (player == null || _procedureGame == null || player.Coin < cost)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// player.Coin -= cost;
|
||||
//
|
||||
// int refreshPrice = (_refreshTime + 1) * _procedureGame.CurrentLevel;
|
||||
// _refreshTime++;
|
||||
//
|
||||
// return new ShopRefreshResult
|
||||
// {
|
||||
// GoodsItems = BuildRandomGoodsItems(4),
|
||||
// RefreshPrice = refreshPrice
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public ShopPurchaseResult TryPurchase(int goodsIndex)
|
||||
// {
|
||||
// if (goodsIndex < 0 || goodsIndex >= _selections.Count)
|
||||
// {
|
||||
// Log.Warning("ShopFormUseCase::TryPurchase: Invalid index");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// ShopGoodsSelection selection = _selections[goodsIndex];
|
||||
// if (selection == null)
|
||||
// {
|
||||
// Log.Warning("ShopFormUseCase::TryPurchase: Item already purchased.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Player player = Player;
|
||||
// if (player == null || player.Coin < selection.Price)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// DisplayItemContext displayItem = ApplyGoodsPurchase(selection);
|
||||
// if (displayItem == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// player.Coin -= selection.Price;
|
||||
// _selections[goodsIndex] = null;
|
||||
//
|
||||
// return new ShopPurchaseResult
|
||||
// {
|
||||
// GoodsIndex = goodsIndex,
|
||||
// DisplayItem = displayItem
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public void Continue()
|
||||
// {
|
||||
// _gameStateShop.ShopFinish = true;
|
||||
// }
|
||||
//
|
||||
// private List<GoodsItemContext> BuildRandomGoodsItems(int count)
|
||||
// {
|
||||
// if (_allGoods == null || _allGoods.Length == 0)
|
||||
// {
|
||||
// Log.Error("ShopFormUseCase::BuildRandomGoodsItems(): _allGoods is empty");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// int finalCount = Mathf.Min(count, _allGoods.Length);
|
||||
// List<GoodsItemContext> goodsItems = new List<GoodsItemContext>(finalCount);
|
||||
// _selections.Clear();
|
||||
//
|
||||
// int currentLevel = _procedureGame != null ? _procedureGame.CurrentLevel : 1;
|
||||
//
|
||||
// for (int i = 0; i < finalCount; i++)
|
||||
// {
|
||||
// ItemRarity rarity = RarityUtility.SelectRarityForLevel(_levelRarityTable, currentLevel);
|
||||
// DRGoods drGoods = PickGoodsByRarity(rarity);
|
||||
// if (drGoods == null)
|
||||
// {
|
||||
// Log.Warning("ShopFormUseCase::BuildRandomGoodsItems: No available goods for selection.");
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// GoodsItemContext goodsItem = new GoodsItemContext();
|
||||
// int price;
|
||||
//
|
||||
// if (drGoods.GoodsType == GoodsType.Prop)
|
||||
// {
|
||||
// DRProp drProp = _propDataTable.GetDataRow(drGoods.GoodsTypeId);
|
||||
// if (drProp == null)
|
||||
// {
|
||||
// Log.Warning($"ShopFormUseCase::BuildRandomGoodsItems: Missing DRProp, id = {drGoods.GoodsTypeId}");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// price = CalculateRandomizedPrice(drProp.Price, drProp.PriceRandomPercent);
|
||||
// goodsItem.Title = drProp.Title;
|
||||
// goodsItem.Type = "Prop";
|
||||
// goodsItem.Rarity = drProp.Rarity;
|
||||
// GameEntry.SpriteCache.GetSprite(drProp.IconAssetName, sprite => goodsItem.Icon = sprite);
|
||||
// goodsItem.Description = ItemDescUtility.CreatePropDescription(drProp.Modifiers);
|
||||
// }
|
||||
// else if (drGoods.GoodsType == GoodsType.Weapon)
|
||||
// {
|
||||
// DRWeapon drWeapon = _weaponDataTable.GetDataRow(drGoods.GoodsTypeId);
|
||||
// if (drWeapon == null)
|
||||
// {
|
||||
// Log.Warning($"ShopFormUseCase::BuildRandomGoodsItems: Missing DRWeapon, id = {drGoods.GoodsTypeId}");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// price = CalculateRandomizedPrice(drWeapon.Price, drWeapon.PriceRandomPercent);
|
||||
// goodsItem.Title = drWeapon.Title;
|
||||
// goodsItem.Type = "Weapon";
|
||||
// goodsItem.Rarity = drWeapon.Rarity;
|
||||
// GameEntry.SpriteCache.GetSprite(drWeapon.IconAssetName, sprite => goodsItem.Icon = sprite);
|
||||
// goodsItem.Description = ItemDescUtility.CreateWeaponDescription(drWeapon);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Log.Warning($"ShopFormUseCase::BuildRandomGoodsItems: Unsupported goods type = {drGoods.GoodsType}");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// goodsItem.Price = price;
|
||||
//
|
||||
// _selections.Add(new ShopGoodsSelection
|
||||
// {
|
||||
// GoodsType = drGoods.GoodsType,
|
||||
// GoodsTypeId = drGoods.GoodsTypeId,
|
||||
// Price = price
|
||||
// });
|
||||
//
|
||||
// goodsItems.Add(goodsItem);
|
||||
// }
|
||||
//
|
||||
// return goodsItems;
|
||||
// }
|
||||
//
|
||||
// private void BuildGoodsRarityPools()
|
||||
// {
|
||||
// _goodsByRarity.Clear();
|
||||
// _validGoods.Clear();
|
||||
//
|
||||
// if (_allGoods == null) return;
|
||||
//
|
||||
// foreach (DRGoods goods in _allGoods)
|
||||
// {
|
||||
// if (goods == null) continue;
|
||||
//
|
||||
// if (!TryGetGoodsRarity(goods, out ItemRarity rarity))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// _validGoods.Add(goods);
|
||||
//
|
||||
// if (!_goodsByRarity.TryGetValue(rarity, out List<DRGoods> list))
|
||||
// {
|
||||
// list = new List<DRGoods>();
|
||||
// _goodsByRarity.Add(rarity, list);
|
||||
// }
|
||||
//
|
||||
// list.Add(goods);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private DRGoods PickGoodsByRarity(ItemRarity rarity)
|
||||
// {
|
||||
// if (_goodsByRarity.TryGetValue(rarity, out List<DRGoods> list) && list.Count > 0)
|
||||
// {
|
||||
// return list[Random.Range(0, list.Count)];
|
||||
// }
|
||||
//
|
||||
// if (_validGoods.Count > 0)
|
||||
// {
|
||||
// return _validGoods[Random.Range(0, _validGoods.Count)];
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private bool TryGetGoodsRarity(DRGoods goods, out ItemRarity rarity)
|
||||
// {
|
||||
// rarity = ItemRarity.None;
|
||||
// if (goods == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (goods.GoodsType == GoodsType.Prop)
|
||||
// {
|
||||
// DRProp drProp = _propDataTable != null ? _propDataTable.GetDataRow(goods.GoodsTypeId) : null;
|
||||
// if (drProp == null)
|
||||
// {
|
||||
// Log.Warning($"ShopFormUseCase::TryGetGoodsRarity: Missing DRProp, id = {goods.GoodsTypeId}");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// rarity = drProp.Rarity;
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (goods.GoodsType == GoodsType.Weapon)
|
||||
// {
|
||||
// DRWeapon drWeapon = _weaponDataTable != null ? _weaponDataTable.GetDataRow(goods.GoodsTypeId) : null;
|
||||
// if (drWeapon == null)
|
||||
// {
|
||||
// Log.Warning($"ShopFormUseCase::TryGetGoodsRarity: Missing DRWeapon, id = {goods.GoodsTypeId}");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// rarity = drWeapon.Rarity;
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// Log.Warning($"ShopFormUseCase::TryGetGoodsRarity: Unsupported goods type = {goods.GoodsType}");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// private static int CalculateRandomizedPrice(int basePrice, float priceRandomPercent)
|
||||
// {
|
||||
// float normalizedPercent = priceRandomPercent > 1f ? priceRandomPercent / 100f : priceRandomPercent;
|
||||
// normalizedPercent = Mathf.Max(0f, normalizedPercent);
|
||||
// float offsetPercent = Random.Range(-normalizedPercent, normalizedPercent);
|
||||
// int finalPrice = Mathf.RoundToInt(basePrice * (1f + offsetPercent));
|
||||
// return Mathf.Max(1, finalPrice);
|
||||
// }
|
||||
//
|
||||
// private DisplayItemContext ApplyGoodsPurchase(ShopGoodsSelection goods)
|
||||
// {
|
||||
// if (goods == null || Player == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (goods.GoodsType == GoodsType.Prop)
|
||||
// {
|
||||
// DRProp drProp = _propDataTable != null ? _propDataTable.GetDataRow(goods.GoodsTypeId) : null;
|
||||
// if (drProp == null || drProp.Modifiers == null || drProp.Modifiers.Length == 0)
|
||||
// {
|
||||
// Log.Warning("ShopFormUseCase::ApplyGoodsPurchase: Prop modifiers are empty");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Player.AddProp(new PropItem(drProp.Modifiers, drProp.Rarity, drProp.Title, drProp.IconAssetName));
|
||||
// return new DisplayItemContext
|
||||
// {
|
||||
// IconAssetName = drProp.IconAssetName,
|
||||
// Rarity = drProp.Rarity,
|
||||
// IsWeapon = false
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// if (goods.GoodsType == GoodsType.Weapon)
|
||||
// {
|
||||
// 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);
|
||||
// case WeaponType.WeaponLightning:
|
||||
// return new WeaponLightningData(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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,71 @@
|
||||
// using CustomEvent;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.UI;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayItem : MonoBehaviour
|
||||
// {
|
||||
// [SerializeField] private IconArea _iconArea;
|
||||
//
|
||||
// [SerializeField] private RectTransform _itemRect;
|
||||
//
|
||||
// private DisplayItemContext _context;
|
||||
//
|
||||
// private int _index = -1;
|
||||
//
|
||||
// public void SetIndex(int index)
|
||||
// {
|
||||
// _index = index;
|
||||
// }
|
||||
//
|
||||
// public void OnInit(DisplayItemContext context, int index)
|
||||
// {
|
||||
// if (context == null) return;
|
||||
//
|
||||
// _context = context;
|
||||
// _index = index;
|
||||
//
|
||||
// if (_iconArea != null)
|
||||
// {
|
||||
// string iconName = _context.IconAssetName;
|
||||
// GameEntry.SpriteCache.GetSprite(iconName, sprite => { _iconArea.OnInit(sprite, context.Rarity); });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void OnReset()
|
||||
// {
|
||||
// _context = null;
|
||||
// _index = -1;
|
||||
//
|
||||
// if (_iconArea != null)
|
||||
// {
|
||||
// _iconArea.OnReset();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void OnItemInfoShow()
|
||||
// {
|
||||
// if (_index < 0) return;
|
||||
// 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 OnItemInfoLock()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, DisplayItemInfoLockEventArgs.Create());
|
||||
// }
|
||||
//
|
||||
// public void OnItemInfoHide()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,205 @@
|
||||
// using CustomEvent;
|
||||
// using TMPro;
|
||||
// using UnityEngine;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayItemInfoForm : UGuiForm
|
||||
// {
|
||||
// [SerializeField] private RectTransform _content;
|
||||
//
|
||||
// [SerializeField] private IconArea _iconArea;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _itemTitle;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _itemTypeText;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _itemDescription;
|
||||
//
|
||||
// [SerializeField] private CommonButton _recycleButton;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _itemPrice;
|
||||
//
|
||||
// [SerializeField] private bool _autoResizeHeight = true;
|
||||
//
|
||||
// [SerializeField] private float _fixedTopHeight = 150f;
|
||||
//
|
||||
// [SerializeField] private float _fixedBottomHeight = 150f;
|
||||
//
|
||||
// [SerializeField] private float _fixedWidth = 300f;
|
||||
//
|
||||
// [SerializeField] private float _screenEdgePadding = 0f;
|
||||
//
|
||||
// private DisplayItemInfoFormContext _context;
|
||||
// private Vector3 _targetPos;
|
||||
//
|
||||
// public void RefreshUI(DisplayItemInfoFormContext context)
|
||||
// {
|
||||
// if (context == null)
|
||||
// {
|
||||
// Log.Warning("DisplayItemInfoForm context is invalid.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _context = context;
|
||||
//
|
||||
// _targetPos = ConvertWorldToAnchored(_context.TargetPos);
|
||||
// Log.Info($"{_context.TargetPos}->{_targetPos}");
|
||||
//
|
||||
// if (_content != null)
|
||||
// {
|
||||
// _content.anchoredPosition3D = _targetPos;
|
||||
// }
|
||||
//
|
||||
// if (_itemTitle != null) _itemTitle.text = _context.Title ?? string.Empty;
|
||||
// if (_itemTypeText != null) _itemTypeText.text = _context.TypeText ?? string.Empty;
|
||||
// if (_itemDescription != null) _itemDescription.text = _context.Description ?? string.Empty;
|
||||
// if (_itemPrice != null) _itemPrice.text = $"{_context.Price} <sprite name=\"coin\" index=0>";
|
||||
//
|
||||
// if (_recycleButton != null)
|
||||
// {
|
||||
// _recycleButton.gameObject.SetActive(_context.IsWeapon);
|
||||
// }
|
||||
//
|
||||
// if (_iconArea != null)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(_context.IconAssetName))
|
||||
// {
|
||||
// string iconAssetName = _context.IconAssetName;
|
||||
// GameEntry.SpriteCache.GetSprite(iconAssetName, sprite =>
|
||||
// {
|
||||
// if (_context != null && _context.IconAssetName == iconAssetName)
|
||||
// {
|
||||
// _iconArea.OnInit(sprite, context.Rarity);
|
||||
// ResizeToFitContent();
|
||||
// ApplyClampedTargetPos();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ResizeToFitContent();
|
||||
// ApplyClampedTargetPos();
|
||||
// }
|
||||
//
|
||||
// protected override void OnOpen(object userData)
|
||||
// {
|
||||
// base.OnOpen(userData);
|
||||
//
|
||||
// if (!(userData is DisplayItemInfoFormContext context))
|
||||
// {
|
||||
// Log.Error("DisplayItemInfoFormContext is invalid.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// RefreshUI(context);
|
||||
// }
|
||||
//
|
||||
// protected override void OnClose(bool isShutdown, object userData)
|
||||
// {
|
||||
// _context = null;
|
||||
// base.OnClose(isShutdown, userData);
|
||||
// }
|
||||
//
|
||||
// private void ResizeToFitContent()
|
||||
// {
|
||||
// if (!_autoResizeHeight || _content == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (_itemDescription == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _itemDescription.ForceMeshUpdate();
|
||||
// var descriptionSize = _itemDescription.rectTransform.sizeDelta;
|
||||
// descriptionSize.y = _itemDescription.preferredHeight;
|
||||
// _itemDescription.rectTransform.sizeDelta = descriptionSize;
|
||||
// float descriptionHeight = Mathf.Max(0f, _itemDescription.preferredHeight);
|
||||
// float targetHeight = _fixedTopHeight + descriptionHeight + _fixedBottomHeight;
|
||||
//
|
||||
// Vector2 size = new Vector2(_fixedWidth, targetHeight);
|
||||
// _content.sizeDelta = size;
|
||||
// }
|
||||
//
|
||||
// private void ApplyClampedTargetPos()
|
||||
// {
|
||||
// if (_content == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// RectTransform parent = _content.parent as RectTransform;
|
||||
// if (parent == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Vector2 size = _content.sizeDelta;
|
||||
// if (size.x <= 0f || size.y <= 0f)
|
||||
// {
|
||||
// size = _content.rect.size;
|
||||
// }
|
||||
//
|
||||
// Vector2 pivot = _content.pivot;
|
||||
// float halfWidth = parent.rect.width * 0.5f;
|
||||
// float halfHeight = parent.rect.height * 0.5f;
|
||||
//
|
||||
// float minX = -halfWidth + size.x * pivot.x + _screenEdgePadding;
|
||||
// float maxX = halfWidth - size.x * (1f - pivot.x) - _screenEdgePadding;
|
||||
// float minY = -halfHeight + size.y * pivot.y + _screenEdgePadding;
|
||||
// float maxY = halfHeight - size.y * (1f - pivot.y) - _screenEdgePadding;
|
||||
//
|
||||
// float clampedX = minX <= maxX ? Mathf.Clamp(_targetPos.x, minX, maxX) : 0f;
|
||||
// float clampedY = minY <= maxY ? Mathf.Clamp(_targetPos.y, minY, maxY) : 0f;
|
||||
//
|
||||
// _content.anchoredPosition3D = new Vector3(clampedX, clampedY, _targetPos.z);
|
||||
// }
|
||||
//
|
||||
// private Vector3 ConvertWorldToAnchored(Vector3 worldPos)
|
||||
// {
|
||||
// if (_content == null)
|
||||
// {
|
||||
// return worldPos;
|
||||
// }
|
||||
//
|
||||
// RectTransform parent = _content.parent as RectTransform;
|
||||
// if (parent == null)
|
||||
// {
|
||||
// return worldPos;
|
||||
// }
|
||||
//
|
||||
// Canvas canvas = _content.GetComponentInParent<Canvas>();
|
||||
// Canvas rootCanvas = canvas != null ? canvas.rootCanvas : null;
|
||||
// Camera uiCamera = null;
|
||||
// if (rootCanvas != null && rootCanvas.renderMode != RenderMode.ScreenSpaceOverlay)
|
||||
// {
|
||||
// uiCamera = rootCanvas.worldCamera != null ? rootCanvas.worldCamera : Camera.main;
|
||||
// }
|
||||
//
|
||||
// Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(uiCamera, worldPos);
|
||||
// if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, screenPoint, uiCamera,
|
||||
// out Vector2 localPoint))
|
||||
// {
|
||||
// return worldPos;
|
||||
// }
|
||||
//
|
||||
// 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());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,27 @@
|
||||
// using GameFramework;
|
||||
// using GameFramework.ObjectPool;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class DisplayItemObject : ObjectBase
|
||||
// {
|
||||
// public static DisplayItemObject Create(object target)
|
||||
// {
|
||||
// DisplayItemObject displayItemObject = ReferencePool.Acquire<DisplayItemObject>();
|
||||
// displayItemObject.Initialize(target);
|
||||
// return displayItemObject;
|
||||
// }
|
||||
//
|
||||
// protected override void Release(bool isShutdown)
|
||||
// {
|
||||
// DisplayItem item = (DisplayItem)Target;
|
||||
// if (item == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Object.Destroy(item.gameObject);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,285 @@
|
||||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using GameFramework.ObjectPool;
|
||||
// using TMPro;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.UI;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public enum DisplayListAreaType : byte
|
||||
// {
|
||||
// None = 0,
|
||||
// Prop = 1,
|
||||
// Weapon = 2
|
||||
// }
|
||||
//
|
||||
// public class DisplayListArea : MonoBehaviour
|
||||
// {
|
||||
// [SerializeField] private TMP_Text _titleText;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _countText;
|
||||
//
|
||||
// [SerializeField] private DisplayItem _displayItemTemplate;
|
||||
//
|
||||
// [SerializeField] private Transform _displayItemRoot;
|
||||
//
|
||||
// [SerializeField] private Vector2 _startPosition = Vector2.zero;
|
||||
//
|
||||
// [SerializeField] private float _itemSize = 150f;
|
||||
//
|
||||
// [SerializeField] private float _itemSpacing = 10f;
|
||||
//
|
||||
// [SerializeField] private int _fixedColumnCount = 0;
|
||||
//
|
||||
// [SerializeField] private int _instancePoolCapacity = 32;
|
||||
//
|
||||
// private DisplayListAreaContext _context;
|
||||
//
|
||||
// private IObjectPool<DisplayItemObject> _displayItemObjectPool;
|
||||
// private const string DisplayItemPoolName = "DisplayItem";
|
||||
//
|
||||
// private readonly List<DisplayItem> _activeItems = new List<DisplayItem>();
|
||||
//
|
||||
// public void OnInit(DisplayListAreaContext context)
|
||||
// {
|
||||
// if (context == null)
|
||||
// {
|
||||
// Log.Warning("DisplayListArea context is invalid.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// EnsurePool();
|
||||
// _context = context;
|
||||
//
|
||||
// if (_titleText != null) _titleText.text = context.Title;
|
||||
// UpdateCountText(context.CurrentCount, context.MaxCount);
|
||||
//
|
||||
// int itemCount = context.ItemContexts?.Length ?? 0;
|
||||
// int targetCount = Mathf.Min(context.CurrentCount, itemCount);
|
||||
// EnsureItemCount(targetCount);
|
||||
// for (int i = 0; i < targetCount; i++)
|
||||
// {
|
||||
// _activeItems[i].OnInit(context.ItemContexts[i], i);
|
||||
// }
|
||||
//
|
||||
// LayoutItems();
|
||||
// }
|
||||
//
|
||||
// public void OnReset()
|
||||
// {
|
||||
// _context = null;
|
||||
//
|
||||
// for (int i = _activeItems.Count - 1; i >= 0; i--)
|
||||
// {
|
||||
// HideItem(_activeItems[i]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void OnDestroy()
|
||||
// {
|
||||
// _displayItemObjectPool?.ReleaseAllUnused();
|
||||
// }
|
||||
//
|
||||
// public DisplayItem AddItem(DisplayItemContext itemContext)
|
||||
// {
|
||||
// EnsurePool();
|
||||
// if (_displayItemObjectPool == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// DisplayItem item = CreateItem();
|
||||
// if (item == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// int index = _activeItems.Count;
|
||||
// _activeItems.Add(item);
|
||||
// item.OnInit(itemContext, index);
|
||||
// item.SetIndex(index);
|
||||
//
|
||||
// int columnCount = _fixedColumnCount > 0 ? _fixedColumnCount : CalculateColumnCount(GetRootWidth());
|
||||
// LayoutItem(item, index, columnCount);
|
||||
//
|
||||
// int currentCount = _activeItems.Count;
|
||||
// int maxCount = _context != null ? _context.MaxCount : -1;
|
||||
// if (_context != null)
|
||||
// {
|
||||
// _context.CurrentCount = currentCount;
|
||||
// }
|
||||
//
|
||||
// UpdateCountText(currentCount, maxCount);
|
||||
//
|
||||
// return item;
|
||||
// }
|
||||
//
|
||||
// public bool RemoveItemAt(int index)
|
||||
// {
|
||||
// if (index < 0 || index >= _activeItems.Count)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// HideItem(_activeItems[index]);
|
||||
// LayoutItems();
|
||||
//
|
||||
// int currentCount = _activeItems.Count;
|
||||
// int maxCount = _context != null ? _context.MaxCount : -1;
|
||||
// if (_context != null)
|
||||
// {
|
||||
// _context.CurrentCount = currentCount;
|
||||
// }
|
||||
//
|
||||
// UpdateCountText(currentCount, maxCount);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// private void EnsurePool()
|
||||
// {
|
||||
// if (_displayItemObjectPool != null) return;
|
||||
//
|
||||
// if (_displayItemRoot == null)
|
||||
// {
|
||||
// _displayItemRoot = transform;
|
||||
// }
|
||||
//
|
||||
// GridLayoutGroup gridLayout = _displayItemRoot.GetComponent<GridLayoutGroup>();
|
||||
// if (gridLayout != null)
|
||||
// {
|
||||
// gridLayout.enabled = false;
|
||||
// }
|
||||
//
|
||||
// if (GameEntry.ObjectPool.HasObjectPool<DisplayItemObject>(DisplayItemPoolName))
|
||||
// {
|
||||
// _displayItemObjectPool = GameEntry.ObjectPool.GetObjectPool<DisplayItemObject>(DisplayItemPoolName);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (_displayItemTemplate == null)
|
||||
// {
|
||||
// Debug.LogError("DisplayListArea requires a DisplayItem template.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _displayItemObjectPool =
|
||||
// GameEntry.ObjectPool.CreateSingleSpawnObjectPool<DisplayItemObject>(DisplayItemPoolName,
|
||||
// _instancePoolCapacity);
|
||||
// }
|
||||
//
|
||||
// private void EnsureItemCount(int count)
|
||||
// {
|
||||
// if (_displayItemObjectPool == null) return;
|
||||
//
|
||||
// for (int i = _activeItems.Count; i < count; i++)
|
||||
// {
|
||||
// DisplayItem item = CreateItem();
|
||||
// if (item == null)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// _activeItems.Add(item);
|
||||
// }
|
||||
//
|
||||
// for (int i = _activeItems.Count - 1; i >= count; i--)
|
||||
// {
|
||||
// HideItem(_activeItems[i]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private DisplayItem CreateItem()
|
||||
// {
|
||||
// DisplayItem item = null;
|
||||
// DisplayItemObject itemObject = _displayItemObjectPool.Spawn();
|
||||
// if (itemObject != null)
|
||||
// {
|
||||
// item = (DisplayItem)itemObject.Target;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (_displayItemTemplate == null)
|
||||
// {
|
||||
// Debug.LogError("DisplayListArea requires a DisplayItem template.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// item = Instantiate(_displayItemTemplate);
|
||||
// _displayItemObjectPool.Register(DisplayItemObject.Create(item), true);
|
||||
// }
|
||||
//
|
||||
// if (_displayItemRoot != null)
|
||||
// {
|
||||
// Transform itemTransform = item.transform;
|
||||
// itemTransform.SetParent(_displayItemRoot, false);
|
||||
// }
|
||||
//
|
||||
// item.gameObject.SetActive(true);
|
||||
// return item;
|
||||
// }
|
||||
//
|
||||
// private void HideItem(DisplayItem item)
|
||||
// {
|
||||
// if (item == null) return;
|
||||
// item.OnReset();
|
||||
// _activeItems.Remove(item);
|
||||
// item.gameObject.SetActive(false);
|
||||
// _displayItemObjectPool?.Unspawn(item);
|
||||
// }
|
||||
//
|
||||
// private void LayoutItems()
|
||||
// {
|
||||
// if (_displayItemRoot == null) return;
|
||||
//
|
||||
// int columnCount = _fixedColumnCount > 0 ? _fixedColumnCount : CalculateColumnCount(GetRootWidth());
|
||||
//
|
||||
// for (int i = 0; i < _activeItems.Count; i++)
|
||||
// {
|
||||
// DisplayItem item = _activeItems[i];
|
||||
// item.SetIndex(i);
|
||||
// LayoutItem(item, i, columnCount);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void LayoutItem(DisplayItem item, int index, int columnCount)
|
||||
// {
|
||||
// if (item == null) return;
|
||||
// RectTransform itemRect = item.GetComponent<RectTransform>();
|
||||
// if (itemRect == null) return;
|
||||
//
|
||||
// float step = _itemSize + _itemSpacing;
|
||||
// int row = index / columnCount;
|
||||
// int col = index % columnCount;
|
||||
//
|
||||
// itemRect.anchorMin = new Vector2(0f, 1f);
|
||||
// itemRect.anchorMax = new Vector2(0f, 1f);
|
||||
// itemRect.pivot = new Vector2(0f, 1f);
|
||||
// itemRect.sizeDelta = new Vector2(_itemSize, _itemSize);
|
||||
// itemRect.anchoredPosition = _startPosition + new Vector2(col * step, -row * step);
|
||||
// }
|
||||
//
|
||||
// private float GetRootWidth()
|
||||
// {
|
||||
// RectTransform rootRect = _displayItemRoot as RectTransform;
|
||||
// return rootRect != null ? rootRect.rect.width : 0f;
|
||||
// }
|
||||
//
|
||||
// private int CalculateColumnCount(float rootWidth)
|
||||
// {
|
||||
// if (rootWidth <= 0f) return 1;
|
||||
//
|
||||
// float step = _itemSize + _itemSpacing;
|
||||
// int columns = Mathf.FloorToInt((rootWidth + _itemSpacing) / step);
|
||||
// return Mathf.Max(1, columns);
|
||||
// }
|
||||
//
|
||||
// private void UpdateCountText(int currentCount, int maxCount)
|
||||
// {
|
||||
// if (_countText == null) return;
|
||||
// _countText.text = maxCount == -1 ? $"({currentCount})" : $"({currentCount}/{maxCount})";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,142 @@
|
||||
// using CustomComponent;
|
||||
// using CustomEvent;
|
||||
// using GameFramework.Event;
|
||||
// using TMPro;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.UI;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class HudForm : UGuiForm
|
||||
// {
|
||||
// [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;
|
||||
//
|
||||
// [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)
|
||||
// {
|
||||
// base.OnInit(userData);
|
||||
//
|
||||
// GameEntry.Event.Subscribe(PlayerHealthChangeEventArgs.EventId, PlayerHpChange);
|
||||
// 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)
|
||||
// {
|
||||
// GameEntry.Event.Unsubscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
|
||||
// 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
|
||||
//
|
||||
// #region Event Handlers
|
||||
//
|
||||
// private void PlayerHpChange(object sender, GameEventArgs e)
|
||||
// {
|
||||
// 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;
|
||||
//
|
||||
// _currentHpPercent = percent;
|
||||
//
|
||||
// if (_hpSliderFadeCoroutine != null) StopCoroutine(_hpSliderFadeCoroutine);
|
||||
// _hpSliderFadeCoroutine = StartCoroutine(_hpSlider.SmoothValue(percent, _sliderFadeDuration));
|
||||
// }
|
||||
//
|
||||
// private void PlayerExpChange(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is PlayerExpChangeEventArgs args)) return;
|
||||
// float percent = (float)args.CurrentExp / args.MaxExp;
|
||||
// if (Mathf.Approximately(_currentExpPercent, percent)) return;
|
||||
//
|
||||
// _currentExpPercent = percent;
|
||||
//
|
||||
// if (_expSliderFadeCoroutine != null) StopCoroutine(_expSliderFadeCoroutine);
|
||||
// _expSliderFadeCoroutine = StartCoroutine(_expSlider.SmoothValue(percent, _sliderFadeDuration));
|
||||
// }
|
||||
//
|
||||
// private void PlayerLevelUp(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is PlayerLevelUpEventArgs)) return;
|
||||
//
|
||||
// _playerCurrentLevel++;
|
||||
// _expText.text = $"LV.{_playerCurrentLevel}";
|
||||
// }
|
||||
//
|
||||
// private void PlayerCoinChange(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is PlayerCoinChangeEventArgs args)) return;
|
||||
// if (_currentCoin == args.CoinCount) return;
|
||||
//
|
||||
// _coinText.text = $"<sprite name=\"coin\" index=0> {args.CoinCount}";
|
||||
// _currentCoin = args.CoinCount;
|
||||
// }
|
||||
//
|
||||
// private void LevelProcess(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is LevelProcessEventArgs args)) return;
|
||||
// if (_currentTimeLeft == args.LevelTimeLeft) return;
|
||||
//
|
||||
// _currentTimeLeft = args.LevelTimeLeft;
|
||||
// _levelTimeLeftText.text = _currentTimeLeft.ToString();
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,70 @@
|
||||
// using CustomEvent;
|
||||
// using TMPro;
|
||||
// using UnityEngine;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class LevelUpForm : UGuiForm
|
||||
// {
|
||||
// [SerializeField] private LevelUpRewardItem[] _propItems;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _refreshButtonText;
|
||||
//
|
||||
// private LevelUpFormContext _context;
|
||||
//
|
||||
// public void RefreshUI(LevelUpFormContext context)
|
||||
// {
|
||||
// _context = context;
|
||||
//
|
||||
// foreach (var propItem in _propItems)
|
||||
// {
|
||||
// propItem.gameObject.SetActive(false);
|
||||
// }
|
||||
//
|
||||
// if (_context.Props == null) return;
|
||||
// int count = Mathf.Min(_propItems.Length, _context.Props.Count);
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// _propItems[i].gameObject.SetActive(true);
|
||||
// _propItems[i].Init(_context.Props[i]);
|
||||
// }
|
||||
//
|
||||
// //刷新 -20 <sprite name="coin" index=0>
|
||||
// _refreshButtonText.text = $"刷新 -{context.RefreshPrice} <sprite name=\"coin\" index=0>";
|
||||
// }
|
||||
//
|
||||
// #region FSM
|
||||
//
|
||||
// protected override void OnOpen(object userData)
|
||||
// {
|
||||
// base.OnOpen(userData);
|
||||
//
|
||||
// if (userData is LevelUpFormContext context)
|
||||
// {
|
||||
// RefreshUI(context);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Warning("LevelUpForm requires LevelUpFormContext as userData.");
|
||||
// }
|
||||
//
|
||||
// protected override void OnClose(bool isShutdown, object userData)
|
||||
// {
|
||||
// _context = null;
|
||||
// base.OnClose(isShutdown, userData);
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// public void OnSelectButtonClick(int index)
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, LevelUpPropSelectedEventArgs.Create(index));
|
||||
// }
|
||||
//
|
||||
// public void OnRefreshButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, RefreshEventArgs.Create(_context.RefreshPrice));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,47 @@
|
||||
// using TMPro;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.UI;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class LevelUpRewardItem : MonoBehaviour
|
||||
// {
|
||||
// [SerializeField] private IconArea _iconArea;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _titleText;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _typeText;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _descriptionText;
|
||||
//
|
||||
// private LevelUpRewardItemContext _context;
|
||||
//
|
||||
//
|
||||
// public void Init(LevelUpRewardItemContext context)
|
||||
// {
|
||||
// if (context == null)
|
||||
// {
|
||||
// Log.Error("LevelUpPropContext context is invalid.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _context = context;
|
||||
//
|
||||
// if (_titleText != null) _titleText.text = context.Title;
|
||||
// if (_descriptionText != null) _descriptionText.text = context.Description;
|
||||
// if (_iconArea != null) _iconArea.OnInit(context.Icon, context.ItemRarity);
|
||||
//
|
||||
// LoadIcon(_context.IconAssetName);
|
||||
// }
|
||||
//
|
||||
// private void LoadIcon(string iconAssetName)
|
||||
// {
|
||||
// if (_iconArea == null) return;
|
||||
//
|
||||
// if (string.IsNullOrEmpty(iconAssetName)) return;
|
||||
//
|
||||
// GameEntry.SpriteCache.GetSprite(iconAssetName, sprite => _iconArea.SetIcon(sprite));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,192 @@
|
||||
// using System.Collections.Generic;
|
||||
// using CustomEvent;
|
||||
// using GameFramework.Event;
|
||||
// using TMPro;
|
||||
// using UnityEngine;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class ShopForm : UGuiForm
|
||||
// {
|
||||
// #region Property
|
||||
//
|
||||
// [SerializeField] private TMP_Text _titleText;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _continueButtonText;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _refreshPriceText;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _playerCoinText;
|
||||
// private int _currentCoin;
|
||||
//
|
||||
// [SerializeField] private ShopGoodsItem[] _goodsItems;
|
||||
//
|
||||
// [SerializeField] private DisplayListArea _propListArea;
|
||||
//
|
||||
// [SerializeField] private DisplayListArea _weaponListArea;
|
||||
//
|
||||
// private ShopFormContext _context;
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
//
|
||||
// public void RefreshUI(ShopFormContext context)
|
||||
// {
|
||||
// _context = context;
|
||||
//
|
||||
// _titleText.text = $"商店 (Lv.{context.CurrentLevel})";
|
||||
// _continueButtonText.text = $"继续 (Lv.{context.CurrentLevel + 1})";
|
||||
// RefreshRefreshPrice(context.RefreshPrice);
|
||||
// _playerCoinText.text = $"<sprite name=\"coin\" index=0> {context.PlayerCoin}";
|
||||
//
|
||||
// RefreshGoodsItems(context.GoodsItems);
|
||||
//
|
||||
// if (_propListArea != null && context.PropListContext != null)
|
||||
// {
|
||||
// _propListArea.OnInit(context.PropListContext);
|
||||
// }
|
||||
//
|
||||
// if (_weaponListArea != null && context.WeaponListContext != null)
|
||||
// {
|
||||
// _weaponListArea.OnInit(context.WeaponListContext);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// internal void RefreshGoodsItems(List<GoodsItemContext> goodsItems)
|
||||
// {
|
||||
// foreach (var item in _goodsItems)
|
||||
// {
|
||||
// item.gameObject.SetActive(false);
|
||||
// }
|
||||
//
|
||||
// if (goodsItems == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int count = Mathf.Min(_goodsItems.Length, goodsItems.Count);
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// _goodsItems[i].Init(goodsItems[i]);
|
||||
// _goodsItems[i].gameObject.SetActive(true);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// internal void RefreshRefreshPrice(int refreshPrice)
|
||||
// {
|
||||
// _refreshPriceText.text = $"刷新 -{refreshPrice} <sprite name=\"coin\" index=0>";
|
||||
// }
|
||||
//
|
||||
// internal void ApplyGoodsPurchased(int goodsIndex, DisplayItemContext displayItem)
|
||||
// {
|
||||
// SetGoodsItemVisible(goodsIndex, false);
|
||||
//
|
||||
// if (displayItem == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (displayItem.IsWeapon)
|
||||
// {
|
||||
// AddWeaponDisplayItem(displayItem);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AddPropDisplayItem(displayItem);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void SetGoodsItemVisible(int index, bool visible)
|
||||
// {
|
||||
// if (_goodsItems == null || index < 0 || index >= _goodsItems.Length)
|
||||
// {
|
||||
// Log.Warning("ShopForm.SetGoodsItemVisible: Invalid index.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _goodsItems[index].gameObject.SetActive(visible);
|
||||
// }
|
||||
//
|
||||
// private void AddPropDisplayItem(DisplayItemContext context)
|
||||
// {
|
||||
// if (_propListArea == null || context == null) return;
|
||||
// _propListArea.AddItem(context);
|
||||
// }
|
||||
//
|
||||
// private void AddWeaponDisplayItem(DisplayItemContext context)
|
||||
// {
|
||||
// if (_weaponListArea == null || context == null) return;
|
||||
// _weaponListArea.AddItem(context);
|
||||
// }
|
||||
//
|
||||
// internal void RemoveWeaponDisplayItem(int index)
|
||||
// {
|
||||
// if (_weaponListArea == null) return;
|
||||
// _weaponListArea.RemoveItemAt(index);
|
||||
// }
|
||||
//
|
||||
// #region ButtonClick
|
||||
//
|
||||
// public void OnContinueButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, ShopContinueEventArgs.Create());
|
||||
// }
|
||||
//
|
||||
// public void OnPurchaseButtonClick(int index)
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, ShopPurchaseEventArgs.Create(index));
|
||||
// }
|
||||
//
|
||||
// public void OnRefreshButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, RefreshEventArgs.Create(_context.RefreshPrice));
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// #region FSM
|
||||
//
|
||||
// protected override void OnOpen(object userData)
|
||||
// {
|
||||
// base.OnOpen(userData);
|
||||
//
|
||||
// GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
|
||||
//
|
||||
// if (userData is ShopFormContext context)
|
||||
// {
|
||||
// RefreshUI(context);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Warning("ShopForm requires ShopFormContext as userData.");
|
||||
// }
|
||||
//
|
||||
// protected override void OnClose(bool isShutdown, object userData)
|
||||
// {
|
||||
// _context = null;
|
||||
//
|
||||
// GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
|
||||
//
|
||||
// _propListArea?.OnReset();
|
||||
// _weaponListArea?.OnReset();
|
||||
//
|
||||
// base.OnClose(isShutdown, userData);
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// #region Event Handlers
|
||||
//
|
||||
// private void OnPlayerCoinChange(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is PlayerCoinChangeEventArgs args)) return;
|
||||
// if (args.CoinCount == _currentCoin) return;
|
||||
//
|
||||
// _currentCoin = args.CoinCount;
|
||||
// _playerCoinText.text = $"<sprite name=\"coin\" index=0> {_currentCoin}";
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,8 @@
|
||||
// namespace UI
|
||||
// {
|
||||
// public class RoleItemContext : UIContext
|
||||
// {
|
||||
// public int RoleId;
|
||||
// public string IconName;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,8 @@
|
||||
// namespace UI
|
||||
// {
|
||||
// public class RolePropertyAreaContext : UIContext
|
||||
// {
|
||||
// public string RoleName;
|
||||
// public string InitialPropertyText;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,9 @@
|
||||
// namespace UI
|
||||
// {
|
||||
// public class SelectRoleFormContext : UIContext
|
||||
// {
|
||||
// public RoleItemContext[] RoleItemContexts;
|
||||
// public RolePropertyAreaContext RolePropertyAreaContext;
|
||||
// public int[] RoleIds;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,6 @@
|
||||
// namespace UI
|
||||
// {
|
||||
// public class StartMenuFormContext : UIContext
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,156 @@
|
||||
// using CustomEvent;
|
||||
// using Definition.Enum;
|
||||
// using GameFramework.Event;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class SelectRoleFormController : UIFormControllerCommonBase<SelectRoleFormContext, SelectRoleForm>
|
||||
// {
|
||||
// private SelectRoleFormUseCase _useCase;
|
||||
//
|
||||
// protected override UIFormType UIFormTypeId => UIFormType.SelectRoleForm;
|
||||
//
|
||||
// protected override void RefreshUI(SelectRoleForm form, SelectRoleFormContext context)
|
||||
// {
|
||||
// form.RefreshUI(context);
|
||||
// }
|
||||
//
|
||||
// protected override void SubscribeCustomEvents()
|
||||
// {
|
||||
// GameEntry.Event.Subscribe(MenuSelectRoleReturnEventArgs.EventId, OnMenuSelectRoleReturn);
|
||||
// GameEntry.Event.Subscribe(MenuSelectRoleSelectedEventArgs.EventId, OnMenuSelectRoleSelected);
|
||||
// GameEntry.Event.Subscribe(MenuSelectRoleConfirmEventArgs.EventId, OnMenuSelectRoleConfirm);
|
||||
// }
|
||||
//
|
||||
// protected override void UnsubscribeCustomEvents()
|
||||
// {
|
||||
// GameEntry.Event.Unsubscribe(MenuSelectRoleReturnEventArgs.EventId, OnMenuSelectRoleReturn);
|
||||
// GameEntry.Event.Unsubscribe(MenuSelectRoleSelectedEventArgs.EventId, OnMenuSelectRoleSelected);
|
||||
// GameEntry.Event.Unsubscribe(MenuSelectRoleConfirmEventArgs.EventId, OnMenuSelectRoleConfirm);
|
||||
// }
|
||||
//
|
||||
// private static SelectRoleFormContext BuildContext(SelectRoleFormRawData rawData)
|
||||
// {
|
||||
// if (rawData == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// int count = rawData.RoleIds?.Length ?? 0;
|
||||
// RoleItemContext[] roleItems = new RoleItemContext[count];
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// string iconName = rawData.RoleIconNames != null && i < rawData.RoleIconNames.Length
|
||||
// ? rawData.RoleIconNames[i]
|
||||
// : null;
|
||||
//
|
||||
// roleItems[i] = new RoleItemContext
|
||||
// {
|
||||
// RoleId = rawData.RoleIds[i],
|
||||
// IconName = iconName
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// RolePropertyAreaContext propertyContext = null;
|
||||
// if (rawData.SelectedRoleId >= 0)
|
||||
// {
|
||||
// propertyContext = new RolePropertyAreaContext
|
||||
// {
|
||||
// RoleName = rawData.SelectedRoleName,
|
||||
// InitialPropertyText = rawData.SelectedRoleInitialPropertyText
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// return new SelectRoleFormContext
|
||||
// {
|
||||
// RoleItemContexts = roleItems,
|
||||
// RolePropertyAreaContext = propertyContext,
|
||||
// RoleIds = rawData.RoleIds
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public override int? OpenUI(object userData = null)
|
||||
// {
|
||||
// if (userData is SelectRoleFormContext selectRoleFormContext)
|
||||
// {
|
||||
// return OpenUIInternal(selectRoleFormContext);
|
||||
// }
|
||||
//
|
||||
// if (userData != null)
|
||||
// {
|
||||
// Log.Warning("SelectRoleFormController.OpenUI() userData type is invalid.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (_useCase == null)
|
||||
// {
|
||||
// Log.Error("SelectRoleFormController.OpenUI() useCase is null.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// SelectRoleFormRawData rawData = _useCase.CreateModel();
|
||||
// SelectRoleFormContext context = BuildContext(rawData);
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// public override void BindUseCase(IUIUseCase useCase)
|
||||
// {
|
||||
// if (!(useCase is SelectRoleFormUseCase selectRoleUseCase))
|
||||
// {
|
||||
// Log.Error("SelectRoleUseCase.BindUseCase() useCase is invalid.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _useCase = selectRoleUseCase;
|
||||
// }
|
||||
//
|
||||
// public void UpdateShowRole(RolePropertyAreaContext rolePropertyAreaContext)
|
||||
// {
|
||||
// if (Context != null)
|
||||
// {
|
||||
// Context.RolePropertyAreaContext = rolePropertyAreaContext;
|
||||
// }
|
||||
//
|
||||
// Form?.UpdateShowRole(rolePropertyAreaContext);
|
||||
// }
|
||||
//
|
||||
// private void OnMenuSelectRoleReturn(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is SelectRoleForm) || !(e is MenuSelectRoleReturnEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// CloseUI();
|
||||
// }
|
||||
//
|
||||
// private void OnMenuSelectRoleSelected(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is MenuSelectRoleSelectedEventArgs args))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// SelectRoleFormRawData rawData = _useCase != null ? _useCase.SelectRole(args.RoleId) : null;
|
||||
// SelectRoleFormContext context = BuildContext(rawData);
|
||||
// if (context == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// SetContext(context);
|
||||
// UpdateShowRole(context.RolePropertyAreaContext);
|
||||
// }
|
||||
//
|
||||
// private void OnMenuSelectRoleConfirm(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(e is MenuSelectRoleConfirmEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _useCase?.ConfirmSelectedRole();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,137 @@
|
||||
// using CustomEvent;
|
||||
// using Definition.Enum;
|
||||
// using GameFramework.Event;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class StartMenuFormController : UIFormControllerCommonBase<StartMenuFormContext, StartMenuForm>
|
||||
// {
|
||||
// protected override UIFormType UIFormTypeId => UIFormType.StartMenuForm;
|
||||
//
|
||||
// protected override void RefreshUI(StartMenuForm form, StartMenuFormContext context)
|
||||
// {
|
||||
// form.RefreshUI(context);
|
||||
// }
|
||||
//
|
||||
// protected override void SubscribeCustomEvents()
|
||||
// {
|
||||
// GameEntry.Event.Subscribe(MenuStartGameEventArgs.EventId, OnMenuStartGameButtonClick);
|
||||
// GameEntry.Event.Subscribe(MenuFileButtonClickEventArgs.EventId, OnMenuFileButtonClick);
|
||||
// GameEntry.Event.Subscribe(MenuGuideButtonClickEventArgs.EventId, OnMenuGuideButtonClick);
|
||||
// GameEntry.Event.Subscribe(MenuSettingButtonClickEventArgs.EventId, OnMenuSettingButtonClick);
|
||||
// GameEntry.Event.Subscribe(MenuQuitButtonClickEventArgs.EventId, OnMenuQuitButtonClick);
|
||||
// GameEntry.Event.Subscribe(MenuAboutButtonClickEventArgs.EventId, OnMenuAboutButtonClick);
|
||||
// }
|
||||
//
|
||||
// protected override void UnsubscribeCustomEvents()
|
||||
// {
|
||||
// GameEntry.Event.Unsubscribe(MenuStartGameEventArgs.EventId, OnMenuStartGameButtonClick);
|
||||
// GameEntry.Event.Unsubscribe(MenuFileButtonClickEventArgs.EventId, OnMenuFileButtonClick);
|
||||
// GameEntry.Event.Unsubscribe(MenuGuideButtonClickEventArgs.EventId, OnMenuGuideButtonClick);
|
||||
// GameEntry.Event.Unsubscribe(MenuSettingButtonClickEventArgs.EventId, OnMenuSettingButtonClick);
|
||||
// GameEntry.Event.Unsubscribe(MenuQuitButtonClickEventArgs.EventId, OnMenuQuitButtonClick);
|
||||
// GameEntry.Event.Unsubscribe(MenuAboutButtonClickEventArgs.EventId, OnMenuAboutButtonClick);
|
||||
// }
|
||||
//
|
||||
// private static StartMenuFormContext BuildStartMenuFormContext()
|
||||
// {
|
||||
// return new StartMenuFormContext();
|
||||
// }
|
||||
//
|
||||
// public override int? OpenUI(object userData = null)
|
||||
// {
|
||||
// if (userData is StartMenuFormContext context)
|
||||
// {
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// if (userData != null)
|
||||
// {
|
||||
// Log.Warning("StartMenuFormController.OpenUI() userData type is invalid.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return OpenUIInternal(BuildStartMenuFormContext());
|
||||
// }
|
||||
//
|
||||
// public int? OpenUI(StartMenuFormContext context)
|
||||
// {
|
||||
// return OpenUIInternal(context);
|
||||
// }
|
||||
//
|
||||
// public override void BindUseCase(IUIUseCase useCase)
|
||||
// {
|
||||
// Log.Info("StartMenuForm doesn't need UseCase");
|
||||
// }
|
||||
//
|
||||
// private void OnMenuStartGameButtonClick(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is StartMenuForm) || !(e is MenuStartGameEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// GameEntry.UIRouter.OpenUI(UIFormType.SelectRoleForm);
|
||||
// }
|
||||
//
|
||||
// private void OnMenuFileButtonClick(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is StartMenuForm) || !(e is MenuFileButtonClickEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Warning("Menu file button click is not implemented.");
|
||||
// }
|
||||
//
|
||||
// private void OnMenuGuideButtonClick(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is StartMenuForm) || !(e is MenuGuideButtonClickEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Warning("Menu guide button click is not implemented.");
|
||||
// }
|
||||
//
|
||||
// private void OnMenuSettingButtonClick(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is StartMenuForm) || !(e is MenuSettingButtonClickEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// GameEntry.UIRouter.OpenUI(UIFormType.SettingForm);
|
||||
// }
|
||||
//
|
||||
// private void OnMenuQuitButtonClick(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is StartMenuForm) || !(e is MenuQuitButtonClickEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// GameEntry.UIRouter.OpenUI(UIFormType.DialogForm, new DialogFormRawData
|
||||
// {
|
||||
// Mode = 2,
|
||||
// Title = GameEntry.Localization.GetString("AskQuitGame.Title"),
|
||||
// Message = GameEntry.Localization.GetString("AskQuitGame.Message"),
|
||||
// OnClickConfirm = delegate(object userData)
|
||||
// {
|
||||
// UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private void OnMenuAboutButtonClick(object sender, GameEventArgs e)
|
||||
// {
|
||||
// if (!(sender is StartMenuForm) || !(e is MenuAboutButtonClickEventArgs))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Warning("Menu about button click is not implemented.");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace UI
|
||||
{
|
||||
public class SelectRoleFormRawData
|
||||
{
|
||||
public int[] RoleIds;
|
||||
public string[] RoleIconNames;
|
||||
public int SelectedRoleId;
|
||||
public string SelectedRoleName;
|
||||
public string SelectedRoleInitialPropertyText;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace UI
|
||||
{
|
||||
public class StartMenuFormRawData
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// using System.Text;
|
||||
// using DataTable;
|
||||
// using GameFramework.DataTable;
|
||||
// using Procedure;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class SelectRoleFormUseCase : IUIUseCase
|
||||
// {
|
||||
// private readonly IDataTable<DRRole> _roleDataTable;
|
||||
//
|
||||
// private readonly ProcedureStartMenu _procedureStartMenu;
|
||||
//
|
||||
// public int SelectedRoleId { get; private set; }
|
||||
//
|
||||
// public SelectRoleFormUseCase(ProcedureStartMenu procedureStartMenu)
|
||||
// {
|
||||
// _procedureStartMenu = procedureStartMenu;
|
||||
// _roleDataTable = GameEntry.DataTable.GetDataTable<DRRole>();
|
||||
// }
|
||||
//
|
||||
// public SelectRoleFormRawData CreateModel()
|
||||
// {
|
||||
// return BuildModel(0);
|
||||
// }
|
||||
//
|
||||
// public SelectRoleFormRawData SelectRole(int roleId)
|
||||
// {
|
||||
// SelectedRoleId = roleId;
|
||||
// return BuildModel(roleId);
|
||||
// }
|
||||
//
|
||||
// public bool ConfirmSelectedRole()
|
||||
// {
|
||||
// DRRole[] roles = _roleDataTable != null ? _roleDataTable.GetAllDataRows() : null;
|
||||
// if (roles == null || roles.Length == 0)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (SelectedRoleId < 0 || _roleDataTable.GetDataRow(SelectedRoleId) == null)
|
||||
// {
|
||||
// int randomIndex = Random.Range(0, roles.Length);
|
||||
// SelectedRoleId = roles[randomIndex].Id;
|
||||
// }
|
||||
//
|
||||
// bool result = SelectedRoleId >= 0;
|
||||
// if (result)
|
||||
// {
|
||||
// _procedureStartMenu.StartGame(SelectedRoleId);
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private SelectRoleFormRawData BuildModel(int selectedRoleId)
|
||||
// {
|
||||
// DRRole[] roles = _roleDataTable.GetAllDataRows();
|
||||
// int count = _roleDataTable.Count;
|
||||
// int[] roleIds = new int[count];
|
||||
// string[] iconNames = new string[count];
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// roleIds[i] = roles[i].Id;
|
||||
// iconNames[i] = roles[i].IconName;
|
||||
// }
|
||||
//
|
||||
// DRRole selectedRole = selectedRoleId > 0 ? _roleDataTable.GetDataRow(selectedRoleId) : null;
|
||||
// return new SelectRoleFormRawData
|
||||
// {
|
||||
// RoleIds = roleIds,
|
||||
// RoleIconNames = iconNames,
|
||||
// SelectedRoleId = selectedRole?.Id ?? -1,
|
||||
// SelectedRoleName = selectedRole?.RoleName,
|
||||
// SelectedRoleInitialPropertyText = selectedRole != null
|
||||
// ? BuildRoleInitialPropertyText(selectedRole)
|
||||
// : null
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// private static string BuildRoleInitialPropertyText(DRRole role)
|
||||
// {
|
||||
// if (role == null || role.InitialProperties == null || role.InitialProperties.Length == 0)
|
||||
// {
|
||||
// return string.Empty;
|
||||
// }
|
||||
//
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (int i = 0; i < role.InitialProperties.Length; i++)
|
||||
// {
|
||||
// sb.Append(role.InitialProperties[i]);
|
||||
// sb.Append('\n');
|
||||
// }
|
||||
//
|
||||
// return sb.ToString();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,40 @@
|
||||
// using CustomEvent;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.UI;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class RoleItem : MonoBehaviour
|
||||
// {
|
||||
// [SerializeField] private Image _roleImage = null;
|
||||
//
|
||||
// private RoleItemContext _context = null;
|
||||
//
|
||||
// public void OnInit(RoleItemContext context)
|
||||
// {
|
||||
// _context = context;
|
||||
// if (_context == null || string.IsNullOrEmpty(_context.IconName))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// GameEntry.SpriteCache.GetSprite(_context.IconName, sprite => _roleImage.sprite = sprite);
|
||||
// }
|
||||
//
|
||||
// public void OnReset()
|
||||
// {
|
||||
// _context = null;
|
||||
// }
|
||||
//
|
||||
// public void UpdateShowRole()
|
||||
// {
|
||||
// int roleId = _context?.RoleId ?? -1;
|
||||
// GameEntry.Event.Fire(this, MenuSelectRoleSelectedEventArgs.Create(roleId));
|
||||
// }
|
||||
//
|
||||
// public void OnConfirmRoleClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuSelectRoleConfirmEventArgs.Create());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,37 @@
|
||||
// using TMPro;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.UI;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class RolePropertyArea : MonoBehaviour
|
||||
// {
|
||||
// [SerializeField] private TMP_Text _roleNameText;
|
||||
//
|
||||
// [SerializeField] private RawImage _roleAvatar;
|
||||
//
|
||||
// [SerializeField] private TMP_Text _roleInitialPropertyText;
|
||||
//
|
||||
// [SerializeField] private Transform _roleInitialItemParent;
|
||||
//
|
||||
// private RolePropertyAreaContext _context;
|
||||
//
|
||||
// public void OnInit(RolePropertyAreaContext context)
|
||||
// {
|
||||
// _context = context;
|
||||
// if (_context == null)
|
||||
// {
|
||||
// OnReset();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _roleNameText.text = _context.RoleName;
|
||||
// _roleInitialPropertyText.text = _context.InitialPropertyText;
|
||||
// }
|
||||
//
|
||||
// public void OnReset(object userData = null)
|
||||
// {
|
||||
// _context = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,100 @@
|
||||
// using System;
|
||||
// using CustomEvent;
|
||||
// using UnityEngine;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class SelectRoleForm : UGuiForm
|
||||
// {
|
||||
// [SerializeField] private GameObject _randomRoleCard = null;
|
||||
//
|
||||
// [SerializeField] private GameObject _roleCard = null;
|
||||
//
|
||||
// [SerializeField] private RolePropertyArea _propertyArea = null;
|
||||
//
|
||||
// private SelectRoleFormContext _context = null;
|
||||
//
|
||||
// private RoleItem[] _roleItems = null;
|
||||
//
|
||||
// public void RefreshUI(SelectRoleFormContext context)
|
||||
// {
|
||||
// _context = context;
|
||||
//
|
||||
// int itemIndex = 1, roleIndex = 0;
|
||||
// while (itemIndex < _roleItems.Length)
|
||||
// {
|
||||
// if (roleIndex < _context.RoleItemContexts.Length)
|
||||
// {
|
||||
// _roleItems[itemIndex].OnInit(_context.RoleItemContexts[roleIndex]);
|
||||
// _roleItems[itemIndex].gameObject.SetActive(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _roleItems[itemIndex].gameObject.SetActive(false);
|
||||
// _roleItems[itemIndex].OnReset();
|
||||
// }
|
||||
//
|
||||
// itemIndex++;
|
||||
// roleIndex++;
|
||||
// }
|
||||
//
|
||||
// UpdateShowRole(_context.RolePropertyAreaContext);
|
||||
// }
|
||||
//
|
||||
// #region FSM
|
||||
//
|
||||
// protected override void OnInit(object userData)
|
||||
// {
|
||||
// base.OnInit(userData);
|
||||
// _roleItems = this.transform.GetComponentsInChildren<RoleItem>();
|
||||
// }
|
||||
//
|
||||
// protected override void OnOpen(object userData)
|
||||
// {
|
||||
// base.OnOpen(userData);
|
||||
//
|
||||
// if (userData is SelectRoleFormContext context)
|
||||
// {
|
||||
// RefreshUI(context);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Warning("SelectRoleForm requires SelectRoleFormContext as userData.");
|
||||
// }
|
||||
//
|
||||
// protected override void OnClose(bool isShutdown, object userData)
|
||||
// {
|
||||
// base.OnClose(isShutdown, userData);
|
||||
//
|
||||
// _context = null;
|
||||
// foreach (var item in _roleItems)
|
||||
// {
|
||||
// item.OnReset();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// public void UpdateShowRole(RolePropertyAreaContext propertyAreaContext)
|
||||
// {
|
||||
// if (propertyAreaContext == null)
|
||||
// {
|
||||
// _randomRoleCard.SetActive(true);
|
||||
// _roleCard.SetActive(false);
|
||||
// _propertyArea.OnReset();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _randomRoleCard.SetActive(false);
|
||||
// _propertyArea.OnInit(propertyAreaContext);
|
||||
// _roleCard.SetActive(true);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void OnReturnButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuSelectRoleReturnEventArgs.Create());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,189 @@
|
||||
// //------------------------------------------------------------
|
||||
// // Game Framework
|
||||
// // Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// // Homepage: https://gameframework.cn/
|
||||
// // Feedback: mailto:ellan@gameframework.cn
|
||||
// //------------------------------------------------------------
|
||||
//
|
||||
// using Definition;
|
||||
// using GameFramework.Localization;
|
||||
// using StarForce;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.UI;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class SettingForm : UGuiForm
|
||||
// {
|
||||
// [SerializeField] private Toggle _musicMuteToggle = null;
|
||||
// [SerializeField] private Slider _musicVolumeSlider = null;
|
||||
//
|
||||
// [SerializeField] private Toggle _soundMuteToggle = null;
|
||||
// [SerializeField] private Slider _soundVolumeSlider = null;
|
||||
//
|
||||
// [SerializeField] private Toggle _uiSoundMuteToggle = null;
|
||||
// [SerializeField] private Slider _uiSoundVolumeSlider = null;
|
||||
//
|
||||
// [SerializeField] private CanvasGroup _languageTipsCanvasGroup = null;
|
||||
//
|
||||
// [SerializeField] private Toggle _englishToggle = null;
|
||||
// [SerializeField] private Toggle _chineseSimplifiedToggle = null;
|
||||
// [SerializeField] private Toggle _chineseTraditionalToggle = null;
|
||||
// [SerializeField] private Toggle _koreanToggle = null;
|
||||
//
|
||||
// private Language _selectedLanguage = Language.Unspecified;
|
||||
//
|
||||
// public void OnMusicMuteChanged(bool isOn)
|
||||
// {
|
||||
// GameEntry.Sound.Mute("Music", !isOn);
|
||||
// _musicVolumeSlider.gameObject.SetActive(isOn);
|
||||
// }
|
||||
//
|
||||
// public void OnMusicVolumeChanged(float volume)
|
||||
// {
|
||||
// GameEntry.Sound.SetVolume("Music", volume);
|
||||
// }
|
||||
//
|
||||
// public void OnSoundMuteChanged(bool isOn)
|
||||
// {
|
||||
// GameEntry.Sound.Mute("Sound", !isOn);
|
||||
// _soundVolumeSlider.gameObject.SetActive(isOn);
|
||||
// }
|
||||
//
|
||||
// public void OnSoundVolumeChanged(float volume)
|
||||
// {
|
||||
// GameEntry.Sound.SetVolume("Sound", volume);
|
||||
// }
|
||||
//
|
||||
// public void OnUISoundMuteChanged(bool isOn)
|
||||
// {
|
||||
// GameEntry.Sound.Mute("UISound", !isOn);
|
||||
// _uiSoundVolumeSlider.gameObject.SetActive(isOn);
|
||||
// }
|
||||
//
|
||||
// public void OnUISoundVolumeChanged(float volume)
|
||||
// {
|
||||
// GameEntry.Sound.SetVolume("UISound", volume);
|
||||
// }
|
||||
//
|
||||
// public void OnEnglishSelected(bool isOn)
|
||||
// {
|
||||
// if (!isOn)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _selectedLanguage = Language.English;
|
||||
// RefreshLanguageTips();
|
||||
// }
|
||||
//
|
||||
// public void OnChineseSimplifiedSelected(bool isOn)
|
||||
// {
|
||||
// if (!isOn)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _selectedLanguage = Language.ChineseSimplified;
|
||||
// RefreshLanguageTips();
|
||||
// }
|
||||
//
|
||||
// public void OnChineseTraditionalSelected(bool isOn)
|
||||
// {
|
||||
// if (!isOn)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _selectedLanguage = Language.ChineseTraditional;
|
||||
// RefreshLanguageTips();
|
||||
// }
|
||||
//
|
||||
// public void OnKoreanSelected(bool isOn)
|
||||
// {
|
||||
// if (!isOn)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _selectedLanguage = Language.Korean;
|
||||
// RefreshLanguageTips();
|
||||
// }
|
||||
//
|
||||
// public void OnSubmitButtonClick()
|
||||
// {
|
||||
// if (_selectedLanguage == GameEntry.Localization.Language)
|
||||
// {
|
||||
// Close();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// GameEntry.Setting.SetString(Constant.Setting.Language, _selectedLanguage.ToString());
|
||||
// GameEntry.Setting.Save();
|
||||
//
|
||||
// GameEntry.Sound.StopMusic();
|
||||
// UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Restart);
|
||||
// }
|
||||
//
|
||||
// #if UNITY_2017_3_OR_NEWER
|
||||
// protected override void OnOpen(object userData)
|
||||
// #else
|
||||
// protected internal override void OnOpen(object userData)
|
||||
// #endif
|
||||
// {
|
||||
// base.OnOpen(userData);
|
||||
//
|
||||
// _musicMuteToggle.isOn = !GameEntry.Sound.IsMuted("Music");
|
||||
// _musicVolumeSlider.value = GameEntry.Sound.GetVolume("Music");
|
||||
//
|
||||
// _soundMuteToggle.isOn = !GameEntry.Sound.IsMuted("Sound");
|
||||
// _soundVolumeSlider.value = GameEntry.Sound.GetVolume("Sound");
|
||||
//
|
||||
// _uiSoundMuteToggle.isOn = !GameEntry.Sound.IsMuted("UISound");
|
||||
// _uiSoundVolumeSlider.value = GameEntry.Sound.GetVolume("UISound");
|
||||
//
|
||||
// _selectedLanguage = GameEntry.Localization.Language;
|
||||
// switch (_selectedLanguage)
|
||||
// {
|
||||
// case Language.English:
|
||||
// _englishToggle.isOn = true;
|
||||
// break;
|
||||
//
|
||||
// case Language.ChineseSimplified:
|
||||
// _chineseSimplifiedToggle.isOn = true;
|
||||
// break;
|
||||
//
|
||||
// case Language.ChineseTraditional:
|
||||
// _chineseTraditionalToggle.isOn = true;
|
||||
// break;
|
||||
//
|
||||
// case Language.Korean:
|
||||
// _koreanToggle.isOn = true;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// #if UNITY_2017_3_OR_NEWER
|
||||
// protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
// #else
|
||||
// protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
// #endif
|
||||
// {
|
||||
// base.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
//
|
||||
// if (_languageTipsCanvasGroup.gameObject.activeSelf)
|
||||
// {
|
||||
// _languageTipsCanvasGroup.alpha = 0.5f + 0.5f * Mathf.Sin(Mathf.PI * Time.time);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void RefreshLanguageTips()
|
||||
// {
|
||||
// _languageTipsCanvasGroup.gameObject.SetActive(_selectedLanguage != GameEntry.Localization.Language);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,64 @@
|
||||
// using CustomEvent;
|
||||
// using UnityGameFramework.Runtime;
|
||||
//
|
||||
// namespace UI
|
||||
// {
|
||||
// public class StartMenuForm : UGuiForm
|
||||
// {
|
||||
// public void RefreshUI(StartMenuFormContext context)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// #region Lifecycle
|
||||
//
|
||||
// protected override void OnOpen(object userData)
|
||||
// {
|
||||
// base.OnOpen(userData);
|
||||
//
|
||||
// if (userData is StartMenuFormContext context)
|
||||
// {
|
||||
// RefreshUI(context);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Warning("StartMenuForm requires StartMenuFormContext as userData.");
|
||||
// }
|
||||
//
|
||||
// protected override void OnClose(bool isShutdown, object userData)
|
||||
// {
|
||||
// base.OnClose(isShutdown, userData);
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// public void OnStartButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuStartGameEventArgs.Create());
|
||||
// }
|
||||
//
|
||||
// public void OnFileButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuFileButtonClickEventArgs.Create());
|
||||
// }
|
||||
//
|
||||
// public void OnGuideButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuGuideButtonClickEventArgs.Create());
|
||||
// }
|
||||
//
|
||||
// public void OnSettingButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuSettingButtonClickEventArgs.Create());
|
||||
// }
|
||||
//
|
||||
// public void OnQuitButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuQuitButtonClickEventArgs.Create());
|
||||
// }
|
||||
//
|
||||
// public void OnAboutButtonClick()
|
||||
// {
|
||||
// GameEntry.Event.Fire(this, MenuAboutButtonClickEventArgs.Create());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user