diff --git a/Assets/GameMain/Scripts/Runtime/CustomComponent/DebugPanel.meta b/Assets/GameMain/DebugPanel.meta similarity index 100% rename from Assets/GameMain/Scripts/Runtime/CustomComponent/DebugPanel.meta rename to Assets/GameMain/DebugPanel.meta diff --git a/Assets/GameMain/DebugPanel/RuntimeDebugPanelComponent.cs b/Assets/GameMain/DebugPanel/RuntimeDebugPanelComponent.cs new file mode 100644 index 0000000..884dc61 --- /dev/null +++ b/Assets/GameMain/DebugPanel/RuntimeDebugPanelComponent.cs @@ -0,0 +1,528 @@ +#if UNITY_EDITOR || DEVELOPMENT_BUILD +using System; +using System.Linq; +using Components; +using CustomComponent; +using SepCore.Event; +using SepCore.DataTable; +using SepCore.Definition; +using Entity; +using CustomUtility; +using Procedure; +using UnityEngine; +using UnityGameFramework.Runtime; +#if ENABLE_INPUT_SYSTEM +using UnityEngine.InputSystem; +#endif + + +public class RuntimeDebugPanelComponent : MonoBehaviour + +{ + private const float MinSpawnRate = 0.1f; + private const float CornerTapWindow = 0.6f; + private const int RequiredCornerTapCount = 3; + private const int DebugHealAmount = 200; + + [Header("Window Content")] [SerializeField] + private bool _showBuffSection = true; + + [SerializeField] private bool _showBattleOverview = true; + [SerializeField] private bool _showCollisionStats = true; + [SerializeField] private bool _showSpawnControls = true; + [SerializeField] private bool _showBattleDurationControls = true; + [SerializeField] private bool _showPlayerWeaponControls = true; + [SerializeField] private bool _showPlayerHealthControls = true; + [SerializeField] private bool _showTips = true; + + private Rect _windowRect = new Rect(20f, 60f, 460f, 800f); + private bool _isPanelVisible; + private int _windowId; + + private string _searchText = string.Empty; + private int _selectedIndex; + private int _addCount = 1; + private Vector2 _buffScroll; + + private float _spawnRateScaleInput = 1f; + private float _extendDurationSeconds = 30f; + + private DRProp[] _allProps = Array.Empty(); + private DRProp[] _filteredProps = Array.Empty(); + private string[] _displayNames = Array.Empty(); + + private int _cornerTapCount; + private float _lastCornerTapTime = -10f; + private bool _lockPlayerHealthToMax; + + private void Awake() + { + _windowId = GetInstanceID(); + } + + private void Update() + { + if (IsTogglePressed()) + { + _isPanelVisible = !_isPanelVisible; + } + + HandleCornerTapGesture(); + if (_lockPlayerHealthToMax) + { + KeepPlayerHealthAtMax(); + } + } + + private void OnGUI() + { + DrawToggleButton(); + if (!_isPanelVisible) return; + + _windowRect = GUI.Window(_windowId, _windowRect, DrawWindow, "Runtime Debug Panel"); + } + + private void DrawToggleButton() + { + const float width = 64f; + const float height = 30f; + Rect buttonRect = new Rect(Screen.width - width - 12f, 10f, width, height); + if (GUI.Button(buttonRect, "DEBUG")) + { + _isPanelVisible = !_isPanelVisible; + } + } + + private void DrawWindow(int windowId) + { + if (_showBuffSection) + { + EnsurePropList(); + } + + GUILayout.BeginVertical(); + + bool hasPreviousSection = false; + if (_showBuffSection) + { + DrawBuffSection(); + hasPreviousSection = true; + } + + if (HasVisibleBattleSection()) + { + if (hasPreviousSection) + { + GUILayout.Space(8f); + GUILayout.Label(string.Empty, GUI.skin.horizontalSlider); + GUILayout.Space(8f); + } + + DrawBattleSection(); + hasPreviousSection = true; + } + + if (_showTips) + { + if (hasPreviousSection) + { + GUILayout.Space(8f); + } + + GUILayout.Label("Tips: press `F8` or tap top-left corner 3 times to toggle.", GUILayout.Height(20f)); + } + + GUILayout.EndVertical(); + GUI.DragWindow(new Rect(0, 0, 10000, 22)); + } + + private void DrawBuffSection() + { + GUILayout.Label("Buff Debug"); + GUILayout.BeginHorizontal(); + GUILayout.Label("Search", GUILayout.Width(52f)); + _searchText = GUILayout.TextField(_searchText); + if (GUILayout.Button("Refresh", GUILayout.Width(80f))) + { + EnsurePropList(true); + } + + GUILayout.EndHorizontal(); + + ApplyFilter(_searchText); + if (_displayNames.Length == 0) + { + GUILayout.Label("No Buff data. Enter battle and try again."); + return; + } + + _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1); + _buffScroll = GUILayout.BeginScrollView(_buffScroll, GUILayout.Height(120f)); + _selectedIndex = GUILayout.SelectionGrid(_selectedIndex, _displayNames, 1); + GUILayout.EndScrollView(); + + DRProp selectedProp = GetSelectedProp(); + if (selectedProp == null) return; + + GUILayout.Label($"Selected: {selectedProp.Title} ({selectedProp.Rarity})"); + GUILayout.Label(ItemDescUtility.CreatePropDescription(selectedProp.Modifiers), GUILayout.Height(40f)); + + GUILayout.BeginHorizontal(); + GUILayout.Label("Count", GUILayout.Width(52f)); + string addCountText = GUILayout.TextField(_addCount.ToString(), GUILayout.Width(60f)); + if (!int.TryParse(addCountText, out _addCount)) _addCount = 1; + _addCount = Mathf.Clamp(_addCount, 1, 99); + + if (GUILayout.Button("Add Buff To Player", GUILayout.Height(24f))) + { + AddSelectedBuffToPlayer(selectedProp, _addCount); + } + + GUILayout.EndHorizontal(); + } + + private void DrawBattleSection() + { + GUILayout.Label("Battle Debug"); + ProcedureGame procedure = GameEntry.Procedure.CurrentProcedure as ProcedureGame; + EnemyManagerComponent enemyManager = GameEntry.EnemyManager; + Player player = FindPlayer(); + HealthComponent playerHealth = player != null ? player.GetComponent() : null; + + if (enemyManager == null) + { + GUILayout.Label("EnemyManager unavailable."); + return; + } + + if (procedure == null) + { + GUILayout.Label("ProcedureGame unavailable."); + return; + } + + if (_showBattleOverview) + { + GUILayout.Label($"Spawn Rate: {enemyManager.SpawnRateScale:F2}"); + GUILayout.Label( + $"Battle Time: {enemyManager.ElapsedBattleTime:F1}s / {enemyManager.BattleDuration:F1}s"); + GUILayout.Label($"Enemy Count: {enemyManager.CurrentEnemyCount}"); + } + + Simulation.SimulationWorld simulationWorld = GameEntry.SimulationWorld; + if (_showCollisionStats && simulationWorld != null) + { + GUILayout.Space(4f); + GUILayout.Label( + $"Collision Queries: total {simulationWorld.LastCollisionQueryCount} (Projectile {simulationWorld.LastProjectileCollisionQueryCount} / Area {simulationWorld.LastAreaCollisionQueryCount})"); + GUILayout.Label( + $"Collision Candidates: total {simulationWorld.LastCollisionCandidateCount} (Projectile {simulationWorld.LastProjectileCollisionCandidateCount} / Area {simulationWorld.LastAreaCollisionCandidateCount})"); + GUILayout.Label( + $"Area Resolve: hits {simulationWorld.LastResolvedAreaHitCount}"); + GUILayout.Label( + $"Broad Phase: cell {simulationWorld.LastCollisionCellSize:F2}, hasEnemyTargets {(simulationWorld.LastCollisionHasEnemyTargets ? "Yes" : "No")}"); + if (simulationWorld.LastCollisionCandidateCount != 0) + { + Log.Info($"LastCollisionCandidateCount:{simulationWorld.LastCollisionCandidateCount}"); + } + + if (simulationWorld.LastResolvedAreaHitCount != 0) + { + Log.Info($"LastResolvedAreaHitCount:{simulationWorld.LastResolvedAreaHitCount}"); + } + } + + if (_showSpawnControls) + { + GUILayout.BeginHorizontal(); + GUILayout.Label("Rate", GUILayout.Width(52f)); + string rateText = GUILayout.TextField(_spawnRateScaleInput.ToString("F2"), GUILayout.Width(60f)); + if (float.TryParse(rateText, out float parsedRate)) + { + _spawnRateScaleInput = Mathf.Clamp(parsedRate, MinSpawnRate, 50f); + } + + if (GUILayout.Button("Apply", GUILayout.Width(70f))) + { + enemyManager.SetSpawnRateScale(_spawnRateScaleInput); + } + + if (GUILayout.Button("x0.5", GUILayout.Width(60f))) + { + _spawnRateScaleInput = Mathf.Max(MinSpawnRate, enemyManager.SpawnRateScale * 0.5f); + enemyManager.SetSpawnRateScale(_spawnRateScaleInput); + } + + if (GUILayout.Button("x2", GUILayout.Width(60f))) + { + _spawnRateScaleInput = enemyManager.SpawnRateScale * 2f; + enemyManager.SetSpawnRateScale(_spawnRateScaleInput); + } + + GUILayout.EndHorizontal(); + } + + if (_showBattleDurationControls) + { + GUILayout.BeginHorizontal(); + GUILayout.Label("Add Sec", GUILayout.Width(52f)); + string durationText = GUILayout.TextField(_extendDurationSeconds.ToString("F0"), GUILayout.Width(60f)); + if (float.TryParse(durationText, out float parsedDuration)) + { + _extendDurationSeconds = Mathf.Clamp(parsedDuration, 1f, 3600f); + } + + if (GUILayout.Button("Extend Battle", GUILayout.Height(24f))) + { + if (procedure.CurrentGameState is GameStateBattle gameState) + { + gameState.AddBattleDuration(_extendDurationSeconds); + } + } + + GUILayout.EndHorizontal(); + } + + if (_showPlayerWeaponControls) + { + GUILayout.Label( + $"Player Weapon: {(player == null ? "Player not found" : (player.WeaponEnabled ? "Enabled" : "Disabled"))}"); + GUILayout.BeginHorizontal(); + GUI.enabled = player != null; + if (GUILayout.Button("Disable Weapons", GUILayout.Height(24f))) + { + player.SetWeaponEnabled(false); + } + + if (GUILayout.Button("Enable Weapons", GUILayout.Height(24f))) + { + player.SetWeaponEnabled(true); + } + + GUI.enabled = true; + GUILayout.EndHorizontal(); + } + + if (_showPlayerHealthControls) + { + GUILayout.Space(4f); + GUILayout.Label( + $"Player HP: {(playerHealth == null ? "Unavailable" : $"{playerHealth.CurrentHealth}/{playerHealth.MaxHealth}")}"); + GUILayout.BeginHorizontal(); + GUI.enabled = playerHealth != null; + if (GUILayout.Button($"+{DebugHealAmount} HP", GUILayout.Height(24f))) + { + AddPlayerHealth(playerHealth, DebugHealAmount); + } + + if (GUILayout.Button(_lockPlayerHealthToMax ? "GodMode: ON" : "GodMode: OFF", GUILayout.Height(24f))) + { + _lockPlayerHealthToMax = !_lockPlayerHealthToMax; + if (_lockPlayerHealthToMax) + { + RestorePlayerHealthToMax(playerHealth); + } + } + + GUI.enabled = true; + GUILayout.EndHorizontal(); + } + } + + private bool HasVisibleBattleSection() + { + return _showBattleOverview || + _showCollisionStats || + _showSpawnControls || + _showBattleDurationControls || + _showPlayerWeaponControls || + _showPlayerHealthControls; + } + + private void EnsurePropList(bool force = false) + { + if (!force && _allProps != null && _allProps.Length > 0) return; + + if (GameEntry.DataTable == null) + { + _allProps = Array.Empty(); + _filteredProps = Array.Empty(); + _displayNames = Array.Empty(); + return; + } + + var table = GameEntry.DataTable.GetDataTable(); + _allProps = table != null ? table.ToArray() : Array.Empty(); + _selectedIndex = Mathf.Clamp(_selectedIndex, 0, Mathf.Max(0, _allProps.Length - 1)); + ApplyFilter(_searchText); + } + + private void ApplyFilter(string keyword) + { + if (_allProps == null || _allProps.Length == 0) + { + _filteredProps = Array.Empty(); + _displayNames = Array.Empty(); + return; + } + + if (string.IsNullOrWhiteSpace(keyword)) + { + _filteredProps = _allProps; + } + else + { + string search = keyword.Trim(); + _filteredProps = _allProps.Where(p => + p != null && + (p.Title?.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 || + p.Id.ToString().Contains(search))).ToArray(); + } + + _displayNames = _filteredProps.Select(p => $"[{p.Id}] {p.Title} ({p.Rarity})").ToArray(); + if (_displayNames.Length == 0) _selectedIndex = 0; + else _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1); + } + + private DRProp GetSelectedProp() + { + if (_filteredProps == null || _filteredProps.Length == 0) return null; + _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _filteredProps.Length - 1); + return _filteredProps[_selectedIndex]; + } + + private static Player FindPlayer() + { + return UnityEngine.Object.FindObjectOfType(); + } + + private void KeepPlayerHealthAtMax() + { + Player player = FindPlayer(); + if (player == null) return; + + HealthComponent playerHealth = player.GetComponent(); + if (playerHealth == null) return; + + RestorePlayerHealthToMax(playerHealth); + } + + private static void AddPlayerHealth(HealthComponent playerHealth, int amount) + { + if (playerHealth == null || amount <= 0) return; + if (playerHealth.CurrentHealth <= 0) return; + + int maxHealth = playerHealth.MaxHealth; + if (maxHealth <= 0) return; + + int nextHealth = Mathf.Clamp(playerHealth.CurrentHealth + amount, 0, maxHealth); + if (nextHealth == playerHealth.CurrentHealth) return; + + playerHealth.CurrentHealth = nextHealth; + PublishPlayerHealthChanged(playerHealth); + } + + private static void RestorePlayerHealthToMax(HealthComponent playerHealth) + { + if (playerHealth == null) return; + if (playerHealth.CurrentHealth <= 0) return; + + int maxHealth = playerHealth.MaxHealth; + if (maxHealth <= 0 || playerHealth.CurrentHealth >= maxHealth) return; + + playerHealth.CurrentHealth = maxHealth; + PublishPlayerHealthChanged(playerHealth); + } + + private static void PublishPlayerHealthChanged(HealthComponent playerHealth) + { + if (playerHealth == null || GameEntry.Event == null) return; + + GameEntry.Event.Fire(null, + PlayerHealthChangeEventArgs.Create(0, playerHealth.CurrentHealth, playerHealth.MaxHealth)); + } + + private static void AddSelectedBuffToPlayer(DRProp prop, int count) + { + Player player = FindPlayer(); + if (player == null || prop == null || prop.Modifiers == null) return; + + int applyCount = Mathf.Clamp(count, 1, 99); + for (int i = 0; i < applyCount; i++) + { + player.AddProp(new PropItem(prop.Modifiers, prop.Rarity, prop.Title, prop.IconAssetName)); + } + } + + private void HandleCornerTapGesture() + { + if (!TryGetTouchReleased(out Vector2 touchPosition)) return; + if (touchPosition.x > 80f || touchPosition.y < Screen.height - 80f) return; + + float now = Time.unscaledTime; + if (now - _lastCornerTapTime > CornerTapWindow) + { + _cornerTapCount = 0; + } + + _lastCornerTapTime = now; + _cornerTapCount++; + + if (_cornerTapCount >= RequiredCornerTapCount) + { + _cornerTapCount = 0; + _isPanelVisible = !_isPanelVisible; + } + } + + private static bool IsTogglePressed() + { +#if ENABLE_INPUT_SYSTEM + Keyboard keyboard = Keyboard.current; + if (keyboard == null) return false; + return keyboard.backquoteKey.wasPressedThisFrame || keyboard.f8Key.wasPressedThisFrame; +#else + return Input.GetKeyDown(KeyCode.BackQuote) || Input.GetKeyDown(KeyCode.F8); +#endif + } + + private static bool TryGetTouchReleased(out Vector2 touchPosition) + { +#if ENABLE_INPUT_SYSTEM + Touchscreen touchscreen = Touchscreen.current; + if (touchscreen == null) + { + touchPosition = default; + return false; + } + + var touch = touchscreen.primaryTouch; + if (!touch.press.wasReleasedThisFrame) + { + touchPosition = default; + return false; + } + + touchPosition = touch.position.ReadValue(); + return true; +#else + if (Input.touchCount <= 0) + { + touchPosition = default; + return false; + } + + Touch touch = Input.GetTouch(0); + if (touch.phase != TouchPhase.Ended) + { + touchPosition = default; + return false; + } + + touchPosition = touch.position; + return true; +#endif + } +} + +#endif diff --git a/Assets/GameMain/Scripts/Runtime/CustomComponent/DebugPanel/RuntimeDebugPanelComponent.cs.meta b/Assets/GameMain/DebugPanel/RuntimeDebugPanelComponent.cs.meta similarity index 100% rename from Assets/GameMain/Scripts/Runtime/CustomComponent/DebugPanel/RuntimeDebugPanelComponent.cs.meta rename to Assets/GameMain/DebugPanel/RuntimeDebugPanelComponent.cs.meta diff --git a/Assets/GameMain/Scripts/Base/Entity/EntityLogic/EntityBase.cs b/Assets/GameMain/Scripts/Base/Entity/EntityLogic/EntityBase.cs index 00e4d9b..6f14b94 100644 --- a/Assets/GameMain/Scripts/Base/Entity/EntityLogic/EntityBase.cs +++ b/Assets/GameMain/Scripts/Base/Entity/EntityLogic/EntityBase.cs @@ -1,11 +1,4 @@ -//------------------------------------------------------------ -// Game Framework -// Copyright © 2013-2021 Jiang Yin. All rights reserved. -// Homepage: https://gameframework.cn/ -// Feedback: mailto:ellan@gameframework.cn -//------------------------------------------------------------ - -using Entity.EntityData; +using Entity.EntityData; using GameFramework; using UnityEngine; using UnityGameFramework.Runtime; @@ -19,18 +12,18 @@ namespace Entity public int Id => Entity.Id; public Animation CachedAnimation { get; private set; } - + protected override void OnInit(object userData) { base.OnInit(userData); CachedAnimation = GetComponent(); } - + protected override void OnRecycle() { base.OnRecycle(); } - + protected override void OnShow(object userData) { base.OnShow(userData); @@ -48,35 +41,35 @@ namespace Entity CachedTransform.localScale = Vector3.one; } - + protected override void OnHide(bool isShutdown, object userData) { base.OnHide(isShutdown, userData); } - + protected override void OnAttached(EntityLogic childEntity, Transform parentTransform, object userData) { base.OnAttached(childEntity, parentTransform, userData); } - + protected override void OnDetached(EntityLogic childEntity, object userData) { base.OnDetached(childEntity, userData); } - + protected override void OnAttachTo(EntityLogic parentEntity, Transform parentTransform, object userData) { base.OnAttachTo(parentEntity, parentTransform, userData); } - + protected override void OnDetachFrom(EntityLogic parentEntity, object userData) { base.OnDetachFrom(parentEntity, userData); } - + protected override void OnUpdate(float elapseSeconds, float realElapseSeconds) { base.OnUpdate(elapseSeconds, realElapseSeconds); } } -} \ No newline at end of file +} diff --git a/Assets/GameMain/Scripts/Editor/SepCore.Editor.asmdef b/Assets/GameMain/Scripts/Editor/SepCore.Editor.asmdef index 1c95ed2..1e3d413 100644 --- a/Assets/GameMain/Scripts/Editor/SepCore.Editor.asmdef +++ b/Assets/GameMain/Scripts/Editor/SepCore.Editor.asmdef @@ -4,7 +4,9 @@ "references": [ "GUID:47a82ffa13c291447ab895cd0bc251cd", "GUID:363c5eb08ff8e6a439b85e37b8c20d96", - "GUID:a2d8a19598eca814496b089021d08d60" + "GUID:a2d8a19598eca814496b089021d08d60", + "GUID:6f6ea874d7669044095abb01ec4c2f8d", + "GUID:0e1d182005e0ae647ab3fa40f5492dbb" ], "includePlatforms": [ "Editor" diff --git a/Assets/GameMain/Scripts/Presentation/Common/AboutForm/AboutForm.cs b/Assets/GameMain/Scripts/Presentation/Common/AboutForm/AboutForm.cs index b3048a2..f908d90 100644 --- a/Assets/GameMain/Scripts/Presentation/Common/AboutForm/AboutForm.cs +++ b/Assets/GameMain/Scripts/Presentation/Common/AboutForm/AboutForm.cs @@ -7,7 +7,6 @@ using StarForce; using UnityEngine; -using UnityEngine.Serialization; using UnityEngine.UI; using UnityGameFramework.Runtime; @@ -79,4 +78,4 @@ namespace UI } } } -} \ No newline at end of file +} diff --git a/Assets/GameMain/Scripts/Presentation/Main/Context/DisplayItemContext.cs b/Assets/GameMain/Scripts/Presentation/Main/Context/DisplayItemContext.cs index c3bcc92..8091275 100644 --- a/Assets/GameMain/Scripts/Presentation/Main/Context/DisplayItemContext.cs +++ b/Assets/GameMain/Scripts/Presentation/Main/Context/DisplayItemContext.cs @@ -7,5 +7,19 @@ namespace UI public string IconAssetName; public ItemRarity Rarity; public bool IsWeapon; + + public DisplayItemContext() + { + IconAssetName = string.Empty; + Rarity = ItemRarity.None; + IsWeapon = false; + } + + public DisplayItemContext(DisplayItemRawData rawData) + { + this.IconAssetName = rawData.IconAssetName; + this.Rarity = rawData.Rarity; + this.IsWeapon = rawData.IsWeapon; + } } -} \ No newline at end of file +} diff --git a/Assets/GameMain/Scripts/Presentation/Main/Context/GoodsItemContext.cs b/Assets/GameMain/Scripts/Presentation/Main/Context/GoodsItemContext.cs index cf8de06..5def738 100644 --- a/Assets/GameMain/Scripts/Presentation/Main/Context/GoodsItemContext.cs +++ b/Assets/GameMain/Scripts/Presentation/Main/Context/GoodsItemContext.cs @@ -11,5 +11,15 @@ namespace UI public Sprite Icon; public string Description; public int Price; + + public GoodsItemContext(GoodsItemRawData rawData) + { + Title = rawData.Title; + Description = rawData.Description; + Price = rawData.Price; + Rarity = rawData.Rarity; + Type = rawData.Type; + Icon = rawData.Icon; + } } -} \ No newline at end of file +} diff --git a/Assets/GameMain/Scripts/Presentation/Main/ShopForm/ShopFormController.cs b/Assets/GameMain/Scripts/Presentation/Main/ShopForm/ShopFormController.cs index 8e6d604..762708f 100644 --- a/Assets/GameMain/Scripts/Presentation/Main/ShopForm/ShopFormController.cs +++ b/Assets/GameMain/Scripts/Presentation/Main/ShopForm/ShopFormController.cs @@ -51,12 +51,18 @@ namespace UI _rawData = rawData; + List goodsItems = new List(); + foreach (var item in rawData.GoodsItems) + { + goodsItems.Add(new GoodsItemContext(item)); + } + return new ShopFormContext { CurrentLevel = rawData.CurrentLevel, RefreshPrice = rawData.RefreshPrice, PlayerCoin = rawData.PlayerCoin, - GoodsItems = rawData.GoodsItems, + GoodsItems = goodsItems, PropListContext = BuildDisplayListAreaContext(DisplayListAreaType.Prop, rawData.PropItems, rawData.PropMaxCount), WeaponListContext = BuildDisplayListAreaContext(DisplayListAreaType.Weapon, rawData.WeaponItems, @@ -267,7 +273,18 @@ namespace UI return; } - Context.GoodsItems = result.GoodsItems; + for (int i = 0; i < result.GoodsItems.Count; i++) + { + if (i < Context.GoodsItems.Count) Context.GoodsItems[i] = new GoodsItemContext(result.GoodsItems[i]); + else Context.GoodsItems.Add(new GoodsItemContext(result.GoodsItems[i])); + } + + if (Context.GoodsItems.Count != result.GoodsItems.Count) + { + Context.GoodsItems.RemoveRange(Context.GoodsItems.Count, + Context.GoodsItems.Count - Context.GoodsItems.Count); + } + Context.RefreshPrice = result.RefreshPrice; if (Form == null) @@ -276,8 +293,8 @@ namespace UI return; } - Form.RefreshGoodsItems(result.GoodsItems); - Form.RefreshRefreshPrice(result.RefreshPrice); + Form.RefreshGoodsItems(Context.GoodsItems); + Form.RefreshRefreshPrice(Context.RefreshPrice); } private void ApplyGoodsPurchased(ShopPurchaseResult result) @@ -299,19 +316,21 @@ namespace UI Context.GoodsItems[result.GoodsIndex] = null; } + DisplayItemContext context = new DisplayItemContext(result.DisplayItem); + if (result.DisplayItem != null) { if (result.DisplayItem.IsWeapon) { - AppendDisplayItemContext(Context.WeaponListContext, result.DisplayItem); + AppendDisplayItemContext(Context.WeaponListContext, context); } else { - AppendDisplayItemContext(Context.PropListContext, result.DisplayItem); + AppendDisplayItemContext(Context.PropListContext, context); } } - Form?.ApplyGoodsPurchased(result.GoodsIndex, result.DisplayItem); + Form?.ApplyGoodsPurchased(result.GoodsIndex, context); } private bool IsCurrentFormEventSender(object sender) diff --git a/Assets/GameMain/Scripts/Presentation/SepCore.Presentation.asmdef b/Assets/GameMain/Scripts/Presentation/SepCore.Presentation.asmdef new file mode 100644 index 0000000..4b3bcf2 --- /dev/null +++ b/Assets/GameMain/Scripts/Presentation/SepCore.Presentation.asmdef @@ -0,0 +1,18 @@ +{ + "name": "SepCore.Presentation", + "rootNamespace": "SepCore.UI", + "references": [ + "GUID:6055be8ebefd69e48b49212b09b47b2f", + "GUID:47a82ffa13c291447ab895cd0bc251cd", + "GUID:363c5eb08ff8e6a439b85e37b8c20d96" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/GameMain/Scripts/Presentation/SepCore.Presentation.asmdef.meta b/Assets/GameMain/Scripts/Presentation/SepCore.Presentation.asmdef.meta new file mode 100644 index 0000000..6ad86ee --- /dev/null +++ b/Assets/GameMain/Scripts/Presentation/SepCore.Presentation.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0e1d182005e0ae647ab3fa40f5492dbb +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Procedure/Base/ProcedurePreload.cs b/Assets/GameMain/Scripts/Procedure/Base/ProcedurePreload.cs index 7382d3a..84f3417 100644 --- a/Assets/GameMain/Scripts/Procedure/Base/ProcedurePreload.cs +++ b/Assets/GameMain/Scripts/Procedure/Base/ProcedurePreload.cs @@ -1,11 +1,4 @@ -//------------------------------------------------------------ -// Game Framework -// Copyright © 2013-2021 Jiang Yin. All rights reserved. -// Homepage: https://gameframework.cn/ -// Feedback: mailto:ellan@gameframework.cn -//------------------------------------------------------------ - -using GameFramework; +using GameFramework; using GameFramework.Event; using GameFramework.Resource; using System.Collections.Generic; diff --git a/Assets/GameMain/Scripts/Procedure/Base/ProcedureUpdateResources.cs b/Assets/GameMain/Scripts/Procedure/Base/ProcedureUpdateResources.cs index 4eea85e..3f0a973 100644 --- a/Assets/GameMain/Scripts/Procedure/Base/ProcedureUpdateResources.cs +++ b/Assets/GameMain/Scripts/Procedure/Base/ProcedureUpdateResources.cs @@ -2,7 +2,6 @@ using GameFramework; using GameFramework.Event; using System.Collections.Generic; using SepCore.Definition; -using StarForce; using UI; using UnityEngine; using UnityGameFramework.Runtime; @@ -19,13 +18,7 @@ namespace Procedure private List m_UpdateLengthData = new List(); private UpdateResourceForm m_UpdateResourceForm = null; - public override bool UseNativeDialog - { - get - { - return true; - } - } + public override bool UseNativeDialog => true; protected override void OnEnter(ProcedureOwner procedureOwner) { @@ -55,7 +48,10 @@ namespace Procedure ConfirmText = GameEntry.Localization.GetString("UpdateResourceViaCarrierDataNetwork.UpdateButton"), OnClickConfirm = StartUpdateResources, CancelText = GameEntry.Localization.GetString("UpdateResourceViaCarrierDataNetwork.QuitButton"), - OnClickCancel = delegate (object userData) { UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit); }, + OnClickCancel = delegate(object userData) + { + UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit); + }, }); return; @@ -96,7 +92,8 @@ namespace Procedure { if (m_UpdateResourceForm == null) { - m_UpdateResourceForm = Object.Instantiate(GameEntry.BuiltinData.UpdateResourceFormTemplate); + m_UpdateResourceForm = Object.Instantiate(GameEntry.BuiltinData.UpdateResourceFormTemplate) + .GetComponent(); } Log.Info("Start update resources..."); @@ -112,7 +109,10 @@ namespace Procedure } float progressTotal = (float)currentTotalUpdateLength / m_UpdateTotalCompressedLength; - string descriptionText = GameEntry.Localization.GetString("UpdateResource.Tips", m_UpdateSuccessCount.ToString(), m_UpdateCount.ToString(), GetByteLengthString(currentTotalUpdateLength), GetByteLengthString(m_UpdateTotalCompressedLength), progressTotal, GetByteLengthString((int)GameEntry.Download.CurrentSpeed)); + string descriptionText = GameEntry.Localization.GetString("UpdateResource.Tips", + m_UpdateSuccessCount.ToString(), m_UpdateCount.ToString(), + GetByteLengthString(currentTotalUpdateLength), GetByteLengthString(m_UpdateTotalCompressedLength), + progressTotal, GetByteLengthString((int)GameEntry.Download.CurrentSpeed)); m_UpdateResourceForm.SetProgress(progressTotal, descriptionText); } @@ -223,12 +223,14 @@ namespace Procedure ResourceUpdateFailureEventArgs ne = (ResourceUpdateFailureEventArgs)e; if (ne.RetryCount >= ne.TotalRetryCount) { - Log.Error("Update resource '{0}' failure from '{1}' with error message '{2}', retry count '{3}'.", ne.Name, ne.DownloadUri, ne.ErrorMessage, ne.RetryCount.ToString()); + Log.Error("Update resource '{0}' failure from '{1}' with error message '{2}', retry count '{3}'.", + ne.Name, ne.DownloadUri, ne.ErrorMessage, ne.RetryCount.ToString()); return; } else { - Log.Info("Update resource '{0}' failure from '{1}' with error message '{2}', retry count '{3}'.", ne.Name, ne.DownloadUri, ne.ErrorMessage, ne.RetryCount.ToString()); + Log.Info("Update resource '{0}' failure from '{1}' with error message '{2}', retry count '{3}'.", + ne.Name, ne.DownloadUri, ne.ErrorMessage, ne.RetryCount.ToString()); } for (int i = 0; i < m_UpdateLengthData.Count; i++) @@ -255,17 +257,10 @@ namespace Procedure public string Name { - get - { - return m_Name; - } + get { return m_Name; } } - public int Length - { - get; - set; - } + public int Length { get; set; } } } } diff --git a/Assets/GameMain/Scripts/Procedure/Game/GameStateLevelUp.cs b/Assets/GameMain/Scripts/Procedure/Game/GameStateLevelUp.cs index ab570b6..d076edd 100644 --- a/Assets/GameMain/Scripts/Procedure/Game/GameStateLevelUp.cs +++ b/Assets/GameMain/Scripts/Procedure/Game/GameStateLevelUp.cs @@ -22,7 +22,7 @@ namespace Procedure _procedureGame = master; - var useCase = new LevelUpFormUseCase(_procedureGame.Player, this); + var useCase = new LevelUpFormUseCase(_procedureGame.Player, () => IsCompleted = true); GameEntry.UIRouter.BindUIUseCase(UIFormType.LevelUpForm, useCase); } diff --git a/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs b/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs index 8cc3170..ead8872 100644 --- a/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs +++ b/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs @@ -21,7 +21,7 @@ namespace Procedure Log.Debug("GameStateShop::OnInit"); _procedureGame = master; - var shopFormUseCase = new ShopFormUseCase(_procedureGame, this); + var shopFormUseCase = new ShopFormUseCase(_procedureGame.Player, _procedureGame.CurrentLevel, () => ShopFinish = true); GameEntry.UIRouter.BindUIUseCase(UIFormType.ShopForm, shopFormUseCase); } diff --git a/Assets/GameMain/Scripts/Procedure/ProcedureStartMenu.cs b/Assets/GameMain/Scripts/Procedure/ProcedureStartMenu.cs index f010070..718cbc4 100644 --- a/Assets/GameMain/Scripts/Procedure/ProcedureStartMenu.cs +++ b/Assets/GameMain/Scripts/Procedure/ProcedureStartMenu.cs @@ -28,7 +28,7 @@ namespace Procedure GameEntry.UIRouter.OpenUI(UIFormType.StartMenuForm); - var useCase2 = new SelectRoleFormUseCase(this); + var useCase2 = new SelectRoleFormUseCase(roleId => StartGame(roleId)); GameEntry.UIRouter.BindUIUseCase(UIFormType.SelectRoleForm, useCase2); QualitySettings.vSyncCount = 0; diff --git a/Assets/GameMain/Scripts/Procedure/SepCore.Procedure.asmdef b/Assets/GameMain/Scripts/Procedure/SepCore.Procedure.asmdef new file mode 100644 index 0000000..adafaea --- /dev/null +++ b/Assets/GameMain/Scripts/Procedure/SepCore.Procedure.asmdef @@ -0,0 +1,19 @@ +{ + "name": "SepCore.Procedure", + "rootNamespace": "SepCore.Procedure", + "references": [ + "GUID:363c5eb08ff8e6a439b85e37b8c20d96", + "GUID:47a82ffa13c291447ab895cd0bc251cd", + "GUID:0e1d182005e0ae647ab3fa40f5492dbb", + "GUID:6055be8ebefd69e48b49212b09b47b2f" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/GameMain/Scripts/Procedure/SepCore.Procedure.asmdef.meta b/Assets/GameMain/Scripts/Procedure/SepCore.Procedure.asmdef.meta new file mode 100644 index 0000000..e7af05a --- /dev/null +++ b/Assets/GameMain/Scripts/Procedure/SepCore.Procedure.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6f6ea874d7669044095abb01ec4c2f8d +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/Base/GameEntry.Custom.cs b/Assets/GameMain/Scripts/Runtime/Base/GameEntry.Custom.cs index f4b23b9..63bb68a 100644 --- a/Assets/GameMain/Scripts/Runtime/Base/GameEntry.Custom.cs +++ b/Assets/GameMain/Scripts/Runtime/Base/GameEntry.Custom.cs @@ -1,14 +1,5 @@ -//------------------------------------------------------------ -// Game Framework -// Copyright © 2013-2021 Jiang Yin. All rights reserved. -// Homepage: https://gameframework.cn/ -// Feedback: mailto:ellan@gameframework.cn -//------------------------------------------------------------ - -using CustomComponent; +using CustomComponent; using Simulation; -using StarForce; -using UI; using UnityEngine; /// @@ -22,10 +13,6 @@ public partial class GameEntry : MonoBehaviour public static DamageTextComponent DamageText { get; private set; } -#if UNITY_EDITOR || DEVELOPMENT_BUILD - public static RuntimeDebugPanelComponent RuntimeDebugPanel { get; private set; } -#endif - public static EnemyManagerComponent EnemyManager { get; private set; } public static SimulationWorld SimulationWorld { get; private set; } @@ -39,17 +26,8 @@ public partial class GameEntry : MonoBehaviour BuiltinData = UnityGameFramework.Runtime.GameEntry.GetComponent(); HPBar = UnityGameFramework.Runtime.GameEntry.GetComponent(); DamageText = UnityGameFramework.Runtime.GameEntry.GetComponent(); - -#if UNITY_EDITOR || DEVELOPMENT_BUILD - RuntimeDebugPanel = UnityGameFramework.Runtime.GameEntry.GetComponent(); -#endif - EnemyManager = UnityGameFramework.Runtime.GameEntry.GetComponent(); SimulationWorld = UnityGameFramework.Runtime.GameEntry.GetComponent(); - if (SimulationWorld == null && Base != null) - { - SimulationWorld = Base.gameObject.AddComponent(); - } SpriteCache = UnityGameFramework.Runtime.GameEntry.GetComponent(); UIRouter = UnityGameFramework.Runtime.GameEntry.GetComponent(); } diff --git a/Assets/GameMain/Scripts/Base/Entity/EntityExtension.cs b/Assets/GameMain/Scripts/Runtime/BuiltinComponent/EntityExtension.cs similarity index 100% rename from Assets/GameMain/Scripts/Base/Entity/EntityExtension.cs rename to Assets/GameMain/Scripts/Runtime/BuiltinComponent/EntityExtension.cs diff --git a/Assets/GameMain/Scripts/Base/Entity/EntityExtension.cs.meta b/Assets/GameMain/Scripts/Runtime/BuiltinComponent/EntityExtension.cs.meta similarity index 100% rename from Assets/GameMain/Scripts/Base/Entity/EntityExtension.cs.meta rename to Assets/GameMain/Scripts/Runtime/BuiltinComponent/EntityExtension.cs.meta diff --git a/Assets/GameMain/Scripts/Runtime/CustomComponent/SoundExtension.cs b/Assets/GameMain/Scripts/Runtime/BuiltinComponent/SoundExtension.cs similarity index 100% rename from Assets/GameMain/Scripts/Runtime/CustomComponent/SoundExtension.cs rename to Assets/GameMain/Scripts/Runtime/BuiltinComponent/SoundExtension.cs diff --git a/Assets/GameMain/Scripts/Runtime/CustomComponent/SoundExtension.cs.meta b/Assets/GameMain/Scripts/Runtime/BuiltinComponent/SoundExtension.cs.meta similarity index 100% rename from Assets/GameMain/Scripts/Runtime/CustomComponent/SoundExtension.cs.meta rename to Assets/GameMain/Scripts/Runtime/BuiltinComponent/SoundExtension.cs.meta diff --git a/Assets/GameMain/Scripts/Runtime/CustomComponent/BuiltinData/BuiltinDataComponent.cs b/Assets/GameMain/Scripts/Runtime/CustomComponent/BuiltinData/BuiltinDataComponent.cs index 3557784..3898314 100644 --- a/Assets/GameMain/Scripts/Runtime/CustomComponent/BuiltinData/BuiltinDataComponent.cs +++ b/Assets/GameMain/Scripts/Runtime/CustomComponent/BuiltinData/BuiltinDataComponent.cs @@ -10,48 +10,37 @@ using GameFramework; using StarForce; using UI; using UnityEngine; +using UnityEngine.Serialization; using UnityGameFramework.Runtime; namespace CustomComponent { public class BuiltinDataComponent : GameFrameworkComponent { - [SerializeField] - private TextAsset m_BuildInfoTextAsset = null; + [FormerlySerializedAs("m_BuildInfoTextAsset")] [SerializeField] + private TextAsset _buildInfoTextAsset = null; - [SerializeField] - private TextAsset m_DefaultDictionaryTextAsset = null; + [FormerlySerializedAs("m_DefaultDictionaryTextAsset")] [SerializeField] + private TextAsset _defaultDictionaryTextAsset = null; - [SerializeField] - private UpdateResourceForm m_UpdateResourceFormTemplate = null; + [FormerlySerializedAs("m_UpdateResourceFormTemplate")] [SerializeField] + private GameObject _updateResourceFormTemplate = null; private BuildInfo m_BuildInfo = null; - public BuildInfo BuildInfo - { - get - { - return m_BuildInfo; - } - } + public BuildInfo BuildInfo => m_BuildInfo; - public UpdateResourceForm UpdateResourceFormTemplate - { - get - { - return m_UpdateResourceFormTemplate; - } - } + public GameObject UpdateResourceFormTemplate => _updateResourceFormTemplate; public void InitBuildInfo() { - if (m_BuildInfoTextAsset == null || string.IsNullOrEmpty(m_BuildInfoTextAsset.text)) + if (_buildInfoTextAsset == null || string.IsNullOrEmpty(_buildInfoTextAsset.text)) { Log.Info("Build info can not be found or empty."); return; } - m_BuildInfo = Utility.Json.ToObject(m_BuildInfoTextAsset.text); + m_BuildInfo = Utility.Json.ToObject(_buildInfoTextAsset.text); if (m_BuildInfo == null) { Log.Warning("Parse build info failure."); @@ -61,13 +50,13 @@ namespace CustomComponent public void InitDefaultDictionary() { - if (m_DefaultDictionaryTextAsset == null || string.IsNullOrEmpty(m_DefaultDictionaryTextAsset.text)) + if (_defaultDictionaryTextAsset == null || string.IsNullOrEmpty(_defaultDictionaryTextAsset.text)) { Log.Info("Default dictionary can not be found or empty."); return; } - if (!GameEntry.Localization.ParseData(m_DefaultDictionaryTextAsset.text)) + if (!GameEntry.Localization.ParseData(_defaultDictionaryTextAsset.text)) { Log.Warning("Parse default dictionary failure."); return; diff --git a/Assets/GameMain/Scripts/Runtime/CustomComponent/DebugPanel/RuntimeDebugPanelComponent.cs b/Assets/GameMain/Scripts/Runtime/CustomComponent/DebugPanel/RuntimeDebugPanelComponent.cs deleted file mode 100644 index cb303e6..0000000 --- a/Assets/GameMain/Scripts/Runtime/CustomComponent/DebugPanel/RuntimeDebugPanelComponent.cs +++ /dev/null @@ -1,527 +0,0 @@ -#if UNITY_EDITOR || DEVELOPMENT_BUILD -using System; -using System.Linq; -using Components; -using SepCore.Event; -using SepCore.DataTable; -using SepCore.Definition; -using Entity; -using CustomUtility; -using Procedure; -using UnityEngine; -using UnityGameFramework.Runtime; -#if ENABLE_INPUT_SYSTEM -using UnityEngine.InputSystem; -#endif - -namespace CustomComponent -{ - public class RuntimeDebugPanelComponent : GameFrameworkComponent - { - private const float MinSpawnRate = 0.1f; - private const float CornerTapWindow = 0.6f; - private const int RequiredCornerTapCount = 3; - private const int DebugHealAmount = 200; - - [Header("Window Content")] - [SerializeField] private bool _showBuffSection = true; - [SerializeField] private bool _showBattleOverview = true; - [SerializeField] private bool _showCollisionStats = true; - [SerializeField] private bool _showSpawnControls = true; - [SerializeField] private bool _showBattleDurationControls = true; - [SerializeField] private bool _showPlayerWeaponControls = true; - [SerializeField] private bool _showPlayerHealthControls = true; - [SerializeField] private bool _showTips = true; - - private Rect _windowRect = new Rect(20f, 60f, 460f, 800f); - private bool _isPanelVisible; - private int _windowId; - - private string _searchText = string.Empty; - private int _selectedIndex; - private int _addCount = 1; - private Vector2 _buffScroll; - - private float _spawnRateScaleInput = 1f; - private float _extendDurationSeconds = 30f; - - private DRProp[] _allProps = Array.Empty(); - private DRProp[] _filteredProps = Array.Empty(); - private string[] _displayNames = Array.Empty(); - - private int _cornerTapCount; - private float _lastCornerTapTime = -10f; - private bool _lockPlayerHealthToMax; - - protected override void Awake() - { - base.Awake(); - - _windowId = GetInstanceID(); - } - - private void Update() - { - if (IsTogglePressed()) - { - _isPanelVisible = !_isPanelVisible; - } - - HandleCornerTapGesture(); - if (_lockPlayerHealthToMax) - { - KeepPlayerHealthAtMax(); - } - } - - private void OnGUI() - { - DrawToggleButton(); - if (!_isPanelVisible) return; - - _windowRect = GUI.Window(_windowId, _windowRect, DrawWindow, "Runtime Debug Panel"); - } - - private void DrawToggleButton() - { - const float width = 64f; - const float height = 30f; - Rect buttonRect = new Rect(Screen.width - width - 12f, 10f, width, height); - if (GUI.Button(buttonRect, "DEBUG")) - { - _isPanelVisible = !_isPanelVisible; - } - } - - private void DrawWindow(int windowId) - { - if (_showBuffSection) - { - EnsurePropList(); - } - - GUILayout.BeginVertical(); - - bool hasPreviousSection = false; - if (_showBuffSection) - { - DrawBuffSection(); - hasPreviousSection = true; - } - - if (HasVisibleBattleSection()) - { - if (hasPreviousSection) - { - GUILayout.Space(8f); - GUILayout.Label(string.Empty, GUI.skin.horizontalSlider); - GUILayout.Space(8f); - } - - DrawBattleSection(); - hasPreviousSection = true; - } - - if (_showTips) - { - if (hasPreviousSection) - { - GUILayout.Space(8f); - } - - GUILayout.Label("Tips: press `F8` or tap top-left corner 3 times to toggle.", GUILayout.Height(20f)); - } - - GUILayout.EndVertical(); - GUI.DragWindow(new Rect(0, 0, 10000, 22)); - } - - private void DrawBuffSection() - { - GUILayout.Label("Buff Debug"); - GUILayout.BeginHorizontal(); - GUILayout.Label("Search", GUILayout.Width(52f)); - _searchText = GUILayout.TextField(_searchText); - if (GUILayout.Button("Refresh", GUILayout.Width(80f))) - { - EnsurePropList(true); - } - - GUILayout.EndHorizontal(); - - ApplyFilter(_searchText); - if (_displayNames.Length == 0) - { - GUILayout.Label("No Buff data. Enter battle and try again."); - return; - } - - _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1); - _buffScroll = GUILayout.BeginScrollView(_buffScroll, GUILayout.Height(120f)); - _selectedIndex = GUILayout.SelectionGrid(_selectedIndex, _displayNames, 1); - GUILayout.EndScrollView(); - - DRProp selectedProp = GetSelectedProp(); - if (selectedProp == null) return; - - GUILayout.Label($"Selected: {selectedProp.Title} ({selectedProp.Rarity})"); - GUILayout.Label(ItemDescUtility.CreatePropDescription(selectedProp.Modifiers), GUILayout.Height(40f)); - - GUILayout.BeginHorizontal(); - GUILayout.Label("Count", GUILayout.Width(52f)); - string addCountText = GUILayout.TextField(_addCount.ToString(), GUILayout.Width(60f)); - if (!int.TryParse(addCountText, out _addCount)) _addCount = 1; - _addCount = Mathf.Clamp(_addCount, 1, 99); - - if (GUILayout.Button("Add Buff To Player", GUILayout.Height(24f))) - { - AddSelectedBuffToPlayer(selectedProp, _addCount); - } - - GUILayout.EndHorizontal(); - } - - private void DrawBattleSection() - { - GUILayout.Label("Battle Debug"); - ProcedureGame procedure = GameEntry.Procedure.CurrentProcedure as ProcedureGame; - EnemyManagerComponent enemyManager = GameEntry.EnemyManager; - Player player = FindPlayer(); - HealthComponent playerHealth = player != null ? player.GetComponent() : null; - - if (enemyManager == null) - { - GUILayout.Label("EnemyManager unavailable."); - return; - } - - if (procedure == null) - { - GUILayout.Label("ProcedureGame unavailable."); - return; - } - - if (_showBattleOverview) - { - GUILayout.Label($"Spawn Rate: {enemyManager.SpawnRateScale:F2}"); - GUILayout.Label($"Battle Time: {enemyManager.ElapsedBattleTime:F1}s / {enemyManager.BattleDuration:F1}s"); - GUILayout.Label($"Enemy Count: {enemyManager.CurrentEnemyCount}"); - } - - Simulation.SimulationWorld simulationWorld = GameEntry.SimulationWorld; - if (_showCollisionStats && simulationWorld != null) - { - GUILayout.Space(4f); - GUILayout.Label( - $"Collision Queries: total {simulationWorld.LastCollisionQueryCount} (Projectile {simulationWorld.LastProjectileCollisionQueryCount} / Area {simulationWorld.LastAreaCollisionQueryCount})"); - GUILayout.Label( - $"Collision Candidates: total {simulationWorld.LastCollisionCandidateCount} (Projectile {simulationWorld.LastProjectileCollisionCandidateCount} / Area {simulationWorld.LastAreaCollisionCandidateCount})"); - GUILayout.Label( - $"Area Resolve: hits {simulationWorld.LastResolvedAreaHitCount}"); - GUILayout.Label( - $"Broad Phase: cell {simulationWorld.LastCollisionCellSize:F2}, hasEnemyTargets {(simulationWorld.LastCollisionHasEnemyTargets ? "Yes" : "No")}"); - if (simulationWorld.LastCollisionCandidateCount != 0) - { - Log.Info($"LastCollisionCandidateCount:{simulationWorld.LastCollisionCandidateCount}"); - } - - if (simulationWorld.LastResolvedAreaHitCount != 0) - { - Log.Info($"LastResolvedAreaHitCount:{simulationWorld.LastResolvedAreaHitCount}"); - } - } - - if (_showSpawnControls) - { - GUILayout.BeginHorizontal(); - GUILayout.Label("Rate", GUILayout.Width(52f)); - string rateText = GUILayout.TextField(_spawnRateScaleInput.ToString("F2"), GUILayout.Width(60f)); - if (float.TryParse(rateText, out float parsedRate)) - { - _spawnRateScaleInput = Mathf.Clamp(parsedRate, MinSpawnRate, 50f); - } - - if (GUILayout.Button("Apply", GUILayout.Width(70f))) - { - enemyManager.SetSpawnRateScale(_spawnRateScaleInput); - } - - if (GUILayout.Button("x0.5", GUILayout.Width(60f))) - { - _spawnRateScaleInput = Mathf.Max(MinSpawnRate, enemyManager.SpawnRateScale * 0.5f); - enemyManager.SetSpawnRateScale(_spawnRateScaleInput); - } - - if (GUILayout.Button("x2", GUILayout.Width(60f))) - { - _spawnRateScaleInput = enemyManager.SpawnRateScale * 2f; - enemyManager.SetSpawnRateScale(_spawnRateScaleInput); - } - - GUILayout.EndHorizontal(); - } - - if (_showBattleDurationControls) - { - GUILayout.BeginHorizontal(); - GUILayout.Label("Add Sec", GUILayout.Width(52f)); - string durationText = GUILayout.TextField(_extendDurationSeconds.ToString("F0"), GUILayout.Width(60f)); - if (float.TryParse(durationText, out float parsedDuration)) - { - _extendDurationSeconds = Mathf.Clamp(parsedDuration, 1f, 3600f); - } - - if (GUILayout.Button("Extend Battle", GUILayout.Height(24f))) - { - if (procedure.CurrentGameState is GameStateBattle gameState) - { - gameState.AddBattleDuration(_extendDurationSeconds); - } - } - - GUILayout.EndHorizontal(); - } - - if (_showPlayerWeaponControls) - { - GUILayout.Label( - $"Player Weapon: {(player == null ? "Player not found" : (player.WeaponEnabled ? "Enabled" : "Disabled"))}"); - GUILayout.BeginHorizontal(); - GUI.enabled = player != null; - if (GUILayout.Button("Disable Weapons", GUILayout.Height(24f))) - { - player.SetWeaponEnabled(false); - } - - if (GUILayout.Button("Enable Weapons", GUILayout.Height(24f))) - { - player.SetWeaponEnabled(true); - } - - GUI.enabled = true; - GUILayout.EndHorizontal(); - } - - if (_showPlayerHealthControls) - { - GUILayout.Space(4f); - GUILayout.Label( - $"Player HP: {(playerHealth == null ? "Unavailable" : $"{playerHealth.CurrentHealth}/{playerHealth.MaxHealth}")}"); - GUILayout.BeginHorizontal(); - GUI.enabled = playerHealth != null; - if (GUILayout.Button($"+{DebugHealAmount} HP", GUILayout.Height(24f))) - { - AddPlayerHealth(playerHealth, DebugHealAmount); - } - - if (GUILayout.Button(_lockPlayerHealthToMax ? "GodMode: ON" : "GodMode: OFF", GUILayout.Height(24f))) - { - _lockPlayerHealthToMax = !_lockPlayerHealthToMax; - if (_lockPlayerHealthToMax) - { - RestorePlayerHealthToMax(playerHealth); - } - } - - GUI.enabled = true; - GUILayout.EndHorizontal(); - } - } - - private bool HasVisibleBattleSection() - { - return _showBattleOverview || - _showCollisionStats || - _showSpawnControls || - _showBattleDurationControls || - _showPlayerWeaponControls || - _showPlayerHealthControls; - } - - private void EnsurePropList(bool force = false) - { - if (!force && _allProps != null && _allProps.Length > 0) return; - - if (GameEntry.DataTable == null) - { - _allProps = Array.Empty(); - _filteredProps = Array.Empty(); - _displayNames = Array.Empty(); - return; - } - - var table = GameEntry.DataTable.GetDataTable(); - _allProps = table != null ? table.ToArray() : Array.Empty(); - _selectedIndex = Mathf.Clamp(_selectedIndex, 0, Mathf.Max(0, _allProps.Length - 1)); - ApplyFilter(_searchText); - } - - private void ApplyFilter(string keyword) - { - if (_allProps == null || _allProps.Length == 0) - { - _filteredProps = Array.Empty(); - _displayNames = Array.Empty(); - return; - } - - if (string.IsNullOrWhiteSpace(keyword)) - { - _filteredProps = _allProps; - } - else - { - string search = keyword.Trim(); - _filteredProps = _allProps.Where(p => - p != null && - (p.Title?.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 || - p.Id.ToString().Contains(search))).ToArray(); - } - - _displayNames = _filteredProps.Select(p => $"[{p.Id}] {p.Title} ({p.Rarity})").ToArray(); - if (_displayNames.Length == 0) _selectedIndex = 0; - else _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1); - } - - private DRProp GetSelectedProp() - { - if (_filteredProps == null || _filteredProps.Length == 0) return null; - _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _filteredProps.Length - 1); - return _filteredProps[_selectedIndex]; - } - - private static Player FindPlayer() - { - return UnityEngine.Object.FindObjectOfType(); - } - - private void KeepPlayerHealthAtMax() - { - Player player = FindPlayer(); - if (player == null) return; - - HealthComponent playerHealth = player.GetComponent(); - if (playerHealth == null) return; - - RestorePlayerHealthToMax(playerHealth); - } - - private static void AddPlayerHealth(HealthComponent playerHealth, int amount) - { - if (playerHealth == null || amount <= 0) return; - if (playerHealth.CurrentHealth <= 0) return; - - int maxHealth = playerHealth.MaxHealth; - if (maxHealth <= 0) return; - - int nextHealth = Mathf.Clamp(playerHealth.CurrentHealth + amount, 0, maxHealth); - if (nextHealth == playerHealth.CurrentHealth) return; - - playerHealth.CurrentHealth = nextHealth; - PublishPlayerHealthChanged(playerHealth); - } - - private static void RestorePlayerHealthToMax(HealthComponent playerHealth) - { - if (playerHealth == null) return; - if (playerHealth.CurrentHealth <= 0) return; - - int maxHealth = playerHealth.MaxHealth; - if (maxHealth <= 0 || playerHealth.CurrentHealth >= maxHealth) return; - - playerHealth.CurrentHealth = maxHealth; - PublishPlayerHealthChanged(playerHealth); - } - - private static void PublishPlayerHealthChanged(HealthComponent playerHealth) - { - if (playerHealth == null || GameEntry.Event == null) return; - - GameEntry.Event.Fire(null, - PlayerHealthChangeEventArgs.Create(0, playerHealth.CurrentHealth, playerHealth.MaxHealth)); - } - - private static void AddSelectedBuffToPlayer(DRProp prop, int count) - { - Player player = FindPlayer(); - if (player == null || prop == null || prop.Modifiers == null) return; - - int applyCount = Mathf.Clamp(count, 1, 99); - for (int i = 0; i < applyCount; i++) - { - player.AddProp(new PropItem(prop.Modifiers, prop.Rarity, prop.Title, prop.IconAssetName)); - } - } - - private void HandleCornerTapGesture() - { - if (!TryGetTouchReleased(out Vector2 touchPosition)) return; - if (touchPosition.x > 80f || touchPosition.y < Screen.height - 80f) return; - - float now = Time.unscaledTime; - if (now - _lastCornerTapTime > CornerTapWindow) - { - _cornerTapCount = 0; - } - - _lastCornerTapTime = now; - _cornerTapCount++; - - if (_cornerTapCount >= RequiredCornerTapCount) - { - _cornerTapCount = 0; - _isPanelVisible = !_isPanelVisible; - } - } - - private static bool IsTogglePressed() - { -#if ENABLE_INPUT_SYSTEM - Keyboard keyboard = Keyboard.current; - if (keyboard == null) return false; - return keyboard.backquoteKey.wasPressedThisFrame || keyboard.f8Key.wasPressedThisFrame; -#else - return Input.GetKeyDown(KeyCode.BackQuote) || Input.GetKeyDown(KeyCode.F8); -#endif - } - - private static bool TryGetTouchReleased(out Vector2 touchPosition) - { -#if ENABLE_INPUT_SYSTEM - Touchscreen touchscreen = Touchscreen.current; - if (touchscreen == null) - { - touchPosition = default; - return false; - } - - var touch = touchscreen.primaryTouch; - if (!touch.press.wasReleasedThisFrame) - { - touchPosition = default; - return false; - } - - touchPosition = touch.position.ReadValue(); - return true; -#else - if (Input.touchCount <= 0) - { - touchPosition = default; - return false; - } - - Touch touch = Input.GetTouch(0); - if (touch.phase != TouchPhase.Ended) - { - touchPosition = default; - return false; - } - - touchPosition = touch.position; - return true; -#endif - } - } -} -#endif diff --git a/Assets/GameMain/Scripts/Runtime/CustomComponent/EnemyManager/EnemyManagerComponent.cs b/Assets/GameMain/Scripts/Runtime/CustomComponent/EnemyManager/EnemyManagerComponent.cs index 1cdc02f..449b03a 100644 --- a/Assets/GameMain/Scripts/Runtime/CustomComponent/EnemyManager/EnemyManagerComponent.cs +++ b/Assets/GameMain/Scripts/Runtime/CustomComponent/EnemyManager/EnemyManagerComponent.cs @@ -4,8 +4,6 @@ using SepCore.Definition; using Entity; using Entity.EntityData; using GameFramework.Event; -using Procedure; -using StarForce; using UnityEngine; using UnityGameFramework.Runtime; using Random = UnityEngine.Random; diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Common/AboutForm.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Common/AboutForm.meta new file mode 100644 index 0000000..7ff0367 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Common/AboutForm.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 710248cee26a898459031e4336703628 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData.meta new file mode 100644 index 0000000..e3dbc89 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de04e3a2f42efa84798cde2397f505db +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RoleItemRawData.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RoleItemRawData.cs new file mode 100644 index 0000000..f834915 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RoleItemRawData.cs @@ -0,0 +1,8 @@ +namespace UI +{ + public class RoleItemRawData + { + public int RoleId; + public string IconName; + } +} diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RoleItemRawData.cs.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RoleItemRawData.cs.meta new file mode 100644 index 0000000..014b1b8 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RoleItemRawData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bd682bb88cf9b8c4fac0fe7002d3646b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RolePropertyAreaRawData.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RolePropertyAreaRawData.cs new file mode 100644 index 0000000..394d4ca --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RolePropertyAreaRawData.cs @@ -0,0 +1,8 @@ +namespace UI +{ + public class RolePropertyAreaRawData + { + public string RoleName; + public string InitialPropertyText; + } +} diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RolePropertyAreaRawData.cs.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RolePropertyAreaRawData.cs.meta new file mode 100644 index 0000000..da73211 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Common/RawData/RolePropertyAreaRawData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3a582029cb4c5e5459ebe6d42335299f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Common/UseCase.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Common/UseCase.meta new file mode 100644 index 0000000..508a3e5 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Common/UseCase.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 476e0babdb10df1499873cc46eaaa41e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/DisplayItemInfoForm/DisplayItemInfoFormUseCase.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/DisplayItemInfoForm/DisplayItemInfoFormUseCase.cs index 1a8cfbe..9885ddd 100644 --- a/Assets/GameMain/Scripts/Runtime/UIBase/Main/DisplayItemInfoForm/DisplayItemInfoFormUseCase.cs +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/DisplayItemInfoForm/DisplayItemInfoFormUseCase.cs @@ -2,19 +2,18 @@ using SepCore.Definition; using Entity; using CustomUtility; using Entity.Weapon; -using Procedure; namespace UI { public class DisplayItemInfoFormUseCase : IUIUseCase { - private readonly ProcedureGame _procedureGame; + private readonly Player _player; - private Player Player => _procedureGame != null ? _procedureGame.Player : null; + private Player Player => _player; - public DisplayItemInfoFormUseCase(ProcedureGame procedureGame) + public DisplayItemInfoFormUseCase(Player player) { - _procedureGame = procedureGame; + _player = player; } public DisplayItemInfoFormRawData CreateModel(int index, bool isWeapon) @@ -72,4 +71,4 @@ namespace UI }; } } -} \ No newline at end of file +} diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/LevelUpForm/LevelUpFormUseCase.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/LevelUpForm/LevelUpFormUseCase.cs index e609a64..da9007a 100644 --- a/Assets/GameMain/Scripts/Runtime/UIBase/Main/LevelUpForm/LevelUpFormUseCase.cs +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/LevelUpForm/LevelUpFormUseCase.cs @@ -1,20 +1,20 @@ +using System; using System.Collections.Generic; using System.Linq; using SepCore.DataTable; using SepCore.Definition; using Entity; -using Procedure; -using UnityEngine; +using Random = UnityEngine.Random; using UnityGameFramework.Runtime; using CustomUtility; using GameFramework.DataTable; namespace UI { - internal class LevelUpFormUseCase : IUIUseCase + public class LevelUpFormUseCase : IUIUseCase { private const int BaseRefreshPrice = 2; - private readonly GameStateLevelUp _gameStateLevelUp; + private readonly Action _onCompleted; private readonly DRLevelUpReward[] _allRewards; private readonly IDataTable _levelRarityTable; private readonly Dictionary> _rewardsByRarity = new(); @@ -22,13 +22,13 @@ namespace UI private int _refreshCount; private LevelUpFormRawData _currentModel; - + private readonly Player _player; - public LevelUpFormUseCase(Player player, GameStateLevelUp gameStateLevelUp) + public LevelUpFormUseCase(Player player, Action onCompleted) { _player = player; - _gameStateLevelUp = gameStateLevelUp; + _onCompleted = onCompleted; _allRewards = GameEntry.DataTable.GetDataTable().ToArray(); _levelRarityTable = GameEntry.DataTable.GetDataTable(); @@ -39,7 +39,7 @@ namespace UI { _refreshCount = 0; - if (_gameStateLevelUp == null || _player.PendingLevelPoints <= 0) + if (_player == null || _player.PendingLevelPoints <= 0) { _currentModel = null; return null; @@ -90,7 +90,7 @@ namespace UI return _currentModel; } - _gameStateLevelUp.IsCompleted = true; + _onCompleted?.Invoke(); _currentModel = null; return null; } diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData.meta new file mode 100644 index 0000000..8659bd6 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f9cd57f1c1a63854e8ba23be83ead8b4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayItemRawData.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayItemRawData.cs new file mode 100644 index 0000000..e5c9777 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayItemRawData.cs @@ -0,0 +1,11 @@ +using SepCore.Definition; + +namespace UI +{ + public class DisplayItemRawData + { + public string IconAssetName; + public ItemRarity Rarity; + public bool IsWeapon; + } +} diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayItemRawData.cs.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayItemRawData.cs.meta new file mode 100644 index 0000000..67ba124 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayItemRawData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a8892ea402a6ca4b943466ac00676e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayListAreaRawData.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayListAreaRawData.cs new file mode 100644 index 0000000..c51be4b --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayListAreaRawData.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace UI +{ + public class DisplayListAreaRawData + { + public string Title; + public int CurrentCount; + public int MaxCount = -1; + public DisplayItemRawData[] ItemContexts; + } +} diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayListAreaRawData.cs.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayListAreaRawData.cs.meta new file mode 100644 index 0000000..f16c03f --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/DisplayListAreaRawData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 06d87c8d30eefa645b7d84c306bf2cb8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/GoodsItemRawData.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/GoodsItemRawData.cs new file mode 100644 index 0000000..9272b09 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/GoodsItemRawData.cs @@ -0,0 +1,15 @@ +using SepCore.Definition; +using UnityEngine; + +namespace UI +{ + public class GoodsItemRawData + { + public string Title; + public ItemRarity Rarity; + public string Type; + public Sprite Icon; + public string Description; + public int Price; + } +} diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/GoodsItemRawData.cs.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/GoodsItemRawData.cs.meta new file mode 100644 index 0000000..c14a700 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/GoodsItemRawData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9b9270fdc0ddab146bd3b5d9b2261a39 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/LevelUpRewardItemRawData.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/LevelUpRewardItemRawData.cs new file mode 100644 index 0000000..66e54a0 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/LevelUpRewardItemRawData.cs @@ -0,0 +1,14 @@ +using SepCore.Definition; +using UnityEngine; + +namespace UI +{ + public class LevelUpRewardItemRawData + { + public string Title; + public Sprite Icon; + public ItemRarity ItemRarity; + public string Description; + public string IconAssetName; + } +} diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/LevelUpRewardItemRawData.cs.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/LevelUpRewardItemRawData.cs.meta new file mode 100644 index 0000000..e10bec5 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/RawData/LevelUpRewardItemRawData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 56a75fb39cca45c4ea220af2c850e677 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormRawData.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormRawData.cs index 6d8c4ab..e0bda99 100644 --- a/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormRawData.cs +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormRawData.cs @@ -9,7 +9,7 @@ namespace UI public int CurrentLevel; public int RefreshPrice; public int PlayerCoin; - public List GoodsItems; + public List GoodsItems; public IReadOnlyList PropItems; public int PropMaxCount = -1; public IReadOnlyList WeaponItems; diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormUseCase.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormUseCase.cs index 4f76664..a1726f5 100644 --- a/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormUseCase.cs +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/ShopForm/ShopFormUseCase.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using SepCore.DataTable; @@ -6,30 +7,30 @@ 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 sealed class ShopRefreshResult { - public List GoodsItems; + public List GoodsItems; public int RefreshPrice; } - internal sealed class ShopPurchaseResult + public sealed class ShopPurchaseResult { public int GoodsIndex; - public DisplayItemContext DisplayItem; + public DisplayItemRawData DisplayItem; } - internal class ShopFormUseCase : IUIUseCase + public class ShopFormUseCase : IUIUseCase { - private readonly ProcedureGame _procedureGame; - private readonly GameStateShop _gameStateShop; - + private readonly Player _player; + private readonly int _currentLevel; + private readonly Action _onShopFinish; + private readonly DRGoods[] _allGoods; private readonly IDataTable _propDataTable; private readonly IDataTable _weaponDataTable; @@ -41,7 +42,7 @@ namespace UI private readonly List _selections = new(); private int _refreshTime; - private Player Player => _procedureGame.Player; + private Player Player => _player; private sealed class ShopGoodsSelection { @@ -50,10 +51,11 @@ namespace UI public int Price; } - public ShopFormUseCase(ProcedureGame procedureGame, GameStateShop gameStateShop) + public ShopFormUseCase(Player player, int currentLevel, Action onShopFinish) { - _procedureGame = procedureGame; - _gameStateShop = gameStateShop; + _player = player; + _currentLevel = currentLevel; + _onShopFinish = onShopFinish; _allGoods = GameEntry.DataTable.GetDataTable().ToArray(); _propDataTable = GameEntry.DataTable.GetDataTable(); _weaponDataTable = GameEntry.DataTable.GetDataTable(); @@ -67,12 +69,12 @@ namespace UI _refreshTime = 0; Player player = Player; - if (_procedureGame == null || player == null) + if (_player == null || player == null) { return null; } - int currentLevel = _procedureGame.CurrentLevel; + int currentLevel = _currentLevel; return new ShopFormRawData { CurrentLevel = currentLevel, @@ -89,14 +91,14 @@ namespace UI public ShopRefreshResult TryRefresh(int cost) { Player player = Player; - if (player == null || _procedureGame == null || player.Coin < cost) + if (player == null || _player == null || player.Coin < cost) { return null; } player.Coin -= cost; - int refreshPrice = (_refreshTime + 1) * _procedureGame.CurrentLevel; + int refreshPrice = (_refreshTime + 1) * _currentLevel; _refreshTime++; return new ShopRefreshResult @@ -127,7 +129,7 @@ namespace UI return null; } - DisplayItemContext displayItem = ApplyGoodsPurchase(selection); + DisplayItemRawData displayItem = ApplyGoodsPurchase(selection); if (displayItem == null) { return null; @@ -145,10 +147,10 @@ namespace UI public void Continue() { - _gameStateShop.ShopFinish = true; + _onShopFinish?.Invoke(); } - private List BuildRandomGoodsItems(int count) + private List BuildRandomGoodsItems(int count) { if (_allGoods == null || _allGoods.Length == 0) { @@ -157,10 +159,10 @@ namespace UI } int finalCount = Mathf.Min(count, _allGoods.Length); - List goodsItems = new List(finalCount); + List goodsItems = new List(finalCount); _selections.Clear(); - int currentLevel = _procedureGame != null ? _procedureGame.CurrentLevel : 1; + int currentLevel = _currentLevel > 0 ? _currentLevel : 1; for (int i = 0; i < finalCount; i++) { @@ -172,7 +174,7 @@ namespace UI break; } - GoodsItemContext goodsItem = new GoodsItemContext(); + GoodsItemRawData goodsItem = new GoodsItemRawData(); int price; if (drGoods.GoodsType == GoodsType.Prop) @@ -318,7 +320,7 @@ namespace UI return Mathf.Max(1, finalPrice); } - private DisplayItemContext ApplyGoodsPurchase(ShopGoodsSelection goods) + private DisplayItemRawData ApplyGoodsPurchase(ShopGoodsSelection goods) { if (goods == null || Player == null) { @@ -335,7 +337,7 @@ namespace UI } Player.AddProp(new PropItem(drProp.Modifiers, drProp.Rarity, drProp.Title, drProp.IconAssetName)); - return new DisplayItemContext + return new DisplayItemRawData { IconAssetName = drProp.IconAssetName, Rarity = drProp.Rarity, @@ -368,7 +370,7 @@ namespace UI GameEntry.Entity.ShowWeapon(weaponData); - return new DisplayItemContext + return new DisplayItemRawData { IconAssetName = drWeapon.IconAssetName, Rarity = drWeapon.Rarity, diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Main/UseCase.meta b/Assets/GameMain/Scripts/Runtime/UIBase/Main/UseCase.meta new file mode 100644 index 0000000..bc60095 --- /dev/null +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Main/UseCase.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 07fd450f557f928488983d5aff38ae8f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameMain/Scripts/Runtime/UIBase/Menu/SelectRoleForm/SelectRoleFormUseCase.cs b/Assets/GameMain/Scripts/Runtime/UIBase/Menu/SelectRoleForm/SelectRoleFormUseCase.cs index 7f5fd67..514d66e 100644 --- a/Assets/GameMain/Scripts/Runtime/UIBase/Menu/SelectRoleForm/SelectRoleFormUseCase.cs +++ b/Assets/GameMain/Scripts/Runtime/UIBase/Menu/SelectRoleForm/SelectRoleFormUseCase.cs @@ -1,8 +1,8 @@ +using System; using System.Text; using SepCore.DataTable; using GameFramework.DataTable; -using Procedure; -using UnityEngine; +using Random = UnityEngine.Random; namespace UI { @@ -10,13 +10,13 @@ namespace UI { private readonly IDataTable _roleDataTable; - private readonly ProcedureStartMenu _procedureStartMenu; + private readonly Action _onStartGame; public int SelectedRoleId { get; private set; } - public SelectRoleFormUseCase(ProcedureStartMenu procedureStartMenu) + public SelectRoleFormUseCase(Action onStartGame) { - _procedureStartMenu = procedureStartMenu; + _onStartGame = onStartGame; _roleDataTable = GameEntry.DataTable.GetDataTable(); } @@ -48,7 +48,7 @@ namespace UI bool result = SelectedRoleId >= 0; if (result) { - _procedureStartMenu.StartGame(SelectedRoleId); + _onStartGame?.Invoke(SelectedRoleId); } return result; @@ -96,4 +96,4 @@ namespace UI return sb.ToString(); } } -} \ No newline at end of file +} diff --git a/Assets/GameMain/VampireLike.asmdef b/Assets/GameMain/Scripts/VampireLike.asmdef similarity index 100% rename from Assets/GameMain/VampireLike.asmdef rename to Assets/GameMain/Scripts/VampireLike.asmdef diff --git a/Assets/GameMain/VampireLike.asmdef.meta b/Assets/GameMain/Scripts/VampireLike.asmdef.meta similarity index 100% rename from Assets/GameMain/VampireLike.asmdef.meta rename to Assets/GameMain/Scripts/VampireLike.asmdef.meta