Beispiel #1
0
    void SpawnPuppy()
    {
        if (waitToSpawnPupsTimer < waitToSpawnPupsTime)
        {
            waitToSpawnPupsTimer += Time.deltaTime;
            return;
        }

        if (puppySpawnTimer >= puppySpawnTime)
        {
            puppySpawnTimer = 0f;
            if (inactivePups.Count > 0)
            {
                PuppyEnemy newPup = inactivePups[0];
                inactivePups.RemoveAt(0);
                activePups.Add(newPup);
                InitializePup(newPup);
            }
            else
            {
                GameObject newPup    = (GameObject)Instantiate(puppyPrefab, transform.position, Quaternion.identity);
                PuppyEnemy pupScript = newPup.GetComponent <PuppyEnemy>();
                InitializePup(pupScript);
            }
        }

        puppySpawnTimer += Time.deltaTime;
    }
Beispiel #2
0
    void InitializePup(PuppyEnemy pup)
    {
        int     randInt   = Random.Range(0, 2);
        Vector3 direction = crossVector;

        if (randInt == 0)
        {
            direction = -direction;
        }
        pup.InitializeWithVector(direction, this.gameObject);
        pup.Reset();
    }
Beispiel #3
0
 public void PupIsDestroyed(PuppyEnemy pup)
 {
     activePups.Remove(pup);
     inactivePups.Add(pup);
     pup.gameObject.SetActive(false);
 }