Beispiel #1
0
        public void RigidUpdate(GameTime gt)
        {
            //Update inputs.
            Input.Update();

            if (StaticValues.Close)
            {
                StaticValues.SaveHighscores();

                Exit();
            }

            //Update stars.
            stars.Update(cam);

            AnimationManager.Update(gt);

            //Update menus.
            mm.Update(cam, gt);

            if (StaticValues.Gamestate == 1)
            {
                cam.SetPos(0, 0);
            }

            if (TargetElapsedTime == TimeSpan.FromSeconds(1f / 240))
            {
                cam.SetPos(0, 0);
            }

            //Update old inputs.
            Input.OldUpdate();
        }
Beispiel #2
0
        public void Update(GameTime gt, ref Ship ship, ref List <Highscore> scores)
        {
            int num = 180 - (int)health;

            phase = (int)Math.Floor(num / 60.0) + 1;

            if (ai)
            {
                AI(gt, ref ship);
            }
            else if (intro)
            {
                Intro();
            }

            foreach (Missile missile in missiles)
            {
                missile.Update(ref ship);
            }

            for (int i = bullets.Count - 1; i >= 0; i--)
            {
                bullets[i].Update();

                if (bullets[i].hitbox.Intersects(ship.hitbox))
                {
                    ship.Damage(1);

                    bullets.RemoveAt(i);
                }
            }

            for (int i = ship.bullets.Count - 1; i >= 0; i--)
            {
                if (ship.bullets[i].hitbox.Intersects(hitbox))
                {
                    Damage(1);
                    ship.bullets.Remove(ship.bullets[i]);
                }
            }

            if (health <= 0)
            {
                AnimationManager.Play(hitbox.X, hitbox.Y + 64, "bigExplode");
                SoundManager.PlaySound("bigExplode");
                dead = true;

                scores.Add(new Highscore(10000000, (int)pos.X + 200, (int)pos.Y + 300));

                StaticValues.highscore += 10000000;

                StaticValues.SaveHighscores();
            }

            if (bbullet != null && bbullet.ready)
            {
                hole.Update(ref ship, gt);
            }

            base.Update();
        }