Compare commits

..

No commits in common. "2a0f18491c16f6c9908b3bc1fd4654f957da785d" and "15a8e135df64906b63fab42d94610e5d150071be" have entirely different histories.

3 changed files with 11 additions and 17 deletions

View File

@ -13,10 +13,17 @@ public class GridManager : MonoBehaviour
[DoNotSerialize] public List<GameObject> SpawnedSlots = new();
/// <summary>
/// Not implimented
/// </summary>
[DoNotSerialize] public string[,] GridStates;
private void OnEnable()
{
TowerPlacementManager.OnSpawnGridRequested += SpawnSlots;
TowerPlacementManager.OnGridDeleteRequested += DeleteGrid;
GridStates = new string[GridSize.x, GridSize.y];
}
private void OnDisable()

View File

@ -93,7 +93,8 @@ public class TowerPlacementManager : MonoBehaviour
// slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
OnSelectSlot(slot);
SpawnTowerAtSelected(slot, SelectedTowerPrefab);
SpawnTowerAtSelected(SelectedTowerPrefab);
Debug.Log("TAX");
GameManager.Instance.Balance.Value -= SelectedTowerInfo.price;
}
@ -114,17 +115,13 @@ public class TowerPlacementManager : MonoBehaviour
prevSlot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.white;
}
public void SpawnTowerAtSelected(SlotManager slotRef, GameObject towerPrefab)
public void SpawnTowerAtSelected(GameObject towerPrefab)
{
var spawnedTower = Instantiate(towerPrefab, CurrentSelectedSlot.transform);
Quaternion newRotation = Quaternion.AngleAxis(CurrentRotation * 90f, transform.up);
spawnedTower.transform.localRotation = newRotation;
Tower towerScript = spawnedTower.GetComponent<Tower>();
slotRef.TowerHealth = towerScript.GetComponent<HealthComponent>();
towerScript.Placed();
spawnedTower.GetComponent<Tower>().Placed();
FinishBuild();
}

View File

@ -9,10 +9,6 @@ public class SlotManager : MonoBehaviour
public int x;
public int y;
public HealthComponent TowerHealth;
public bool IsOccupied => TowerHealth.TryGetComponent(out HealthComponent _);
public Transform TowerSpawnPoint;
/// <summary>
@ -25,22 +21,16 @@ public class SlotManager : MonoBehaviour
public void OnClick()
{
if (IsOccupied) return;
OnSlotClicked?.Invoke(this, spawnerRef, x, y);
}
public void OnHovered()
{
if (IsOccupied) return;
OnSlotHovered?.Invoke(this, spawnerRef, x, y);
}
public void OnUnHovered()
{
if (IsOccupied) return;
OnSlotUnHovered?.Invoke(this, spawnerRef, x, y);
}
}