Compare commits

..

No commits in common. "60ca297352eb618abfd126ebf3332a058954a168" and "3b804215bc2cbcb785a99aec3f3e161c6f26cbd5" have entirely different histories.

1 changed files with 4 additions and 27 deletions

View File

@ -16,9 +16,7 @@ public class TowerPlacementManager : MonoBehaviour
// Section: Mouse // Section: Mouse
private SlotManager CurrentSelectedSlot; private SlotManager CurrentSelectedSlot;
private SlotManager CurrentHovered; // Not implemented private SlotManager CurrentHovered;
private int CurrentRotation = 0; // 0, 1, 2, 3
private GameObject SilhouettedObject; private GameObject SilhouettedObject;
@ -36,20 +34,6 @@ public class TowerPlacementManager : MonoBehaviour
OnSpawnGridRequested?.Invoke(this); OnSpawnGridRequested?.Invoke(this);
} }
private void Update()
{
if (Input.GetKeyDown(KeyCode.R) && Input.GetKey(KeyCode.LeftShift))
{
CurrentRotation--;
CurrentRotation = CurrentRotation % 4;
}
else if (Input.GetKeyDown(KeyCode.R))
{
CurrentRotation++;
CurrentRotation = CurrentRotation % 4;
}
}
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y) public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
{ {
slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue; slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
@ -77,9 +61,7 @@ public class TowerPlacementManager : MonoBehaviour
public void SpawnTowerAtSelected(GameObject towerPrefab) public void SpawnTowerAtSelected(GameObject towerPrefab)
{ {
var spawnedTower = Instantiate(towerPrefab, CurrentSelectedSlot.transform); Instantiate(towerPrefab, CurrentSelectedSlot.transform);
Quaternion newRotation = Quaternion.AngleAxis(CurrentRotation * 90f, transform.up);
spawnedTower.transform.localRotation = newRotation;
} }
public void OnSlotHovered(SlotManager slot, GridManager grid, int x, int y) public void OnSlotHovered(SlotManager slot, GridManager grid, int x, int y)
@ -87,15 +69,10 @@ public class TowerPlacementManager : MonoBehaviour
if (SilhouettedObject == null) if (SilhouettedObject == null)
SilhouettedObject = ToSilhouette(DebugTowerPrefab); SilhouettedObject = ToSilhouette(DebugTowerPrefab);
// Sets tower rotation
Quaternion newRotation = Quaternion.AngleAxis(CurrentRotation * 90f, transform.up);
SilhouettedObject.transform.localRotation = newRotation;
Vector3 offset = DebugTowerPrefab.transform.position;
//SilhouettedObject.SetActive(true); //SilhouettedObject.SetActive(true);
SilhouettedObject.transform.parent = slot.TowerSpawnPoint.transform; SilhouettedObject.transform.parent = slot.TowerSpawnPoint.transform;
SilhouettedObject.transform.localPosition = offset; SilhouettedObject.transform.localPosition = Vector3.zero;
SilhouettedObject.transform.localRotation = quaternion.identity;
} }
public void OnSlotUnHovered(SlotManager slot, GridManager grid, int x, int y) public void OnSlotUnHovered(SlotManager slot, GridManager grid, int x, int y)