当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.Count方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Count方法的具体用法?C# Rectangle.Count怎么用?C# Rectangle.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Rectangle的用法示例。


在下文中一共展示了Rectangle.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawOccluders

        private void DrawOccluders()
        {
            Rectangle[] rects = new Rectangle[4];
            rects[0] = new Rectangle(80, 200, 64, 200);
            rects[1] = new Rectangle(180, 200, 64, 200);
            rects[2] = new Rectangle(270, 200, 64, 200);
            rects[3] = new Rectangle(400, 200, 64, 200);

            //GraphicsDevice.SetRenderTarget(0, sceneRenderTarget);
            //graphics.GraphicsDevice.Clear(ClearOptions.Target, Color.Blue, 1f, 0, rects);
            //GraphicsDevice.SetRenderTarget(0, null);
            for (int i = 0; i < rects.Count(); i++)
                DrawSprite(blackTexture, rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height,
                    SpriteBlendMode.None, Color.Black);
        }
开发者ID:wintermute-motherbrain,项目名称:kaorudono,代码行数:15,代码来源:Kaoru.cs

示例2: Draw

        public override void Draw(GameTime gameTime)
        {
            bool current = data[index];

            float transitionOffset = TransitionPosition;

            if (lastIndex == -1)
                transitionOffset *= (ScreenState == ScreenState.TransitionOn) ? 1 : -1;
            else if (ScreenState == ScreenState.TransitionOn)
                transitionOffset *= (lastIndex > index) ? -1 : 1;
            else
            {
                if (nextIndex == -1)
                    transitionOffset *= -1;
                else
                    transitionOffset *= (index > nextIndex) ? 1 : -1;
            }

            SpriteBatch spriteBatch = Manager.SpriteBatch;
            spriteBatch.Begin();

            float scale = 3.5f;

            Rectangle source = spriteSheet[currentKey][0];
            Vector2 spriteLoc = ScreenHelper.Center;

            spriteLoc -= (new Vector2(source.Width / 2, source.Height / 2) * scale);
            Rectangle destination;

            Color color = current ? Color.White : Color.Black;
            destination = new Rectangle((int)spriteLoc.X, (int)spriteLoc.Y, (int)(source.Width * scale), (int)(source.Height * scale));

            #region Special Cases

            Rectangle[] extraSource = new Rectangle[10];
            Rectangle[] extra = new Rectangle[10];
            if (currentKey.Equals("smasher"))
            {
                //special draw handling
                extraSource[0] = spriteSheet["smasherball"][0];
                extra[0] = new Rectangle(destination.X - destination.Width, destination.Y, (int)(extraSource[0].Width * scale), (int)(extraSource[0].Height * scale));
            }

            else if (currentKey.Equals("birdbody"))
            {
                //bird contains two sprites so needs special draw handling
                extraSource[0] = spriteSheet["birdhead"][2];
                extra[0] = new Rectangle(destination.X + (int)(73 * scale), destination.Y + (int)(51 * scale), (int)(extraSource[0].Width * scale), (int)(extraSource[0].Height * scale));
            }

            else if (currentKey.Equals("blimp"))
            {
                scale = 4.5f;
            }

            else if (currentKey.Equals("giantgraybossship"))
            {
                scale = 4f;
            }

            else if (currentKey.Equals("killerhead"))
            {
                //likewise here
                extraSource[0] = spriteSheet["killerleftgun"][0];
                extraSource[1] = spriteSheet["killerrightgun"][0];

                extra[0] = new Rectangle(destination.X - (int)(25 * scale), destination.Y + (int)(19 * scale), (int)(extraSource[0].Width * scale), (int)(extraSource[0].Height * scale));
                extra[1] = new Rectangle(destination.X + (int)(118 * scale), destination.Y + (int)(18 * scale), (int)(extraSource[1].Width * scale), (int)(extraSource[1].Height * scale));
            }

            if (scale != 5f)
            {
                spriteLoc = ScreenHelper.Center;
                spriteLoc -= (new Vector2(source.Width / 2, source.Height / 2) * scale);
                destination.X = (int)(spriteLoc.X);
                destination.Y = (int)(spriteLoc.Y);

                destination.Width = (int)(source.Width * scale);
                destination.Height = (int)(source.Height * scale);

                for (int x = 0; x < extra.Count(); ++x)
                {
                    if (extra[x] != Rectangle.Empty)
                    {
                        extra[x].Width = (int)(extraSource[x].Width * scale);
                        extra[x].Height = (int)(extraSource[x].Height * scale);
                    }
                }
            }

            #endregion Special Cases

            destination.X += (int)(transitionOffset * ScreenHelper.Viewport.Width);
            spriteBatch.Draw(spriteSheet.Texture, destination, source, color);

            for (int x = 0; x < extra.Count(); ++x)
            {
                if (extra[x] != Rectangle.Empty)
                {
                    extra[x].X += (int)(transitionOffset * ScreenHelper.Viewport.Width);
//.........这里部分代码省略.........
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:101,代码来源:BossScreen.cs

示例3: LoadContent

        public void LoadContent(ContentManager content, string filename, Color boundingColor, float layer)
        {
            #region Getting Colors

            Texture2D tex = content.Load<Texture2D>(filename);

            Color[] data = new Color[tex.Width * tex.Height];
            tex.GetData<Color>(data);

            //Get the data in 2D array form
            Color[,] colors = new Color[tex.Width, tex.Height];

            int z = 0;

            for (int y = 0; y < tex.Height; y++)
            {
                for (int x = 0; x < tex.Width; x++, z++)
                {
                    colors[x, y] = data[z];
                }
            }

            #endregion Getting Colors

            #region Getting Rectangles

            int y1 = 1;
            int x1 = 1;
            int rectCount = 0;
            int lastXBound = 0;
            int nextXBound = 0;
            int height = tex.Height - 2;

            Rectangle[] rects = new Rectangle[41];
            while (rectCount < rects.Count())
            {
                while (colors[x1, 1] != boundingColor)
                {
                    x1++;
                }
                nextXBound = x1;

                Rectangle rect = new Rectangle(lastXBound + 1, y1, nextXBound - lastXBound - 1, height);
                rects[rectCount] = rect;
                rectCount++;
                lastXBound = nextXBound;
                x1++;
            }

            #endregion Getting Rectangles

            #region Removing Source Rectangles

            for (int j = 0; j < data.Count(); j++)
            {
                if (data[j] == boundingColor)
                {
                    data[j] = new Color(0, 0, 0, 0);
                }
            }

            texture = new Texture2D(ScreenHelper.GraphicsDevice, tex.Width, tex.Height);
            texture.SetData<Color>(data);

            #endregion Removing Source Rectangles

            #region Adding chars

            int charNext = 65;
            int i = 0;
            while (charNext <= 90)
            {
                letters.Add((char)charNext++, rects[i++]);
            }

            charNext = 49;

            while (charNext <= 57)
            {
                letters.Add((char)charNext++, rects[i++]);
            }

            letters.Add('0', rects[i++]);
            letters.Add('%', rects[i++]);
            letters.Add(':', rects[i++]);
            letters.Add('!', rects[i++]);
            letters.Add('?', rects[i++]);
            letters.Add('.', rects[i]);

            #endregion Adding chars

            Layer = layer;
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:93,代码来源:ImageFont.cs


注:本文中的Microsoft.Xna.Framework.Rectangle.Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。