Пример #1
0
    public void Die()
    {
        // var WaveSpawnerWave = WaveSpawnerObject.GetComponent<NS_WaveSpawner>();

        //  WaveSpawnerWave.EnemiesLeftOver.Remove(this.gameObject);
        isDead = true;
        NS_WaveSpawner.EnemiesInGame--;

        var score       = scoreObject.GetComponent <ScoreHolder>(); // reference to score manager
        var Achievement = AchievementObserver.GetComponent <MB_AchievementObserver>();

        NS_GameManager.Money += moneyRewarded;
        NS_GameManager.MoneyChanged(); //matthews function addition for money UI

        score.AddOrSubtractPoints();   // No need to actually put a number in there. The script handles that. :3

        a_Audio.clip = enemydeath;
        a_Audio.PlayOneShot(enemydeath);
        GameObject effect = (GameObject)Instantiate(deatheffect, transform.position, Quaternion.identity);

        Destroy(effect, 3f);
        Destroy(gameObject, 0.15f);

        Achievement.EnemyDeathNum++;                       // Increases the amount of enemies we killed...

        if (!Achievement.HasUnlockedEnemyDeathAchievement) // Did we meet the enemy achievement goal?
        {
            Achievement.CheckAchievements();
        }
    }
Пример #2
0
    public void SellTurret()
    {
        Scene CurrentScene = SceneManager.GetActiveScene();                                                                           // Gets the current scene

        if (CurrentScene.name == "NS_ProtoType 05" || CurrentScene.name == "MeteorLV2" || CurrentScene.name == "NS_MeteorxSandstorm") // Are we on the Meteor level?
        {
            if (turret.tag == "Turret")
            {
                var MeatyOre = GameObject.FindObjectOfType <NS_MeteorMovement>(); // Reference to the meteor script
                MeatyOre.Turrets.Remove(gameObject);                              // Removes self from turrets
            }
        }
        if (isUpgraded == false)
        {
            NS_GameManager.Money += turretBlueprint.GetSellAmount();
            NS_GameManager.MoneyChanged(); //matthews function addition for money UI
        }
        else if (isUpgraded == true)
        {
            NS_GameManager.Money += turretBlueprint.GetSellAmount() * 2;
            NS_GameManager.MoneyChanged(); //matthews function addition for money UI
        }

        GameObject sellEffect = (GameObject)Instantiate(sellParticle, GetBuildPosition(), Quaternion.identity);

        Destroy(sellEffect, 3f);
        a_Audio.clip = sold;
        a_Audio.PlayOneShot(sold);
        Destroy(turret);
        isUpgraded      = false;
        turretBlueprint = null;
    }
Пример #3
0
    public void UpgradeTurret()
    {
        if (turretBlueprint == null)
        {
            return;
        }

        if (NS_GameManager.Money < turretBlueprint.upgradecost)
        {
            a_Audio.clip = error;
            a_Audio.PlayOneShot(error);
            Debug.Log("Not enough money");
            return;
        }

        NS_GameManager.Money -= turretBlueprint.upgradecost;
        NS_GameManager.MoneyChanged(); //matthews function addition for money UI

        //deleting old turret
        Destroy(turret);

        //building new turret
        GameObject _turret = (GameObject)Instantiate(turretBlueprint.upgradedPrefab, GetBuildPosition(), Quaternion.identity);

        turret       = _turret;
        turretHealth = _turret.GetComponent <NS_Turret>().health / _turret.GetComponent <NS_Turret>().startHealth;
        a_Audio.clip = upgradeMade;
        a_Audio.PlayOneShot(upgradeMade);

        GameObject upgradeEffect = (GameObject)Instantiate(upgradeParticle, GetBuildPosition(), Quaternion.identity);

        Destroy(upgradeEffect, 3f);
        isUpgraded = true;
        Debug.Log("turret upgraded");
    }
Пример #4
0
    public IEnumerator SpawnWave()
    {
        if (waveNumber != waves.Length)
        {
            WaveNum.text = "Wave: " + (waveNumber + 1);

            NS_Wave wave = waves[waveNumber];
            // Is the second enemy type null?
            if (wave.enemy2 == null && wave.enemy3 == null)
            {
                EnemiesInGame = wave.count;                      // Then proceed as normal.
            }
            else if (wave.enemy2 != null && wave.enemy3 == null) // If it is,
            {
                EnemiesInGame = wave.count + wave.count2;        // Then add to wave.count
            }
            else if (wave.enemy2 != null && wave.enemy3 != null)
            {
                EnemiesInGame = wave.count + wave.count2 + wave.count3;
            }

            for (int i = 0; i < wave.count; i++) // Normal enemy
            {
                if (EnemiesInGame > 0)           // Are the enemies left greater than 0?
                {
                    SpawnEnemy(wave.enemy);
                    yield return(new WaitForSeconds(1f / wave.enemyspawnrate));

                    if (wave.enemy2 != null)
                    {
                        SpawnEnemy(wave.enemy2);
                        yield return(new WaitForSeconds(1f / wave.enemy2spawnrate));
                    }

                    if (wave.enemy3 != null)
                    {
                        SpawnEnemy(wave.enemy3);
                        yield return(new WaitForSeconds(1f / wave.enemy3spawnrate));
                    }
                    if (EnemiesInGame <= 0) // Are the enemies left equal to or less than 0?
                    {
                        break;
                    }
                }
            }

            waveNumber++;
            NS_GameManager.Money += waveMoney;
            NS_GameManager.MoneyChanged();
        }
    }
Пример #5
0
    public void Start()
    {
        Money = startMoney;

        a           = GameObject.Find("SceneManager").GetComponent <AudioSource>();
        waveSpawner = FindObjectOfType <NS_WaveSpawner>().gameObject;

        LevelCompleteImageThatIsStupid = GameObject.Find("LevelCompleteImage").GetComponent <Image>();

        MoneyUI = GameObject.Find("MoneyNum").GetComponent <Text>(); // Can't set it in the editor, so we have to use the other way...
        NS_GameManager.MoneyChanged();                               //matthews function addition for money UI

        Scene  currentScene = SceneManager.GetActiveScene();
        string sceneName    = currentScene.name;
    }
Пример #6
0
    public void RepairTurret()
    {
        if (turretBlueprint == null)
        {
            return;
        }

        if (NS_GameManager.Money < turretBlueprint.GetRepairAmount() || turretHealth == 1) //>= turret.GetComponent<NS_Turret>().startHealth)
        {
            a_Audio.clip = error;
            a_Audio.PlayOneShot(error);
            Debug.Log("Not enough money");
            return;
        }



        if (turretHealth < 1 && turretHealth > 0.5f)
        {
            NS_GameManager.Money -= turretBlueprint.GetRepairAmount();
            NS_GameManager.MoneyChanged();

            turret.GetComponent <NS_Turret>().health = turretStartingHealth;

            a_Audio.clip = upgradeMade;
            a_Audio.PlayOneShot(upgradeMade);

            GameObject repairEffect = (GameObject)Instantiate(repairParticle, GetBuildPosition(), Quaternion.identity);
            Destroy(repairEffect, 3f);
        }

        else if (turretHealth < 0.5f)
        {
            NS_GameManager.Money -= turretBlueprint.GetRepairAmount() * 2;
            NS_GameManager.MoneyChanged();

            turret.GetComponent <NS_Turret>().health = turretStartingHealth;

            a_Audio.clip = upgradeMade;
            a_Audio.PlayOneShot(upgradeMade);

            GameObject repairEffect = (GameObject)Instantiate(repairParticle, GetBuildPosition(), Quaternion.identity);
            Destroy(repairEffect, 3f);
        }
    }
Пример #7
0
    void BuildTurret(TurretBlueprint blueprint)
    {
        //  if (blueprint.prefab != null)
        //  {
        var achievement = AchievmentThingy.GetComponent <MB_AchievementObserver>();    // Initializes the achievment observer...

        if (blueprint == null)
        {
            return;
        }

        if (NS_GameManager.Money < blueprint.cost)
        {
            a_Audio.clip = error;
            a_Audio.PlayOneShot(error);
            Debug.Log("Not enough money");
            return;
        }

        NS_GameManager.Money -= blueprint.cost;
        NS_GameManager.MoneyChanged();     //matthews function addition for money UI

        GameObject _turret = (GameObject)Instantiate(blueprint.prefab, GetBuildPosition(), Quaternion.identity);

        turret = _turret;

        turretHealth = turret.GetComponent <NS_Turret>().health;    // _turret.GetComponent<NS_Turret>().startHealth;


        turretBlueprint = blueprint;
        achievement.TurretAchievementNum++;

        if (achievement.HasUnlockedTurretAchivement == false)
        {
            achievement.CheckAchievements();     // Checks achievement progress...
        }

        a_Audio.clip = turretplaced;
        a_Audio.PlayOneShot(turretplaced);
        Debug.Log("turret built");

        // }
    }
Пример #8
0
    public int EnemiesLeft;                                         // used for converting the list count into an int, it works better and idk why lol

    public IEnumerator SpawnWave()                                  // IEnumerator for spawning a wave.
    {
        var dialog = DialogSystem.GetComponent <MB_DialogSystem>(); // Use this in your script to reference the dialog system.

        if (waveNumber != waves.Length)
        {
            WaveNum.text = "Wave: " + (waveNumber + 1) + "/" + waves.Length;
            StartCoroutine(WaveTextEvent());
            if (IsTutorialLevel == false)
            {
                StartCoroutine(dialog.ShowTutorialDialog(DialogTips[Random.Range(0, DialogTips.Length)])); // Shows a random tutorial tip.
            }
            NS_Wave wave = waves[waveNumber];
            // Is the second enemy type null?
            if (wave.enemy2 == null && wave.enemy3 == null)
            {
                EnemiesInGame = wave.count;                      // Then proceed as normal.
            }
            else if (wave.enemy2 != null && wave.enemy3 == null) // If it is,
            {
                EnemiesInGame = wave.count + wave.count2;        // Then add to wave.count
            }
            else if (wave.enemy2 != null && wave.enemy3 != null) // Conditions for third enemy
            {
                EnemiesInGame = wave.count + wave.count2 + wave.count3;
            }

            for (int i = 0; i < wave.count; i++) // Enemy Spawning
            {
                //  if (EnemiesInGame > 0) // Are the enemies left greater than 0?
                // {
                SpawnEnemy(wave.enemy);
                yield return(new WaitForSeconds(1f / wave.enemyspawnrate));

                if (wave.enemy2 != null)
                {
                    SpawnEnemy(wave.enemy2);
                    yield return(new WaitForSeconds(1f / wave.enemy2spawnrate));
                }

                if (wave.enemy3 != null)
                {
                    SpawnEnemy(wave.enemy3);
                    yield return(new WaitForSeconds(1f / wave.enemy3spawnrate));
                }
                if (EnemiesInGame <= 15)                             // Are the enemies left equal to or less than 0?
                {
                    if (EnemiesLeft <= 0)                            //checks for enemies left in game
                    {
                        EnemiesLeftOver.RemoveAll((o) => o == null); //resets list, just a safety measure
                        break;
                    }
                    //    }
                }
            }

            //if (LastWaveNumber != waveNumber)
            //{
            //    EnemyDiag1 = false;
            //    EnemyDiag2 = false;
            //    EnemyDiag3 = false;
            //    EnemyDiag4 = false;
            //    MultipleEnemiesInAWaveDialog = false;
            //}

            StartCoroutine(EndWaveChecker());
            CheckDiags();
            waveNumber++;
            NS_GameManager.Money += waveMoney;
            NS_GameManager.MoneyChanged();
        }
    }