Beispiel #1
0
        /// <summary>
        /// Mise à jour avant les waits
        /// </summary>

        public void Updating()
        {
            // attente que les deux players soientt prêt
            if (State == PlayStates.ChooseGamepadP1andP2)
            {
                // on continue a faire un scroll lent mais on affiche aucun autre sprte a part le texte "press start" et waiting for p2"
                ScrollX += 0.5f;

                return;
            }

            if (State != PlayStates.Quit)
            {
                if (opa.IsAlive && opa.IsDying == false)
                {
                    ScrollX += opa.Speed;
                }

                if (frameDucks > (60 * 8))
                {
                    frameDucks = 0;

                    const int duckCount = 4;
                    var       step      = machine.Screen.BoundsClipped.Height / (duckCount + 1);

                    for (int y = 0; y < duckCount; y++)
                    {
                        this.ducks.GetFreeSprite().Born(step + y * step);
                    }
                }
                else
                {
                    frameDucks++;
                }

                if (frameFlies > (60 * 12))
                {
                    frameFlies = 0;

                    var centerY = (machine.Screen.BoundsClipped.Height - 16) / 2;

                    this.flies.GetFreeSprite().Born(0, centerY);

                    this.flies.GetFreeSprite().Born(20, centerY - 8);
                    this.flies.GetFreeSprite().Born(20, centerY + 8);

                    this.flies.GetFreeSprite().Born(40, centerY - 16);
                    this.flies.GetFreeSprite().Born(40, centerY);
                    this.flies.GetFreeSprite().Born(40, centerY + 16);

                    this.flies.GetFreeSprite().Born(60, centerY - 24);
                    this.flies.GetFreeSprite().Born(60, centerY - 8);
                    this.flies.GetFreeSprite().Born(60, centerY + 8);
                    this.flies.GetFreeSprite().Born(60, centerY + 24);
                }
                else
                {
                    frameFlies++;
                }

                // il y a un ordre dans les Updated
                // selon que les sprites soient créees par d'autres sprites : par exemple bomb est crée par opa, baby par mothers, ...
                opa.Updated();

                ammos.Updated();
                bombs.Updated();

                mothers.Updated();
                babies.Updated();
                ducks.Updated();
                flies.Updated();
                bullets.Updated();

                mothers.CheckCollision(opa, CollisionStrategies.RectIntersect);
                babies.CheckCollision(opa, CollisionStrategies.RectIntersect);
                ducks.CheckCollision(opa, CollisionStrategies.RectIntersect);
                flies.CheckCollision(opa, CollisionStrategies.RectIntersect);
                bullets.CheckCollision(opa, CollisionStrategies.RectIntersect);
                coins.CheckCollision(opa, CollisionStrategies.RectIntersect);

                ammos.CheckCollision(mothers, CollisionStrategies.RectIntersect);
                ammos.CheckCollision(babies, CollisionStrategies.RectIntersect);
                ammos.CheckCollision(ducks, CollisionStrategies.RectIntersect);
                ammos.CheckCollision(flies, CollisionStrategies.RectIntersect);

                bombs.CheckCollision(mothers, CollisionStrategies.RectIntersect);
                bombs.CheckCollision(babies, CollisionStrategies.RectIntersect);
                bombs.CheckCollision(ducks, CollisionStrategies.RectIntersect);
                bombs.CheckCollision(flies, CollisionStrategies.RectIntersect);


                // Mise à jour des coins car appeler par les collisions
                coins.Updated();
                // Mise à jour de Kaboom à la fin car les collisions peuvent l'appeler
                kabooms.Updated();

                // Quit le GameOver au bout d'un certain temps si le player n'a pas appuyé sur son choix (retry, exit)

                if (this.Player == Players.Solo || this.multiPage.State == MultiPlayPage.MultiStates.GameOver)
                {
                    if (State == PlayStates.GameOver)
                    {
                        if (frameGameOver == 60 * 20)
                        {
                            // il ne passera qu'une seule fois
                            frameGameOver++;
                            this.machine.StopWait(false);

                            this.Quit();
                        }
                        else
                        {
                            frameGameOver++;
                        }
                    }
                }
            }
        }