예제 #1
0
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            if (!endGame)
            {
                wingFlaps += angel.Update(currentLevel.walls);

                #region Lol glitch
                if (angel.position.Y > 2000 && currentLevel.type != Level.Type.EasterEgg)
                {
                    currentLevel.type = Level.Type.EasterEgg;
                    currentLevel.fore = null;
                    ChangeSong();
                }
                #endregion

                #region Update collectables
                foreach (Cat c in currentLevel.cats)
                {
                    if (angel.hitBox.Intersects(c.hitBox) && !c.hit)
                    {
                        c.hit = true;
                        catCount++;
                        if (currentLevel == levels[8, 10])
                        {
                            if (goTime)
                            {
                                creditsMus.Play();
                                endGame = true;
                                break;
                            }
                        }
                        meow.Play(0.4F, 0.0F, 0.0F);
                    }
                    c.Update();
                }

                if (currentLevel.gem != null)
                {
                    if (angel.hitBox.Intersects(currentLevel.gem.hitBox) && !currentLevel.gem.taken)
                    {
                        currentLevel.gem.taken = true;
                        getGem.Play();
                        foreach (ElectricFence e in finalFences)
                        {
                            if (e.color == currentLevel.gem.color)
                            {
                                e.isDeadly = false;
                                break;
                            }
                        }
                        gemExplosion = new Explosion(new Vector2(currentLevel.gem.hitBox.X, currentLevel.gem.hitBox.Y), currentLevel.gem.color, explosionTexture);
                    }
                    currentLevel.gem.Update();
                }
                #endregion

                if (deathExplosion != null)
                {
                    deathExplosion.Update();
                }
                if (gemExplosion != null)
                {
                    gemExplosion.Update();
                }

                #region Update obstacles
                bool check = true;
                foreach (DeathWall o in currentLevel.deathWalls)
                {
                    if (o.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (FallingRock o in currentLevel.rocks)
                {
                    o.Update();
                    if (o.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (ElectricFence e in currentLevel.fences)
                {
                    e.Update();
                    if (e.index < currentLevel.timers.Count)
                    {
                        e.isDeadly = !currentLevel.timers[e.index].activated;
                    }
                    if (e.hitBox.Intersects(angel.hitBox))
                    {
                        if (e.isDeadly)
                        {
                            KillAngel();
                            check = false;
                            continue;
                        }
                    }
                }
                if (currentLevel.coordinates.X == 0 && currentLevel.coordinates.Y == 10)
                {
                    foreach (ElectricFence e in finalFences)
                    {
                        e.Update();
                        if (e.index < currentLevel.timers.Count)
                        {
                            e.isDeadly = !currentLevel.timers[e.index].activated;
                        }
                        if (e.hitBox.Intersects(angel.hitBox))
                        {
                            if (e.isDeadly)
                            {
                                KillAngel();
                                check = false;
                                continue;
                            }
                        }
                    }
                }
                foreach (SpinningPlasma o in currentLevel.plasmas)
                {
                    o.Update();
                    if (o.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (RocketLauncher r in currentLevel.launchers)
                {
                    if (r.explosion != null)
                    {
                        r.explosion.Update();
                    }
                    if (r.Update(angel, currentLevel.walls, currentLevel.links, rocketLaunch))
                    {
                        r.explosion = new Explosion(new Vector2(r.rocket.hitBox.X, r.rocket.hitBox.Y), Color.OrangeRed, explosionTexture);
                        explode.Play(0.5f, 0.0f, 0.0f);
                        if (angel.hitBox.Intersects(r.rocket.hitBox))
                        {
                            KillAngel();
                            check = false;
                        }
                        r.pause             = 0;
                        r.rocket.position.X = -10000;
                        r.rocket.position.Y = -10000;
                    }
                }
                foreach (Bubbles b in currentLevel.bubbles)
                {
                    b.Update();
                    if (angel.hitBox.Intersects(b.hitBox))
                    {
                        if (b.motion.X > 0 && angel.motion.X < b.motion.X ||
                            b.motion.X < 0 && angel.motion.X > b.motion.X ||
                            b.motion.Y < 0 && angel.motion.Y > b.motion.Y ||
                            b.motion.Y > 0 && angel.motion.Y < b.motion.Y)
                        {
                            angel.motion += Vector2.Normalize(b.motion) * b.motion.Length() / 10;
                        }
                    }
                }
                foreach (Starfish s in currentLevel.starfish)
                {
                    s.Update(currentLevel.walls, currentLevel.links);
                    if (s.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (Fish s in currentLevel.fish)
                {
                    s.Update(angel, currentLevel.walls, currentLevel.fish);
                    if (s.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                #endregion

                #region Update timers and buttons
                bool oneisticking = false;
                foreach (Timer t in currentLevel.timers)
                {
                    t.Update(currentLevel);
                    if (t.activated && !t.loop)
                    {
                        loopTick.Play();
                        oneisticking = true;
                    }
                }
                if (!oneisticking)
                {
                    loopTick.Stop();
                }

                for (int i = 0; i < currentLevel.buttons.Count; i++)
                {
                    if (angel.hitBox.Intersects(currentLevel.buttons[i].hitBox))
                    {
                        currentLevel.buttons[i].activated = true;
                        currentLevel.timers[i].activated  = true;
                    }
                }
                #endregion

                #region Check links
                if (check)
                {
                    foreach (Link l in currentLevel.links)
                    {
                        if (angel.hitBox.Intersects(l.hitBox))
                        {
                            if (levels[(int)l.levelTo.X, (int)l.levelTo.Y] != null)
                            {
                                previousLevel = currentLevel;
                                currentLevel  = levels[(int)l.levelTo.X, (int)l.levelTo.Y];
                                LoadLevels();

                                foreach (FallingRock r in currentLevel.rocks)
                                {
                                    r.hitBox.Y = (int)r.initialPosition.Y;
                                    r.motion.Y = r.initialSpeed.Y;
                                }
                                gemExplosion   = null;
                                deathExplosion = null;
                                foreach (RocketLauncher r in currentLevel.launchers)
                                {
                                    r.explosion       = null;
                                    r.rocket.position = new Vector2(-10000, -10000);
                                    r.pause           = 0;
                                    r.rocket.trail.RemoveRange(0, r.rocket.trail.Count);
                                }
                                foreach (Fish f in currentLevel.fish)
                                {
                                    f.position = f.startPosition;
                                    f.motion   = Vector2.Zero;
                                }
                                if (previousLevel.type != currentLevel.type || currentLevel == levels[8, 10] || previousLevel == levels[8, 10])
                                {
                                    ChangeSong();
                                }
                            }
                            else
                            {
                                KillAngel();
                                break;
                            }

                            if (l.flipx)
                            {
                                angel.position.X = (angel.position.X < windowWidth / 2 ? windowWidth - 56 : -16);
                            }
                            if (l.flipy)
                            {
                                angel.position.Y = (angel.position.Y < windowHeight / 2 ? windowHeight - 40 : -16);
                            }
                            break;
                        }
                    }
                }
                #endregion

                HUDCat.hit = false;
                HUDCat.Update();
            }
            else
            {
                if (goTime)
                {
                    seconds = gameTime.TotalGameTime;
                    goTime  = false;
                }

                if (creditPosition.Y < -800)
                {
                    endGame = false;
                }
                else
                {
                    creditPosition.Y -= 4;
                }
            }

            base.Update(gameTime);
        }
예제 #2
0
 private void KillAngel()
 {
     deathExplosion = new Explosion(new Vector2(angel.hitBox.X + 8, angel.hitBox.Y + 8), Color.White, explosionTexture);
     // TODO: Play sound
     angel.position = currentLevel.restartPosition[previousLevel.coordinates];
     angel.motion = Vector2.Zero;
     deaths++;
 }
예제 #3
0
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();

            if (!endGame)
            {
                wingFlaps += angel.Update(currentLevel.walls);

                #region Lol glitch
                if (angel.position.Y > 2000 && currentLevel.type != Level.Type.EasterEgg)
                {
                    currentLevel.type = Level.Type.EasterEgg;
                    currentLevel.fore = null;
                    ChangeSong();
                }
                #endregion

                #region Update collectables
                foreach (Cat c in currentLevel.cats)
                {
                    if (angel.hitBox.Intersects(c.hitBox) && !c.hit)
                    {
                        c.hit = true;
                        catCount++;
                        if (currentLevel == levels[8, 10])
                            if (goTime)
                            {
                                creditsMus.Play();
                                endGame = true;
                                break;
                            }
                        meow.Play(0.4F, 0.0F, 0.0F);
                    }
                    c.Update();
                }

                if (currentLevel.gem != null)
                {
                    if (angel.hitBox.Intersects(currentLevel.gem.hitBox) && !currentLevel.gem.taken)
                    {
                        currentLevel.gem.taken = true;
                        getGem.Play();
                        foreach (ElectricFence e in finalFences)
                            if (e.color == currentLevel.gem.color)
                            {
                                e.isDeadly = false;
                                break;
                            }
                        gemExplosion = new Explosion(new Vector2(currentLevel.gem.hitBox.X, currentLevel.gem.hitBox.Y), currentLevel.gem.color, explosionTexture);
                    }
                    currentLevel.gem.Update();
                }
                #endregion

                if (deathExplosion != null)
                    deathExplosion.Update();
                if (gemExplosion != null)
                    gemExplosion.Update();

                #region Update obstacles
                bool check = true;
                foreach (DeathWall o in currentLevel.deathWalls)
                {
                    if (o.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (FallingRock o in currentLevel.rocks)
                {
                    o.Update();
                    if (o.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (ElectricFence e in currentLevel.fences)
                {
                    e.Update();
                    if (e.index < currentLevel.timers.Count)
                        e.isDeadly = !currentLevel.timers[e.index].activated;
                    if (e.hitBox.Intersects(angel.hitBox))
                    {
                        if (e.isDeadly)
                        {
                            KillAngel();
                            check = false;
                            continue;
                        }
                    }
                }
                if (currentLevel.coordinates.X == 0 && currentLevel.coordinates.Y == 10)
                    foreach (ElectricFence e in finalFences)
                    {
                        e.Update();
                        if (e.index < currentLevel.timers.Count)
                            e.isDeadly = !currentLevel.timers[e.index].activated;
                        if (e.hitBox.Intersects(angel.hitBox))
                        {
                            if (e.isDeadly)
                            {
                                KillAngel();
                                check = false;
                                continue;
                            }
                        }
                    }
                foreach (SpinningPlasma o in currentLevel.plasmas)
                {
                    o.Update();
                    if (o.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (RocketLauncher r in currentLevel.launchers)
                {
                    if (r.explosion != null)
                        r.explosion.Update();
                    if (r.Update(angel, currentLevel.walls, currentLevel.links, rocketLaunch))
                    {
                        r.explosion = new Explosion(new Vector2(r.rocket.hitBox.X, r.rocket.hitBox.Y), Color.OrangeRed, explosionTexture);
                        explode.Play(0.5f, 0.0f, 0.0f);
                        if (angel.hitBox.Intersects(r.rocket.hitBox))
                        {
                            KillAngel();
                            check = false;
                        }
                        r.pause = 0;
                        r.rocket.position.X = -10000;
                        r.rocket.position.Y = -10000;
                    }
                }
                foreach (Bubbles b in currentLevel.bubbles)
                {
                    b.Update();
                    if (angel.hitBox.Intersects(b.hitBox))
                    {
                        if (b.motion.X > 0 && angel.motion.X < b.motion.X ||
                            b.motion.X < 0 && angel.motion.X > b.motion.X ||
                            b.motion.Y < 0 && angel.motion.Y > b.motion.Y ||
                            b.motion.Y > 0 && angel.motion.Y < b.motion.Y)
                            angel.motion += Vector2.Normalize(b.motion) * b.motion.Length() / 10;
                    }
                }
                foreach (Starfish s in currentLevel.starfish)
                {
                    s.Update(currentLevel.walls, currentLevel.links);
                    if (s.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                foreach (Fish s in currentLevel.fish)
                {
                    s.Update(angel, currentLevel.walls, currentLevel.fish);
                    if (s.hitBox.Intersects(angel.hitBox))
                    {
                        KillAngel();
                        check = false;
                        continue;
                    }
                }
                #endregion

                #region Update timers and buttons
                bool oneisticking = false;
                foreach (Timer t in currentLevel.timers)
                {
                    t.Update(currentLevel);
                    if (t.activated && !t.loop)
                    {
                        loopTick.Play();
                        oneisticking = true;
                    }
                }
                if (!oneisticking)
                    loopTick.Stop();

                for (int i = 0; i < currentLevel.buttons.Count; i++)
                {
                    if (angel.hitBox.Intersects(currentLevel.buttons[i].hitBox))
                    {
                        currentLevel.buttons[i].activated = true;
                        currentLevel.timers[i].activated = true;
                    }
                }
                #endregion

                #region Check links
                if (check)
                {
                    foreach (Link l in currentLevel.links)
                    {
                        if (angel.hitBox.Intersects(l.hitBox))
                        {
                            if (levels[(int)l.levelTo.X, (int)l.levelTo.Y] != null)
                            {
                                previousLevel = currentLevel;
                                currentLevel = levels[(int)l.levelTo.X, (int)l.levelTo.Y];
                                LoadLevels();

                                foreach (FallingRock r in currentLevel.rocks)
                                {
                                    r.hitBox.Y = (int)r.initialPosition.Y;
                                    r.motion.Y = r.initialSpeed.Y;
                                }
                                gemExplosion = null;
                                deathExplosion = null;
                                foreach (RocketLauncher r in currentLevel.launchers)
                                {
                                    r.explosion = null;
                                    r.rocket.position = new Vector2(-10000, -10000);
                                    r.pause = 0;
                                    r.rocket.trail.RemoveRange(0, r.rocket.trail.Count);
                                }
                                foreach (Fish f in currentLevel.fish)
                                {
                                    f.position = f.startPosition;
                                    f.motion = Vector2.Zero;
                                }
                                if (previousLevel.type != currentLevel.type || currentLevel == levels[8, 10] || previousLevel == levels[8, 10])
                                    ChangeSong();
                            }
                            else
                            {
                                KillAngel();
                                break;
                            }

                            if (l.flipx)
                                angel.position.X = (angel.position.X < windowWidth / 2 ? windowWidth - 56 : -16);
                            if (l.flipy)
                                angel.position.Y = (angel.position.Y < windowHeight / 2 ? windowHeight - 40 : -16);
                            break;
                        }
                    }
                }
                #endregion

                HUDCat.hit = false;
                HUDCat.Update();
            }
            else
            {
                if (goTime)
                {
                    seconds = gameTime.TotalGameTime;
                    goTime = false;
                }

                if (creditPosition.Y < -800)
                    endGame = false;
                else
                    creditPosition.Y -= 4;
            }

            base.Update(gameTime);
        }