Fixed cursor issues
This commit is contained in:
@@ -1804,6 +1804,9 @@ MonoBehaviour:
|
||||
BuildingPreview: {fileID: 1194686692}
|
||||
CursorImage: {fileID: 1330313876}
|
||||
BuildingManager: {fileID: 2005593405}
|
||||
MinStrength: 0.5
|
||||
MaxStrength: 1.5
|
||||
Radius: 60
|
||||
CurrentMouseClickStrength: 0
|
||||
GridPosition: {x: 0, y: 0}
|
||||
SelectedBuildingToBuild:
|
||||
|
||||
@@ -11,9 +11,6 @@ namespace Fruitomation.UI
|
||||
{
|
||||
public class GameCursor : MonoBehaviour
|
||||
{
|
||||
private const float MIN_STRENGTH = 0.5f;
|
||||
private const float MAX_STRENGTH = 1.7f;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Camera ActiveCamera;
|
||||
[SerializeField] private CircleCollider2D CursorCollider;
|
||||
@@ -21,7 +18,12 @@ namespace Fruitomation.UI
|
||||
[SerializeField] private Image BuildingPreview;
|
||||
[SerializeField] private Image CursorImage;
|
||||
[SerializeField] private BuildingManager BuildingManager;
|
||||
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField] private float MinStrength = 0.5f;
|
||||
[SerializeField] private float MaxStrength = 1.5f;
|
||||
[SerializeField] private int Radius = 30;
|
||||
|
||||
[Header("Read Only")]
|
||||
[SerializeField, InspectorReadOnly] private float CurrentMouseClickStrength;
|
||||
[SerializeField, InspectorReadOnly] private Vector2Int GridPosition;
|
||||
@@ -75,8 +77,8 @@ namespace Fruitomation.UI
|
||||
|
||||
CursorImage.enabled = false;
|
||||
BuildingPreview.enabled = false;
|
||||
|
||||
CurrentMouseClickStrength = MIN_STRENGTH;
|
||||
|
||||
CurrentMouseClickStrength = MinStrength;
|
||||
switch (GameStateController.State)
|
||||
{
|
||||
case GameState.Simulation:
|
||||
@@ -98,7 +100,7 @@ namespace Fruitomation.UI
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
CurrentMouseClickStrength = Mathf.Clamp(CurrentMouseClickStrength, MIN_STRENGTH, MAX_STRENGTH);
|
||||
CurrentMouseClickStrength = Mathf.Clamp(CurrentMouseClickStrength, MinStrength, MaxStrength);
|
||||
|
||||
CalculateGridPosition();
|
||||
|
||||
@@ -111,9 +113,9 @@ namespace Fruitomation.UI
|
||||
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
CurrentMouseClickStrength = MIN_STRENGTH;
|
||||
CurrentMouseClickStrength = MinStrength;
|
||||
|
||||
CursorCollider.radius = CurrentMouseClickStrength * 30f;
|
||||
CursorCollider.radius = CurrentMouseClickStrength * Radius;
|
||||
Physics2D.OverlapCollider(CursorCollider, ContactFilter, Colliders);
|
||||
|
||||
foreach (Collider2D col in Colliders)
|
||||
@@ -130,7 +132,7 @@ namespace Fruitomation.UI
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
StartOfMouseClick = Time.time;
|
||||
CurrentMouseClickStrength = MIN_STRENGTH;
|
||||
CurrentMouseClickStrength = MinStrength;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@ namespace Fruitomation.UI
|
||||
|
||||
else
|
||||
{
|
||||
CurrentMouseClickStrength = MIN_STRENGTH;
|
||||
CurrentMouseClickStrength = MinStrength;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user