// Use this for initialization
 void Start()
 {
     rotation    = transform.rotation.eulerAngles.y;
     speed       = 10;
     life        = 30;
     currentLife = 30;
     towerLife   = (TowerLifeBar)GameObject.Find("TowerLife").GetComponent("TowerLifeBar");
     buyMenuAux  = (BuyingMenu)GameObject.Find("Player").GetComponent("BuyingMenu");
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        cityInfo    = cityInfoObj.GetComponent <Text>();
        buyingMenu  = buyMenuObj.GetComponent <BuyingMenu>();
        compassText = compassTextObj.GetComponent <Text>();

        windDir = Random.Range(0, 359);
        compass.transform.Rotate(0, 0, -windDir);
        UpdateWind();
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        //RGB
        color.x = 0; //Red
        color.y = 1; //Green
        color.z = 0; //Blue

        life        = 300;
        currentLife = 300;

        barScale      = transform.localScale.x;
        buyingMenuAux = (BuyingMenu)GameObject.Find("Player").GetComponent("BuyingMenu");
    }
    // Update is called once per frame
    void Update()
    {
        buyingMenu.text = 0;
        Ray        radius = mainCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit collision;

        child = transform.GetChild(0);
        if (Physics.Raycast(radius, out collision, Mathf.Infinity))
        {
            SetTransform(collision.point.x, 9 + transform.lossyScale.y / 2, collision.point.z);

            create = true;
            int qntFilhos = transform.childCount;
            int i;

            for (i = 0; i < qntFilhos; i++)
            {
                Transform currentChild = transform.GetChild(i);
                if (Physics.Raycast(currentChild.position, -Vector3.up, out collision, Mathf.Infinity))
                {
                    if (collision.point.y < 8.9f || collision.point.y > 9.1f)
                    {
                        create = false;
                        break;
                    }
                }
            }

            if (create)
            {
                lastClickTime = 0;
                catchTime     = 25;
                if (Input.GetMouseButtonDown(0))
                {
                    if (Time.time - lastClickTime < catchTime)
                    {
                        tower             = this.gameObject;
                        towerAux          = (GameObject)Instantiate(tower, transform.position, transform.rotation);
                        buyingMenu        = (BuyingMenu)GameObject.Find("Player").GetComponent("BuyingMenu");
                        buyingMenu.money -= price;
                        towerAux.tag      = text;
                        Destroy(gameObject);
                    }
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        priceAux.text = 0;
        Ray radius = mainCamera.ScreenPointToRay(Input.mousePosition);

        RaycastHit collision;

        child = transform.GetChild(0);
        if (Physics.Raycast(radius, out collision, Mathf.Infinity))
        {
            transform.position = new Vector3(collision.point.x, 9f + transform.lossyScale.y / 2, collision.point.z);
            canCreate          = true;
            int childCount = transform.childCount;
            int i;
            for (i = 0; i < childCount; i++)
            {
                Transform childObj = transform.GetChild(i);
                if (Physics.Raycast(childObj.position, -Vector3.up, out collision, Mathf.Infinity))
                {
                    if (collision.point.y > -15.9f || collision.point.y < -16.1f)
                    {
                        canCreate = false;
                        break;
                    }
                }
            }
            if (canCreate)
            {
                lastClickTime = 0;
                catchTime     = 25;
                if (Input.GetMouseButtonDown(0))
                {
                    Vector3 instancePos = new Vector3(transform.position.x, 16.0f, transform.position.z);
                    towerAux        = (GameObject)Instantiate(tower, transform.position, transform.rotation);
                    priceAux        = (BuyingMenu)GameObject.Find("Player").GetComponent("BuyingMenu");
                    priceAux.money -= price;
                    Destroy(gameObject);
                }

                if (Input.GetMouseButtonDown(1))
                {
                    Destroy(gameObject);
                }
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     mainCamera = Camera.main;
     create     = false;
     buyingMenu = (BuyingMenu)GameObject.Find("Player").GetComponent("BuyingMenu");
 }