Example #1
0
    internal void SpawnDebrisAt(int x, int y)
    {
        for (int sy = 0; sy < 2; sy++)
        {
            for (int sx = 0; sx < 2; sx++)
            {
                var inst = debrisPrefab.Alloc();
                inst.transform.position = new Vector2(x + sx * 0.5f, y + sy * 0.5f);



                inst.rigidbody.AddForce(new Vector3((float)rand.NextDouble() - 0.5f * 50, 300, 0));
                if (y > height - 1)               //hacky whatever
                {
                    inst.GetComponent <SpriteRenderer> ().sprite = debrisSprites [0];
                }
                else
                {
                    inst.GetComponent <SpriteRenderer> ().sprite = debrisSprites [1];
                }



                float c = (float)rand.NextDouble() * 0.25f + 0.65f;
                inst.GetComponent <SpriteRenderer> ().color = new Color(c, c, c);
            }
        }
    }