// Use this for initialization new void Start() { base.Start(); LightningGenerator lg = GetComponentInChildren <LightningGenerator>(); if (lg == null) { enabled = false; } else { Fire = lg.Fire; } }
private void ProcessEmailRequest(HttpRequestMessage request, HttpResponseMessage response) { XDocument doc = XDocument.Parse(ApplyTemplate(request), LoadOptions.PreserveWhitespace); doc.TransformAll("format", element => element.Format()); doc.TransformAll("chart", (element, index) => ToImgTag(element, index)); using (DataContext dataContext = new DataContext()) { doc.TransformAll("pqi", (element) => PQIGenerator.GetPqiInformation(dataContext.Connection, element)); doc.TransformAll("structure", (element) => StructureLocationGenerator.GetStructureLocationInformation(element)); doc.TransformAll("lightning", (element) => LightningGenerator.GetLightningInfo(dataContext.Connection, element)); doc.TransformAll("faultType", (element) => FaultTypeGenerator.GetFaultType(element)); } string html = doc.ToString(SaveOptions.DisableFormatting).Replace("&", "&").Replace("<", "<").Replace(">", ">"); response.Content = new StringContent(html); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); }
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; }
void Start() { lg = GetComponentInChildren <LightningGenerator> (); }