diff --git a/Assets/GameMain/Scripts/CustomComponent/CombatNode/CombatScheduler/CombatScheduler.cs b/Assets/GameMain/Scripts/CustomComponent/CombatNode/CombatScheduler/CombatScheduler.cs index e0239ed..1ae7f10 100644 --- a/Assets/GameMain/Scripts/CustomComponent/CombatNode/CombatScheduler/CombatScheduler.cs +++ b/Assets/GameMain/Scripts/CustomComponent/CombatNode/CombatScheduler/CombatScheduler.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using GeometryTD.CustomEvent; using GeometryTD.DataTable; using GeometryTD.Definition; using GeometryTD.Entity; using GeometryTD.Procedure; -using GeometryTD.UI; using UnityEngine; using UnityGameFramework.Runtime; @@ -95,9 +93,8 @@ namespace GeometryTD.CustomComponent _runtime.NextDropOrdinal = 0; _runtime.NextRewardOrdinal = 0; _runtime.CombatRunResourceStore.InitializeForCombat(level); - for (int i = 0; i < phases.Count; i++) + foreach (var phase in phases) { - DRLevelPhase phase = phases[i]; if (phase != null) { _runtime.PhaseBuffer.Add(phase); @@ -115,7 +112,8 @@ namespace GeometryTD.CustomComponent _runtime.PhaseLoopRuntime.SetPhases(_runtime.PhaseBuffer); if (_runtime.PhaseLoopRuntime.PhaseCount <= 0) { - return _coordinator.HandleStartFailure($"CombatScheduler start failed. Level '{level.Id}' has no phase data."); + return _coordinator.HandleStartFailure( + $"CombatScheduler start failed. Level '{level.Id}' has no phase data."); } ChangeState(new CombatLoadingState(_runtime, _coordinator)); @@ -325,6 +323,5 @@ namespace GeometryTD.CustomComponent } #endregion - } -} +} \ No newline at end of file diff --git a/Assets/GameMain/Scripts/Entity/EntityLogic/CombatSelectInputService.cs b/Assets/GameMain/Scripts/Entity/EntityLogic/CombatSelectInputService.cs index 25a9245..913e607 100644 --- a/Assets/GameMain/Scripts/Entity/EntityLogic/CombatSelectInputService.cs +++ b/Assets/GameMain/Scripts/Entity/EntityLogic/CombatSelectInputService.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using GeometryTD.UI; using UnityEngine; +using UnityEngine.InputSystem; using UnityEngine.Tilemaps; namespace GeometryTD.Entity @@ -70,7 +71,14 @@ namespace GeometryTD.Entity return false; } - Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); + Mouse mouse = Mouse.current; + if (mouse == null) + { + return false; + } + + Vector2 pointerPosition = mouse.position.ReadValue(); + Ray ray = mainCamera.ScreenPointToRay(pointerPosition); float mapPlaneZ = tilemap != null ? tilemap.transform.position.z : (mapTransform != null ? mapTransform.position.z : 0f); @@ -84,7 +92,7 @@ namespace GeometryTD.Entity } worldPosition = ray.GetPoint(enterDistance); - screenPosition = BuildScreenPosition(Input.mousePosition); + screenPosition = BuildScreenPosition(pointerPosition); return true; } diff --git a/Assets/GameMain/Scripts/Entity/EntityLogic/MapEntity.cs b/Assets/GameMain/Scripts/Entity/EntityLogic/MapEntity.cs index fb04bf0..8c056cf 100644 --- a/Assets/GameMain/Scripts/Entity/EntityLogic/MapEntity.cs +++ b/Assets/GameMain/Scripts/Entity/EntityLogic/MapEntity.cs @@ -7,6 +7,7 @@ using GeometryTD.Entity.EntityData; using GeometryTD.UI; using UnityEngine; using UnityEngine.EventSystems; +using UnityEngine.InputSystem; using UnityEngine.Tilemaps; using UnityGameFramework.Runtime; @@ -15,17 +16,17 @@ namespace GeometryTD.Entity public class MapEntity : EntityBase { private const int DefaultTowerTypeId = 401; - + private static readonly Spawner[] EmptySpawners = Array.Empty(); [SerializeField] private bool _enableCombatSelectInput = true; - + [SerializeField] private int _towerTypeId = DefaultTowerTypeId; - + [SerializeField] private int[] _buildTowerCosts = { 40, 60, 60, 80 }; - + [SerializeField] private int _upgradeCost = 50; - + [SerializeField] private int _destroyGain = 40; private MapDataRefs _mapDataRefs; @@ -119,7 +120,7 @@ namespace GeometryTD.Entity } base.OnShow(_mapData); - + _combatRuntimeBridge?.Initialize(loadContext, name); RefreshTiles(); @@ -272,7 +273,8 @@ namespace GeometryTD.Entity private void HandleCombatSelectInput() { - if (!_enableCombatSelectInput || !Input.GetMouseButtonDown(0)) + Mouse mouse = Mouse.current; + if (!_enableCombatSelectInput || mouse == null || !mouse.leftButton.wasPressedThisFrame) { return; } diff --git a/Assets/GameMain/Scripts/UI/General/View/ItemDescForm.cs b/Assets/GameMain/Scripts/UI/General/View/ItemDescForm.cs index bae83a4..7d879b2 100644 --- a/Assets/GameMain/Scripts/UI/General/View/ItemDescForm.cs +++ b/Assets/GameMain/Scripts/UI/General/View/ItemDescForm.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using TMPro; using UnityEngine; +using UnityEngine.InputSystem; using UnityEngine.UI; using UnityGameFramework.Runtime; @@ -39,7 +40,7 @@ namespace GeometryTD.UI [SerializeField] private float _sideGap = 16f; [SerializeField] private float _anchorItemWidth = 0f; - + private readonly List _runtimeTagItems = new List(); private ItemDescFormContext _context; @@ -78,7 +79,7 @@ namespace GeometryTD.UI { base.OnOpen(userData); _isOpened = true; - + if (!(userData is ItemDescFormContext context)) { Log.Error("ItemDescFormContext is invalid."); @@ -360,24 +361,27 @@ namespace GeometryTD.UI private static bool TryGetPointerDownScreenPosition(out Vector2 screenPoint) { - if (Input.touchCount > 0) + Touchscreen touchscreen = Touchscreen.current; + if (touchscreen != null) { - for (int i = 0; i < Input.touchCount; i++) + var touches = touchscreen.touches; + for (int i = 0; i < touches.Count; i++) { - Touch touch = Input.GetTouch(i); - if (touch.phase != TouchPhase.Began) + var touch = touches[i]; + if (!touch.press.wasPressedThisFrame) { continue; } - screenPoint = touch.position; + screenPoint = touch.position.ReadValue(); return true; } } - if (Input.GetMouseButtonDown(0)) + Mouse mouse = Mouse.current; + if (mouse != null && mouse.leftButton.wasPressedThisFrame) { - screenPoint = Input.mousePosition; + screenPoint = mouse.position.ReadValue(); return true; }