use new input system
This commit is contained in:
parent
a38a8d4b39
commit
1422db3b19
|
|
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue