/// <summary> /// Replace the powerup elsewhere. /// </summary> private void Respawn() { // Move up to root level transform.parent = transform.parent.parent; transform.rotation = Quaternion.identity; transform.position = SpawnController.FindFreeLocation(4); EnablePickup(true); }
/// <summary> /// Go boom and respawn /// </summary> /// <param name="other">Object that entered the area</param> internal void OnTriggerEnter2D(Collider2D other) { GetComponent <AudioSource>().Play(); ScoreManager.IncreaseScore(other.gameObject, -20); Instantiate(ExplosionPrefab, transform.position, Quaternion.identity); // Respawn transform.position = SpawnController.FindFreeLocation(2); }
/// <summary> /// Run toward the goal /// </summary> /// <param name="tank">Tank being controlled</param> /// <returns>True if behavior wants to keep running</returns> public override bool Tick(AITankControl tank) { while (WallBetween(tank.transform.position, goal)) { goal = SpawnController.FindFreeLocation(1); } if (Vector3.Distance(goal, tank.transform.position) > 1) { tank.MoveTowards(goal); return(true); } else { return(false); } }
/// <summary> /// Teleport the player /// </summary> public override void Fire() { transform.parent.GetComponent <Rigidbody2D>().MovePosition(SpawnController.FindFreeLocation(2)); PowerUpDone(); }