protected override void Die() { ABR_Asteroid asteroid = GetComponent <ABR_Asteroid>(); asteroid.ReleaseItem(); asteroid.Perish(); }
/// <summary> /// Places a game object acquired from an object pool at an approximate location specified by the user. /// </summary> /// <param name="objectToSpawn">A pick up selected from a pool of pick ups.</param> private void SpawnObjectAtRandomLocation(GameObject objectToSpawn) { float x = Random.Range(-m_spawningArea.x, m_spawningArea.x); float y = Random.Range(-m_spawningArea.y, m_spawningArea.y); Vector3 targetLocation = new Vector3(x, y, 0.0f); DebugLog("Spawning " + objectToSpawn.name + " @ " + targetLocation); objectToSpawn.SetActive(true); objectToSpawn.transform.position = targetLocation; objectToSpawn.tag = ABR_Tags.AsteroidTag; ///Change later ABR_Asteroid asteroid = objectToSpawn.GetComponent <ABR_Asteroid>(); if (asteroid) { asteroid.GetComponent <Rigidbody2D>().velocity = Random.insideUnitCircle * asteroid.maxSpeed; GameObject pickup = ABR_GlobalInfo.WeaponPickupManager.GetObjectFromTaggedPool(RandomEnumValue <eBulletType>().ToString()); asteroid.AddItem(pickup); } }
private void OnTriggerExit2D(Collider2D other) { ABR_Ship ship = other.GetComponent <ABR_Ship>(); if (ship != null) { runaways.Add(ship); NotificationReciever notificationReciever = ship.GetComponent <NotificationReciever>(); if (notificationReciever != null) { notificationReciever.Notify("Lost Control"); } } else { ABR_Asteroid asteroid = other.GetComponent <ABR_Asteroid>(); if (asteroid) { other.gameObject.SetActive(false); } } }