Ejemplo n.º 1
0
    void Raycast()
    {
        RaycastHit hit;

        if (pointer.holder.activeSelf)
        {
            Physics.Raycast(pointer.pointer.transform.position, pointer.pointer.transform.forward, out hit);
            if (hit.collider.tag == unbuildTowerTag && buttons.triggerPressed)
            {
                if (sn.GetBalance() >= buyCost)
                {
                    Transform  parent = hit.transform.parent.parent;
                    Vector3    pos    = hit.transform.parent.position;
                    Quaternion rot    = hit.transform.parent.rotation;

                    Destroy(hit.transform.parent.gameObject);

                    string selectedHouse = PlayerPrefs.GetString("house");
                    //selectedHouse = "serpents";

                    int i = 0;
                    if (i == 0)
                    {
                        GameObject.Find("IntroWave").GetComponent <introWave>().ExternalInput("TowerBuilt");
                        i++;
                    }

                    switch (selectedHouse)
                    {
                    case "dragons":
                        Instantiate(towerDragons, pos, rot, parent);
                        break;

                    case "serpents":
                        Instantiate(towerSerpents, pos, rot, parent);
                        break;

                    case "vikings":
                        Instantiate(towerVikings, pos, rot, parent);
                        break;

                    case "ravens":
                        Instantiate(towerRavens, pos, rot, parent);
                        break;
                    }
                    sn.BuyTower(buyCost);
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Raycast()
    {
        RaycastHit hit;

        if (pointer.holder.activeSelf)
        {
            Physics.Raycast(pointer.pointer.transform.position, pointer.pointer.transform.forward, out hit);
            if (hit.collider.tag == towerTag && buttons.triggerPressed)
            {
                if (sn.GetBalance() >= upgradeCost)
                {
                    Turret t = hit.transform.GetComponentInChildren <Turret>();
                    t.UpgradeTurret();
                    sn.BuyTower(upgradeCost);
                }
            }
        }
    }