public void Draw(Sprite sprite) { if (_isHover) sprite.Draw(_texShd.Texture, new Rectangle(3, 0, 45, 52), new Vector3(0f, 0f, 0f), new Vector3((Single)_rect.X, (Single)_rect.Y, 0f), Color.White); sprite.Draw(_tex.Texture, new Rectangle(3, 0, 45, 52), new Vector3(0f, 0f, 0f), new Vector3((Single)_rect.X, (Single)_rect.Y, 0f), Color.White); }
public override void Render(Sprite sprite) { Rectangle rect = new Rectangle(0, 0, 1280, 720); if (currentFrame >= frames.Length) { if (delay > 1.25f) { sprite.Draw(frames[frames.Length - 1], rect, ColorValue.White); ColorValue color = ColorValue.White; color.A = (byte)(byte.MaxValue * (1 - MathEx.Saturate((delay - 1.25f) / 1.25f))); sprite.Draw(blackBg, rect, color); } else { ColorValue color = ColorValue.White; color.A = (byte)(byte.MaxValue * MathEx.Saturate(delay / 1.25f)); sprite.Draw(blackBg, rect, color); } delay -= 0.04f; } else { sprite.Draw(frames[currentFrame], rect, ColorValue.White); } }
public override void Render(Sprite sprite) { ColorValue color = ColorValue.White; color.A = (byte)(byte.MaxValue * MathEx.Saturate(alpha)); sprite.Draw(overlay34, 0, 0, color); if (alpha>=1) { sprite.Draw(lds_bg, 0, 0, ColorValue.White); } }
public override void Draw(SpriteBatch spriteBatch) { if (!isActive || !IsVisible) { return; } Sprite?.Draw(spriteBatch, effect: FacingDirection == HorizontalDirection.Left ? SpriteEffects.FlipHorizontally : SpriteEffects.None); if (Debugger.IsAttached) { Texture2D debugTexture = new Texture2D(spriteBatch.GraphicsDevice, 1, 1); debugTexture.SetData(new[] { new Color(154, 0, 0, 50) }); if (hitAreas.Count > 0) { foreach (KeyValuePair <string, Rectangle> area in hitAreas) { spriteBatch.Draw(debugTexture, GetHitArea(area.Key), Color.Red); } } else { spriteBatch.Draw(debugTexture, Boundings, Color.Red); } } }
public override void DrawHUD(SpriteBatch spriteBatch, Character character) { if (crosshairSprite == null) { return; } if (character == null || !character.IsKeyDown(InputType.Aim)) { return; } //camera focused on some other item/device, don't draw the crosshair if (character.ViewTarget != null && (character.ViewTarget is Item item) && item.Prefab.FocusOnSelected) { return; } GUI.HideCursor = (crosshairSprite != null || crosshairPointerSprite != null) && GUI.MouseOn == null && !Inventory.IsMouseOnInventory() && !GameMain.Instance.Paused; if (GUI.HideCursor) { crosshairSprite?.Draw(spriteBatch, crosshairPos, Color.White, 0, currentCrossHairScale); crosshairPointerSprite?.Draw(spriteBatch, crosshairPointerPos, 0, currentCrossHairPointerScale); } }
private void DrawBloomedElements(SpriteBatch spriteBatch) { BeginDrawCameraSpace(); PlayerHitbox?.Draw(spriteBatch); _game.PerformanceManager.StartStopwatch(PerformanceStopwatchType.BossBulletDraw); foreach (var mover in BossBullets) { if (mover.IsVisible()) { spriteBatch.Draw(mover.Sprite); } } foreach (var laser in Lasers) { laser.Draw(spriteBatch); } _game.PerformanceManager.StopStopwatch(PerformanceStopwatchType.BossBulletDraw); spriteBatch.End(); }
public override void Draw() { if (_activated && !Used) { Sprite?.Draw((Location + DrawOffset).ToVector2()); } }
public override void DrawHUD(SpriteBatch spriteBatch, Character character) { if (character == null || !character.IsKeyDown(InputType.Aim)) { return; } //camera focused on some other item/device, don't draw the crosshair if (character.ViewTarget != null && (character.ViewTarget is Item viewTargetItem) && viewTargetItem.Prefab.FocusOnSelected) { return; } //don't draw the crosshair if the item is in some other type of equip slot than hands (e.g. assault rifle in the bag slot) if (!character.HeldItems.Contains(item)) { return; } GUI.HideCursor = (crosshairSprite != null || crosshairPointerSprite != null) && GUI.MouseOn == null && !Inventory.IsMouseOnInventory && !GameMain.Instance.Paused; if (GUI.HideCursor) { crosshairSprite?.Draw(spriteBatch, crosshairPos, Color.White, 0, currentCrossHairScale); crosshairPointerSprite?.Draw(spriteBatch, crosshairPointerPos, 0, currentCrossHairPointerScale); } }
public virtual void Draw() { if (!Used) { Sprite?.Draw((Location + DrawOffset).ToVector2()); } }
protected override void DrawButton(SpriteBatch spriteBatch) { base.DrawButton(spriteBatch); if (checkState == CheckState.Checked) { checkedSprite?.Draw(spriteBatch, bounds, foreground * ((checkState == CheckState.Intermediate) ? intermediateTransparency : 1)); } }
public virtual void Draw(SpriteBatch batch, Vector2 offset) { Sprite?.Draw(batch, Position - offset - Sprite.Offset); if (drawHitbox) { batch.Draw(hitboxSprite, AddVectorToRect(Hitbox, Position - offset), null, Color.White, (float)0.0, new Vector2(0, 0), SpriteEffects.None, (float)0.04); } }
public override void Render(Sprite sprite) { //Sprite.Transform = Matrix.Translation(X, Y, 0); base.Render(sprite); if (image != null) { sprite.Draw(image, X, Y, modColor); } }
public void Draw(Sprite sprite_resource, int diffuse) { sprite_resource.Transform = Matrix.Scaling(Scaling) * Matrix.RotationX(Rotation.X) * Matrix.RotationY(Rotation.Y) * Matrix.RotationZ(Rotation.Z) * Matrix.Translation(Position); sprite_resource.Draw(Texture, Center, Vector3.Empty, diffuse); }
public override void Render(Sprite sprite) { base.Render(sprite); sprite.Draw(background, new Vector2(0, 613), ColorValue.White); string msg = "TRANSFORM 23 CITIES"; fedge6.DrawString(sprite, msg, 130, 660, ColorValue.White); fedge6.DrawString(sprite, "\n " + player.Area.CityCount.ToString() + " / 23 )", 130, 660, ColorValue.Yellow); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { spritePosition = new Vector3(200f, 200f, 0f); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0); device.BeginScene(); using (Sprite sprite = new Sprite(device)) { sprite.Begin(SpriteFlags.AlphaBlend); sprite.Draw(tileSet.Texture, tilePosition, spriteCenter, spritePosition, Color.FromArgb(255,255,255,255)); sprite.End(); } device.EndScene(); device.Present(); this.Invalidate(); }
public override void Render(Sprite sprite) { base.Render(sprite); if (exitButton.IsMouseOver) { sprite.Draw(exitButton.Image, new Rectangle(-13, 0, exitButton.Image.Width, exitButton.Image.Height), ColorValue.Yellow); } else { sprite.Draw(exitButton.Image, new Rectangle(-13, 0, exitButton.Image.Width, exitButton.Image.Height), ColorValue.White); } }
void TextureViewer_Load(object sender, EventArgs e) { this.Show(); Application.DoEvents(); pp = new PresentParameters(); pp.BackBufferCount = 2; pp.SwapEffect = SwapEffect.Discard; pp.Windowed = true; Direct3D d3d = new Direct3D(); d3d_device = new Device(d3d, 0, DeviceType.Hardware, d3dPanel.Handle, CreateFlags.HardwareVertexProcessing, pp); texture = Texture.FromFile(d3d_device, texturePath); int texWidth = texture.GetLevelDescription(0).Width; int texHeight = texture.GetLevelDescription(0).Height; d3dPanel.Top = menuStrip1.Height; d3dPanel.Left = 0; d3dPanel.ClientSize = new Size(texWidth, texHeight); this.ClientSize = new System.Drawing.Size( d3dPanel.Width, d3dPanel.Height + menuStrip1.Height ); pp.BackBufferWidth = texWidth; pp.BackBufferHeight = texHeight; d3d_device.Reset(pp); sprite = new Sprite(d3d_device); while (this.Visible) { d3d_device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, new Color4(Color.Black), 1.0f, 0); d3d_device.BeginScene(); sprite.Begin(SpriteFlags.AlphaBlend); Rectangle rect = new Rectangle() { X = 0, Y = 0, Width = texture.GetLevelDescription(0).Width, Height = texture.GetLevelDescription(0).Height }; sprite.Draw(texture, rect, new Color4(Color.White)); sprite.End(); d3d_device.EndScene(); d3d_device.Present(); Application.DoEvents(); } }
protected virtual void DrawButton(SpriteBatch spriteBatch) { if (sprite is SlicedSprite) { if (root is IRenderDelegator) { ((IRenderDelegator)root).Delegate(sprite, new SpriteDrawSettings() { Color = hover ? backgroundHover : background, Bounds = bounds }); } } else { sprite?.Draw(spriteBatch, bounds, hover ? backgroundHover : background); } }
private void DrawBloomedElements(GameTime gameTime) { BeginDrawCameraSpace(); PlayerHitbox?.Draw(_game.SpriteBatch); _game.PerformanceManager.StartStopwatch(PerformanceStopwatchType.BossBulletDraw); foreach (var mover in BossBullets) { _game.SpriteBatch.Draw(mover.Sprite); } foreach (var laser in Lasers) { laser.Draw(gameTime); } _game.PerformanceManager.StopStopwatch(PerformanceStopwatchType.BossBulletDraw); _game.SpriteBatch.End(); }
/// <summary> /// Draw the icon /// </summary> public void FastRender(DrawArgs drawArgs, Sprite sprite, Vector3 projectedPoint) { // Check icons for within "visual" range float distanceToIcon = Vector3.Length(this.Position - drawArgs.WorldCamera.Position); if(distanceToIcon > this.MaximumDisplayDistance) return; if(distanceToIcon < this.MinimumDisplayDistance) return; if (!this.isInitialized) this.Initialize(drawArgs); if ((!this.m_isUpdated) || (drawArgs.WorldCamera.Altitude < 300000)) { this.UpdatePosition(drawArgs); } JHU_IconTexture iconTexture = this.GetTexture(); if(iconTexture==null) { // Render label if(this.Name != null) { // Center over target as we have no bitmap Rectangle rect = new Rectangle( (int)projectedPoint.X - (labelWidth>>1), (int)(projectedPoint.Y - (drawArgs.defaultDrawingFont.Description.Height >> 1)), labelWidth, drawArgs.screenHeight ); drawArgs.defaultDrawingFont.DrawText(sprite, this.Name, rect, DrawTextFormat.Center, normalColor); } } else { // Render icon sprite.Transform = Matrix.Scaling(this.XScale,this.YScale,0); if (m_isRotated) sprite.Transform *= Matrix.RotationZ((float)m_rotation.Radians - (float) drawArgs.WorldCamera.Heading.Radians); sprite.Transform *= Matrix.Translation(projectedPoint.X, projectedPoint.Y, 0); sprite.Draw( iconTexture.Texture, new Vector3(iconTexture.Width>>1, iconTexture.Height>>1,0), Vector3.Empty, normalColor ); if (m_iconTexture2Show) { sprite.Draw ( m_iconTexture2.Texture, new Vector3(m_iconTexture2.Width>>1, m_iconTexture2.Height>>1, 0), Vector3.Empty, normalColor ); } if (m_iconTexture3Show) { sprite.Draw ( m_iconTexture3.Texture, new Vector3(m_iconTexture3.Width>>1, m_iconTexture3.Height>>1, 0), Vector3.Empty, normalColor ); } // Reset transform to prepare for text rendering later sprite.Transform = Matrix.Identity; } if (m_drawGroundStick) { Vector2[] groundStick = new Vector2[2]; Angle testAngle = new Angle(); testAngle.Degrees = 45.0; Vector3 projectedGroundPoint = drawArgs.WorldCamera.Project(m_groundPoint); m_groundStick.Begin(); groundStick[0].X = projectedPoint.X; groundStick[0].Y = projectedPoint.Y; groundStick[1].X = projectedGroundPoint.X; groundStick[1].Y = projectedGroundPoint.Y; m_groundStick.Draw(groundStick, m_groundStickColor); m_groundStick.End(); } }
public void RenderRank(Sprite sprite) { List<Player> players = new List<Player>(); for (int i = 0; i < gameLogic.LocalPlayerCount; i++) players.Add(gameLogic.GetLocalPlayer(i)); RankInfo.StatisticRank(players); int startX = 543; int startY = 160; for (int i = 0; i < players.Count; i++) { if (players[i].Type != PlayerType.LocalHuman) { string s = (i + 1).ToString(); sprite.Draw(rankBackground, startX, startY, ColorValue.White); f8.DrawString(sprite, s, startX, startY - 20, ColorValue.White); Matrix trans = Matrix.Scaling(0.33f, 0.33f, 1) * Matrix.Translation(new Vector3(startX + 19, startY + 14, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, "TH", 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); sprite.Draw(rankColor, startX + 35, startY + 9, players[i].SideColor); f8.DrawString(sprite, players[i].Area.CityCount.ToString(), startX + 80, startY - 20, ColorValue.White); startY += 37; } else { string s = (i + 1).ToString(); sprite.Draw(homeBackground, startX, startY - 4, players[i].SideColor); f8.DrawString(sprite, s, startX + 2, startY, ColorValue.White); Matrix trans = Matrix.Scaling(0.35f, 0.35f, 1) * Matrix.Translation(new Vector3(startX + 22, startY + 35, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, "TH", 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); f6.DrawString(sprite, players[i].Area.CityCount.ToString(), startX + 73, startY - 45, ColorValue.White); startY += 70; } } }
public override void DrawHUD(SpriteBatch spriteBatch, Character character) { if (HudTint.A > 0) { GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), new Color(HudTint.R, HudTint.G, HudTint.B) * (HudTint.A / 255.0f), true); } GetAvailablePower(out float batteryCharge, out float batteryCapacity); List <Item> availableAmmo = new List <Item>(); foreach (MapEntity e in item.linkedTo) { var linkedItem = e as Item; if (linkedItem == null) { continue; } var itemContainer = linkedItem.GetComponent <ItemContainer>(); if (itemContainer?.Inventory?.Items == null) { continue; } availableAmmo.AddRange(itemContainer.Inventory.Items); } float chargeRate = powerConsumption <= 0.0f ? 1.0f : batteryCapacity > 0.0f ? batteryCharge / batteryCapacity : 0.0f; bool charged = batteryCharge * 3600.0f > powerConsumption; bool readyToFire = reload <= 0.0f && charged && availableAmmo.Any(p => p != null); if (ShowChargeIndicator && PowerConsumption > 0.0f) { powerIndicator.Color = charged ? Color.Green : Color.Red; if (flashLowPower) { powerIndicator.BarSize = 1; powerIndicator.Color *= (float)Math.Sin(flashTimer * 12); powerIndicator.RectTransform.ChangeScale(Vector2.Lerp(Vector2.One, Vector2.One * 1.01f, 2 * (float)Math.Sin(flashTimer * 15))); } else { powerIndicator.BarSize = chargeRate; } powerIndicator.DrawManually(spriteBatch, true); int requiredChargeIndicatorPos = (int)((powerConsumption / (batteryCapacity * 3600.0f)) * powerIndicator.Rect.Width); GUI.DrawRectangle(spriteBatch, new Rectangle(powerIndicator.Rect.X + requiredChargeIndicatorPos, powerIndicator.Rect.Y, 3, powerIndicator.Rect.Height), Color.White * 0.5f, true); } if (ShowProjectileIndicator) { Point slotSize = new Point((int)(60 * GUI.Scale), (int)(30 * GUI.Scale)); int spacing = 5; int slotsPerRow = Math.Min(availableAmmo.Count, 6); int totalWidth = slotSize.X * slotsPerRow + spacing * (slotsPerRow - 1); Point invSlotPos = new Point(GameMain.GraphicsWidth / 2 - totalWidth / 2, (int)(60 * GUI.Scale)); for (int i = 0; i < availableAmmo.Count; i++) { // TODO: Optimize? Creates multiple new classes per frame? Inventory.DrawSlot(spriteBatch, null, new InventorySlot(new Rectangle(invSlotPos + new Point((i % slotsPerRow) * (slotSize.X + spacing), (int)Math.Floor(i / (float)slotsPerRow) * (slotSize.Y + spacing)), slotSize)), availableAmmo[i], true); } if (flashNoAmmo) { Rectangle rect = new Rectangle(invSlotPos.X, invSlotPos.Y, totalWidth, slotSize.Y); float inflate = MathHelper.Lerp(3, 8, (float)Math.Abs(1 * Math.Sin(flashTimer * 5))); rect.Inflate(inflate, inflate); Color color = Color.Red * MathHelper.Max(0.5f, (float)Math.Sin(flashTimer * 12)); GUI.DrawRectangle(spriteBatch, rect, color, thickness: 3); } } float zoom = cam == null ? 1.0f : (float)Math.Sqrt(cam.Zoom); crosshairSprite?.Draw(spriteBatch, crosshairPos, readyToFire ? Color.White : Color.White * 0.2f, 0, zoom); crosshairPointerSprite?.Draw(spriteBatch, crosshairPointerPos, 0, zoom); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { deltaTime = hrt.ElapsedTime; UpdateSprite(deltaTime); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0); device.BeginScene(); using (Sprite sprite = new Sprite(device)) { sprite.Begin(SpriteFlags.None); //Set rotation center for sprite spriteCenter.X = spritePosition.X + tileSet.ExtentX; spriteCenter.Y = spritePosition.Y + tileSet.ExtentY; //Spin, Shift, Stretch :-) sprite.Transform = Matrix.RotationZ(angle) * Matrix.Translation(spriteCenter); sprite.Draw(tileSet.Texture, tilePosition, spriteCenter, spritePosition, Color.FromArgb(255,255,255,255)); sprite.End(); } device.EndScene(); device.Present(); this.Invalidate(); }
public virtual void Draw(SpriteBatch spriteBatch, Color color) { Sprite.Draw(spriteBatch, Position, color); }
public override void Render(Sprite sprite) { //spr.Transform = Matrix.Translation((int)(bounds.X + (bounds.Width - lblWidth) * 0.5f), (int)(bounds.Y + (bounds.Height - lblHeight) * 0.5f), 0); if (IsValid) { if (Enabled) { if (IsPressed) { if (ImageMouseDown != null) { if (ResizeImage) { sprite.Draw(ImageMouseDown, new Rectangle(X, Y, radius * 2, radius * 2), modColor); } else { sprite.Draw(ImageMouseDown, X, Y, modColor); } } } else if (IsMouseOver) { if (ImageMouseOver != null) { if (ResizeImage) { sprite.Draw(ImageMouseOver, new Rectangle(X, Y, radius * 2, radius * 2), modColor); } else { sprite.Draw(ImageMouseOver, X, Y, modColor); } } } else { if (Image != null) { if (ResizeImage) { sprite.Draw(Image, new Rectangle(X, Y, radius * 2, radius * 2), modColor); } else { sprite.Draw(Image, X, Y, modColor); } } } } else { if (ImageDisabled != null) { if (ResizeImage) { sprite.Draw(ImageDisabled, new Rectangle(X, Y, radius * 2, radius * 2), modColor); } else { sprite.Draw(ImageDisabled, X, Y, modColor); } } } } else { if (ImageInvalid != null) { if (ResizeImage) { sprite.Draw(ImageInvalid, new Rectangle(X, Y, radius * 2, radius * 2), modColor); } else { sprite.Draw(ImageInvalid, X, Y, modColor); } } } //if (IsPressed) //{ // Sprite.Transform = Matrix.Translation(X + 1, Y + 1, 0); //} base.Render(sprite); }
private void RenderBallIcon(Sprite sprite) { if (selectCity != null && selectCity.Owner == player) { //Array.Sort(resBallsCount, BallRecordCompare); int left = 0; for (int i = 0; i < resBallsCount.Length; i++) { RBallType ballType = resBallsCount[i].Type; bool overrideDraw = selectCity.CanProduceProduction() ? (ballType == selectCity.GetProductionType()) : false; //resBallsCount[i].Type == selectCity.GetProductionType() switch (ballType) { case RBallType.Green: { if (resBallsCount[i].count != 0 || overrideDraw) { if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Green) { if (selectCity.IsFull()) { sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White); } else { int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height); sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height), new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White); } } int x = 687 + 69 * left - greenBallTex.Width / 2; int y = 692 - greenBallTex.Height / 2; sprite.Draw(greenBallTex, x, y, ColorValue.White); Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation(new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); left++; } } break; case RBallType.Education: { if (resBallsCount[i].count != 0 || overrideDraw) { if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Education) { if (selectCity.IsFull()) { sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White); } else { int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height); sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height), new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White); } } int x = 687 + 69 * left - educationBallTex.Width / 2; int y = 692 - educationBallTex.Height /2 ; sprite.Draw(educationBallTex, x, y, ColorValue.White); Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation( new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); left++; } } break; case RBallType.Health: { if (resBallsCount[i].count != 0 || overrideDraw) { if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Health) { if (selectCity.IsFull()) { sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White); } else { int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height); sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height), new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White); } } int x = 687 + 69 * left - healthBallTex.Width / 2; int y = 692 - healthBallTex.Height / 2; sprite.Draw(healthBallTex, x, y, ColorValue.White); Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation(new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); left++; } } break; } } } }
private void RenderSelectedCityHP(Sprite sprite) { if (SelectedCity != null) { float radLng = MathEx.Degree2Radian(SelectedCity.Longitude); float radLat = MathEx.Degree2Radian(SelectedCity.Latitude); Vector3 tangy = PlanetEarth.GetTangentY(radLng, radLat); Vector3 tangx = PlanetEarth.GetTangentX(radLng, radLat); Vector3 cityNormal = PlanetEarth.GetNormal(radLng, radLat); cityNormal.Normalize(); Vector3 hpPos = SelectedCity.Position + tangy * 150 + cityNormal * 400; Viewport vp = renderSys.Viewport; Vector3 screenPos = vp.Project(hpPos, scene.Camera.ProjectionMatrix, scene.Camera.ViewMatrix, Matrix.Identity); Vector3 lp = vp.Project(hpPos + tangx, scene.Camera.ProjectionMatrix, scene.Camera.ViewMatrix, Matrix.Identity); Vector3 rp = vp.Project(hpPos - tangx, scene.Camera.ProjectionMatrix, scene.Camera.ViewMatrix, Matrix.Identity); float scale = 1.75f * Vector3.Distance(lp, rp) / 2; Matrix trans = Matrix.Translation(-onCityHPBackground.Width / 2, -onCityHPBackground.Height / 2, 0) * Matrix.Scaling(scale, scale, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0); int hpTexWidth = (int)(onCityHPTex.Width * SelectedCity.HPRate); sprite.SetTransform(trans); sprite.Draw(onCityHPBase, 0, 0, ColorValue.White); sprite.Draw(onCityHPTex, new Rectangle(0, 0, hpTexWidth, onCityHPTex.Height), new Rectangle(0, 0, hpTexWidth, onCityHPTex.Height), ColorValue.White); sprite.Draw(onCityHPBackground, 0, 0, ColorValue.White); f6.DrawString(sprite, SelectedCity.Level.ToString(), 25, -16, ColorValue.White); sprite.SetTransform(Matrix.Identity); } }
private void RenderSendBall(Sprite sprite) { if (targetCity != null) { float radLng = MathEx.Degree2Radian(targetCity.Longitude); float radLat = MathEx.Degree2Radian(targetCity.Latitude); float lngSign = Math.Sign(radLng); Vector3 tangy = PlanetEarth.GetTangentY(radLng, radLat); Vector3 tangx = PlanetEarth.GetTangentX(radLng, radLat); Vector3 cityNormal = PlanetEarth.GetNormal(radLng, radLat); cityNormal.Normalize(); Vector3 hpPos = targetCity.Position + cityNormal * 100 + tangx * (lngSign * City.CityRadius * 0.55f); Viewport vp = renderSys.Viewport; Vector3 screenPos = vp.Project(hpPos, scene.Camera.ProjectionMatrix, scene.Camera.ViewMatrix, Matrix.Identity); Vector3 lp = vp.Project(hpPos + tangx, scene.Camera.ProjectionMatrix, scene.Camera.ViewMatrix, Matrix.Identity); Vector3 rp = vp.Project(hpPos - tangx, scene.Camera.ProjectionMatrix, scene.Camera.ViewMatrix, Matrix.Identity); float scale0 = MathEx.Saturate(1.5f * Vector3.Distance(lp, rp)); float scale = (animProgress * animProgress) * scale0; Matrix trans = Matrix.Translation(0, -background.Height / 2, 0) * Matrix.Scaling(scale, scale, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0); sprite.SetTransform(trans); if (selectedIndex == -1) { sprite.Draw(background, 0, 0, ColorValue.White); } else { sprite.Draw(backgroundSelected[selectedIndex], 0, 0, ColorValue.White); } UpdateHotarea(ref trans); if (state == State.Opened) { Matrix trans2 = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) * Matrix.Scaling(scale0, scale0, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0); sprite.SetTransform(trans2); RenderBallIcon(sprite); } sprite.SetTransform(Matrix.Identity); } }
public override void Draw() { Sprite?.Draw(); }
public void Draw(SpriteBatch spriteBatch) { Sprite.Draw(spriteBatch, DestinationRectangle); }
public virtual void Draw(SpriteBatch batch, Vector2 offset) { Sprite?.Draw(batch, Position - offset); }
public override void Draw(SpriteBatch spriteBatch) { sprite.Draw(spriteBatch, new Point((int)position.X, (int)position.Y)); }
private void SlimDX_Render() { if (device == null) { return; } if (LoadingImages) { return; } device.Clear(ClearFlags.Target, new Color4(BackColor), 1.0f, 0); device.BeginScene(); device.SetRenderState(RenderState.AlphaBlendEnable, true); device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha); if (NeedsUpdate) { } if ((CurrentMap != null) && (CurrentMap.Tex != null)) { float smooth = 1.0f - (((float)SmoothingUpDown.Value) * 0.9f); float elapsed = (float)Math.Min(FrameTimer.Elapsed.TotalSeconds, 0.1); CurrentZoom = CurrentZoom + (TargetZoom - CurrentZoom) * smooth; CurrentViewCenter = CurrentViewCenter + (TargetViewCenter - CurrentViewCenter) * smooth; float w = ClientSize.Width; float h = ClientSize.Height; Matrix scale = Matrix.Scaling(CurrentZoom, CurrentZoom, 0.0f); Matrix trans = Matrix.Translation(-CurrentViewCenter); Matrix offset = Matrix.Translation(w * 0.5f, h * 0.5f, 0.0f); Matrix matrix = Matrix.Multiply(Matrix.Multiply(trans, scale), offset); sprite.Begin(SpriteFlags.None); sprite.Transform = matrix; sprite.Draw(CurrentMap.Tex, Color.White); sprite.End(); sprite.Begin(SpriteFlags.None); sprite.Transform = Matrix.Identity; //sort by Y to make markers look correct RenderMarkers.Clear(); RenderMarkers.AddRange(Markers); RenderMarkers.Sort((m1, m2) => m1.TexturePos.Y.CompareTo(m2.TexturePos.Y)); //draw all the markers foreach (MapMarker m in RenderMarkers) { if ((m.Icon != null) && (m.Icon.Tex != null)) { UpdateMarkerScreenPos(m); sprite.Transform = GetMarkerRenderMatrix(m); sprite.Draw(m.Icon.Tex, Color.White); } } //draw the locator marker MapIcon locic = LocatorMarker.Icon; if ((ShowLocatorCheckBox.Checked) && (locic != null) && (locic.Tex != null)) { UpdateMarkerScreenPos(LocatorMarker); sprite.Transform = GetMarkerRenderMatrix(LocatorMarker); sprite.Draw(locic.Tex, Color.White); } sprite.End(); } device.EndScene(); device.Present(); if (SelectedMarker != null) { UpdateSelectionPanel(); } FrameTimer.Restart(); }
public override void Draw(GameTime gameTime) { sprite.DestinationRectangle.Location = Rectangle.Location; sprite.Draw(gameTime); }
/// <summary> /// 绘制动画当前帧 /// </summary> /// <returns>是否正常绘制</returns> public bool Draw(Sprite sprite , Vector3 pos) { AnimationFrame aniFrame = currentFrame; sprite.Draw(texture, aniFrame.ClipRect, aniFrame.FrameOffset, pos, Color.White.ToArgb()); return true; }
public virtual void Draw(SpriteBatch spriteBatch) { //Console.WriteLine(Sprite?.CurrentFrame); //Console.WriteLine("sprite size: " + Sprite.Size); Sprite?.Draw(spriteBatch, Position - Sprite.Offset); }
/// <summary> /// Draw the tile to the screen /// </summary> /// <param name="sb">The SpriteBatch used to draw the textures</param> public virtual void Draw(SpriteBatch sb) { sprite.Draw(sb); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { try { RenderIntoSurface(); m_d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, m_clBackColor , 1.0f, 0); SetupCamera(); m_d3dDevice.BeginScene(); if(this.Editor != null && this.Editor.PhysicalStructure != null && m_d3dDevice != null) if(Editor.PhysicalStructure.RootBody != null) { RigidBodies.RigidBody_DX rbRoot = (RigidBodies.RigidBody_DX)Editor.PhysicalStructure.RootBody; if(rbRoot.Device == null || m_bReset) { rbRoot.InitDevice(m_d3dDevice); m_bReset = false; this.Invalidate(); } else Editor.PhysicalStructure.Draw(Editor.CommandBar.CommandMode); } using (Sprite s = new Sprite(m_d3dDevice)) { //save the renderTexture to a graphics stream //gsStream = TextureLoader.SaveToStream(ImageFileFormat.Dds, renderTexture); //load the renderTexture to a texture object with a color key for transparency //texTransBillBoard = TextureLoader.FromStream(Device,gsStream,0,0,1,Usage.None,Format.Unknown,Pool.Managed,Filter.None, Filter.None,Color.Black.ToArgb()); //Draw the texture s.Begin(SpriteFlags.None); s.Draw(renderTexture, new Rectangle(0,0, RenderSurfaceSize, RenderSurfaceSize), new Vector3(), new Vector3(0,0,0.0f), Color.White); s.End(); } m_d3dDevice.EndScene(); m_d3dDevice.Present(this); } catch(Microsoft.DirectX.Direct3D.DeviceLostException) { try { m_d3dDevice.Reset(m_ppPresentParams); this.Invalidate(); } catch (DeviceLostException) { // If it's still lost or lost again, just do nothing } } catch(Exception ex) { Util.Logger.LogMsg(AnimatTools.Interfaces.Logger.enumLogLevel.Error, Util.GetErrorDetails("", ex)); if(Editor.PhysicalStructure.RootBody == null) return; } }
private void RenderCityStatus(Sprite sprite) { if (selectCity != null) { int hp = (int)selectCity.HealthValue; int hpFull = (int)(selectCity.HealthValue / selectCity.HPRate); int level = selectCity.Level; string name = selectCity.Name; if (selectCity.Owner == player) { sprite.Draw(statusBackground, 405, 580, ColorValue.White); } else { sprite.Draw(statusEnemyBackground, 405, 580, ColorValue.White); } if (isHPBuffer) { Matrix buffScale = Matrix.Scaling(new Vector3(0.1f * (float)Math.Sin(buffWave) + 1)); buffScale.TranslationValue = new Vector3(776 + statusHPBufferTex.Width / 2, 624 + statusHPBufferTex.Height / 2, 0); sprite.SetTransform(buffScale); sprite.Draw(statusHPBufferTex, -statusHPBufferTex.Width / 2, -statusHPBufferTex.Height / 2, ColorValue.White); } if (isExpBuffer) { Matrix buffScale = Matrix.Scaling(new Vector3(0.1f * (float)Math.Sin(buffWave) + 1)); buffScale.TranslationValue = new Vector3(802 + statusExpBuffTex.Width / 2, 624 + statusExpBuffTex.Height / 2, 0); sprite.SetTransform(buffScale); sprite.Draw(statusExpBuffTex, -statusExpBuffTex.Width / 2, -statusExpBuffTex.Height / 2, ColorValue.White); } if (isDownShow) { Matrix buffScale = Matrix.Scaling(new Vector3(0.1f * (float)Math.Sin(buffWave) + 1)); buffScale.TranslationValue = new Vector3(839 + statusExpdownBuff.Width / 2, 622 + statusExpdownBuff.Height / 2, 0); sprite.SetTransform(buffScale); sprite.Draw(statusExpdownBuff, -statusExpdownBuff.Width / 2, -statusExpdownBuff.Height / 2, ColorValue.White); } sprite.SetTransform(Matrix.Identity); f6.DrawString(sprite, selectCity.Name.ToUpperInvariant(), 456, 572, ColorValue.White); f6.DrawString(sprite, level.ToString().ToUpperInvariant(), 775, 570, ColorValue.White); //画资源球图标 int hpTexWidth = (int)(statusHPTex.Width * SelectedCity.HPRate); string hpInfo = hp.ToString() + "/" + hpFull.ToString(); int expTexWidth = (int)(statusExpTex.Width * selectCity.LevelEP); string expInfo = "EXP " + ((int)(selectCity.LevelEP * 100)).ToString() + "/100"; //HP sprite.Draw(statusHPTex, new Rectangle(505, 638, hpTexWidth, statusHPTex.Height), new Rectangle(0, 0, hpTexWidth, statusHPTex.Height), ColorValue.White); sprite.Draw(statusHPBackground, 506, 640, ColorValue.White); if (selectCity.Owner == player) { Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation(new Vector3(579, 638, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, hpInfo, 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); //EXP sprite.Draw(statusExpTex, new Rectangle(578, 624, expTexWidth, statusExpTex.Height), new Rectangle(0, 0, expTexWidth, statusExpTex.Height), ColorValue.White); sprite.Draw(statusExpBackground, 579, 624, ColorValue.White); trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation(new Vector3(635, 620, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, expInfo, 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); } } }
public override void Render(Sprite sprite) { sprite.Draw(background, 0, 0, ColorValue.White); if (showPrg > 0.5f) { Matrix trans = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) * Matrix.Scaling((showPrg - 0.5f) * 2 * 0.8f + 0.2f, 1, 1) * Matrix.Translation(97 + background.Width / 2, 24 + background.Height / 2, 0); sprite.SetTransform(trans); sprite.Draw(panel, 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); } //int idx = currentPage; //if (idx >= TotalPages) // idx = TotalPages - 1; if (state == NIGDialogState.Showing) { sprite.Draw(nextBtn, nextButton.X, nextButton.Y, ColorValue.White); if (nextButton.IsMouseOver && !nextButton.IsPressed) { sprite.Draw(nextBtn, nextButton.X, nextButton.Y - 1, ColorValue.White); } sprite.Draw(prevBtn, prevButton.X, prevButton.Y, ColorValue.White); if (prevButton.IsMouseOver && !exitButton.IsPressed) { sprite.Draw(prevBtn, prevButton.X, prevButton.Y - 1, ColorValue.White); } sprite.Draw(exitBtn, exitButton.X, exitButton.Y, ColorValue.White); if (exitButton.IsMouseOver && !exitButton.IsPressed) { sprite.Draw(exitBtn, exitButton.X, exitButton.Y - 3, ColorValue.White); } sprite.Draw(help[currentPage], 0, 0, ColorValue.White); } sprite.Draw(cursor, mousePosition.X, mousePosition.Y, ColorValue.White); }
public override void DrawStone(byte x, byte y, bool black) { sprite.Draw(black ? blackStone : whiteStone, Vector3.Empty, new Vector3(x * stoneSize, y * stoneSize, 0), Color.White.ToArgb()); }
public void drawImage2d(Device i_dev,int i_x,int i_y,INyARRgbRaster i_raster) { NyARIntSize s = i_raster.getSize(); if (this._texture == null) { this._texture=new NyARD3dTexture(i_dev,s.w,s.h); } else if (!this._texture.isEqualSize(s)) { this._texture.Dispose(); this._texture = new NyARD3dTexture(i_dev, s.w, s.h); } this._texture.setRaster(i_raster); using (Sprite sp = new Sprite(i_dev)) { sp.Begin(SpriteFlags.None); sp.Draw((Texture)this._texture, new Rectangle(i_x,i_y, s.w,s.h), Vector3.Empty,new Vector3(i_dev.Viewport.X, i_dev.Viewport.Y, 0),Color.White); sp.End(); } }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { Sprite?.Draw(spriteBatch, Position); //Collider?.DebugDraw(spriteBatch, _debugTexture, Color.DarkRed); }
public void Draw(SpriteBatch spriteBatch) { _sprite.Draw(spriteBatch); }
public override void Render(Sprite sprite) { if (state != NIGDialogState.Hiding) { ColorValue overlayColor = ColorValue.Transparent; overlayColor.A = (byte)(165 * showPrg); sprite.Draw(overlay, 0, 0, overlayColor); int x = 451; int y = 157; float scale = -MathEx.Sqr(MathEx.Saturate(showPrg) * 1.5f - 1) + 1; scale = (1.0f / 0.75f) * scale; Matrix trans = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) * Matrix.Scaling(scale, scale, 1) * Matrix.Translation(x + background.Width / 2, y + background.Height / 2, 0); sprite.SetTransform(trans); sprite.Draw(background, 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); sprite.Draw(resumeButton.Image, resumeButton.X, resumeButton.Y, ColorValue.White); if (resumeButton.IsMouseOver) { sprite.Draw(resumeButton.Image, resumeButton.X, resumeButton.Y - 4, ColorValue.White); } sprite.Draw(restartButton.Image, restartButton.X, restartButton.Y, ColorValue.White); if (restartButton.IsMouseOver) { sprite.Draw(restartButton.Image, restartButton.X, restartButton.Y - 4, ColorValue.White); } sprite.Draw(exitButton.Image, exitButton.X, exitButton.Y, ColorValue.White); if (exitButton.IsMouseOver) { sprite.Draw(exitButton.Image, exitButton.X, exitButton.Y - 4, ColorValue.White); } } }
internal void Draw(SpriteBatch spriteBatch, GameTime gameTime) { switch (op.NewGameState) { case EventOperator.MENU_STATE: #region SplashScreen if (op.GameState == EventOperator.SPLASH_SCREEN_STATE) { if (InputHandler.isJustPressed(MouseButton.LEFT)) { eventTimer.Finish(); } else { int alphaChannel = (int)(455 * (SPLASHTIME - eventTimer.currentTime) / SPLASHTIME) - 100; logo.MColor = new Color(255, 255, 255, alphaChannel); logo.Draw(spriteBatch, gameTime); } } #endregion #region GiveUp else { op.ResetGame(false); game.UpdateGame(gameTime, false); game.DrawGame(spriteBatch, gameTime, false); string s = "Mediocre!"; //! spriteBatch.DrawOutlinedString(3, new Color(32, 32, 32), font, s, DrawHelper.CenteredWordPosition(s, font), Color.Gold); } #endregion break; case EventOperator.GAME_STATE: #region CountDown game.DrawGame(spriteBatch, gameTime, false); DrawCountDown(spriteBatch, gameTime); #endregion break; case EventOperator.GAME_OVER_STATE: #region GameOver Animation if (eventTimer.currentTime > STATSTIME) { game.UpdateGame(gameTime, false); game.DrawGame(spriteBatch, gameTime, false); Vector2 shitvect = new Vector2(WindowSize.Width / 2 - font.MeasureString("GAME OVER").X / 2, WindowSize.Height / 2 - font.MeasureString("GAME OVER").Y / 2); //previously bigFont in Game1 spriteBatch.DrawOutlinedString(3, new Color(32, 32, 32), font, "GAME OVER", shitvect, Color.OrangeRed); } #endregion #region DrawStats else { SoundHandler.PlaySong((int)IDs.GAMEOVER); DrawStats(spriteBatch, gameTime); if (InputHandler.isJustPressed(MouseButton.LEFT)) { eventTimer = new Timer(0); } } #endregion break; case EventOperator.CUT_SCENE_STATE: #region Cutscenes switch (op.CutSceneType) { case 1: BossFinishedScene(spriteBatch, gameTime); break; case 2: BossAppearanceScene(spriteBatch, gameTime); break; } #endregion break; } }
public void DrawOverlay(Surface targetSurface) { Texture subTexture; Subtitle currentSubtitle; lock (_syncObj) { currentSubtitle = _currentSubtitle; subTexture = _subTexture; // Available sub is not due if (currentSubtitle == null || !currentSubtitle.ShouldDraw) return; if (targetSurface == null || targetSurface.Disposed || subTexture == null) { if (_drawCount > 0) ServiceRegistration.Get<ILogger>().Debug("Draw count for last sub: {0}", _drawCount); _drawCount = 0; return; } _drawCount++; } try { if (!subTexture.Disposed) { // TemporaryRenderTarget changes RenderTarget to texture and restores settings when done (Dispose) using (new TemporaryRenderTarget(targetSurface)) using (TemporaryRenderState temporaryRenderState = new TemporaryRenderState()) using (Sprite sprite = new Sprite(_device)) { sprite.Begin(SpriteFlags.AlphaBlend); // No alpha test here, allow all values temporaryRenderState.SetTemporaryRenderState(RenderState.AlphaTestEnable, 0); // Use the SourceAlpha channel and InverseSourceAlpha for destination temporaryRenderState.SetTemporaryRenderState(RenderState.BlendOperation, (int) BlendOperation.Add); temporaryRenderState.SetTemporaryRenderState(RenderState.SourceBlend, (int) Blend.SourceAlpha); temporaryRenderState.SetTemporaryRenderState(RenderState.DestinationBlend, (int) Blend.InverseSourceAlpha); // Check the target texture dimensions and adjust scaling and translation SurfaceDescription desc = targetSurface.Description; Matrix transform = Matrix.Identity; transform *= Matrix.Translation(currentSubtitle.HorizontalPosition, currentSubtitle.FirstScanLine, 0); // Subtitle could be smaller for 16:9 anamorphic video (subtitle width: 720, video texture: 1024) // then we need to scale the subtitle width also. if (currentSubtitle.ScreenWidth != desc.Width) transform *= Matrix.Scaling((float) desc.Width / currentSubtitle.ScreenWidth, 1, 1); sprite.Transform = transform; sprite.Draw(subTexture, Color.White); sprite.End(); } } } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Debug("Error in DrawOverlay", ex); } if (_onTextureInvalidated != null) _onTextureInvalidated(); }
public void Draw(SpriteBatch spriteBatch) { Sprite?.Draw(spriteBatch, Position); }
public override void Render(Sprite sprite) { if (state != NIGDialogState.Hiding) { ColorValue overlayColor = ColorValue.Transparent; overlayColor.A = (byte)(165 * showPrg); sprite.Draw(overlay, 0, 0, overlayColor); int x = 373; int y = 54; float scale = -MathEx.Sqr(MathEx.Saturate(showPrg) * 1.5f - 1) + 1; scale = (1.0f / 0.75f) * scale; Matrix trans = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) * Matrix.Scaling(scale, scale, 1) * Matrix.Translation(x + background.Width / 2, y + background.Height / 2, 0); sprite.SetTransform(trans); sprite.Draw(background, 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); } if (state == NIGDialogState.Showing) { //sprite.Draw(failTex, 661, 54, ColorValue.White); if (clearProgress > 1) { float scale = -MathEx.Sqr(MathEx.Saturate(1 * 6) * 1.5f - 1) + 1; scale = 0.5f + 1.5f * scale; Matrix trans = Matrix.Scaling(scale, scale, 1) * Matrix.Translation(661 + failTex.Width / 2, 54 + failTex.Height / 2, 0); sprite.SetTransform(trans); sprite.Draw(failTex, -failTex.Width / 2, -failTex.Height / 2, ColorValue.White); sprite.SetTransform(Matrix.Identity); } if (clearProgress <= 1) { float scale = -MathEx.Sqr(MathEx.Saturate(clearProgress * 6) * 1.5f - 1) + 1; scale = 0.5f + 1.5f * scale; Matrix trans = Matrix.Scaling(scale, scale, 1) * Matrix.Translation(661 + failTex.Width / 2, 54 + failTex.Height / 2, 0); sprite.SetTransform(trans); sprite.Draw(failTex, -failTex.Width / 2, -failTex.Height / 2, ColorValue.White); sprite.SetTransform(Matrix.Identity); } sprite.Draw(backButton.Image, backButton.X, backButton.Y, ColorValue.White); if (backButton.IsMouseOver) { sprite.Draw(backButton.Image, backButton.X, backButton.Y - 4, ColorValue.White); } sprite.Draw(replayButton.Image, replayButton.X, replayButton.Y, ColorValue.White); if (replayButton.IsMouseOver) { sprite.Draw(replayButton.Image, replayButton.X, replayButton.Y - 4, ColorValue.White); } RenderRank(sprite); } }
public override void Render(Sprite sprite) { if (state != NIGDialogState.Hiding) { ColorValue overlayColor = ColorValue.Transparent; overlayColor.A = (byte)(165 * showPrg); sprite.Draw(overlay, 0, 0, overlayColor); int x = 442; int y = 164; float scale = -MathEx.Sqr(MathEx.Saturate(showPrg) * 1.5f - 1) + 1; scale = (1.0f / 0.75f) * scale; Matrix trans = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) * Matrix.Scaling(scale, scale, 1) * Matrix.Translation(x + background.Width / 2, y + background.Height / 2, 0); sprite.SetTransform(trans); sprite.Draw(background, 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); } if (state == NIGDialogState.Showing) { sprite.Draw(okButton.Image, okButton.X, okButton.Y, ColorValue.White); if (okButton.IsMouseOver) { sprite.Draw(okButton.Image, okButton.X, okButton.Y - 4, ColorValue.White); } GameFontManager.Instance.FRuanEdged8.DrawString(sprite, "TRANSFORM 23 CITIES.\nYOU MUST SURVIVE.", 540, 240, ColorValue.White); } }
public override void DrawHUD(SpriteBatch spriteBatch, Character character) { if (HudTint.A > 0) { GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), new Color(HudTint.R, HudTint.G, HudTint.B) * (HudTint.A / 255.0f), true); } GetAvailablePower(out float batteryCharge, out float batteryCapacity); List <Item> availableAmmo = new List <Item>(); foreach (MapEntity e in item.linkedTo) { if (!(e is Item linkedItem)) { continue; } var itemContainer = linkedItem.GetComponent <ItemContainer>(); if (itemContainer == null) { continue; } availableAmmo.AddRange(itemContainer.Inventory.AllItems); for (int i = 0; i < itemContainer.Inventory.Capacity - itemContainer.Inventory.AllItems.Count(); i++) { availableAmmo.Add(null); } } float chargeRate = powerConsumption <= 0.0f ? 1.0f : batteryCapacity > 0.0f ? batteryCharge / batteryCapacity : 0.0f; bool charged = batteryCharge * 3600.0f > powerConsumption; bool readyToFire = reload <= 0.0f && charged && availableAmmo.Any(p => p != null); if (ShowChargeIndicator && PowerConsumption > 0.0f) { powerIndicator.Color = charged ? GUI.Style.Green : GUI.Style.Red; if (flashLowPower) { powerIndicator.BarSize = 1; powerIndicator.Color *= (float)Math.Sin(flashTimer * 12); powerIndicator.RectTransform.ChangeScale(Vector2.Lerp(Vector2.One, Vector2.One * 1.01f, 2 * (float)Math.Sin(flashTimer * 15))); } else { powerIndicator.BarSize = chargeRate; } powerIndicator.DrawManually(spriteBatch, true); Rectangle sliderRect = powerIndicator.GetSliderRect(1.0f); int requiredChargeIndicatorPos = (int)(powerConsumption / (batteryCapacity * 3600.0f) * sliderRect.Width); GUI.DrawRectangle(spriteBatch, new Rectangle(sliderRect.X + requiredChargeIndicatorPos, sliderRect.Y, 2, sliderRect.Height), Color.White * 0.5f, true); } if (ShowProjectileIndicator) { Point slotSize = (Inventory.SlotSpriteSmall.size * Inventory.UIScale).ToPoint(); Point spacing = new Point(GUI.IntScale(5), GUI.IntScale(20)); int slotsPerRow = Math.Min(availableAmmo.Count, 6); int totalWidth = slotSize.X * slotsPerRow + spacing.X * (slotsPerRow - 1); int rows = (int)Math.Ceiling(availableAmmo.Count / (float)slotsPerRow); Point invSlotPos = new Point(GameMain.GraphicsWidth / 2 - totalWidth / 2, powerIndicator.Rect.Y - (slotSize.Y + spacing.Y) * rows); for (int i = 0; i < availableAmmo.Count; i++) { // TODO: Optimize? Creates multiple new objects per frame? Inventory.DrawSlot(spriteBatch, null, new VisualSlot(new Rectangle(invSlotPos + new Point((i % slotsPerRow) * (slotSize.X + spacing.X), (int)Math.Floor(i / (float)slotsPerRow) * (slotSize.Y + spacing.Y)), slotSize)), availableAmmo[i], -1, true); } Rectangle rect = new Rectangle(invSlotPos.X, invSlotPos.Y, totalWidth, slotSize.Y); float inflate = MathHelper.Lerp(3, 8, (float)Math.Abs(Math.Sin(flashTimer * 5))); rect.Inflate(inflate, inflate); Color color = GUI.Style.Red * Math.Max(0.5f, (float)Math.Sin(flashTimer * 12)); if (flashNoAmmo) { GUI.DrawRectangle(spriteBatch, rect, color, thickness: 3); } else if (flashLoaderBroken) { GUI.DrawRectangle(spriteBatch, rect, color, thickness: 3); GUI.BrokenIcon.Draw(spriteBatch, rect.Center.ToVector2(), color, scale: rect.Height / GUI.BrokenIcon.size.Y); GUIComponent.DrawToolTip(spriteBatch, TextManager.Get("turretloaderbroken"), new Rectangle(invSlotPos.X + totalWidth + GUI.IntScale(10), invSlotPos.Y + slotSize.Y / 2 - GUI.IntScale(9), 0, 0)); } } float zoom = cam == null ? 1.0f : (float)Math.Sqrt(cam.Zoom); GUI.HideCursor = (crosshairSprite != null || crosshairPointerSprite != null) && GUI.MouseOn == null && !GameMain.Instance.Paused; if (GUI.HideCursor) { crosshairSprite?.Draw(spriteBatch, crosshairPos, readyToFire ? Color.White : Color.White * 0.2f, 0, zoom); crosshairPointerSprite?.Draw(spriteBatch, crosshairPointerPos, 0, zoom); } }
public override void Render(IntPtr rendererId, Point viewOffset) { sprite.Draw(rendererId, Location.ToPoint() - viewOffset); }
/// <summary> /// Draw the icon /// </summary> public void MouseOverRender(DrawArgs drawArgs, Sprite sprite, Vector3 projectedPoint) { JHU_IconTexture iconTexture = this.GetTexture(); if(this.isSelectable) DrawArgs.MouseCursor = CursorType.Hand; if (!this.isInitialized) this.Initialize(drawArgs); if ((!this.m_isUpdated) || (drawArgs.WorldCamera.Altitude < 300000)) { this.UpdatePosition(drawArgs); } // set description to icon descrption m_globals.GeneralInfoLabel.Text = GeneralInfo(); m_globals.DetailedInfoLabel.Text = DetailedInfo(); m_globals.DescriptionLabel.Text = DescriptionInfo(); if(iconTexture==null) { // Render label if(this.Name != null) { // Center over target as we have no bitmap Rectangle rect = new Rectangle( (int)projectedPoint.X - (labelWidth>>1), (int)(projectedPoint.Y - (drawArgs.defaultDrawingFont.Description.Height >> 1)), labelWidth, drawArgs.screenHeight ); drawArgs.defaultDrawingFont.DrawText(sprite, this.Name, rect, DrawTextFormat.Center, hotColor); } } else { // Render label if(this.Name != null) { // Adjust text to make room for icon int spacing = (int)(this.Width * 0.3f); if(spacing>10) spacing = 10; int offsetForIcon = (this.Width>>1) + spacing; Rectangle rect = new Rectangle( (int)projectedPoint.X + offsetForIcon, (int)(projectedPoint.Y - (drawArgs.defaultDrawingFont.Description.Height >> 1)), labelWidth, drawArgs.screenHeight ); drawArgs.defaultDrawingFont.DrawText(sprite, this.Name, rect, DrawTextFormat.WordBreak, hotColor); } // Render icon sprite.Transform = Matrix.Scaling(this.XScale,this.YScale,0); if (m_isRotated) sprite.Transform *= Matrix.RotationZ((float)m_rotation.Radians - (float) drawArgs.WorldCamera.Heading.Radians); sprite.Transform *= Matrix.Translation(projectedPoint.X, projectedPoint.Y, 0); sprite.Draw( iconTexture.Texture, new Vector3(iconTexture.Width>>1, iconTexture.Height>>1,0), Vector3.Empty, hotColor ); if (m_iconTexture2Show) { sprite.Draw ( m_iconTexture2.Texture, new Vector3(m_iconTexture2.Width>>1, m_iconTexture2.Height>>1, 0), Vector3.Empty, hotColor ); } if (m_iconTexture3Show) { sprite.Draw ( m_iconTexture3.Texture, new Vector3(m_iconTexture3.Width>>1, m_iconTexture3.Height>>1, 0), Vector3.Empty, hotColor ); } // Reset transform to prepare for text rendering later sprite.Transform = Matrix.Identity; } if (m_drawGroundStick) { Vector2[] groundStick = new Vector2[2]; Vector3 projectedGroundPoint = drawArgs.WorldCamera.Project(m_groundPoint); m_groundStick.Begin(); groundStick[0].X = projectedPoint.X; groundStick[0].Y = projectedPoint.Y; groundStick[1].X = projectedGroundPoint.X; groundStick[1].Y = projectedGroundPoint.Y; m_groundStick.Draw(groundStick, m_groundStickColor); m_groundStick.End(); } }
public override void Draw() { base.Draw(); Item?.Draw(); PrimarySprite?.Draw(); }
public override void Render(Vector2 topLeft, Vector2 bottomRight) { if (IsCurrentlyWorn && currentSprite == baseSprite) { base.Render(topLeft, bottomRight); return; } else if (IsCurrentlyCarried && currentSprite != CarriedSprite) { SetSprite(CarriedSprite); base.Render(topLeft, bottomRight); return; } //Render slaves beneath IEnumerable <SpriteComponent> renderablesBeneath = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth < DrawDepth select c; foreach (SpriteComponent component in renderablesBeneath.ToList()) { component.Render(topLeft, bottomRight); } //Render this sprite if (!visible) { return; } if (NotWornSprite == null) { return; } Sprite spriteToRender = NotWornSprite; var bounds = spriteToRender.GetLocalBounds(); Vector2 renderPos = CluwneLib.WorldToScreen( Owner.GetComponent <ITransformComponent>().Position); spriteToRender.Position = new Vector2f(renderPos.X - (bounds.Width / 2), renderPos.Y - (bounds.Height / 2)); if (Owner.GetComponent <ITransformComponent>().Position.X + bounds.Left + bounds.Width < topLeft.X || Owner.GetComponent <ITransformComponent>().Position.X > bottomRight.X || Owner.GetComponent <ITransformComponent>().Position.Y + bounds.Top + bounds.Height < topLeft.Y || Owner.GetComponent <ITransformComponent>().Position.Y > bottomRight.Y) { return; } spriteToRender.Scale = new Vector2f(HorizontalFlip ? -1 : 1, 1); spriteToRender.Draw(); //Render slaves above IEnumerable <SpriteComponent> renderablesAbove = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth >= DrawDepth select c; foreach (SpriteComponent component in renderablesAbove.ToList()) { component.Render(topLeft, bottomRight); } }
public override void Render(Sprite sprite) { if (!game.IsIngame) { mainMenu.Render(sprite); if (currentScreen != null) { //if (overlayAlpha < 1) // overlayAlpha += 0.1f; //else // overlayAlpha = 1; ColorValue color = ColorValue.White; color.A = (byte)(byte.MaxValue * MathEx.Saturate(overlayAlpha) * 0.5f); currentScreen.Render(sprite); sprite.Draw(overlay34, 0, 0, color); } else { //if (overlayAlpha > 0) //{ //overlayAlpha -= 0.1f; ColorValue color = ColorValue.White; color.A = (byte)(byte.MaxValue * MathEx.Saturate(overlayAlpha) * 0.5f); sprite.Draw(overlay34, 0, 0, color); //} //else //overlayAlpha = 0; } } loadingOverlay.Render(sprite); if (intro != null) { intro.Render(sprite); } }
/// <summary> /// Renders the scene. /// </summary> public void RenderScene(Color background, List<LightObj> lights, Camera camera) { bool useGlow = false; // Sets the variables for the shader. SetVariables(lights, camera); //effect.Technique = "Test"; for (int i = 0; i < mesh.Count; i++) { if (mesh[i].Emissive.Enable && !mesh[i].Emissive.Path.Equals("")) { useGlow = true; break; } } // If/Else statement to control rendering with emissive glow or not. if (useGlow) RenderGlow(); else BeginRender(background); // If emissive glow is used, the base scene is rendered to a texture. if (useGlow) { surfRender.BeginScene(renderedScene.GetSurfaceLevel(0), device.Viewport); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, background, 1.0f, 0); } if (groundPlane.Enabled) RenderModel((Model)groundPlane, lights[0].Shadows, 0); // Loops through all the models and renders each. for (int i = 0; i < mesh.Count; i++) { if (mesh[i].Enabled) RenderModel(mesh[i], lights[0].Shadows, 0); } if (showLights) { using (Sprite spriteobject = new Sprite(device)) { foreach (LightObj light in lights) { if (!light.Enabled) continue; spriteobject.SetWorldViewRH(device.Transform.World, device.Transform.View); spriteobject.Begin(SpriteFlags.AlphaBlend | SpriteFlags.Billboard | SpriteFlags.SortTexture | SpriteFlags.ObjectSpace); //spriteobject.Transform = Matrix.Scaling(0.25f, 0.25f, 0.25f); spriteobject.Draw(lightTexture, Rectangle.Empty, Vector3.Empty, light.Direction, Color.White); spriteobject.End(); } } } // If emissive glow is used, the textures are set to the shader and rendered to a sprite. if (useGlow) { surfRender.EndScene(Filter.None); effect.SetValue("renderedScene", renderedScene); BeginRender(background); using (Sprite spriteobject = new Sprite(device)) { prevTechnique = effect.Technique; effect.Technique = "Bloom"; effect.Begin(FX.None); spriteobject.Begin(SpriteFlags.None); effect.BeginPass(0); spriteobject.Draw(renderedGlow, Rectangle.Empty, new Vector3(0, 0, 0), new Vector3(0, 0, 0), Color.White); effect.EndPass(); spriteobject.End(); effect.End(); effect.Technique = prevTechnique; } } EndRender(); }
public override void Render(Sprite sprite) { sprite.SetTransform(Matrix.Translation(PanelX, PanelY + PanelHeight, 0)); sprite.Draw(background, 0, -PanelHeight, ColorValue.White); //if (switchButton.IsPressed) //{ // sprite.Draw(switchButton.ImageMouseDown, switchButton.X, switchButton.Y - (PanelY + PanelHeight), switchButton.ModulateColor); //} //else if (switchButton.IsMouseOver) //{ // sprite.Draw(switchButton.ImageMouseOver, switchButton.X, switchButton.Y - (PanelY + PanelHeight), switchButton.ModulateColor); //} //else //{ // sprite.Draw(switchButton.Image, switchButton.X, switchButton.Y - (PanelY + PanelHeight), switchButton.ModulateColor); //} BattleField field = gameLogic.Field; #region 遍历战场上的城市,绘制地图上点 for (int i = 0; i < field.CityCount; i++) { City cc = field.Cities[i]; if (!cc.IsHomeCity) { ColorValue modColor; if (cc.IsCaptured) { modColor = cc.Owner.SideColor; } else { modColor = ColorValue.White; } Point pt; if (!positionBuffer.TryGetValue(cc, out pt)) { pt = GetPosition(MathEx.Degree2Radian(cc.Longitude), MathEx.Degree2Radian(cc.Latitude)); pt.X += MapX; pt.Y = pt.Y + MapY - PanelHeight; positionBuffer.Add(cc, pt); } sprite.Draw(mapdot, pt.X - 7, pt.Y - 7, modColor); } else { ColorValue modColor; if (cc.IsCaptured) { modColor = cc.Owner.SideColor; } else { modColor = ColorValue.White; } if (cc.IsCaptured) { Point pt; if (!positionBuffer.TryGetValue(cc, out pt)) { pt = GetPosition(MathEx.Degree2Radian(cc.Longitude), MathEx.Degree2Radian(cc.Latitude)); pt.X += MapX; pt.Y = pt.Y + MapY - PanelHeight; positionBuffer.Add(cc, pt); } sprite.Draw(mapCircle, pt.X - 12, pt.Y - 12, modColor); } } } #endregion #region 绘制摄像机 { Point pt = GetPosition(camera.Longitude, camera.Latitude); float ratio = camera.Height / 60f; Rectangle rect = new Rectangle( pt.X + MapX - (int)(cameraView.Width * ratio * 0.5f), pt.Y + MapY - (int)(cameraView.Height * ratio * 0.5f), (int)(cameraView.Width * ratio), (int)(cameraView.Height * ratio)); rect.Y -= PanelHeight; sprite.Draw(cameraView, rect, ColorValue.White); } #endregion sprite.SetTransform(Matrix.Identity); #region 绘制事件标记 for (int i = 0; i < marks.Count; i++) { marks[i].Render(sprite); } #endregion //sprite.Draw(compass, -21, 666, ColorValue.White); }
private void RenderBallIcon(Sprite sprite) { if (targetCity != null) { //Array.Sort(resBallsCount, BallRecordCompare); resBallItemSelectedCount[0] = 0; resBallItemSelectedCount[1] = 0; resBallItemSelectedCount[2] = 0; resBallItemCount[0] = 0; resBallItemCount[1] = 0; resBallItemCount[2] = 0; int order = 0; for (int i = 0; i < resBallsCount.Length; i++) { switch (resBallsCount[i].Type) { case RBallType.Green: { if (resBallsCount[i].count != 0) { UpdateSelCount(order, i); resBallsItemType[order] = RBallType.Green; resBallItemSelectedCount[order] = (int)resBallsCount[i].selectedCount; resBallItemCount[order] = resBallsCount[i].count; int x = 82 - greenBallBtn.Width / 2; int y = startY[order] - greenBallBtn.Height / 2; sprite.Draw(greenBallBtn, x, y, ColorValue.White); string count = ((int)resBallsCount[i].selectedCount).ToString(); f8.DrawString(sprite, count.ToString(), x + countStartX[order], y + countStartY[order], ColorValue.White); order++; } } break; case RBallType.Education: { if (resBallsCount[i].count != 0) { UpdateSelCount(order, i); resBallsItemType[order] = RBallType.Education; resBallItemSelectedCount[order] = (int)resBallsCount[i].selectedCount; resBallItemCount[order] = resBallsCount[i].count; int x = 88 - educationBallBtn.Width / 2; int y = startY[order] - educationBallBtn.Height / 2; sprite.Draw(educationBallBtn, x, y, ColorValue.White); string count = ((int)resBallsCount[i].selectedCount).ToString(); f8.DrawString(sprite, count.ToString(), x + countStartX[order], y + countStartY[order], ColorValue.White); order++; } } break; case RBallType.Health: { if (resBallsCount[i].count != 0) { UpdateSelCount(order, i); resBallsItemType[order] = RBallType.Health; resBallItemSelectedCount[order] = (int)resBallsCount[i].selectedCount; resBallItemCount[order] = resBallsCount[i].count; int x = 88 - healthBallBtn.Width / 2; int y = startY[order] - healthBallBtn.Height / 2; sprite.Draw(healthBallBtn, x, y, ColorValue.White); string count = ((int)resBallsCount[i].selectedCount).ToString(); f8.DrawString(sprite, count.ToString(), x + countStartX[order], y + countStartY[order], ColorValue.White); order++; } } break; } } } }
public void Draw(SpriteBatch spriteBatch) { Sprite.Draw(spriteBatch, Velocity.X < 0); }