Exemplo n.º 1
0
    /// <summary>
    /// Draws the game object's overlay
    /// </summary>
    /// <param id="offset">Current screen offset</param>
    /// <param id="highlight">Highlighting mode</param>
    /// <param id="activePlayer">Player for whom the game object is rendered</param>
    public override void DrawOverlay(Vector2 offset, GameObjectHighlightMode highlight, Player activePlayer)
    {
      if (NearestTile == null) return;
      if (activePlayer != null && activePlayer.Fow[NearestTile.X, NearestTile.Y] != 2) return;
      if (Removed) return;

      int maxWidth = (int)(Size.X * 1.25);
      int hpHeight = 5;
      int conHeight = 3;

      Color c =
        Health * .5f > entry.Health ? Color.White :
        Health > entry.Health ? Color.LightGreen :
        Health > entry.Health * .66f ? Color.Green :
        Health > entry.Health * .33f ? Color.Orange : Color.Red;

      int displayHp = Math.Min(entry.Health, Health);

      Vector2 position = Position - offset + new Vector2(-maxWidth / 2, AlignmentOffset.Y - hpHeight - 5);

      UI.Instance.DrawBox(position + new Vector2(-1, -1), new Vector2(maxWidth + 2, hpHeight + 2), Color.Black, Color.Black, 0);
      UI.Instance.DrawBox(position, new Vector2(displayHp * maxWidth / entry.Health, hpHeight), c, Color.Black, 0);

      if (actionCooldown > 0 && lastOrderTimeout > 100)
      {
        position += new Vector2(0, -conHeight - 2);

        UI.Instance.DrawBox(position + new Vector2(-1, -1), new Vector2(maxWidth + 2, conHeight + 2), Color.Black, Color.Black, 0);
        UI.Instance.DrawBox(position, new Vector2(maxWidth * actionCooldown / lastOrderTimeout, conHeight), Color.Goldenrod, Color.Black, 0);
      }
      else if (State == GameObjectState.DoOrder)
      {
        switch (Order)
        {
          case GameObjectOrder.Attack:
          case GameObjectOrder.Construct:
          case GameObjectOrder.Gather:
            position += new Vector2(0, -conHeight - 2);

            UI.Instance.DrawBox(position + new Vector2(-1, -1), new Vector2(maxWidth + 2, conHeight + 2), Color.Black, Color.Black, 0);
            UI.Instance.DrawBox(position, new Vector2(maxWidth, conHeight), Color.Cyan, Color.Black, 0);
            break;
          default:
            break;
        }
      }


      if (!cache.drawPosition.HasValue)
        cache.drawPosition = Position - offset + AlignmentOffset;

      if (IsSelected)
      {
        UI.Instance.DrawBox(cache.drawPosition.Value, Size, UI.Instance.GetGuiTex("selectionOverlay"), 0);
      }
      if (highlight != GameObjectHighlightMode.None)
      {
        UI.Instance.DrawBox(cache.drawPosition.Value, Size, UI.Instance.GetGuiTex("targetOverlay"), 0);
      }

      if (UI.Instance.KeyHold(SharpDX.Toolkit.Input.Keys.Shift))
      {
        UI.Instance.DrawBox(cache.drawPosition.Value, Size, UI.Instance.GetGuiTex("selectionOverlay"), 0);
      }
    }
Exemplo n.º 2
0
 /// <summary>
 /// Draws the game object's overlay
 /// </summary>
 /// <param id="offset">Current screen offset</param>
 /// <param id="highlight">Highlighting mode</param>
 /// <param id="activePlayer">Player for whom the game object is rendered</param>
 public virtual void DrawOverlay(Vector2 offset, GameObjectHighlightMode highlight, Player activePlayer) { }
Exemplo n.º 3
0
    /// <summary>
    /// Draws the game object
    /// </summary>
    /// <param id="offset">Current screen offset</param>
    /// <param id="highlight">Highlighting mode</param>
    /// <param id="activePlayer">Player for whom the game object is rendered</param>
    public override void Draw(SharpDX.Vector2 offset, GameObjectHighlightMode highlight, Player activePlayer)
    {
      if (NearestTile == null) return;
      if (activePlayer != null && activePlayer.Fow[NearestTile.X, NearestTile.Y] != 2) return;
      if (Removed) return;

      if (!cache.drawPosition.HasValue)
        cache.drawPosition = Position - offset + AlignmentOffset;

      float zLevel = NearestTile.DrawZLevel;
      float zLevelStep = NearestTile.DrawZLevelRange / 3;

      UI.Instance.Draw(cache.drawPosition.Value, entry.Texture, Owner.PlayerColor, zLevel + zLevelStep);

      if ((State == GameObjectState.MovingToOrder || State == GameObjectState.DoOrder) && activePlayer == Owner)
      {
        Texture2D tex = (State == GameObjectState.MovingToOrder) ? textureBullet2 : textureBullet;
        Color c =
          (Order == GameObjectOrder.Attack) ? Color.Yellow :
          (Order == GameObjectOrder.Construct) ? Color.Cyan :
          (Order == GameObjectOrder.Gather) ? Color.Cyan : Color.Lime;

        if (!cache.drawOrderPosition.HasValue && OrderTarget == null)
        {
          Tile tile = game.Map.GetTileFlat(OrderPosition);
          cache.drawOrderPosition = tile.MapPosition - new Vector2(0, (float)tile.Elevation * MapBoard.ELEVATION_SCALING) + MapBoard.TILE_SIZE / 2;
        }

        Vector2 vector = (OrderTarget == null ? cache.drawOrderPosition.Value : OrderTarget.Position) - this.Position;

        DrawTrail(tex, c, Position - offset, vector);

        if (Order == GameObjectOrder.Gather && OrderTarget != lastGatheredResource)
        {
          vector = lastGatheredResource.Position - this.Position;
          DrawTrail(tex, c, Position - offset, vector);
        }
      }
    }
Exemplo n.º 4
0
 /// <summary>
 /// Draws the game object
 /// </summary>
 /// <param id="offset">Current screen offset</param>
 /// <param id="highlight">Highlighting mode</param>
 /// <param id="activePlayer">Player for whom the game object is rendered</param>
 public abstract void Draw(Vector2 offset, GameObjectHighlightMode highlight, Player activePlayer);
Exemplo n.º 5
0
    /// <summary>
    /// Draws a building of given type at given tile
    /// </summary>
    /// <param name="offset">Screen offset</param>
    /// <param name="tile">Tile, where the building should be drawn</param>
    /// <param name="highlight">Highlight mode</param>
    /// <param name="entry">Type of the building</param>
    public static void Draw(Vector2 offset, Tile tile, GameObjectHighlightMode highlight, BuildingDb entry)
    {
      float x = tile.MapPosition.X;
      int height = tile.Elevation;
      float y = tile.MapPosition.Y - height * MapBoard.ELEVATION_SCALING;
      Vector2 position = new Vector2(x, y).Round();
      Vector2 textureSize = entry.Texture.Size();
      float aOffX = textureSize.X / 2 - MapBoard.TILE_XSPACING / 2;
      float aOffY = textureSize.Y - MapBoard.TILE_YSPACING;
      Vector2 alignmentOffset = new Vector2(-aOffX, -aOffY);
      Vector2 drawPosition = position - offset + alignmentOffset;

      Color c = Color.Lerp(Color.White, Color.Transparent, .5f);
      if (highlight == GameObjectHighlightMode.InvalidPlacement)
        c = Color.Lerp(c, Color.Red, .5f);

      UI.Instance.Draw(drawPosition, entry.Texture, c, 1f);
    }
Exemplo n.º 6
0
    /// <summary>
    /// Draws the game object's overlay
    /// </summary>
    /// <param id="offset">Current screen offset</param>
    /// <param id="highlight">Highlighting mode</param>
    /// <param id="activePlayer">Player for whom the game object is rendered</param>
    public override void DrawOverlay(Vector2 offset, GameObjectHighlightMode highlight, Player activePlayer)
    {
      if (NearestTile == null) return;
      if (activePlayer != null && activePlayer.Fow[NearestTile.X, NearestTile.Y] != 2) return;
      if (Removed) return;

      int maxWidth = (int)(Size.X * 1.25);
      int hpHeight = 5;
      int conHeight = 3;
      Color c =
        Health > entry.Health * .66f ? Color.Green :
        Health > entry.Health * .33f ? Color.Orange : Color.Red;

      Vector2 position = Position - offset + new Vector2(-maxWidth / 2, -hpHeight - 5) + new Vector2(-AlignmentOffset.X, AlignmentOffset.Y);

      UI.Instance.DrawBox(position + new Vector2(-1, -1), new Vector2(maxWidth + 2, hpHeight + 2), Color.Black, Color.Black, 0);
      UI.Instance.DrawBox(position, new Vector2(Health * maxWidth / entry.Health, hpHeight), c, Color.Black, 0);

      if (!Constructed)
      {
        position += new Vector2(0, -conHeight - 2);

        UI.Instance.DrawBox(position + new Vector2(-1, -1), new Vector2(maxWidth + 2, conHeight + 2), Color.Black, Color.Black, 0);
        UI.Instance.DrawBox(position, new Vector2((Construction / (float)entry.ConstructionAmount) * maxWidth, conHeight), Color.Cyan, Color.Black, 0);
      }
      else if (Spawner != null && Spawner.Active)
      {
        position += new Vector2(0, -conHeight - 2);

        UI.Instance.DrawBox(position + new Vector2(-1, -1), new Vector2(maxWidth + 2, conHeight + 2), Color.Black, Color.Black, 0);
        UI.Instance.DrawBox(position, new Vector2((UI.Instance.UpdateNumber + Spawner.UpdateOffset) % Spawner.Speed * maxWidth / Spawner.Speed, conHeight), Color.Goldenrod, Color.Black, 0);
      }

      //Texture2D tx = UI.Instance.GetTexture("pointer");
      //UI.Instance.Draw(Position - offset - tx.Size() / 2, tx, FontColor.White, 1f);

      if (IsSelected)
      {
        UI.Instance.DrawBox(Position - offset + AlignmentOffset, Size, UI.Instance.GetGuiTex("selectionOverlay"), 0);
      }
      if (highlight != GameObjectHighlightMode.None)
      {
        UI.Instance.DrawBox(Position - offset + AlignmentOffset, Size, UI.Instance.GetGuiTex("targetOverlay"), 0);
      }
    }
Exemplo n.º 7
0
    /// <summary>
    /// Draws the game object
    /// </summary>
    /// <param id="offset">Current screen offset</param>
    /// <param id="highlight">Highlighting mode</param>
    /// <param id="activePlayer">Player for whom the game object is rendered</param>
    public override void Draw(Vector2 offset, GameObjectHighlightMode highlight, Player activePlayer)
    {
      if (NearestTile == null) return;
      if (activePlayer != null && activePlayer.Fow[NearestTile.X, NearestTile.Y] != 2) return;
      if (Removed) return;

      Vector2 drawPosition = Position - offset + AlignmentOffset;

      Color c = Color.White;
      if (Owner != activePlayer)
      {
        c = Color.Lerp(Color.White, Color.Red, 0.25f);
      }

      UI.Instance.Draw(drawPosition, Constructed ? entry.Texture : entry.TextureConstruction, c, FurtestTile.DrawZLevel + FurtestTile.DrawZLevelRange / 2);
    }
Exemplo n.º 8
0
    /// <summary>
    /// Draws the resource
    /// </summary>
    /// <param id="offset">Current screen offset</param>
    /// <param id="highlight">Highlighting mode</param>
    /// <param id="activePlayer">Player for whom the game object is rendered</param>
    public override void Draw(Vector2 offset, GameObjectHighlightMode highlight, Player activePlayer)
    {
      if (NearestTile == null) return;
      if (activePlayer != null && activePlayer.Fow[NearestTile.X, NearestTile.Y] == 0) return;
      if (Removed) return;

      float zLevel = NearestTile.DrawZLevel;
      float zLevelStep = NearestTile.DrawZLevelRange / 3;

      Color c = Color.White;
      if (Amount == 0)
        c = Color.Gray;

      UI.Instance.Draw(GetDrawPosition(offset), entry.Texture, c, zLevel + zLevelStep);

    }