Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public override void OnRender(RenderView view)
        {
            if (view.GetRenderType() == RenderViewType.MAIN)
            {
                DrawLives();
                DrawHealthBar();
                DrawGemProgressBar();

                if (hitFlashTimer >= MAX_FLASH_TIMER) hitFlashTimer = 0;
                else if (hitFlashTimer > 0)
                {
                    hitFlashTimer++;
                    DrawHitFlash();
                }
                if (deathFadeTimer > 0)
                {
                    deathFadeTimer++;
                    DrawDeathFade();
                }
                if (lives < 0)
                {
                    Vector2 max = new Vector2(1, 1);
                    Vector2 min = new Vector2(-1, -1);
                    Gaia.Resources.TextureResource image = Resources.ResourceManager.Inst.GetTexture("Textures/Details/GameOver.png");
                    GUIElement element = new GUIElement(min, max, image);
                    GFX.Inst.GetGUI().AddElement(element);
                }
                if (numGemsCollected >= scene.NUM_GEMS_Required)
                {
                    Vector2 max = new Vector2(1, 1);
                    Vector2 min = new Vector2(-1, -1);
                    Gaia.Resources.TextureResource image = Resources.ResourceManager.Inst.GetTexture("Textures/Details/Congrats.png");
                    GUIElement element = new GUIElement(min, max, image);
                    GFX.Inst.GetGUI().AddElement(element);
                }
            }
            base.OnRender(view);
        }
Ejemplo n.º 3
0
 public void DrawLives()
 {
     for (int i = 0; i < lives; i++)
     {
         Vector2 max = new Vector2(0.99f - 0.08f * i, 0.98f);
         Vector2 min = new Vector2(0.91f - 0.08f * i, 0.83f);
         Gaia.Resources.TextureResource image = Resources.ResourceManager.Inst.GetTexture("Textures/Details/heart.png");
         GUIElement element = new GUIElement(min, max, image);
         GFX.Inst.GetGUI().AddElement(element);
     }
 }
Ejemplo n.º 4
0
 public void DrawHitFlash()
 {
     float alpha = 1.0f - Math.Abs((float)MAX_FLASH_TIMER / 2.0f - (float)hitFlashTimer) / (float)(MAX_FLASH_TIMER / 2.0f);
     GUIElement flash = new GUIElement(new Vector2(-1.0f, -1.0f), new Vector2(1.0f, 1.0f), null, new Vector4(1.0f, 1.0f, 1.0f, alpha));
     GFX.Inst.GetGUI().AddElement(flash);
 }
Ejemplo n.º 5
0
        public void DrawHealthBar()
        {
            float percentHealth = health / MAX_HEALTH;
            float barBottom = -0.98f;
            float barTop = 0.8f;
            float barLeft = 0.93f;
            float barRight = 0.98f;
            float healthBarTop = barBottom + percentHealth * (barTop - barBottom);

            Vector3 color;
            if (percentHealth > 0.5) color = new Vector3(0.0f, 0.8f, 0.2f);
            else if (percentHealth > 0.25) color = new Vector3(0.8f, 0.8f, 0.0f);
            else color = new Vector3(0.8f, 0.0f, 0.0f);

            GUIElement bar = new GUIElement(new Vector2(barLeft, barBottom), new Vector2(barRight, barTop), null, new Vector4(0.0f, 0.0f, 0.0f, 0.5f));
            GUIElement healthBar = new GUIElement(new Vector2(barLeft, barBottom), new Vector2(barRight, healthBarTop), null, new Vector4(color, 0.5f));
            GUIElement healthBarLine = new GUIElement(new Vector2(barLeft, healthBarTop), new Vector2(barRight, healthBarTop + 0.02f), null, new Vector4(color, 1.0f));
            GFX.Inst.GetGUI().AddElement(bar);
            GFX.Inst.GetGUI().AddElement(healthBar);
            GFX.Inst.GetGUI().AddElement(healthBarLine);
        }
Ejemplo n.º 6
0
        public void DrawGemProgressBar()
        {
            float percentGemsCollected = (float)numGemsCollected / (float)scene.NUM_GEMS_Required;
            float barBottom = -0.98f;
            float barTop = 0.8f;
            float barLeft = -0.98f;
            float barRight = -0.93f;
            float progressBarTop = barBottom + percentGemsCollected * (barTop - barBottom);

            Vector3 color = new Vector3(0.0f, 0.2f, 0.8f);

            GUIElement bar = new GUIElement(new Vector2(barLeft, barBottom), new Vector2(barRight, barTop), null, new Vector4(0.0f, 0.0f, 0.0f, 0.5f));
            GUIElement progressBar = new GUIElement(new Vector2(barLeft, barBottom), new Vector2(barRight, progressBarTop), null, new Vector4(color, 0.5f));
            GUIElement progressBarLine = new GUIElement(new Vector2(barLeft, progressBarTop), new Vector2(barRight, progressBarTop + 0.02f), null, new Vector4(color, 1.0f));
            GUIElement gemIcon = new GUIElement(new Vector2(-1.0f, 0.82f), new Vector2(-0.9f, 0.98f), Resources.ResourceManager.Inst.GetTexture("Textures/Trees/ruby_Color.png"));
            GFX.Inst.GetGUI().AddElement(bar);
            GFX.Inst.GetGUI().AddElement(progressBar);
            GFX.Inst.GetGUI().AddElement(progressBarLine);
            GFX.Inst.GetGUI().AddElement(gemIcon);
        }
Ejemplo n.º 7
0
        protected override void OnRender()
        {
            Vector2 minSize = this.position - this.scale;
            Vector2 maxSize = this.position + this.scale;

            if (scrollBarImage != null)
            {
                GUIElement scrollRenderElement = new GUIElement(minSize, maxSize, scrollBarImage.GetTexture(), color);
                GFX.Inst.GetGUI().AddElement(scrollRenderElement);
            }
            base.OnRender();
        }
Ejemplo n.º 8
0
 public void AddElement(GUIElement element)
 {
     Elements.Add(element);
 }
Ejemplo n.º 9
0
        void DrawMapButton()
        {
            float alpha = GetIdleAlpha();

            const float hoverSizeOffset = 0.15f;
            Vector2 minSize = new Vector2(-0.1f, -0.8f);
            Vector2 maxSize = new Vector2(0.2f, -0.5f);
            Vector2 mousePos = Input.InputManager.Inst.GetMousePositionHomogenous();
            if (minSize.X <= mousePos.X && mousePos.X <= maxSize.X
                && minSize.Y <= mousePos.Y && mousePos.Y <= maxSize.Y)
            {
                minSize -= Vector2.One * hoverSizeOffset;
                maxSize += Vector2.One * hoverSizeOffset;
                anyButtonClicked |= InputManager.Inst.IsLeftMouseDown();
                elasedWeaponsVisibleTime = 0;
            }
            TextureResource grenadeImage = ResourceManager.Inst.GetTexture("Textures/UI/map.dds");
            GUIElement grenadeButton = new GUIElement(minSize, maxSize, grenadeImage.GetTexture(), Vector4.One * alpha);
            GFX.Inst.GetGUI().AddElement(grenadeButton);
        }
Ejemplo n.º 10
0
 void DrawInventoryFrame()
 {
     elasedWeaponsVisibleTime += Time.RenderTime.ElapsedTime;
     float alpha = GetWeaponsAlpha();
     Vector2 minSize = new Vector2(-1, -0.75f);
     Vector2 maxSize = new Vector2(-0.65f, 0.75f);
     maxSize.X = MathHelper.Lerp(-1, -0.65f, alpha);
     GUIElement frame = new GUIElement(minSize, maxSize, null, Vector3.One * 0.35f);
     GFX.Inst.GetGUI().AddElement(frame);
 }
Ejemplo n.º 11
0
 void DrawHealth()
 {
     float alpha = GetIdleAlpha();
     const int maxHearts = 8;
     const float minHeartSize = 0.0725f;
     const float maxHeartSize = 0.1f;
     const float paddingSize = maxHeartSize + 0.065f;
     Vector2 origin = new Vector2(0.85f, -1);
     int numHearts = (int)(currTank.GetHealthPercent() * maxHearts);
     TextureResource heartImage = ResourceManager.Inst.GetTexture("Textures/Details/heart.png");
     GUIElementManager guiMgr = GFX.Inst.GetGUI();
     for (int i = 1; i <= numHearts; i++)
     {
         Vector2 center = origin + new Vector2(0, paddingSize * i);
         float offset = 7.256633f*MathHelper.TwoPi*((float)i/(float)maxHearts);
         float lerpAmount = (float)Math.Sin(offset+Time.RenderTime.TotalTime*2.25f) * 0.5f + 0.5f;
         float currSize = MathHelper.Lerp(minHeartSize, maxHeartSize, lerpAmount);
         GUIElement heart = new GUIElement(center - Vector2.One * currSize, center + Vector2.One * currSize, heartImage.GetTexture(), Vector4.One * alpha);
         guiMgr.AddElement(heart);
     }
 }
Ejemplo n.º 12
0
 void DrawCursor()
 {
     bool leftMouseDown = InputManager.Inst.IsLeftMouseDown();
     if (leftMouseDown && !anyButtonClicked)
         return;
     float alpha = GetIdleAlpha();
     Vector2 cursorPos = InputManager.Inst.GetMousePositionHomogenous();
     Vector2 cursorHalfSize = new Vector2(0.05f, 0.05f);
     TextureResource cursorImage = ResourceManager.Inst.GetTexture("Textures/UI/cursor.dds");
     GUIElement cursorButton = new GUIElement(cursorPos - cursorHalfSize, cursorPos + cursorHalfSize, cursorImage.GetTexture(), Vector4.One * alpha);
     GFX.Inst.GetGUI().AddElement(cursorButton);
 }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
 void DrawMarkers(Vector2 min, Vector2 max, Vector2 minTC, Vector2 maxTC)
 {
     for (int i = 0; i < markers.Count; i++)
     {
         Vector3 dir = markers[i].GetPosition() - currTransform.GetPosition();
         float theta = 0.5f + 0.5f * (float)Math.Atan2(dir.Z, dir.X) / MathHelper.Pi;
         if (theta < minTC.X)
             theta++;
         if (minTC.X < theta && theta < maxTC.X)
         {
             float lerpAmount = (theta - minTC.X) / (maxTC.X - minTC.X);
             Vector2 textPos = Vector2.Lerp(min, max, lerpAmount);
             textPos.Y = (min.Y + max.Y) * 0.5f;
             Vector2 markerMin = textPos - Vector2.One * 0.05f;
             Vector2 markerMax = textPos + Vector2.One * 0.05f;
             GUIElement markerElem = new GUIElement(markerMin, markerMax, markerImage, new Vector4(1.0f, 0, 0, 1.0f));
             GFX.Inst.GetGUI().AddElement(markerElem);
         }
     }
 }
Ejemplo n.º 15
0
 void DrawPowerBar()
 {
     float alpha = GetIdleAlpha();
     Vector2 minSize = new Vector2(-0.9f, -0.5f);
     Vector2 maxSize = new Vector2(-0.75f, 0.25f);
     Vector4 outlineColor = new Vector4(0.15f, 0.15f, 0.15f, alpha*0.5f);
     GUIElement powerBarOutline = new GUIElement(minSize, maxSize, null, outlineColor);
     GFX.Inst.GetGUI().AddElement(powerBarOutline);
 }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
 public void DrawDeathFade()
 {
     float alpha = Math.Min((float)deathFadeTimer / 20.0f, 1.0f);
     GUIElement fade = new GUIElement(new Vector2(-1.0f, -1.0f), new Vector2(1.0f, 1.0f), null, new Vector4(0.0f, 0.0f, 0.0f, alpha));
     GFX.Inst.GetGUI().AddElement(fade);
 }
Ejemplo n.º 18
0
        protected override void OnRender()
        {
            base.OnRender();
            GUIElement element = new GUIElement(position - scale, position + scale, null, color);
            GFX.Inst.GetGUI().AddElement(element);

            if (displayItems != null)
            {
                for (int i = 0; i < displayItems.Length; i++)
                {
                    if(displayItems[i] != null)
                        displayItems[i].OnDraw();
                }
            }
        }
Ejemplo n.º 19
0
 public void AddElement(GUIElement element)
 {
     Elements.Enqueue(element);
 }