Esempio n. 1
0
            public ShipAttributes(string texName, PlayerColor color, Point pos, int direction, HealthBar healthBar)
            {
                TexName = texName;
                Color = color;
                Direction = direction;
                Pos = pos;
                HealthBar = healthBar;

                  //  TexSize = texSize;

                switch (TexName)
                {
                    case "Fighter":
                    {
                        TexSize = 8;
                        break;
                    }
                    case "Barge":
                    {
                        TexSize = 15;
                        break;
                    }
                    default:
                    {
                        TexSize = 10;
                        break;
                    }
                }
            }
Esempio n. 2
0
        private void DrawHealthBar(HealthBar healthBar)
        {
            UiElement.Frame(healthBar.Position.X, healthBar.Position.Y + 2, healthBar.Position.X + 1, healthBar.Position.Y + 10);
            var f = (float) healthBar.CurrentHealth/healthBar.MaxHealth;
            if (f >= 0.5f)
                Gl.glColor3f(0, 1, 0);
            else if (f > 0.25f && f < 0.5f)
                Gl.glColor3f(1, 1, 0.3f);
            else
                Gl.glColor3f(1, 0, 0);

            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex2f(healthBar.Position.X, healthBar.Position.Y + 10);
            Gl.glVertex2f(healthBar.Position.X + 1, healthBar.Position.Y + 10);
            Gl.glVertex2f(healthBar.Position.X + 1, healthBar.Position.Y + 10 - 8*f);
            Gl.glVertex2f(healthBar.Position.X, healthBar.Position.Y + 10 - 8*f);
            Gl.glEnd();

            UiElement.DrawString(new PointF(healthBar.Position.X, healthBar.Position.Y - 2),
                healthBar.CurrentHealth.ToString());
        }