public override void Draw(GameTime gameTime) { G.Clear(Color.Black); SB.Begin(); SB.Draw(tWisp, G.Viewport.Bounds, Color.Lerp(Color.Transparent, Color.White, MathHelper.Clamp(et / TRANS_DURATION, 0, 1))); SB.End(); }
public override void Draw(GameTime gameTime) { float dt = (float)gameTime.ElapsedGameTime.TotalSeconds; if (!pauseRender) { camera.Update(state.CGrid, RTSConstants.GAME_DELTA_TIME); renderer.Update(state); renderer.Draw(state, RTSConstants.GAME_DELTA_TIME); } else { G.Clear(Color.Black); } vInput.Draw(renderer, SB); DrawFPS(gameTime); game.DrawDevConsole(); game.DrawMouse(); if (tPopup != null) { SB.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied); SB.Draw(tPopup, rPopup, Color.White); SB.End(); } if (end) { tl -= dt; if (tl < 0) { State = ScreenState.ChangePrevious; } Vector2 center = new Vector2(G.Viewport.Width, G.Viewport.Height) * 0.5f; SB.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone); SB.Draw( gResult < 0 ? tDefeat : tVictory, center, null, Color.Lerp(Color.Transparent, Color.White, MathHelper.Clamp(3f - tl, 0, 1)), 0f, gResult < 0 ? ctD : ctV, MathHelper.Lerp(0.3f, 1f, MathHelper.Clamp(3f - tl, 0, 1)), SpriteEffects.None, 0f ); SB.End(); } else if (state.gtC.VictoriousTeam.HasValue) { end = true; tl = 3f; gResult = state.gtC.VictoriousTeam.Value; } }
public override void Draw(GameTime gameTime) { G.Clear(Color.Black); if (ShouldRebuild) { Rebuild(fIn, fOut); } if (rtHeight != null) { SB.Begin(); SB.Draw(rtHeight, G.Viewport.TitleSafeArea, Color.White); SB.End(); } }
private void DrawLightning(LightningData data, float w) { SB.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone); for (int i = 0; i < data.Lines.Count;) { Vector2 s = data.Lines[i++]; Vector2 e = data.Lines[i++]; Vector2 d = e - s; float dist = d.Length(); d /= dist; float r = (float)Math.Atan2(d.Y, d.X); SB.Draw(tLightning, s, rsLEndL, data.Color, r, originLEndL, new Vector2(w, w) * scaleLEnd, SpriteEffects.None, 0); SB.Draw(tLightning, s, rsLMid, data.Color, r, originLMid, new Vector2(dist, w) * scaleLMid, SpriteEffects.None, 0); SB.Draw(tLightning, e, rsLEndR, data.Color, r, originLEndR, new Vector2(w, w) * scaleLEnd, SpriteEffects.None, 0); } SB.End(); }
public override void Draw(GameTime gameTime) { G.Clear(Color.Transparent); if (wr != null) { SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone); SB.Draw(tLoad, G.Viewport.Bounds, Color.White); if (tip != null) { SB.Draw(tPixel, new Rectangle(TIPS_OFFSET, TIPS_OFFSET, G.Viewport.Width - TIPS_OFFSET * 2, TIPS_HEIGHT), COLOR_BACK); SB.DrawString(font, tip, Vector2.One * (TIPS_OFFSET * 2), COLOR_HIGH); } SB.End(); wr.Draw(SB); } else { int minX = BOUNDS_OFFSET - BAR_WIDTH; int maxX = G.Viewport.Bounds.Width - BOUNDS_OFFSET; // Calculate Progress Bar Rectangle rBar = G.Viewport.Bounds; rBar.X = (int)(percent * (maxX - minX)) + minX; rBar.Y = G.Viewport.Height - BOUNDS_OFFSET - BAR_HEIGHT; rBar.Height = BAR_HEIGHT; rBar.Width = BAR_WIDTH; if (rBar.Width + rBar.X > maxX) { rBar.Width = maxX - rBar.X; } else if (rBar.X < BOUNDS_OFFSET) { rBar.Width = rBar.X + rBar.Width - BOUNDS_OFFSET; rBar.X = BOUNDS_OFFSET; } Rectangle rBack = G.Viewport.Bounds; rBack.X = BOUNDS_OFFSET - BACK_SIZE; rBack.Y = G.Viewport.Bounds.Height - BOUNDS_OFFSET - BAR_HEIGHT - BACK_SIZE; rBack.Width -= (BOUNDS_OFFSET - BACK_SIZE) * 2; rBack.Height = BAR_HEIGHT + BACK_SIZE * 2; SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone); // Draw A Background Image SB.Draw(tLoad, G.Viewport.Bounds, Color.White); // Draw The Progress Bar SB.Draw(tPixel, rBack, COLOR_BACK); SB.Draw(tPixel, rBar, Color.Lerp(COLOR_LOW, COLOR_HIGH, percent)); if (tip != null) { SB.Draw(tPixel, new Rectangle(TIPS_OFFSET, TIPS_OFFSET, G.Viewport.Width - TIPS_OFFSET * 2, TIPS_HEIGHT), COLOR_BACK); SB.DrawString(font, tip, Vector2.One * (TIPS_OFFSET * 2), COLOR_HIGH); } SB.End(); } game.DrawMouse(); }
public override void Draw(GameTime gameTime) { if (lastLightning > 0) { lastLightning--; } bool playSound = false; // Compute Lightning LightningData bolts = new LightningData(lBoltArgs.Color); LightningData branches = new LightningData(lBranchArgs.Color); int rC = r.Next(LightningPerFrame); for (int i = 0; i < rC; i++) { Vector2 ts = Vector2.Zero, te = ts; if (r.NextDouble() > uic.BranchProbability) { te = ViewSize / 2f; ts = textPos[r.Next(textPos.Count)]; float d2 = float.MaxValue; for (int ri = 0; ri < LightningNeighborChecks; ri++) { Vector2 tet = textPos[r.Next(textPos.Count)]; float d2t = (tet - ts).LengthSquared(); if (d2t < d2) { d2 = d2t; te = tet; } } lBoltArgs.Start = ts; lBoltArgs.End = te; LightningGenerator.CreateLightning(lBoltArgs, ref bolts, r); } else { playSound = true; float bsx = (float)r.NextDouble() * ViewSize.X; lBranchArgs.Start = new Vector2(bsx, 0); lBranchArgs.End = new Vector2(bsx, ViewSize.Y * 10f); LightningGenerator.CreateBranch(lBranchArgs, ref branches, r); } } playSound &= lastLightning == 0; if (playSound) { lastLightning = uic.LightningPlayPause; seLightning.Play(); } // Set Render Target To Lightning G.SetRenderTarget(rtLightning); G.Clear(Color.Transparent); // Draw Faded Lightning SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); SB.Draw(rtLightningPrev, G.Viewport.TitleSafeArea, new Color(BoltFade, BoltFade, BoltFade, BoltFade)); SB.End(); DrawLightning(bolts, uic.Bolt.Width); // Set Render Target To Lightning Branches G.SetRenderTarget(rtLightningBr); G.Clear(Color.Transparent); // Draw Faded Lightning Branches SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); SB.Draw(rtLightningBrPrev, G.Viewport.TitleSafeArea, new Color(BoltFade, BoltFade, BoltFade, BoltFade)); SB.End(); DrawLightning(branches, uic.Branch.Width); SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); SB.Draw(tLightning, ViewSize / 2f, null, Color.Black, 0, new Vector2(tLightning.Width, tLightning.Height) / 2f, new Vector2(4f, 0.7f), SpriteEffects.None, 0); SB.End(); // Draw Lightning To User G.SetRenderTarget(null); G.Clear(uic.ColorBackground); SB.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); SB.Draw(rtLightning, G.Viewport.TitleSafeArea, Color.White); SB.Draw(rtLightningBr, G.Viewport.TitleSafeArea, Color.White); SB.End(); // Swap Lightning Render Targets var b = rtLightning; rtLightning = rtLightningPrev; rtLightningPrev = b; b = rtLightningBr; rtLightningBr = rtLightningBrPrev; rtLightningBrPrev = b; }
public override void Draw(GameTime gameTime) { SB.Begin(); SB.Draw(tImage, G.Viewport.Bounds, Color.White); SB.End(); }