public void Upgrade() { EFeatureType upgradedFeature = EFeatureType.None; switch (featureType) { case EFeatureType.Village: upgradedFeature = EFeatureType.Town; break; case EFeatureType.Town: upgradedFeature = EFeatureType.City; break; } if (upgradedFeature != EFeatureType.None) { FeatureCosts selectedFeatureCost = homeRegion.FeatureCosts[upgradedFeature.ToString()]; if (selectedFeatureCost.VerifyCosts(homeRegion)) { FeatureType = upgradedFeature; BuildFeature(); } else { StartCoroutine(controller.FlashCursor()); } } }
public void OnPointerClick(PointerEventData eventData) { if (eventData.button == PointerEventData.InputButton.Left) { //Debug.Log("Clicked: " + gameObject.name); if (controller.CurrentFeature == EFeatureType.TradeRoute || controller.CurrentFeature == EFeatureType.Aqueduct) { StartCoroutine(controller.FlashCursor()); } else if (controller.CurrentFeature != EFeatureType.None) { FeatureCosts selectedFeatureCost = featureCosts[controller.CurrentFeature.ToString()]; Vector2 clickWorldPosition = Camera.main.ScreenToWorldPoint(eventData.position); RaycastHit hit; Physics.Raycast(clickWorldPosition, new Vector3(0, 0, 1), out hit, 1); if (selectedFeatureCost.VerifyCosts(this)) { if (controller.CurrentFeature != EFeatureType.Village && !hit.collider.name.Contains(controller.CurrentFeature.ToString())) { StartCoroutine(controller.FlashCursor()); return; } GameObject newFeature = Instantiate(featurePrefab, new Vector3(clickWorldPosition.x, clickWorldPosition.y, 0), Quaternion.identity); newFeature.name = controller.CurrentFeature.ToString(); newFeature.GetComponent <Feature>().SetUpFeature(this, controller.CurrentFeature, controller); newFeature.GetComponent <BoxCollider>().enabled = false; features.Add(newFeature.gameObject); controller.AddFeature(newFeature.GetComponent <Feature>()); } else { StartCoroutine(controller.FlashCursor()); } } } }