예제 #1
0
파일: BattleTurn.cs 프로젝트: Skittss/Hex
 private void Draw_UnitUI(SpriteBatch spriteBatch)
 {
     //need a seperate loop here to prevent units from being drawn over bars.
     foreach (Unit unit in grid.Units)
     {
         //draw health bars
         Vector2   tileCoordinate = CoordConverter.CubeToOffset(unit.CubeCoordinate);
         Texture2D unitTexture    = unitSprites[unit.GetType()];
         Vector2   pos            = grid.Tiles[(int)tileCoordinate.X, (int)tileCoordinate.Y].GetCentrePixelCoordinate(boardScale) - new Vector2(boardScale * (unitTexture.Width / 2), unitTexture.Height * boardScale);
         Color     barColor       = (players.Where(player => player.Id == unit.OwnerId).ToArray().Length == 0) ? Color.Gray : players.Where(player => player.Id == unit.OwnerId).First().Colour;
         PercentageBar.Draw(spriteBatch, emptyRect, pos - new Vector2(0, 15) * WindowTools.GetUpscaleRatio(), healthBarDimensions, barColor, Color.OrangeRed, unit.Stats.MaxHp.Value, unit.Hp);
         //draw an icon to show the unit has augmented stats if it does.
         // (these units are strong!)
         if (unit.Augmented)
         {
             spriteBatch.Draw(augmentIcon,
                              position: pos - new Vector2(0, 15) - uiScale / 2 * new Vector2(augmentIcon.Width, augmentIcon.Height / 2),
                              scale: uiScaleVector / 2);
         }
     }
 }