示例#1
0
    void SpawnEnemy()
    {
        if (spawnTimer < respawnDuration)
        {
            return;
        }

        int playerCount   = GetPlayerCount();
        int spawnCount    = 0;
        int maxSpawnCount = 5 + ((playerCount - 1) * 1);        // 1P: 5, 2P: 6, 3P: 7, 4P: 8
        int zombiesCount  = GameObject.FindGameObjectsWithTag("Enemy").Length;

        foreach (GameObject spawnPoint in spawnPoints)
        {
            // If zombies were spawned too many, just stop.
            if (zombiesCount >= maxZombies)
            {
                break;
            }

            // Check how many zombies are spawning once by player numbers
            else if (spawnCount >= maxSpawnCount)
            {
                break;
            }

            GameObject zombie = PhotonNetwork.Instantiate("Zombie", spawnPoint.transform.position, spawnPoint.transform.rotation, 0);

            float zombieHealth = currentHealth;
            float addtionalHP  = currentHealth * 0.5f;

            zombieHealth = zombieHealth + (addtionalHP * (playerCount - 1));
            zombie.GetComponent <HealthManager>().SetHealth(currentHealth);

            KillReward killReward = zombie.GetComponent <KillReward>();
            killReward.SetReward(currentEXP, currentFund);

            // Boost rotating speed
            float rotateSpeed = 120f + currentMoveSpeed;
            rotateSpeed = Mathf.Max(rotateSpeed, 200f);                 // Max 200f

            Chasing chasing = zombie.GetComponent <Chasing>();
            chasing.SetDamage(currentDamage);
            chasing.SetSpeed(currentMoveSpeed, rotateSpeed);

            spawnCount++;
            zombiesCount++;
        }

        spawnTimer = 0f;
    }
示例#2
0
    void SpawnEnemy()
    {
        if (spawnTimer < respawnDuration)
        {
            return;
        }

        int spawnCount    = 0;
        int maxSpawnCount = 5;
        int zombiesCount  = GameObject.FindGameObjectsWithTag("Enemy").Length;

        foreach (GameObject spawnPoint in spawnPoints)
        {
            // If zombies were spawned too many, just stop.
            //თუ ძალიან ბევრი ზომბია გაჩენილი უბრალოდ გაჩერდეს
            if (zombiesCount >= maxZombies)
            {
                break;
            }

            //შემოწმება თუ რამდენი ზომბი ხდება ერთდროულად მოთამაშის მიხედვით
            else if (spawnCount >= maxSpawnCount)
            {
                break;
            }

            GameObject zombie = Instantiate(zombiePrefab, spawnPoint.transform.position, spawnPoint.transform.rotation);

            zombie.GetComponent <HealthManager>().SetHealth(currentHealth);

            KillReward killReward = zombie.GetComponent <KillReward>();
            killReward.SetReward(currentEXP, currentFund);

            // Boost rotating speed
            float rotateSpeed = 120f + currentMoveSpeed;
            rotateSpeed = Mathf.Max(rotateSpeed, 200f);                 // Max 200f

            Chasing chasing = zombie.GetComponent <Chasing>();
            chasing.SetDamage(currentDamage);
            chasing.SetSpeed(currentMoveSpeed, rotateSpeed);

            spawnCount++;
            zombiesCount++;
        }

        spawnTimer = 0f;
    }
    void SpawnEnemy()
    {
        if (spawnTimer < respawnDuration)
        {
            return;
        }

        int spawnCount    = 0;
        int maxSpawnCount = 5;
        int zombiesCount  = GameObject.FindGameObjectsWithTag("Enemy").Length;

        foreach (GameObject spawnPoint in spawnPoints)
        {
            // If zombies were spawned too many, just stop.
            if (zombiesCount >= maxZombies)
            {
                break;
            }

            // Check how many zombies are spawning once by player numbers
            else if (spawnCount >= maxSpawnCount)
            {
                break;
            }

            GameObject zombie = Instantiate(zombiePrefab, spawnPoint.transform.position, spawnPoint.transform.rotation);

            zombie.GetComponent <HealthManager>().SetHealth(currentHealth);

            KillReward killReward = zombie.GetComponent <KillReward>();
            killReward.SetReward(currentEXP, currentFund);

            // Boost rotating speed
            float rotateSpeed = 120f + currentMoveSpeed;
            rotateSpeed = Mathf.Max(rotateSpeed, 200f);                 // Max 200f

            Chasing chasing = zombie.GetComponent <Chasing>();
            chasing.SetDamage(currentDamage);
            chasing.SetSpeed(currentMoveSpeed, rotateSpeed);

            spawnCount++;
            zombiesCount++;
        }

        spawnTimer = 0f;
    }