public void DoAction()
    {
        Splittable cube = gameObject.GetComponent <Splittable> ();

        if (cube)
        {
            cube.Split();
        }
        Spawner spawn = gameObject.GetComponent <Spawner> ();

        if (spawn)
        {
            spawn.Spawn();
        }
        Sweeper sweep = gameObject.GetComponent <Sweeper> ();

        if (sweep)
        {
            sweep.Sweep();
        }
        Shotgun shotgun = gameObject.GetComponent <Shotgun> ();

        if (shotgun)
        {
            shotgun.Shoot();
        }
    }
 public void Split()
 {
     if (splitsLeft > 0) {
         splitsLeft--;
         Splittable[] children = new Splittable[numChildren];
         for (int i = 0; i < numChildren; i++) {
             children [i] = Instantiate (this, generateNewPosition(), new Quaternion()) as Splittable;
             children[i].transform.localScale = transform.localScale + new Vector3(-.8f,-.8f,-.8f);
         }
     }
     Destroy (gameObject);
 }
Exemple #3
0
 public void Split()
 {
     if (splitsLeft > 0)
     {
         splitsLeft--;
         Splittable[] children = new Splittable[numChildren];
         for (int i = 0; i < numChildren; i++)
         {
             children [i] = Instantiate(this, generateNewPosition(), new Quaternion()) as Splittable;
             children[i].transform.localScale = transform.localScale + new Vector3(-.8f, -.8f, -.8f);
         }
     }
     Destroy(gameObject);
 }