Esempio n. 1
0
 public void SpawnerFunction()
 {
     //Only allow spawning if object is a spawner
     //If object is named spawner
     if (gameObject.name.Contains("Spawner"))
     {
         //run down spawn timer
         timer -= Time.deltaTime;
         if (timer <= 0)
         {
             //randomise spawn
             range = Random.Range(0, 3);
             Debug.Log(range);
             if (range == 0)
             {
                 //create instance of dog
                 Animals.Dog dog = new Animals.Dog();
                 //Set spawn dog parameters
                 Cmd_SpawnDog(dog.name, dog.health, dog.color);
                 //reset timer
                 timer = 2f;
             }
             else if (range == 1)
             {
                 //create instance of cat
                 Animals.Cat cat = new Animals.Cat();
                 //Set spawn cat parameters
                 Cmd_SpawnCat(cat.name, cat.health, cat.color);
                 //reset timer
                 timer = 2f;
             }
         }
     }
 }
Esempio n. 2
0
    public void Cmd_SpawnCat(string aiName, int aiHealth, Color aiColor)
    {
        GameObject clone;

        Animals.Cat cat = new Animals.Cat();
        clone = Instantiate(baseAIPrefab, transform.position, transform.rotation);

        clone.transform.GetComponent <BaseAI>().aiName = aiName;
        clone.transform.GetComponent <BaseAI>().health = aiHealth;
        clone.transform.GetComponent <BaseAI>().color  = aiColor;

        clone.name = aiName;
        clone.GetComponent <Renderer>().material.color = aiColor;
    }