public bool destroy_asteroid() { if (has_collided) { return(false); } score_keeper.add(points); if (spawned_debris != null) { for (int space_rock = 0; space_rock < 2; ++space_rock) { PlanetariaGameObject game_object = PlanetariaGameObject.Instantiate(spawned_debris, planetaria_transform.position, planetaria_transform.direction); Debris debris = game_object.GetComponent <Debris>(); debris.speed = this.speed; DebrisNoirs.live(game_object); // while asteroid revenge velocity (targetting satellite) is an interesting idea, // I don't think it's necessary (or would fully work as intended for that matter - it might be exploitable). // The game will probably be hard enough head/joystick controls // (and pros will still make mistakes eventually, even if its because of sleep deprivation) } } DebrisNoirs.die(this.gameObject); PlanetariaGameObject.Destroy(this.gameObject); return(true); }
public static void heat_death() { foreach (PlanetariaGameObject game_object in debris) { PlanetariaGameObject.Destroy(game_object); } debris.Clear(); }
public void die() { foreach (Projectile projectile in projectiles_on_screen) { PlanetariaGameObject.Destroy(projectile.gameObject, 1f); } projectiles_on_screen.Clear(); next_projectile_to_reuse = 0; }
// while I do like the idea of raycasting in update, that would require PlanetariaColliders or hacking my current raycast implementation, so true-to-original it is // Also, raycasting would be broken with relative projectile velocities public void OnTriggerEnter(Collider collider) { if (!has_collided) // make sure one projectile doesn't collide with 2+ debris. { Debris debris = collider.GetComponent <Debris>(); if (debris.destroy_asteroid()) // make sure two projectiles don't collide with the same debris (wasting one of them). { PlanetariaGameObject.Destroy(this.gameObject); has_collided = true; } } }
public static void heat_death() { foreach (Debris debris in object_pool) { PlanetariaGameObject.Destroy(debris . left_debris . left_debris . gameObject); PlanetariaGameObject.Destroy(debris . left_debris . right_debris . gameObject); PlanetariaGameObject.Destroy(debris . left_debris . gameObject); PlanetariaGameObject.Destroy(debris . right_debris . left_debris . gameObject); PlanetariaGameObject.Destroy(debris . right_debris . right_debris . gameObject); PlanetariaGameObject.Destroy(debris . right_debris . gameObject); PlanetariaGameObject.Destroy(debris . gameObject); } object_pool.Clear(); // The object pool stores the root objects (and medium/small debris implicitly) debris.Clear(); // Debris stores active debris on-screen }
void Start() { // set velocity planetaria_rigidbody.relative_velocity = new Vector2(0, speed); PlanetariaGameObject.Destroy(this.gameObject, lifetime); }