本文整理汇总了C#中Flai.Graphics.GraphicsContext类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsContext类的具体用法?C# GraphicsContext怎么用?C# GraphicsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsContext类属于Flai.Graphics命名空间,在下文中一共展示了GraphicsContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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();
}
示例3: DrawInner
protected override void DrawInner(GraphicsContext graphicsContext)
{
if (_adComponent != null)
{
_adComponent.Draw(graphicsContext.GameTime);
}
}
示例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);
}
}
示例5: Draw
public void Draw(GraphicsContext graphicsContext)
{
if (_visible)
{
this.DrawInner(graphicsContext);
}
}
示例6: Draw
public void Draw(GraphicsContext graphicsContext)
{
if (_visible && this.Initialized )
{
this.DrawInner(graphicsContext);
}
}
示例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();
}
示例8: DrawInner
protected override void DrawInner(GraphicsContext graphicsContext)
{
if (_playerWeapon.Weapon.Type == WeaponType.Laser)
{
this.DrawLaser(graphicsContext, (Laser)_playerWeapon.Weapon);
}
}
示例9: Draw
protected sealed override void Draw(GraphicsContext graphicsContext, ReadOnlyBag<Entity> entities)
{
foreach (Entity entity in entities)
{
this.Draw(graphicsContext, entity);
}
}
示例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);
} */
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
示例15: Draw
public override void Draw(GraphicsContext graphicsContext)
{
if (_takeScreenshot)
{
this.TakeScreenShot();
_takeScreenshot = false;
}
}