• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Graphics.GraphicsContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Flai.Graphics.GraphicsContext的典型用法代码示例。如果您正苦于以下问题:C# GraphicsContext类的具体用法?C# GraphicsContext怎么用?C# GraphicsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GraphicsContext类属于Flai.Graphics命名空间,在下文中一共展示了GraphicsContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DrawMapBorders

        private void DrawMapBorders(GraphicsContext graphicsContext, ICamera2D camera)
        {
            // Room borders
            const int RoomBorderThickness = 2;
            for(int x = 0; x < _map.WidthInRooms; x++)
            {
                for(int y = 0; y < _map.HeightInRooms; y++)
                {
                    Vector2i roomSize = new Vector2i(Room.Width * Tile.Size, Room.Height * Tile.Size);

                    // Draw room sub-borders
                    for (int x1 = 0; x1 < 4; x1++)
                    {
                        for (int y1 = 0; y1 < 4; y1++)
                        {
                            graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(
                                graphicsContext,
                                new RectangleF(x * roomSize.X + x1 * roomSize.X / 4f, y * roomSize.Y + y1 * roomSize.Y / 4f, roomSize.X / 4f, roomSize.Y / 4f),
                                Color.RoyalBlue.MultiplyRGB(0.5f) * 0.5f,
                                RoomBorderThickness / camera.Zoom);
                        }
                    }

                    // Draw room borders
                    graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(graphicsContext, new Rectangle(x * roomSize.X, y * roomSize.Y, roomSize.X, roomSize.Y), Color.RoyalBlue, RoomBorderThickness / camera.Zoom);
                }
            }

            // Full map borders
            const int MapBorderThickness = 4;
            graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(graphicsContext, new Rectangle(0, 0, _map.Width * Tile.Size, _map.Height * Tile.Size), Color.White, MapBorderThickness / camera.Zoom);
        }
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:32,代码来源:EditorMapRenderer.cs


示例2: DrawUI

        public void DrawUI(GraphicsContext graphicsContext, BasicUiContainer levelUiContainer)
        {
            const float FadeSpeed = 4;
            float fadeAmount = graphicsContext.DeltaSeconds * FadeSpeed;

            IGameContainer gameContainer = _world.EntityWorld.Services.Get<IGameContainer>();

            // player ui shouldn't fade out when paused, thus !gameContainer.IsGameOver check
            _playerUiAlpha += fadeAmount * ((gameContainer.IsActive || !gameContainer.IsGameOver) ? 1 : -1);
            _playerUiAlpha = _playerUiAlpha.Clamp(0, 1);

            // all other ui should fade out when game over or paused
            _otherUiAlpha += fadeAmount * (gameContainer.IsActive ? 1 : -1);
            _otherUiAlpha = _otherUiAlpha.Clamp(0, 1);

            // draw with player UI alpha (player UI + booster)
            graphicsContext.SpriteBatch.Alpha.Push(_playerUiAlpha);
            _playerRenderer.DrawUI(graphicsContext);
            _boosterStateRenderer.Draw(graphicsContext);
            graphicsContext.SpriteBatch.Alpha.Pop();

            // draw all other UI (pause, thumbsticks, drop arrow, achievement)
            graphicsContext.SpriteBatch.Alpha.Push(_otherUiAlpha);

            levelUiContainer.Draw(graphicsContext, true);
            _virtualThumbStickRenderer.Draw(graphicsContext);
            _dropArrowRenderer.Draw(graphicsContext);
            _achievementRenderer.Draw(graphicsContext);

            graphicsContext.SpriteBatch.Alpha.Pop();
        }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:31,代码来源:WorldRenderer.cs


示例3: DrawInner

 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     if (_adComponent != null)
     {
         _adComponent.Draw(graphicsContext.GameTime);
     }
 }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:7,代码来源:MicrosoftAdProvider.cs


示例4: DrawInner

 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     foreach (Spring spring in _springs)
     {
         graphicsContext.PrimitiveRenderer.DrawLine(graphicsContext, spring.StartPoint, spring.EndPoint, (spring.IsTriggered ? Color.DarkGray : Color.White) * 0.625f, Spring.Thickness);
     }
 }
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:7,代码来源:SpringRenderer.cs


示例5: Draw

 public void Draw(GraphicsContext graphicsContext)
 {
     if (_visible)
     {
         this.DrawInner(graphicsContext);
     }
 }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:7,代码来源:HouseAd.cs


示例6: Draw

 public void Draw(GraphicsContext graphicsContext)
 {
     if (_visible && this.Initialized )
     {
         this.DrawInner(graphicsContext);
     }
 }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:7,代码来源:AdProvider.cs


示例7: Draw

 protected override void Draw(GraphicsContext graphicsContext)
 {
     graphicsContext.SpriteBatch.Begin();
     graphicsContext.SpriteBatch.DrawFullscreen(graphicsContext.BlankTexture, Color.Black * 0.4f);
     _uiContainer.Draw(graphicsContext, true);
     graphicsContext.SpriteBatch.End();
 }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:7,代码来源:PauseScreen.cs


示例8: DrawInner

 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     if (_playerWeapon.Weapon.Type == WeaponType.Laser)
     {
         this.DrawLaser(graphicsContext, (Laser)_playerWeapon.Weapon);
     }
 }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:7,代码来源:WeaponRenderer.cs


示例9: Draw

 protected sealed override void Draw(GraphicsContext graphicsContext, ReadOnlyBag<Entity> entities)
 {
     foreach (Entity entity in entities)
     {
         this.Draw(graphicsContext, entity);
     }
 }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:7,代码来源:EntityProcessingRenderer.cs


示例10: Draw

        // using _spatialMap.GetAllIntersecting(CCamera2D.Active.GetArea(graphicsContext.ScreenSize))) causes all kinds of problems (render order changes when zombies move from cell and pretty sure other things too)
        protected override void Draw(GraphicsContext graphicsContext, ReadOnlyBag<Entity> entities)
        {
            // the texture size is actually 63x63, but the area in the texture that is of the actual zombie (no shadows) is 48x48
            const float BaseTextureSize = 48;

            RectangleF cameraArea = CCamera2D.Active.GetArea(graphicsContext.ScreenSize);
            foreach (Entity zombie in entities)
            {
                CZombieInfo zombieInfo = zombie.Get<CZombieInfo>();
                if (zombieInfo.AreaRectangle.Intersects(cameraArea))
                {
                    float scale = zombieInfo.Size / BaseTextureSize;
                    graphicsContext.SpriteBatch.DrawCentered(this.GetTexture(zombieInfo.Type), zombie.Transform.Position, ZombieRenderer.GetColor(zombieInfo), zombie.Transform.Rotation, scale);
                }

                // draw golden goblin glow
                if (zombieInfo.Type == ZombieType.GoldenGoblin)
                {
                    graphicsContext.SpriteBatch.DrawCentered(graphicsContext.ContentProvider.DefaultManager.LoadTexture("GoldenGoblinGlow"), zombie.Transform.Position, Color.Gold * 0.5f, 0, 3f + FlaiMath.Sin(graphicsContext.TotalSeconds * 2));

                    // DEBUG //
                  /*  CGoldenGoblinAI goldenGoblinAI = zombie.Get<CGoldenGoblinAI>();
                    if (goldenGoblinAI.State == GoldenGoblinState.TravellingToWaypoint)
                    {
                        graphicsContext.PrimitiveRenderer.DrawLine(goldenGoblinAI.Transform.Position, goldenGoblinAI.CurrentWaypoint, Color.Red, 2f);
                    }

                    for (int i = 0; i < goldenGoblinAI.Waypoints.Length - 1; i++)
                    {
                        graphicsContext.PrimitiveRenderer.DrawLine(goldenGoblinAI.Waypoints[i], goldenGoblinAI.Waypoints[i + 1], Color.Red, 4f);
                    } */
                }
            }
        }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:35,代码来源:ZombieRenderer.cs


示例11: DrawBullet

 private void DrawBullet(GraphicsContext graphicsContext, Entity entity, CBullet bullet)
 {
     TextureDefinition texture = this.GetTexture(bullet.Weapon.Type);
     if (bullet.Weapon.Type == WeaponType.RocketLauncher)
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, Color.White, entity.Transform.Rotation, 2);
     }
     else if (bullet.Weapon.Type == WeaponType.Bouncer)
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(160, 160, 160), entity.Transform.Rotation, 1);
     }
     else if (bullet.Weapon.Type == WeaponType.Flamethrower)
     {
         CLifeTime lifeTime = entity.Get<CLifeTime>();
         Color color = Color.Lerp(Color.LightGoldenrodYellow, Color.OrangeRed, 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
         graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
     }
     else if (bullet.Weapon.Type == WeaponType.Waterblaster)
     {
         CLifeTime lifeTime = entity.Get<CLifeTime>();
         Color color = Color.Lerp(Color.AliceBlue, new Color(0, 69, 255), 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
         graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
     }
     else
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(255, 255, 128) * 0.625f, entity.Transform.Rotation, 4);
     }
 }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:28,代码来源:BulletRenderer.cs


示例12: DrawThumbStick

        private void DrawThumbStick(GraphicsContext graphicsContext, CVirtualThumbstick virtualThumbstickComponent)
        {
            VirtualThumbstick thumbstick = virtualThumbstickComponent.Thumbstick;

            // if the thumbstick style is relative and the user isn't pressing down, the CenterPosition doesn't have a value.
            // don't draw the thumbstick in that case
            if (thumbstick.CenterPosition.HasValue)
            {
                TextureDefinition thumbstickTexture = SkypieaViewConstants.LoadTexture(_contentProvider, "ThumbstickBase");
                float alpha = thumbstick.IsPressed ? 0.5f : 1f;

                // base
                graphicsContext.SpriteBatch.DrawCentered(thumbstickTexture, thumbstick.CenterPosition.Value, Color.Gray * 0.75f * alpha);
                if (thumbstick.Direction.HasValue)
                {
                    // draw the "position"/direction texture only if the thumbstick is actually pressed
                    if (thumbstick.IsPressed)
                    {
                        const float MaxDistance = 60f;
                        graphicsContext.SpriteBatch.DrawCentered(thumbstickTexture, thumbstick.CenterPosition.Value + thumbstick.Direction.Value * MaxDistance, Color.LightGray * 0.5f * alpha, 0, 0.5f);
                    }
                    // otherwise draw the text on the thumbstick
                    else
                    {
                        string name = (virtualThumbstickComponent.Entity.Name == EntityNames.MovementThumbStick) ? "MOVEMENT" : "SHOOTING";
                        graphicsContext.SpriteBatch.DrawStringCentered(graphicsContext.FontContainer["Minecraftia.24"], name, thumbstick.CenterPosition.Value, Color.White * 0.5f * alpha);
                    }
                }
            }
        }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:30,代码来源:VirtualThumbStickRenderer.cs


示例13: DrawInner

        protected override void DrawInner(GraphicsContext graphicsContext)
        {
            if (_currentAchievement != null)
            {
                const float OffsetFromBorder = 8;
                const float TextOffset = 8;
                const float Height = 96;
                const float VerticalPosition = 90;

                const float BackgroundAlpha = 0.3f;
                const float TextAlpha = 0.75f;

                float alpha = this.GetAlpha();

                SpriteFont font = graphicsContext.FontContainer["Minecraftia.16"];
                float maxWidth = FlaiMath.Max(font.GetStringWidth(_currentAchievement.Name), font.GetStringWidth(_currentAchievement.ShortDescription)) + TextOffset * 2;

                float left = graphicsContext.ScreenSize.Width - OffsetFromBorder - maxWidth + (1 - alpha) * maxWidth / 2f;
                float centerX = left + maxWidth / 2f;
                RectangleF backgroundArea = new RectangleF(left, VerticalPosition, maxWidth, Height);

                // background & outlines
                graphicsContext.PrimitiveRenderer.DrawRectangle(backgroundArea, Color.Black * BackgroundAlpha * alpha);
                graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(backgroundArea, Color.Black * TextAlpha * alpha, 1);

                // name
                graphicsContext.SpriteBatch.DrawStringCentered(
                    font, _currentAchievement.Name, new Vector2(centerX, VerticalPosition + TextOffset + font.GetCharacterHeight() / 2f), Color.White * alpha * TextAlpha);

                // description
                graphicsContext.SpriteBatch.DrawStringCentered(
                    font, _currentAchievement.ShortDescription, new Vector2(centerX, VerticalPosition + TextOffset * 2 + font.GetCharacterHeight() * 3 / 2f), Color.White * alpha * TextAlpha);
            }
        }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:34,代码来源:AchievementRenderer.cs


示例14: DrawInner

        protected override void DrawInner(GraphicsContext graphicsContext)
        {
            ICamera2D camera = graphicsContext.Services.GetService<ICameraManager2D>().ActiveCamera;
            RectangleF cameraArea = camera.GetArea(graphicsContext.GraphicsDevice);

            this.DrawTiles(graphicsContext, cameraArea);
            this.DrawMapBorders(graphicsContext, camera);
        }
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:8,代码来源:EditorMapRenderer.cs


示例15: Draw

 public override void Draw(GraphicsContext graphicsContext)
 {
     if (_takeScreenshot)
     {
         this.TakeScreenShot();
         _takeScreenshot = false;
     }
 }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:8,代码来源:ScreenshotCapturer.cs


示例16: DrawInner

 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     // draws the actual map texture
     Vector2i size = SkypieaConstants.MapSizeInPixels / SkypieaViewConstants.PixelSize + Vector2i.One * SkypieaViewConstants.FadeLength / SkypieaViewConstants.PixelSize * 2;
     graphicsContext.SpriteBatch.Draw(
          SkypieaViewConstants.LoadTexture(_contentProvider, _mapTextureName),
          -Vector2.One * SkypieaViewConstants.FadeLength, new Rectangle(0, 0, size.X, size.Y), _color, 0, Vector2.Zero, SkypieaViewConstants.PixelSize, _spriteEffects, 0f);
 }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:8,代码来源:MapRenderer.cs


示例17: DrawInner

 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     foreach (Door door in _doors)
     {
         Texture2D lockTexture = graphicsContext.ContentProvider.DefaultManager.LoadTexture("Lock");
         graphicsContext.SpriteBatch.DrawCentered(lockTexture, door.Area.Center, Color.White * door.Alpha, 0, (Tile.Size / (float)lockTexture.Width) + 2 * (1 - door.Alpha));
     }
 }
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:8,代码来源:DoorRenderer.cs


示例18: DrawInner

        protected override void DrawInner(GraphicsContext graphicsContext)
        {
            ICamera2D camera = graphicsContext.Services.GetService<ICameraManager2D>().ActiveCamera;
            RectangleF cameraArea = camera.GetArea(graphicsContext.GraphicsDevice);

            this.DrawTiles(graphicsContext, cameraArea);
            graphicsContext.PrimitiveRenderer.DrawLine(graphicsContext, new Vector2(0, _map.Height * Tile.Size), new Vector2(_map.Width * Tile.Size, _map.Height * Tile.Size), Color.White, 4f);
        }
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:8,代码来源:WorldMapRenderer.cs


示例19: DrawOther

 // Draw without camera
 public void DrawOther(GraphicsContext graphicsContext)
 {
     const string FontName = "Minecraftia40";
     Color color = _gameClock.RemainingTime > 2f ? new Color(224, 224, 224) : new Color(255, 64, 64);
     graphicsContext.SpriteBatch.Begin(SamplerState.PointClamp);
     graphicsContext.SpriteBatch.DrawStringFadedCentered(graphicsContext.FontContainer[FontName], _gameClock.RemainingTimeString, new Vector2(graphicsContext.ScreenSize.X / 2f, 48), Color.Black, color);
     graphicsContext.SpriteBatch.End();
 }
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:9,代码来源:GameClockRenderer.cs


示例20: Draw

        protected override void Draw(GraphicsContext graphicsContext)
        {
            graphicsContext.GraphicsDevice.Clear(_backgroundColor);

            graphicsContext.SpriteBatch.Begin();
            graphicsContext.SpriteBatch.DrawStringCentered(_font, _text, graphicsContext.ScreenSize.ToVector2i() / 2f);
            graphicsContext.SpriteBatch.End();
        }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:8,代码来源:TextScreen.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Swf.Action类代码示例发布时间:2022-05-24
下一篇:
C# Navigation.NavigationEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap