Пример #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;
             }
         }
     }
 }
Пример #2
0
    //Use Cmd to allow server side spawning
    public void Cmd_SpawnDog(string aiName, int aiHealth, Color aiColor)
    {
        GameObject clone;

        //create instance of dog variable, allows access to variables
        Animals.Dog dog = new Animals.Dog();
        clone = Instantiate(baseAIPrefab, transform.position, transform.rotation);
        //Set clone varaibles to that of a dogs for script
        clone.transform.GetComponent <BaseAI>().aiName = aiName;
        clone.transform.GetComponent <BaseAI>().health = aiHealth;
        clone.transform.GetComponent <BaseAI>().color  = aiColor;
        //Set clones name
        clone.name = aiName;
        //set clone color
        clone.GetComponent <Renderer>().material.color = dog.color;
    }
Пример #3
0
 static void Main(string[] args)
 {
     var sparky = new Animals.Dog();
     var rio    = new Mammals.Dog();
 }