public void OnDrop(PointerEventData eventData) { IncomeTower droppedTower = eventData.pointerDrag.GetComponent <IncomeTower>(); Debug.Log(this.name + " " + droppedTower.name); int combineCost = Mathf.RoundToInt((droppedTower.price + this.price) * 2.5f); if (droppedTower && _money.money >= combineCost) { _money.Buy(combineCost); CombineTowers(droppedTower); } }
public void ChooseTower(string towerName) { switch (towerName) { case "Unicorn": price = 100; projectileFireRate = 0.5f; projectileSpeed = 12f; projectileDamage = 16f; towerIndex = 0; break; case "Orange": price = 90; projectileFireRate = 2f; projectileSpeed = 16f; projectileDamage = 50f; towerIndex = 1; break; case "Wizard": price = 120; projectileFireRate = 0.2f; projectileSpeed = 40f; projectileDamage = 3f; towerIndex = 2; break; case "Trebuchet": price = 150; projectileFireRate = 4f; projectileSpeed = 7f; projectileDamage = 70f; towerIndex = 3; break; case "Sell": Money.Amount += price / 2; gameObject.GetComponent <Image>().sprite = TowerSprites[4]; ToggleMenu(); isBuilt = false; return; case "Upgrade": if (!Money.Buy(price * 0.2f)) { return; } price *= 1.2f; projectileFireRate = projectileFireRate * 0.9f; projectileSpeed = projectileSpeed * 1.1f; projectileDamage = projectileDamage * 1.1f; TowerRange.radius = TowerRange.radius * 1.1f; ToggleMenu(); return; } if (!Money.Buy(price)) { return; } Debug.Log("got here"); gameObject.GetComponent <Image>().sprite = TowerSprites[towerIndex]; ToggleMenu(); TowerRange.radius = RangeObject.transform.localScale[0] / 2; RangeObject.SetActive(false); isBuilt = true; }