public void AttemptToPlace() { if (!GameManager.instance.TryTakeMoney(attemptingToPlace.cost)) { CleanCursor(); return; } Placeable placeable = onCursor.GetComponent <Placeable>(); TeamEnum team = GameManager.instance.currentTeam; if (placeable.GetType() == typeof(Building)) { Building building = (Building)placeable; building.Place(team); } else { placeable.Place(team); } SetShader("Standard", onCursor.transform.GetChild(0).gameObject); attemptingToPlace = null; }
public void SetPlaceableOnCursor(string name) { attemptingToPlace = Array.Find(buildingMenu, mapping => mapping.buildingName == name); onCursor = Instantiate(attemptingToPlace.buildingPrefab); SetShader(highlightShader, onCursor.transform.GetChild(0).gameObject); }
void CleanCursor() { Destroy(onCursor); attemptingToPlace = null; }