Example #1
0
        private void Draw_Units(SpriteBatch spriteBatch)
        {
            //draw bench units
            for (int x = (int)bench.Size.X - 1; x >= 0; x--)
            {
                //get unit on current bench tile iter
                Unit unit = turnPlayer.GetBenchUnits()[x];

                if (unit != null)
                {
                    //draw if not picked up
                    if (GetUnitFromTileData(pickedUpTileData) != unit || !pickedUpTileData.Item2)
                    {
                        Texture2D unitTexture = unit.GetSprite(unitSprites);
                        Vector2   pos         = bench.Tiles[x, 0].GetCentrePixelCoordinate(boardScale) - new Vector2(boardScale * (unitTexture.Width / 2), unitTexture.Height * boardScale);
                        spriteBatch.Draw(unitTexture, position: pos, scale: boardScaleVector);
                        Draw_AugmentIcon(spriteBatch, unit, pos, unitTexture);
                    }
                }
            }

            //draw units on the board - must be done from back of the grid to front
            // to preserve perspective.
            foreach (Unit unit in grid.Units.OrderByDescending(i => i.CubeCoordinate.Z).ThenBy(i => i.CubeCoordinate.Y))
            {
                Vector2 tileCoordinate = CoordConverter.CubeToOffset(unit.CubeCoordinate);
                if (turnPlayer.IsPointInHalf(tileCoordinate, false))
                {
                    if (GetUnitFromTileData(pickedUpTileData) != unit || !pickedUpTileData.Item2)
                    {
                        Texture2D unitTexture = unit.GetSprite(unitSprites);
                        Vector2   pos         = grid.Tiles[(int)tileCoordinate.X, (int)tileCoordinate.Y].GetCentrePixelCoordinate(boardScale) - new Vector2(boardScale * (unitTexture.Width / 2), unitTexture.Height * boardScale);
                        spriteBatch.Draw(unitTexture, position: pos, scale: boardScaleVector);
                        Draw_AugmentIcon(spriteBatch, unit, pos, unitTexture);
                    }
                }
            }

            //draw the picked up unit hovering over the mouse position
            if (pickedUpTileData.Item2)
            {
                Unit      toDraw  = GetUnitFromTileData(pickedUpTileData);
                Texture2D texture = toDraw.GetSprite(unitSprites);
                Vector2   pos     = InputManager.Instance.MousePos - boardScale / 2 * UiTools.BoundsToVector(texture.Bounds);

                spriteBatch.Draw(texture,
                                 position: pos,
                                 scale: boardScaleVector
                                 );
                Draw_AugmentIcon(spriteBatch, toDraw, pos, texture);
            }
        }
Example #2
0
 private void Draw_Units(SpriteBatch spriteBatch)
 {
     //draw units on the board - Ordering by primarily Z coordinate then by Y
     //  ensures units are drawn cascading from the top right to bottom left, and the perspective is maintained
     foreach (Unit unit in grid.Units.OrderByDescending(i => i.CubeCoordinate.Z).ThenBy(i => i.CubeCoordinate.Y))
     {
         Vector2   tileCoordinate = CoordConverter.CubeToOffset(unit.CubeCoordinate);
         Texture2D unitTexture    = unit.GetSprite(unitSprites);
         Vector2   pos            = grid.Tiles[(int)tileCoordinate.X, (int)tileCoordinate.Y].GetCentrePixelCoordinate(boardScale) - new Vector2(boardScale * (unitTexture.Width / 2), unitTexture.Height * boardScale);
         spriteBatch.Draw(unitTexture, position: pos, scale: boardScaleVector);
         Draw_StepActionOverUnits(spriteBatch, unit, pos);
     }
 }
Example #3
0
 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);
         }
     }
 }
Example #4
0
        public bool IsTileOccupied(Vector3 cubeCoordinate)
        {
            Vector2 offsetCoordinate = CoordConverter.CubeToOffset(cubeCoordinate);

            return(tiles[(int)offsetCoordinate.X, (int)offsetCoordinate.Y].Occupied);
        }
Example #5
0
        public void UnoccupyTile(Vector3 cubeCoordinate)
        {
            Vector2 offsetCoordinate = CoordConverter.CubeToOffset(cubeCoordinate);

            tiles[(int)offsetCoordinate.X, (int)offsetCoordinate.Y].Occupied = false;
        }