コード例 #1
0
ファイル: EnemyShip.cs プロジェクト: isaacwycoff/GrimDorkness
        public override void Update(GameTime gameTime)
        {
            switch (aiType)
            {
            case AIType.AngleLeft:
            {
                currentFrame = EnemyAnimFrame.Left;
                xPos        -= speed / 2;
                yPos        += speed;

                break;
            }

            case AIType.AngleRight:
            {
                currentFrame = EnemyAnimFrame.Right;
                xPos        += speed / 2;
                yPos        += speed;

                break;
            }

            case AIType.Basic:
            {
                yPos += speed;
                if (fireCooldownRemaining <= 0.0f)
                {
                    Vector2 bulletPosition = new Vector2((float)xPos + gunBarrelOffset.X, (float)yPos + gunBarrelOffset.Y);
                    game.AddNewBullet(BulletType.FireBall, Direction.South, Team.Enemy, bulletPosition);

                    fireCooldownRemaining = fireDelay;
                }
                else
                {
                    fireCooldownRemaining -= gameTime.ElapsedGameTime.TotalSeconds;
                }
                break;
            }

            case AIType.ZigZag:
            default:
            {
                yPos += speed;


                break;
            }
            }   // end switch
        }
コード例 #2
0
        public override void Update(GameTime gameTime)
        {
            // what phase is the boss in?


            // entering
            if (yPos < 10)
            {
                yPos += 2;
            }
            // between 50% and 100%
            else if (health > maxHealth / 2)
            {
                if (xPos < 400)
                {
                    xPos += 1;
                }

                longCooldownRemaining -= gameTime.ElapsedGameTime.TotalSeconds;
                if (longCooldownRemaining <= 0.0f)
                {
                    if (gunsHot)
                    {
                        gunsHot = false;
                        longCooldownRemaining = gunsCoolTime;
                    }
                    else
                    {
                        gunsHot = true;
                        longCooldownRemaining = gunsHotTime;
                    }
                }



                if (fireCooldownRemaining <= 0.0f && gunsHot)
                {
                    Vector2 bulletPosition = new Vector2((float)xPos + gun1Offset.X, (float)yPos + gun1Offset.Y);
                    game.AddNewBullet(BulletType.FireBall, Direction.South, Team.Enemy, bulletPosition);

                    bulletPosition = new Vector2((float)xPos + gun2Offset.X, (float)yPos + gun2Offset.Y);
                    game.AddNewBullet(BulletType.FireBall, Direction.South, Team.Enemy, bulletPosition);


                    fireCooldownRemaining = fireDelay;
                }
                else
                {
                    fireCooldownRemaining -= gameTime.ElapsedGameTime.TotalSeconds;
                    if (fireCooldownRemaining < 0.0f)
                    {
                        fireCooldownRemaining = 0.0f;
                    }
                }
            }
            // boss health is between 0% and 50%
            else
            {
                sprite.UpdateRect(frameHarmed);

/*                if (moveLeft)
 *              {
 *                  xPos -= 1;
 *                  if (xPos <= 0) moveLeft = false;
 *              }
 *              else
 *              {
 *                  xPos += 1;
 *                  if (xPos >= 800 - 95) moveLeft = true;
 *              }
 */

                if (fireCooldownRemaining <= 0.0f)
                {
                    Vector2 bulletPosition = new Vector2((float)xPos + gun1Offset.X, (float)yPos + gun1Offset.Y);
                    game.AddNewBullet(BulletType.FireBall, Direction.South, Team.Enemy, bulletPosition);

                    bulletPosition = new Vector2((float)xPos + gun2Offset.X, (float)yPos + gun2Offset.Y);
                    game.AddNewBullet(BulletType.FireBall, Direction.South, Team.Enemy, bulletPosition);

                    bulletPosition = new Vector2((float)xPos + gun3Offset.X, (float)yPos + gun3Offset.Y);
                    game.AddNewBullet(BulletType.FireBall, Direction.South, Team.Enemy, bulletPosition);

                    bulletPosition = new Vector2((float)xPos + gun4Offset.X, (float)yPos + gun4Offset.Y);
                    game.AddNewBullet(BulletType.FireBall, Direction.South, Team.Enemy, bulletPosition);

                    fireCooldownRemaining = fireDelay;
                }
                else
                {
                    fireCooldownRemaining -= gameTime.ElapsedGameTime.TotalSeconds;
                    if (fireCooldownRemaining < 0.0f)
                    {
                        fireCooldownRemaining = 0.0f;
                    }
                }
            }



            if (moveLeft)
            {
                xPos -= 1;
                if (xPos <= 0)
                {
                    moveLeft = false;
                }
            }
            else
            {
                xPos += 1;
                if (xPos >= 800 - 95)
                {
                    moveLeft = true;
                }
            }



            base.Update(gameTime);
        }