Ejemplo n.º 1
0
    void DeactiveAllRanges()
    {
        GameObject[] landTurrets  = GameObject.FindGameObjectsWithTag("LandTurret");
        GameObject[] airTurrets   = GameObject.FindGameObjectsWithTag("AirTurret");
        GameObject[] combiTurrets = GameObject.FindGameObjectsWithTag("CombiTurret");

        foreach (GameObject oneTurret in landTurrets)
        {
            Turret temp = oneTurret.GetComponent <Turret>();
            temp.setMarket = false;
        }

        foreach (GameObject oneTurret in airTurrets)
        {
            Turret temp = oneTurret.GetComponent <Turret>();
            temp.setMarket = false;
        }

        foreach (GameObject oneTurret in combiTurrets)
        {
            CombiTurret temp = oneTurret.GetComponent <CombiTurret>();
            temp.setMarket = false;
        }

        stateManager.SetActiveTurret = "";
    }
Ejemplo n.º 2
0
    void DeactiveVisibleRange(string turretName)
    {
        if (string.Compare(turretName, "LandTurret(Clone)") == 0)
        {
            GameObject[] landTurrets = GameObject.FindGameObjectsWithTag("LandTurret");

            foreach (GameObject oneTurret in landTurrets)
            {
                Turret temp = oneTurret.GetComponent <Turret>();
                temp.setMarket = false;
            }
        }
        else if (string.Compare(turretName, "AirTurret(Clone)") == 0)
        {
            GameObject[] airTurrets = GameObject.FindGameObjectsWithTag("AirTurret");

            foreach (GameObject oneTurret in airTurrets)
            {
                Turret temp = oneTurret.GetComponent <Turret>();
                temp.setMarket = false;
            }
        }
        else
        {
            GameObject [] combiTurrets = GameObject.FindGameObjectsWithTag("CombiTurret");

            foreach (GameObject oneTurret in combiTurrets)
            {
                CombiTurret temp = oneTurret.GetComponent <CombiTurret>();
                temp.setMarket = false;
            }
        }
    }
Ejemplo n.º 3
0
    void ActiveVisibleRange(string turretName)
    {
        if (string.Compare(turretName, "LandTurret(Clone)") == 0)
        {
            DeactiveVisibleRange("AirTurret(Clone)");
            DeactiveVisibleRange("CombiTurret(Clone)");

            stateManager.SetActiveTurret = "land";

            GameObject[] landTurrets = GameObject.FindGameObjectsWithTag("LandTurret");

            foreach (GameObject oneTurret in landTurrets)
            {
                Turret temp = oneTurret.GetComponent <Turret>();
                temp.setMarket = true;
            }
        }
        else if (string.Compare(turretName, "AirTurret(Clone)") == 0)
        {
            DeactiveVisibleRange("LandTurret(Clone)");
            DeactiveVisibleRange("CombiTurret(Clone)");

            stateManager.SetActiveTurret = "air";

            GameObject[] airTurrets = GameObject.FindGameObjectsWithTag("AirTurret");

            foreach (GameObject oneTurret in airTurrets)
            {
                Turret temp = oneTurret.GetComponent <Turret>();
                temp.setMarket = true;
            }
        }
        else
        {
            DeactiveVisibleRange("AirTurret(Clone)");
            DeactiveVisibleRange("LandTurret(Clone)");

            stateManager.SetActiveTurret = "combi";

            GameObject[] combiTurrets = GameObject.FindGameObjectsWithTag("CombiTurret");

            foreach (GameObject oneTurret in combiTurrets)
            {
                CombiTurret temp = oneTurret.GetComponent <CombiTurret>();
                temp.setMarket = true;
            }
        }
    }
Ejemplo n.º 4
0
    public void BuildTurretOn(Node node)
    {
        if (!gridManager.noCoinsPlay)
        {
            if (gridManager.coinsAmount < turretToBuild.cost)
            {
                Debug.Log("Sorry, you have not enough coins");
                return;
            }
        }

        GameObject turret = (GameObject)Instantiate(turretToBuild.turretPrefab, node.GetBuildPosition(), Quaternion.identity);

        if (turretToBuild.turretPrefab.name == "AirTurret" || turretToBuild.turretPrefab.name == "CombiTurret")
        {
            Transform positionGameObject = turret.transform.Find("PointToRotate/MisslePositions");
            misslePosition = new Transform[positionGameObject.transform.childCount];

            for (int i = 0; i < misslePosition.Length; i++)
            {
                misslePosition[i] = positionGameObject.transform.GetChild(i);
            }

            foreach (Transform onePosition in misslePosition)
            {
                GameObject missleObject = (GameObject)Instantiate(misslePrefab, onePosition.position, onePosition.rotation);
                Destroy(onePosition.gameObject);
                missleObject.name             = "MissleDummy";
                missleObject.transform.parent = positionGameObject;
            }
        }

        //Turret turretScript = turret.GetComponent<Turret>();


        if (turretToBuild.turretPrefab.name == "LandTurret" || turretToBuild.turretPrefab.name == "AirTurret")
        {
            Turret turretScript = turret.GetComponent <Turret>();

            if (turretToBuild.turretPrefab.name == "LandTurret")
            {
                turretScript.counter    = landTurretCounter;
                turretScript.turretCost = turretToBuild.cost;
                landTurretCounter++;
            }
            else
            {
                turretScript.counter    = airTurretCounter;
                turretScript.turretCost = turretToBuild.cost;
                airTurretCounter++;
            }
        }
        else
        {
            CombiTurret combiTurretScript = turret.GetComponent <CombiTurret>();

            combiTurretScript.counter    = combiTurretCounter;
            combiTurretScript.turretCost = turretToBuild.cost;
            combiTurretCounter++;
        }


        if (!gridManager.noCoinsPlay)
        {
            gridManager.coinsAmount -= turretToBuild.cost;
        }


        node.turret = turret;
    }
Ejemplo n.º 5
0
    void WriteTextValues(GameObject turret, float rangeInPixel)
    {
        if (turret.name == "LandTurret(Clone)")
        {
            Turret turretScript = turret.GetComponent <Turret>();

            float enemyTime        = rangeInPixel / landEnemySpeed;
            float shootsPerSeconds = 1.0f / landFireRate;

            if (shootsPerSeconds < 1)
            {
                shootsPerSeconds = 1.0f / shootsPerSeconds;
            }

            int shootsOnEnemy = (int)(enemyTime / shootsPerSeconds);

            turretNameText.text           = "Name: LandTurret" + " " + turretScript.counter.ToString();
            turretTypeText.text           = "Type: Land";
            turretCostText.text           = "Cost: " + turretScript.turretCost.ToString();
            turretRangeText.text          = "Range: " + landRange.ToString();
            turretBulletFireRateText.text = "Bullet Fire Rate: " + landFireRate.ToString();
            turretMissleFireRateText.text = "Missile Fire Rate: ----";
            bulletDamageText.text         = "Bullet Damage: " + bulletDamage.ToString();
            missleDamageText.text         = "Missile Damage: ----";
            shootsInRangeText.text        = "Shoots in Range: " + shootsOnEnemy.ToString();
            damageOnEnemyText.text        = "Damage on Enemey: " + (shootsOnEnemy * bulletDamage).ToString();
        }
        else if (turret.name == "AirTurret(Clone)")
        {
            Turret turretScript = turret.GetComponent <Turret>();

            float enemyTime        = rangeInPixel / airEnemySpeed;
            float shootsPerSeconds = 1.0f / airFireRate;

            if (shootsPerSeconds < 1)
            {
                shootsPerSeconds = 1.0f / shootsPerSeconds;
            }

            int shootsOnEnemy = (int)(enemyTime / shootsPerSeconds);

            turretNameText.text           = "Name: AirTurret" + " " + turretScript.counter.ToString();
            turretTypeText.text           = "Type: Air";
            turretCostText.text           = "Cost: " + turretScript.turretCost.ToString();
            turretRangeText.text          = "Range: " + airRange.ToString();
            turretBulletFireRateText.text = "Bullet Fire Rate: ----";
            turretMissleFireRateText.text = "Missile Fire Rate: " + airFireRate.ToString();
            bulletDamageText.text         = "Bullet Damage: ----";
            missleDamageText.text         = "Missile Damage: " + missleDamage.ToString();
            shootsInRangeText.text        = "Shoots in Range: " + shootsOnEnemy.ToString();
            damageOnEnemyText.text        = "Damage on Enemey: " + (shootsOnEnemy * missleDamage).ToString();
        }
        else
        {
            CombiTurret turretScript = turret.GetComponent <CombiTurret>();

            float landEnemyTime = rangeInPixel / landEnemySpeed;
            float airEnemyTime  = rangeInPixel / airEnemySpeed;

            float landShootsPerSeconds = 1.0f / landFireRate;
            float airShootsPerSeconds  = 1.0f / airFireRate;

            if (landShootsPerSeconds < 1)
            {
                landShootsPerSeconds = 1.0f / landShootsPerSeconds;
            }

            if (airShootsPerSeconds < 1)
            {
                airShootsPerSeconds = 1.0f / airShootsPerSeconds;
            }

            int landShootsOnEnemy = (int)(landEnemyTime / landShootsPerSeconds);
            int airShootsOnEnemy  = (int)(airEnemyTime / airShootsPerSeconds);

            turretNameText.text           = "Name: CombiTurret" + " " + turretScript.counter.ToString();
            turretTypeText.text           = "Type: Combi";
            turretCostText.text           = "Cost: " + turretScript.turretCost.ToString();
            turretRangeText.text          = "Range: " + combiRange.ToString();
            turretBulletFireRateText.text = "Bullet Fire Rate: " + combiLandFireRate.ToString();
            turretMissleFireRateText.text = "Missile Fire Rate: " + combiAirFireRate.ToString();
            bulletDamageText.text         = "Bullet Damage: " + combiBulletDamage.ToString();
            missleDamageText.text         = "Missile Damage: " + combiMissleDamage.ToString();
            shootsInRangeText.text        = "Shoots in Range: Bullet: " + landShootsOnEnemy.ToString() + " / Missile: " + airShootsOnEnemy.ToString();
            damageOnEnemyText.text        = "Damage on Enemey: Land: " + (landShootsOnEnemy * bulletDamage).ToString() + " / Air: " + (airShootsOnEnemy * missleDamage).ToString();
        }
    }