Ejemplo n.º 1
0
    public bool CanBuildTower(TowerType towerType)
    {
        if (gold < CostForTower(towerType))
        {
            messageDisplay.DisplayTimedMessage("Not enough gold!", 10f);
            return(false);
        }

        var towers = FindObjectsOfType <Tower>();

        foreach (var tower in towers)
        {
            var towerPosition = tower.transform.position;
            towerPosition.y = 0;
            var golfBallPosition = golfBall.position;
            golfBallPosition.y = 0;

            if (Vector3.Distance(towerPosition, golfBallPosition) < MINIMUM_TOWER_BUILD_RADIUS)
            {
                messageDisplay.DisplayTimedMessage("Too close to another tower", 10f);
                return(false);
            }
        }

        var spawnNetworks = FindObjectsOfType <PathingNetwork>();

        foreach (var spawnNetwork in spawnNetworks)
        {
            var spawnNodes = spawnNetwork.GetComponentsInChildren <Transform>();
            foreach (var node in spawnNodes)
            {
                var nodePosition = node.transform.position;
                nodePosition.y = 0;
                var golfBallPosition = golfBall.position;
                golfBallPosition.y = 0;

                if (Vector3.Distance(nodePosition, golfBallPosition) < MINIMUM_NODE_BUILD_RADIUS)
                {
                    messageDisplay.DisplayTimedMessage("Too close to an enemy pathing node!", 10f);
                    return(false);
                }
            }
        }

        return(true);
    }
Ejemplo n.º 2
0
    WaitForSeconds DisplayTimedMessage(string text, float duration)
    {
        if (SceneManager.GetActiveScene().name == "Debug" || fastText)
        {
            duration /= 4f;
        }

        messageDisplay.DisplayTimedMessage(text, duration);
        return(new WaitForSeconds(duration));
    }
Ejemplo n.º 3
0
    IEnumerator SpawnWaves()
    {
        int largeSpawn = 0;
        int giantSpawn = 0;

        while (elapsedTime < 60f)
        {
            elapsedTime += 1.75f;
            yield return(new WaitForSeconds(1.75f));

            SpawnEnemy(1, pathingNetwork);
        }

        messageDisplay.DisplayTimedMessage("Egads! There are larger ones now!", 10f);

        while (elapsedTime < 120f)
        {
            elapsedTime += 1.5f;
            yield return(new WaitForSeconds(1.5f));

            if (largeSpawn == 0)
            {
                SpawnEnemy(2, pathingNetwork);
            }
            else
            {
                SpawnEnemy(1, pathingNetwork);
            }

            largeSpawn = (largeSpawn + 1) % 4;
        }

        messageDisplay.DisplayTimedMessage("Giant goblins?! Has the world gone mad?!", 10f);

        while (elapsedTime < 180f)
        {
            elapsedTime += 1.25f;
            yield return(new WaitForSeconds(1.25f));

            if (giantSpawn == 0)
            {
                SpawnEnemy(3, pathingNetwork);
            }
            else if (largeSpawn == 0)
            {
                SpawnEnemy(2, pathingNetwork);
            }
            else
            {
                SpawnEnemy(1, pathingNetwork);
            }

            largeSpawn = (largeSpawn + 1) % 3;
            giantSpawn = (giantSpawn + 1) % 12;
        }

        messageDisplay.DisplayTimedMessage("Watch out Your Majesty! They now approach on the other side as well!!", 10f);

        while (elapsedTime < 240f)
        {
            elapsedTime += 1f;
            yield return(new WaitForSeconds(1f));

            if (giantSpawn == 0)
            {
                SpawnEnemy(3, pathingNetwork);
            }
            else if (largeSpawn == 0)
            {
                SpawnEnemy(2, pathingNetwork);
            }
            else
            {
                SpawnEnemy(1, pathingNetwork);
            }

            SpawnEnemy(1, pathingNetwork2);

            largeSpawn = (largeSpawn + 1) % 2;
            giantSpawn = (giantSpawn + 1) % 10;
        }

        messageDisplay.DisplayTimedMessage("They're giving it all they've got!", 10f);

        while (elapsedTime < 360f)
        {
            elapsedTime += 0.8f;
            yield return(new WaitForSeconds(0.8f));

            if (giantSpawn == 0)
            {
                SpawnEnemy(3, pathingNetwork);
                SpawnEnemy(3, pathingNetwork2);
            }
            else if (largeSpawn == 0)
            {
                SpawnEnemy(2, pathingNetwork);
                SpawnEnemy(2, pathingNetwork2);
            }
            else
            {
                SpawnEnemy(1, pathingNetwork);
                SpawnEnemy(1, pathingNetwork2);
            }

            largeSpawn = (largeSpawn + 1) % 2;
            giantSpawn = (giantSpawn + 1) % 8;
        }

        musicSource.clip = tutorialMusic;
        musicSource.Play();

        messageDisplay.DisplayTimedMessage("I believe we have them defeated! Hooray! Congratulations!", 10f);

        yield return(new WaitForSeconds(10f));

        messageDisplay.DisplayIndefiniteMessage("(You win! Thanks for playing. Feel free to continue by pressing P.)");

        while (!(Input.GetKeyUp(KeyCode.P)))
        {
            yield return(null);
        }

        messageDisplay.DisplayIndefiniteMessage("");

        while (true)
        {
            elapsedTime += 0.7f;
            yield return(new WaitForSeconds(0.7f));

            if (giantSpawn == 0)
            {
                SpawnEnemy(3, pathingNetwork);
                SpawnEnemy(3, pathingNetwork2);
            }
            else if (largeSpawn == 0)
            {
                SpawnEnemy(2, pathingNetwork);
                SpawnEnemy(2, pathingNetwork2);
            }
            else
            {
                SpawnEnemy(1, pathingNetwork);
                SpawnEnemy(1, pathingNetwork2);
            }

            largeSpawn = (largeSpawn + 1) % 2;
            giantSpawn = (giantSpawn + 1) % 6;
        }
    }