Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MenuTower : MonoBehaviour
- {
- private bool showMenu = false;
- public TowerController tower;
- void Start()
- {
- tower = GetComponent<TowerController>();
- }
- private void OnMouseDown()
- {
- showMenu = true;
- }
- private void OnGUI()
- {
- if (showMenu)
- {
- Vector3 pos = new Vector3(transform.position.x,
- transform.position.y, transform.position.z);
- Vector3 crd = Camera.main.WorldToScreenPoint(pos);
- crd.y = Screen.height - crd.y;
- GUI.Box(new Rect(crd.x - 150, crd.y - 100, 310, 200),
- $"Управление башней {gameObject.name}");
- GUI.Label(new Rect(crd.x - 140, crd.y - 100, 290, 160),
- $"Уровень: {tower.level}\nУрон: {tower.damage}\n" +
- $"Скорость: {tower.speed}\n" +
- $"Радиус: {tower.radius}\n" +
- $"Стоимость улучшения: {tower.priceUpgrade}\n" +
- $"Стоимость продажи: {tower.priceSell}");
- if (GUI.Button(new Rect(crd.x - 145, crd.y + 20, 290, 20),
- "Купить улучшение"))
- {
- if (GameSystem.Money >= tower.priceUpgrade)
- {
- GameSystem.Money -= tower.priceUpgrade;
- tower.LevelUp();
- }
- }
- if (GUI.Button(new Rect(crd.x - 145, crd.y + 40, 290, 20),
- "Продать башню"))
- {
- GameSystem.Money += tower.priceSell;
- Destroy(gameObject);
- showMenu = false;
- }
- if (GUI.Button(new Rect(crd.x - 145, crd.y + 70, 290, 20),
- "Закрыть меню"))
- {
- showMenu = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement