Ejemplo n.º 1
0
        public void Update(Rioman player, AbstractBullet[] rioBullets, double deltaTime, Viewport viewport)
        {
            if (isAlive)
            {
                StatusBar.SetBossHealth(health);

                SubUpdate(player, rioBullets, deltaTime, viewport);
                CheckHit(player, rioBullets);
            }

            if (!isAlive && health <= 0)
            {
                StatusBar.SetBossHealth(health);

                killTime += deltaTime;

                if (killTime > 5 && !madePowerUp)
                {
                    madePowerUp = true;
                    powerUp     = new PowerUp(type - 9,
                                              originalLocation.X + netMovement.X,
                                              originalLocation.Y + netMovement.Y);
                }

                if (wasAlive)
                {
                    Audio.PlayKillBoss();
                }
            }


            wasAlive = isAlive;
        }
Ejemplo n.º 2
0
            public void Update(Viewport viewport, Rioman player, double deltaTime)
            {
                if (isAlive)
                {
                    aliveTime += deltaTime;

                    if (x < 0 - sprite.Height || x > viewport.Width ||
                        y < 0 - sprite.Width / 2 || y > viewport.Height)
                    {
                        isAlive = false;
                    }

                    if (type == 1)
                    {
                        frameTime += deltaTime;
                        if (frameTime > 0.15)
                        {
                            frameTime = 0;
                            frame++;
                            if (frame > 2)
                            {
                                frame = 0;
                            }
                        }
                    }

                    x += speedX * direction;

                    if (type == 2)
                    {
                        y += speedY;
                    }
                }
            }
Ejemplo n.º 3
0
        private Point GetValidSpawnPoint(Rioman player, Viewport viewport)
        {
            int x;
            int y;

            while (true)
            {
                x = r.Next(60, viewport.Width - 34);
                y = r.Next(46, viewport.Height - 34);

                if (Math.Abs(x - player.Hitbox.Center.X) < ATTACK_DISTANCE / 2 &&
                    Math.Abs(y - player.Hitbox.Center.Y) < ATTACK_DISTANCE / 2)
                {
                    continue;
                }
                else if (Math.Abs(x - player.Hitbox.Center.X) > ATTACK_DISTANCE &&
                         Math.Abs(y - player.Hitbox.Center.Y) > ATTACK_DISTANCE)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            return(new Point(x, y));
        }
Ejemplo n.º 4
0
        private void Float(Rioman player, Viewport viewport)
        {
            floatDist = 0;
            Fade();

            state    = State.floating;
            sprite   = floatSprite;
            drawRect = new Rectangle(0, 0, sprite.Width / 2, sprite.Height);

            Point spawn = GetValidSpawnPoint(player, viewport);

            location.X = spawn.X;
            location.Y = spawn.Y;

            FacePlayer(player);

            double diffY = player.Hitbox.Center.Y - GetCollisionRect().Center.Y;
            double diffX = player.Hitbox.Center.X - GetCollisionRect().Center.X;
            double dist  = Math.Sqrt(diffX * diffX + diffY * diffY);

            int x = (int)(ATTACK_SPEED * diffX / dist);
            int y = (int)(ATTACK_SPEED * diffY / dist);

            if (y + 1 >= Math.Abs(x))
            {
                drawRect = new Rectangle(sprite.Width / 2, 0, sprite.Width / 2, sprite.Height);
            }


            attackDir = new Point(x, y);
        }
Ejemplo n.º 5
0
        protected void CheckHit(Rioman player, AbstractBullet[] rioBullets)
        {
            if (isAlive && !player.IsLurking())
            {
                if (GetCollisionRect().Intersects(player.Hitbox))
                {
                    player.Hit(TOUCH_DAMAGE);
                }

                for (int i = 0; i <= rioBullets.Length - 1; i++)
                {
                    if (rioBullets[i] != null)
                    {
                        if (rioBullets[i].Hits(GetCollisionRect()))
                        {
                            int damage = rioBullets[i].TakeDamage(uniqueID);
                            if (damage > 0)
                            {
                                TakeDamage(damage);
                                blinkFrames = 2;
                            }
                        }
                    }
                }
            }

            SubCheckHit(player, rioBullets);
        }
Ejemplo n.º 6
0
            public void Update(Viewport viewport, Rioman player, double deltaTime)
            {
                if (isAlive)
                {
                    if (x < 0 - sprite.Height || x > viewport.Width ||
                        y < 0 - sprite.Width / 2 || y > viewport.Height)
                    {
                        isAlive = false;
                    }

                    frameTime += deltaTime;
                    if (frameTime > 0.15)
                    {
                        frameTime = 0;
                        frame++;
                        if (frame > 1)
                        {
                            frame = 0;
                        }
                    }

                    if (type == 1)
                    {
                        floatAngle += MathHelper.WrapAngle((float)deltaTime * 10);
                        y          += (int)(Math.Sin(floatAngle) * 3);

                        Rectangle target  = player.Hitbox;
                        int       centerY = y + sprite.Height / 2;

                        if (target.Top - centerY > 30)
                        {
                            y += 3;
                        }
                        else if (target.Top - centerY > 3)
                        {
                            y += 1;
                        }
                        else if (target.Bottom - centerY < 30)
                        {
                            y -= 3;
                        }
                        else if (target.Bottom - centerY < 3)
                        {
                            y -= 1;
                        }
                    }
                    else if (type == 2)
                    {
                        speed -= 1;
                        if (speed <= 0)
                        {
                            isAlive = false;
                        }
                    }

                    x += speed * direction;
                }
            }
Ejemplo n.º 7
0
        protected override void SubUpdate(Rioman player, AbstractBullet[] rioBullets, double deltaTime, Viewport viewport)
        {
            screenWidth  = viewport.Width;
            screenHeight = viewport.Height;

            if (fading)
            {
                fadeTime += deltaTime;
                if (fadeTime > 1)
                {
                    fading = false;
                }
            }

            if (IsLurking())
            {
                lurkTime += deltaTime;

                if (lurkTime > 1.2)
                {
                    if (r.Next(100) < 25)
                    {
                        Stand(player);
                    }
                    else
                    {
                        Float(player, viewport);
                    }
                }
            }

            if (IsStanding())
            {
                if (!fading)
                {
                    Lurk();
                }
            }

            if (IsFloating())
            {
                if (fadeTime > 0.1 || !fading)
                {
                    location.X += attackDir.X;
                    location.Y += attackDir.Y;

                    floatDist += (int)Math.Sqrt(Math.Abs(attackDir.X * attackDir.X) + Math.Abs(attackDir.Y * attackDir.Y));

                    if (floatDist > ATTACK_DISTANCE)
                    {
                        Lurk();
                    }
                }
            }
        }
Ejemplo n.º 8
0
 protected void FacePlayer(Rioman player)
 {
     if (player.Hitbox.Center.X < location.X)
     {
         direction = SpriteEffects.None;
     }
     else
     {
         direction = SpriteEffects.FlipHorizontally;
     }
 }
Ejemplo n.º 9
0
        public void SetAlive(Rioman player)
        {
            isAlive = true;
            FacePlayer(player);

            posing   = true;
            poseTime = 0;
            StatusBar.SetBossHealth(0);
            StatusBar.DrawBossHealth();
            StatusBar.IncreaseBossHealth(Constant.MAX_HEALTH);
        }
Ejemplo n.º 10
0
        private void Stand(Rioman player)
        {
            MoveThis(0, -netMovement.Y);
            FacePlayer(player);
            standTime = 0;
            state     = State.standing;
            shooting  = false;
            sprite    = defaultSprite;

            drawRect = new Rectangle(0, 0, sprite.Width / 2, sprite.Height);
        }
Ejemplo n.º 11
0
        private void Jump(Rioman player)
        {
            FacePlayer(player);
            shooting  = false;
            state     = State.jumping;
            jumpTime  = 0;
            shootTime = 0;

            sprite             = jumpSprite;
            drawRect           = new Rectangle(0, 0, sprite.Width / 2, sprite.Height);
            shotsSinceLastJump = 0;
        }
Ejemplo n.º 12
0
        private void Stand(Rioman player)
        {
            if (!fading && IsLurking())
            {
                Fade();
            }
            state    = State.standing;
            sprite   = defaultSprite;
            drawRect = new Rectangle(0, 0, sprite.Width / 2, sprite.Height);

            Point standLoc = standPoints[r.Next(0, 5)];

            location.X = standLoc.X;
            location.Y = standLoc.Y;

            FacePlayer(player);
        }
Ejemplo n.º 13
0
 protected override void SubCheckHit(Rioman player, AbstractBullet[] rioBullets)
 {
     for (int i = 0; i <= bullets.Length - 1; i++)
     {
         if (bullets[i].Hits(player.Hitbox))
         {
             if (bullets[i].type == SEAGULL)
             {
                 player.Hit(SEAGULL_DAMAGE);
             }
             if (bullets[i].type == CLOUD)
             {
                 player.Hit(CLOUD_DAMAGE);
             }
         }
     }
 }
Ejemplo n.º 14
0
 protected override void SubCheckHit(Rioman player, AbstractBullet[] rioBullets)
 {
     for (int i = 0; i <= bullets.Length - 1; i++)
     {
         if (bullets[i].Hits(player.Hitbox))
         {
             if (bullets[i].type == 1)
             {
                 player.Hit(BULLET1_DAMAGE);
             }
             if (bullets[i].type == 2)
             {
                 player.Hit(BULLET2_DAMAGE);
             }
         }
     }
 }
Ejemplo n.º 15
0
 protected abstract void SubCheckHit(Rioman player, AbstractBullet[] rioBullets);
Ejemplo n.º 16
0
 protected abstract void SubUpdate(Rioman player, AbstractBullet[] rioBullets, double deltaTime, Viewport viewport);
Ejemplo n.º 17
0
        protected override void SubUpdate(Rioman player, AbstractBullet[] rioBullets, double deltaTime, Viewport viewport)
        {
            for (int i = 0; i <= bullets.Length - 1; i++)
            {
                bullets[i].Update(viewport, player, deltaTime);
            }

            if (IsStanding())
            {
                standTime += deltaTime;

                if (!shooting && standTime > 0.2)
                {
                    ShootSeagull();
                }


                if (standTime > 0.8)
                {
                    Crouch();
                }
            }

            if (shooting)
            {
                shootTime += deltaTime;
                if (shootTime > 0.2 && seagullBulletsShot < 3)
                {
                    shootTime = 0;
                    ShootSeagull();
                }
            }


            if (IsCrouching())
            {
                crouchTime += deltaTime;
                if (crouchTime > 0.6)
                {
                    Jump();
                }
            }

            if (IsJumping())
            {
                if (location.Y > -drawRect.Height)
                {
                    location.Y -= 10;
                }
                else
                {
                    airTime += deltaTime;
                }


                if (airTime > 3)
                {
                    Random r = new Random();

                    //don't land on screen
                    if (r.Next(6) < 1)
                    {
                        if (r.Next(2) == 1)
                        {
                            location.X = 0;
                        }
                        else
                        {
                            location.X = viewport.Width - drawRect.Width - 38;
                        }

                        fallingAlongSide = true;
                    }
                    //land on screen
                    else
                    {
                        location.X = new Random().Next(Constant.TILE_SIZE * 3,
                                                       viewport.Width - drawRect.Width - Constant.TILE_SIZE * 3);
                    }

                    Fall();
                    FacePlayer(player);
                }
            }

            else if (IsFalling())
            {
                location.Y += 8;

                if (fallingAlongSide && seagullBulletsShot == 0 && location.Y > viewport.Height / 6)
                {
                    shootTime = 0;
                    ShootSeagull();
                }
            }
        }
Ejemplo n.º 18
0
 protected override void SubCheckHit(Rioman player, AbstractBullet[] rioBullets)
 {
     //do nothing
 }
Ejemplo n.º 19
0
        protected override void SubUpdate(Rioman player, AbstractBullet[] rioBullets, double deltaTime, Viewport viewport)
        {
            for (int i = 0; i <= bullets.Length - 1; i++)
            {
                bullets[i].Update(viewport, player, deltaTime);
            }

            if (IsStanding())
            {
                if (shooting)
                {
                    drawRect         = new Rectangle(sprite.Width / 2, 0, sprite.Width / 2, sprite.Height);
                    shootTime       += deltaTime;
                    betweenShotTime += deltaTime;

                    if (betweenShotTime > 0.21)
                    {
                        betweenShotTime = 0;
                        ShootBullet(1, 0f);
                    }

                    if (shootTime > 1)
                    {
                        shooting = false;
                    }
                }
                else
                {
                    standTime += deltaTime;
                    if (standTime > 0.4)
                    {
                        Run();
                    }
                }
            }

            if (IsJumping())
            {
                if (-netMovement.Y < JUMP_HEIGHT)
                {
                    MoveThis(0, -MOVE_SPEED);
                }
                else
                {
                    drawRect = new Rectangle(sprite.Width / 2, 0, sprite.Width / 2, sprite.Height);


                    shootTime       += deltaTime;
                    betweenShotTime += deltaTime;

                    if (shootTime > 1.5)
                    {
                        Fall();
                    }

                    if (betweenShotTime > 1.5 / NUM_JUMP_BULLETS)
                    {
                        betweenShotTime = 0;

                        int   bullet   = (int)Math.Round(shootTime / (1.5 / NUM_JUMP_BULLETS)) - 1;
                        float rotation = ((float)bullet / NUM_JUMP_BULLETS) * MathHelper.Pi;
                        ShootBullet(2, rotation + MathHelper.PiOver4);
                    }
                }
            }

            if (IsFalling())
            {
                if (netMovement.Y > 0)
                {
                    Stand(player);
                }
                else
                {
                    MoveThis(0, MOVE_SPEED);
                }
            }

            if (IsRunning())
            {
                jumpTime += deltaTime;

                if (netMovement.X <= 3 && netMovement.X >= -3 && shotsSinceLastJump >= 2)
                {
                    Jump(player);
                }
                else if (jumpTime > 1.5 && r.Next(1000) < JUMP_PROB)
                {
                    Jump(player);
                }

                else if (FacingLeft())
                {
                    MoveThis(-MOVE_SPEED, 0);
                    if (netMovement.X < MAX_LEFT)
                    {
                        Stand(player);
                        Shoot();
                    }
                }
                else
                {
                    MoveThis(MOVE_SPEED, 0);

                    if (netMovement.X > MAX_RIGHT)
                    {
                        Stand(player);
                        Shoot();
                    }
                }


                animateTime += deltaTime;
                if (animateTime > 0.1)
                {
                    animateTime = 0;
                    frame      += animateDir;

                    if (frame >= 2)
                    {
                        animateDir = -1;
                    }
                    if (frame <= 0)
                    {
                        animateDir = 1;
                    }

                    drawRect = new Rectangle(frame * sprite.Width / 3, 0, sprite.Width / 3, sprite.Height);
                }
            }
        }