コード例 #1
0
ファイル: Debris.cs プロジェクト: 517752548/Planetaria
 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);
 }
コード例 #2
0
ファイル: Turret.cs プロジェクト: 517752548/Planetaria
        private void Update()
        {
            Vector3 rail_position    = turret.forward;
            Vector3 bullet_direction = turret.up;

            if (DebrisNoirsInput.firing() && satellite.alive()) // if firing and not dead
            {
                PlanetariaGameObject.Instantiate(projectile, rail_position, bullet_direction);
            }
        }
コード例 #3
0
        public static void expand(int capacity) // TODO: CONSIDER: For future versions, deleting an object and creating two for every object pool increment may get around the draw call dynamic batching "bug" (might be intended behaviour) -- where ~120 draw calls become ~20 (behaviour I personally expected) for the same number of objects but only after several destruction and instantiation calls.
        {
            int large_rocks_to_spawn = Mathf.Max(0, capacity - object_pool.Count);

            for (int spawned_root_node = 0; spawned_root_node < large_rocks_to_spawn; spawned_root_node += 1)
            {
                // Yeah, this is hardcoded boilerplate, but it gets the job done (rather than coding a recursive function for levels 1,2,3)

                // Large

                PlanetariaGameObject game_object = PlanetariaGameObject.Instantiate(DebrisSpawner.self().large_debris, Vector3.forward, Vector3.up);
                Debris large = game_object.GetComponent <Debris>();
                object_pool.Add(large); // add the root node only

                // Medium

                game_object = PlanetariaGameObject.Instantiate(DebrisSpawner.self().medium_debris, Vector3.forward, Vector3.up);
                Debris medium1 = game_object.GetComponent <Debris>();
                large.left_debris = medium1;

                game_object = PlanetariaGameObject.Instantiate(DebrisSpawner.self().medium_debris, Vector3.forward, Vector3.up);
                Debris medium2 = game_object.GetComponent <Debris>();
                large.right_debris = medium2;

                // Small

                game_object = PlanetariaGameObject.Instantiate(DebrisSpawner.self().small_debris, Vector3.forward, Vector3.up);
                Debris small1 = game_object.GetComponent <Debris>();
                medium1.left_debris = small1;

                game_object = PlanetariaGameObject.Instantiate(DebrisSpawner.self().small_debris, Vector3.forward, Vector3.up);
                Debris small2 = game_object.GetComponent <Debris>();
                medium1.right_debris = small2;

                game_object = PlanetariaGameObject.Instantiate(DebrisSpawner.self().small_debris, Vector3.forward, Vector3.up);
                Debris small3 = game_object.GetComponent <Debris>();
                medium2.left_debris = small3;

                game_object = PlanetariaGameObject.Instantiate(DebrisSpawner.self().small_debris, Vector3.forward, Vector3.up);
                Debris small4 = game_object.GetComponent <Debris>();
                medium2.right_debris = small4;

                // Disable game objects until they are needed

                large.gameObject.SetActive(false);
                medium1.gameObject.SetActive(false);
                medium2.gameObject.SetActive(false);
                small1.gameObject.SetActive(false);
                small2.gameObject.SetActive(false);
                small3.gameObject.SetActive(false);
                small4.gameObject.SetActive(false);
            }
        }
コード例 #4
0
ファイル: DebrisSpawner.cs プロジェクト: 517752548/Planetaria
        private void spawn_debris()
        {
            Vector3 satellite_position = satellite.position;

            for (int debris = 0; debris < debris_to_spawn; debris += 1)
            {
                Vector3 random_position = UnityEngine.Random.onUnitSphere;
                if (Vector3.Dot(random_position, satellite_position) > 0)
                {
                    random_position *= -1;
                }
                DebrisNoirs.live(PlanetariaGameObject.Instantiate(large_debris, random_position));
            }
        }
コード例 #5
0
ファイル: Turret.cs プロジェクト: mattrdowney/planetaria
        private void Update()
        {
            Vector3 rail_position    = turret.forward;
            Vector3 bullet_direction = turret.up;

            if (DebrisNoirsInput.firing() && satellite.alive()) // if firing and not dead
            {
                if (projectiles_on_screen.Count < 14)           // FIXME: MAGIC NUMBER - number of bullets spawned per second
                {
                    PlanetariaGameObject spawned_projectile = PlanetariaGameObject.Instantiate(projectile, rail_position, bullet_direction);
                    projectiles_on_screen.Add(spawned_projectile.internal_game_object.GetComponent <Projectile>());
                }
                else
                {
                    projectiles_on_screen[next_projectile_to_reuse].respawn(rail_position, bullet_direction);
                    next_projectile_to_reuse += 1;
                    if (next_projectile_to_reuse >= 14)
                    {
                        next_projectile_to_reuse -= 14;
                    }
                }
            }
        }