public void AddElement(GUITextElement element) { TextElements.Add(element); }
public void OnRender(RenderView view) { fpsModel.OnRender(view, false); if (view.GetRenderType() == RenderViewType.MAIN && !datablock.IsMelee) { GUIElementManager elemManager = GFX.Inst.GetGUI(); int ammoRatio = (int)((float)ReserveAmmo / (float)AmmoPerClip); GUITextElement elem = new GUITextElement(new Vector2(0.85f, -0.85f), ammo.ToString() + "/"+ammoRatio); elemManager.AddElement(elem); } }
protected override void OnRender() { if (currTransform == null) return; base.OnRender(); Vector2 min = this.position - this.scale; // new Vector2(-0.25f, 0.6f); Vector2 max = this.position + this.scale; //new Vector2(0.25f, 0.7f); float pivot = (float)compassTickDelta / 65.0f; Vector3 dir = currTransform.GetTransform().Forward; float theta = 0.5f + 0.5f * (float)Math.Atan2(dir.Z, dir.X) / MathHelper.Pi; Vector2 minTC = new Vector2(theta - pivot, 0); Vector2 maxTC = new Vector2(theta + pivot, 1); GUIElementTC compass = new GUIElementTC(min, max, compassTexture, Vector4.One, minTC, maxTC); GFX.Inst.GetGUI().AddElement(compass); for (int i = 0; i < compassDirs.Length; i++) { float currDirTC = compassTCs[i]; if (currDirTC < minTC.X) currDirTC++; if (minTC.X < currDirTC && currDirTC < maxTC.X) { float lerpAmount = (currDirTC - minTC.X) / (maxTC.X - minTC.X); Vector2 textPos = Vector2.Lerp(min, max, lerpAmount); textPos.Y = (min.Y + max.Y) * 0.5f; GUITextElement cardinalDirection = new GUITextElement(textPos, compassDirs[i], Vector4.One); GFX.Inst.GetGUI().AddElement(cardinalDirection); } } DrawMarkers(min, max, minTC, maxTC); const float offsetY = 0.045f; float offsetX = offsetY * GFX.Inst.DisplayRes.Y / GFX.Inst.DisplayRes.X; Vector2[] corners = { new Vector2(min.X-offsetX, min.Y), new Vector2(min.X, max.Y), new Vector2(max.X, min.Y), new Vector2(max.X+offsetX, max.Y), new Vector2(min.X-offsetX, min.Y-offsetY), new Vector2(max.X+offsetX, min.Y), new Vector2(min.X-offsetX, max.Y), new Vector2(max.X+offsetX, max.Y+offsetY) }; int quadCount = corners.Length / 2; for (int i = 0; i < quadCount; i++) { int index = i * 2; GUIElement box = new GUIElement(corners[index], corners[index + 1], null, Vector3.One * 0.15f); GFX.Inst.GetGUI().AddElement(box); } }
void DrawGameTime() { Vector2 timerPos = new Vector2(0, 0.85f); float time = Math.Max(timeRemaining, 0); string timerText = timeRemaining.ToString(); int index = timerText.IndexOf('.'); if(index >=0 && (index + 3) < timerText.Length) timerText = timerText.Substring(0, index + 3); float lerpAmt = (float)Math.Cos(timeRemaining*5.0f); Vector4 timerColor = (timeRemaining <= 5.0f) ? Vector4.Lerp(Vector4.One, new Vector4(1, 0, 0, 1), lerpAmt) : Vector4.One; GUITextElement timerElement = new GUITextElement(timerPos, timerText, timerColor); GFX.Inst.GetGUI().AddElement(timerElement); }
void DrawCompass() { Vector2 min = new Vector2(-0.25f, 0.6f); Vector2 max = new Vector2(0.25f, 0.7f); float pivot = (float)compassTickDelta / 45.0f; Vector3 dir = Vector3.Zero;// currTank.GetCannonDirection(); float theta = 0.5f + 0.5f*(float)Math.Atan2(dir.Z, dir.X)/MathHelper.Pi; Vector2 minTC = new Vector2(theta - pivot, 0); Vector2 maxTC = new Vector2(theta + pivot, 1); GUIElementTC compass = new GUIElementTC(min, max, compassTexture, Vector4.One, minTC, maxTC); GFX.Inst.GetGUI().AddElement(compass); for (int i = 0; i < compassDirs.Length; i++) { float currDirTC = compassTCs[i]; if(currDirTC < minTC.X) currDirTC++; if (minTC.X < currDirTC && currDirTC < maxTC.X) { float lerpAmount = (currDirTC - minTC.X) / (maxTC.X - minTC.X); Vector2 textPos = Vector2.Lerp(min, max, lerpAmount); textPos.Y = (min.Y + max.Y) * 0.5f; GUITextElement cardinalDirection = new GUITextElement(textPos, compassDirs[i], Vector4.One); GFX.Inst.GetGUI().AddElement(cardinalDirection); } } const float offsetY = 0.045f; float offsetX = offsetY * GFX.Inst.DisplayRes.Y / GFX.Inst.DisplayRes.X; Vector2[] corners = { new Vector2(min.X-offsetX, min.Y), new Vector2(min.X, max.Y), new Vector2(max.X, min.Y), new Vector2(max.X+offsetX, max.Y), new Vector2(min.X-offsetX, min.Y-offsetY), new Vector2(max.X+offsetX, min.Y), new Vector2(min.X-offsetX, max.Y), new Vector2(max.X+offsetX, max.Y+offsetY) }; int quadCount = corners.Length / 2; for (int i = 0; i < quadCount; i++) { int index = i * 2; GUIElement box = new GUIElement(corners[index], corners[index + 1], null, Vector3.One * 0.15f); GFX.Inst.GetGUI().AddElement(box); } }
protected override void OnRender() { base.OnRender(); Vector2 minSize = this.position - this.scale; Vector2 maxSize = this.position + this.scale; if (buttonImage != null) { GUIElement renderElement = new GUIElement(minSize, maxSize, buttonImage.GetTexture(), buttonColor); GFX.Inst.GetGUI().AddElement(renderElement); } if (buttonText != string.Empty) { GUITextElement textRenderElement = new GUITextElement(this.position, buttonText, textColor); GFX.Inst.GetGUI().AddElement(textRenderElement); } }
public void AddElement(GUITextElement element) { TextElements.Enqueue(element); }