From 74dd3727f62603f64958790f9e588d47c8f000ff Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sat, 23 Dec 2023 03:14:14 +0000
Subject: [PATCH] Added player movement while drilling
---
Assets/Scripts/Managers/GameManager.cs | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs
index c7925d3..d4b9e44 100644
--- a/Assets/Scripts/Managers/GameManager.cs
+++ b/Assets/Scripts/Managers/GameManager.cs
@@ -59,8 +59,9 @@
}
public void CharacterDrill(ContactPoint2D contact, DrillDirection drillDirection)
{
- Vector3Int cellCoord = tilemap.transform.GetComponentInParent<GridLayout>().WorldToCell(contact.point);
- switch(drillDirection)
+ GridLayout grid = tilemap.transform.GetComponentInParent<GridLayout>();
+ Vector3Int cellCoord = grid.WorldToCell(contact.point);
+ switch (drillDirection)
{
case DrillDirection.Left:
cellCoord.x = cellCoord.x - 1;
@@ -72,7 +73,17 @@
cellCoord.y = cellCoord.y - 1;
break;
}
- tilemap.SetTile(cellCoord, null);
+
+ //Debug.Log("cellCoord: " + grid.CellToWorld(cellCoord));
+ //Debug.Log(tilemap.HasTile(cellCoord));
+ if (tilemap.HasTile(cellCoord))
+ {
+ tilemap.SetTile(cellCoord, null);
+ Vector3 moveToPosition = grid.CellToWorld(cellCoord);
+ moveToPosition.x += 0.5f;
+ moveToPosition.y += 0.5f;
+ CharacterEvents.characterDrillingToPosition.Invoke(moveToPosition);
+ }
}
public void GameLoaded()
{
--
Gitblit v1.10.0