Esempio n. 1
0
        /// <summary>
        /// Render the amount of time left of current level.
        /// </summary>
        /// <param name="r">Renderer to use.</param>
        private void renderTimeBar(Renderer r)
        {
            r.beginScreen();
            float left   = 0.2f * r.Screenspace.Size.X;
            float right  = 0.8f * r.Screenspace.Size.X;
            float top    = 0.025f * r.Screenspace.Size.Y;
            float bottom = 0.05f * r.Screenspace.Size.Y;

            r.renderRect(new Vector2(left, top), new Vector2(right, bottom), Color.White);
            float timeleft = (right - left) * this.leveltimeleft / this.leveltime + left;

            r.renderRect(new Vector2(left, top), new Vector2(timeleft, bottom), Color.White, true);
        }
Esempio n. 2
0
        /// <summary>
        /// Render the health bars that belong to objects.
        /// </summary>
        /// <param name="r">Renderer to use.</param>
        /// <param name="objects">Entities with health and maximum health.</param>
        private void renderHBar(Renderer r, List <Entity> objects)
        {
            foreach (Entity e in objects)
            {
                if (e.CombatStats == null || e.Renderable == null)
                {
                    continue;
                }
                float w      = e.Renderable.Size.X;
                float health = 1.0f * e.CombatStats.Health / e.CombatStats.MaxHealth;

                float   top         = e.Physics.Position.Y - e.Renderable.Size.Y / 2 - 15.0f;
                Vector2 topleft     = new Vector2(e.Physics.Position.X - w / 2, top);
                Vector2 bottomRight = new Vector2(e.Physics.Position.X + w / 2, top + 10);
                Vector2 lastOne     = new Vector2(topleft.X + health * w, top + 10);

                r.renderRect(topleft, bottomRight, Color.Red);
                r.renderRect(topleft, lastOne, Color.Green, true);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Render the amount of time left of current level.
 /// </summary>
 /// <param name="r">Renderer to use.</param>
 private void renderTimeBar(Renderer r)
 {
     r.beginScreen();
     float left = 0.2f * r.Screenspace.Size.X;
     float right = 0.8f * r.Screenspace.Size.X;
     float top = 0.025f * r.Screenspace.Size.Y;
     float bottom = 0.05f * r.Screenspace.Size.Y;
     r.renderRect(new Vector2(left, top), new Vector2(right, bottom), Color.White);
     float timeleft = (right - left) * this.leveltimeleft / this.leveltime + left;
     r.renderRect(new Vector2(left, top), new Vector2(timeleft, bottom), Color.White, true);
 }
Esempio n. 4
0
        /// <summary>
        /// Render the health bars that belong to objects.
        /// </summary>
        /// <param name="r">Renderer to use.</param>
        /// <param name="objects">Entities with health and maximum health.</param>
        private void renderHBar(Renderer r, List<Entity> objects)
        {
            foreach (Entity e in objects)
            {
                if (e.CombatStats == null || e.Renderable == null) continue;
                float w = e.Renderable.Size.X;
                float health = 1.0f * e.CombatStats.Health / e.CombatStats.MaxHealth;

                float top = e.Physics.Position.Y - e.Renderable.Size.Y / 2 - 15.0f;
                Vector2 topleft = new Vector2(e.Physics.Position.X - w / 2, top);
                Vector2 bottomRight = new Vector2(e.Physics.Position.X + w / 2, top + 10);
                Vector2 lastOne = new Vector2(topleft.X + health * w, top + 10);

                r.renderRect(topleft, bottomRight, Color.Red);
                r.renderRect(topleft, lastOne, Color.Green, true);
            }
        }