Beispiel #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        for (int i = 0; i < playerColors.Players; i++)
        {
            if (collision.collider.gameObject.name.Equals("Bleep" + i))
            {
                playerIndex = i;

                renderer.color   = RandomizeColor(playerColors.GetParticleColor(playerIndex), randColor);
                renderer.enabled = true;
                Destroy(collision.collider.gameObject);
            }
        }
    }
Beispiel #2
0
 void Shoot()
 {
     if (Time.time - lastShot > shootDelay)
     {
         lastShot = Time.time;
         var p = Instantiate(particle, particleSpawn.position + (Vector3)Random.insideUnitCircle * 0.2f, Quaternion.identity);
         p.name = "Bleep" + playerIndex;
         Destroy(p, 5f);
         var rig = p.GetComponent <Rigidbody2D>();
         rig.angularVelocity = 360f * Random.value;
         rig.velocity        = 2f * blob.velocity;
         var renderer = p.GetComponent <SpriteRenderer>();
         renderer.color = RandomizeColor(colors.GetParticleColor(playerIndex), 0.2f);
     }
 }