예제 #1
0
        public static void Update()
        {
            foreach (var game_object in __GameObjects)
            {
                game_object?.Update();
            }

            //__Bullet?.Update();
            __Bullets.ForEach(b => b.Update());

            foreach (var bullet_to_remove in __Bullets.Where(b => b.Rect.Left > Width).ToArray())
            {
                __Bullets.Remove(bullet_to_remove);
            }

            for (var i = 0; i < __GameObjects.Length; i++)
            {
                var obj = __GameObjects[i];
                if (obj is ICollision)
                {
                    var collision_object = (ICollision)obj;

                    __Spaceship.CheckCollision(collision_object);

                    foreach (var bullet in __Bullets.ToArray())
                    {
                        if (bullet.CheckCollision(collision_object))
                        {
                            //__Bullet = null;
                            __Bullets.Remove(bullet);
                            __GameObjects[i] = null;
                            System.Media.SystemSounds.Beep.Play();
                        }
                    }
                }
            }
        }