Exemple #1
0
    void spawn()
    {
        if (false) //debug
        {
            for (int i = 0; i < spawnLocations.Length; i++)
            {
                GameObject newZombie = Instantiate(zombie, spawnLocations[i], Quaternion.identity);

                moveToPlayer zombie_data  = newZombie.GetComponent <moveToPlayer>();
                zombieStats  zombie_stats = newZombie.GetComponent <zombieStats>();
                zombie_data.zombieSpeed = GlobalVar.instance.getSpawnSpeed();
                zombie_stats.health     = GlobalVar.instance.getHealth();
                zombie_stats.damage     = GlobalVar.instance.getDamage();
                zombie_data.zombieSpeed = 0.1f;
            }
        }
        else if (!GlobalVar.instance.bossMode)
        {
            int        randomNum   = (int)Random.Range(0f, spawnLocations.Length - 0.01f);
            float      randomSpeed = Random.Range(1f, 3f);
            GameObject newZombie   = Instantiate(zombie, spawnLocations[randomNum], Quaternion.identity);
            Debug.Log("Called");
            newZombie.GetComponent <AIDestinationSetter>().target = player;


            AIPath zombie_data = newZombie.GetComponent <AIPath>();
            zombie_data.maxSpeed = randomSpeed;


            zombieStats zombie_stats = newZombie.GetComponent <zombieStats>();
            zombie_stats.health = GlobalVar.instance.getHealth();
            zombie_stats.damage = GlobalVar.instance.getDamage();
        }
        else
        {
            if (!bossSpawned)
            {
                spawnBoss();
            }
            int        randomNum = (int)Random.Range(0f, bossSpawnLocations.Length - 0.01f);
            GameObject newZombie = Instantiate(zombie, bossSpawnLocations[randomNum], Quaternion.identity);


            newZombie.GetComponent <AIDestinationSetter>().target = player;


            AIPath zombie_data = newZombie.GetComponent <AIPath>();
            zombie_data.maxSpeed = 8f;


            zombieStats zombie_stats = newZombie.GetComponent <zombieStats>();
            zombie_stats.health = 1;
            zombie_stats.damage = 15;
        }
    }
Exemple #2
0
    void spawnBoss()
    {
        bossSpawned = true;
        bossObject  = Instantiate(boss, new Vector2(0, 0), Quaternion.identity);
        bossObject.GetComponent <AIDestinationSetter>().target = player;
        GlobalVar.instance.playerDamage = 1;
        AIPath boss_data = boss.GetComponent <AIPath>();

        boss_data.maxSpeed = 2.5f;
        zombieStats boss_stats = bossObject.GetComponent <zombieStats>();

        boss_stats.health = 150;
        boss_stats.damage = 30;
        GlobalVar.instance.bossSpawned = true;
        staticKillText.text            = "Boss:";
        GlobalVar.instance.updateStats = true;
    }