コード例 #1
0
ファイル: Gun.cs プロジェクト: davidc4747/Robo
        public override void draw(SpriteBatch spriteBatch)
        {
            //Draw bullets
            foreach (Bullet bull in bulls)
            {
                bull.draw(spriteBatch);
            }

            //if(this gun isn't equipt) : only draw the bullets
            if (Holder.CurGun != this)
            {
                return;
            }

            //Draw Muzzle flare
            Matrix  myRotationMatrix = Matrix.CreateRotationZ(this.Rotation);
            Vector2 muzzPos          = Vector2.Transform(muzzleOffset, myRotationMatrix) + this.Position;

            muzzleFlare = new RotatingSprite(muzzleFlare.Texture, muzzleFlare.ScaleFactor, 0, muzzPos, this.Rotation);

            if (isShooting)
            {
                muzzleFlare.draw(spriteBatch);
            }

            //Draw Ammo count or Reload timer
            Vector2 ammoPos = Holder.Position + new Vector2(Holder.Rec.Width * 0.9f, Holder.Speed * 10);

            if (reloadTimer > 0)
            {
                spriteBatch.DrawString(Fonts.Normal, reloadTimer.ToString("0.0"), ammoPos, Color.Red);
            }
            else
            {
                spriteBatch.DrawString(Fonts.Normal, "" + CurrMag + "/" + CurAmmo, ammoPos, Color.White);
            }

            //Draw Gun
            base.draw(spriteBatch);
        }