Exemple #1
0
 public void UpdateProjectiles(GameTime gameTime, Map map, ParticleTools particleTools)
 {
     if (projectileA != null)
     {
         if (!projectileA.Update(gameTime, map, particleTools))
         {
             projectileA = null;
         }
     }
     if (projectileB != null)
     {
         if (!projectileB.Update(gameTime, map, particleTools))
         {
             projectileB = null;
         }
     }
 }
Exemple #2
0
        public void StartFire(GameUnit playerX, GameUnit playerY,
            SpriteState.HorizontalFacing horizontalFacing,
            SpriteState.VerticalFacing verticalFacing,
            bool gunUp, ParticleTools particleTools)
        {
            if (projectileA != null && projectileB != null)
            {
                return;
            }
            GameUnit bulletX = GunX(horizontalFacing, playerX) - Units.HalfTile;
            GameUnit bulletY = GunY(verticalFacing, gunUp, playerY) - Units.HalfTile;
            switch (verticalFacing)
            {
                case SpriteState.VerticalFacing.Horizontal:
                    bulletY += NozzleHorizontalY;
                    if (horizontalFacing == SpriteState.HorizontalFacing.Left)
                    {
                        bulletX += NozzleHorizontalLeftX;
                    }
                    else
                    {
                        bulletX += NozzleHorizontalRightX;
                    }
                    break;
                case SpriteState.VerticalFacing.Up:
                    bulletY += NozzleUpY;
                    if (horizontalFacing == SpriteState.HorizontalFacing.Left)
                    {
                        bulletX += NozzleUpLeftX;
                    }
                    else
                    {
                        bulletX += NozzleUpRightX;
                    }
                    break;
                case SpriteState.VerticalFacing.Down:
                    bulletY += NozzleDownY;
                    if (horizontalFacing == SpriteState.HorizontalFacing.Left)
                    {
                        bulletX += NozzleDownLeftX;
                    }
                    else
                    {
                        bulletX += NozzleDownRightX;
                    }
                    break;
                default:
                    break;
            }

            if (projectileA == null)
            {
                projectileA = new Projectile(verticalFacing == SpriteState.VerticalFacing.Horizontal ?
                    horizontalProjectiles[CurrentLevel - 1] :
                    verticalProjectiles[CurrentLevel - 1],
                    horizontalFacing, verticalFacing, bulletX, bulletY, CurrentLevel, particleTools);
            }
            else if (projectileB == null)
            {
                projectileB = new Projectile(verticalFacing == SpriteState.VerticalFacing.Horizontal ?
                    horizontalProjectiles[CurrentLevel - 1] :
                    verticalProjectiles[CurrentLevel - 1],
                    horizontalFacing, verticalFacing, bulletX, bulletY, CurrentLevel, particleTools);
            }
        }