void DropOrbs() { if (canUseWeapon0) { OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity); orb.weaponIndex = 0; orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[0]); orb.Drop(); } if (canUseWeapon1) { OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity); orb.weaponIndex = 1; orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[1]); orb.Drop(); } if (canUseWeapon2) { OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity); orb.weaponIndex = 2; orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[2]); orb.Drop(); } if (canUseWeapon3) { OrbScript orb = Instantiate <OrbScript>(orbPrefab, transform.position + new Vector3(Random.Range(0f, 0.5f), 0.8f, Random.Range(0f, 0.5f)), Quaternion.identity); orb.weaponIndex = 3; orb.GetComponent <MeshRenderer>().material.SetColor("_Color", grid.colors[3]); orb.Drop(); } }
void OnDestroy() { if (orb != null) { orb.gameObject.GetComponent <MeshRenderer>().enabled = true; orb.Drop(); } if (!isQuitting && !grid.resetting) { GameObject rubble = Instantiate(rubblePrefab, transform.position, Quaternion.identity); rubble.GetComponentInChildren <SpriteRenderer>().color = transform.Find("Base").GetComponent <SpriteRenderer>().color; } }