/// <summary> /// Ends the coroutine and resets the buildingPreviewInstance and placementCoroutine to null /// </summary> private void EndPlaceBuildingCoroutine() { buildingPlacementIndicatorInstance.GetComponent <Building>().BuildingPlaced(); //Destroy(buildingPlacementIndicatorInstance.GetComponent<Rigidbody>()); buildingPlacementIndicatorInstance.GetComponent <BuildingPlacementIndicatorUpdate>().ResetMaterials(); buildingPlacementIndicatorInstance.GetComponent <BuildingPlacementIndicatorUpdate>().enabled = false; IncomeManager.GetInstance().SpendFunds(buildingPlacementIndicatorInstance.GetComponent <Building>().GetPrice()); buildingPlacementIndicatorInstance = null; StopCoroutine(placementCoroutine); placementCoroutine = null; }
private void ToggleButtonEnabled() { if (IncomeManager.GetInstance().GetFunds() >= house.GetUpgradePrice() && house.GetUpgradeLevel() < 1) { upgradeButton.interactable = true; } else { upgradeButton.interactable = false; } }
private void Upgrade() { if (IncomeManager.GetInstance().GetFunds() >= house.GetUpgradePrice()) { IncomeManager.GetInstance().SpendFunds(house.GetUpgradePrice()); house.Upgrade(); // For demo purposes, rework for multi-upgrade upgradeButton.GetComponentInChildren <Text>().text = "Upgrade Complete"; upgradeButton.interactable = false; } }
/// <summary> /// Sets all materials on the model to the valid material /// </summary> private void SetMaterialValid() { if (IncomeManager.GetInstance().CanSpendFunds(referencedBuilding.GetPrice())) { isValid = true; holoMtrl.SetColor("_BaseColor", valid); } else { isValid = false; Debug.LogWarning("Cannot afford building"); SetMaterialInvalid(); } }
private void Start() { referencedBuilding = GetComponent <Building>(); renderers = GetComponentsInChildren <Renderer>(); for (int i = 0; i < renderers.Length; ++i) { Material[] mats = renderers[i].materials; origMaterials.AddRange(mats); mats[0] = holoMtrl; renderers[i].materials = mats; } numColliding = 0; SetMaterialValid(); IncomeManager.GetInstance().OnMoneyChanged += MoneyChangedHandler; }
/// <summary> /// Add the amount specified by the funds variable to the player's total funds /// </summary> protected override void CustomRun() { IncomeManager.GetInstance().AddEventIncome(funds); }
private void OnDestroy() { IncomeManager.GetInstance().OnMoneyChanged -= MoneyChangedHandler; }