public void Explode() { Assert.IsTrue(NetworkManager.IsServer); numAsteroids -= 1; var newSize = Size.Value - 1; if (newSize > 0) { int num = Random.Range(1, m_NumCreates + 1); for (int i = 0; i < num; i++) { int dx = Random.Range(0, 4) - 2; int dy = Random.Range(0, 4) - 2; Vector3 diff = new Vector3(dx * 0.3f, dy * 0.3f, 0); var go = m_ObjectPool.GetNetworkObject(NetworkObject.PrefabHash, transform.position + diff, Quaternion.identity); go.GetComponent <Asteroid>().Size.Value = newSize; go.GetComponent <NetworkObject>().Spawn(); go.GetComponent <Rigidbody2D>().AddForce(diff * 10, ForceMode2D.Impulse); } } NetworkObject.Despawn(); m_ObjectPool.ReturnNetworkObject(NetworkObject); }
void DestroyPowerUp() { AudioSource.PlayClipAtPoint(GetComponent <AudioSource>().clip, transform.position); numPowerups -= 1; NetworkObject.Despawn(); m_ObjectPool.ReturnNetworkObject(NetworkObject); }
private void DestroyBullet() { if (!NetworkObject.IsSpawned) { return; } Vector3 pos = transform.position; pos.z = -2; GameObject ex = Instantiate(explosionParticle, pos, Quaternion.identity); Destroy(ex, 0.5f); NetworkObject.Despawn(); m_PoolToReturn.ReturnNetworkObject(NetworkObject); }