Exemplo n.º 1
0
        public void PlayerDrawRoute(int pixelX, int pixelY)
        {
            var startUnit = _units.FindSelectedUnit();

            if (startUnit != null)
            {
                var cube        = HexGridMath.HexToCube(HexGridMath.PixelToHex(pixelX, pixelY));
                var destination = HexGridMath.CubeToOffset(cube.X, cube.Y, cube.Z);

                if (startUnit.Col != destination.Col || startUnit.Row != destination.Row)
                {
                    _shortestPath.ComputeShortestPath((TerrainMap)_terrainMap, startUnit.Col, startUnit.Row, destination.Col, destination.Row, startUnit.UnitType);

                    if (_shortestPath.WayPoint.Count > 0)
                    {
                        _shortestPath.WayPoint.Insert(0, new Offset(startUnit.Col, startUnit.Row));
                    }

                    for (int i = 1; i < _shortestPath.WayPoint.Count; i++)
                    {
                        GameContent.Sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
                        GraphicHelpers.DrawLine(_shortestPath.WayPoint[i - 1].ToPixel, _shortestPath.WayPoint[i].ToPixel, Color.Red, 6);
                        GameContent.Sb.End();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Draw()
        {
            if (WayPoint == null)
            {
                return;
            }

            for (var i = 1; i < WayPoint.Count; i++)
            {
                GameContent.Sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
                GraphicHelpers.DrawLine(WayPoint[i - 1].ToPixel, WayPoint[i].ToPixel, Color.Red, 6);
                GameContent.Sb.End();
            }
        }
Exemplo n.º 3
0
        // this method is used for alignment purposes only
        public void DrawSample()
        {
            int lnX     = 60 * X + GameContent.XOffset;
            int lnY     = 35 * X + Z * 70 + GameContent.YOffset;
            var center  = new Point(lnX, lnY);
            var offsets = new [] { new Point(40, 0), new Point(20, 35), new Point(-20, 35), new Point(-40, 0), new Point(-20, -35), new Point(20, -35) };

            GameContent.Sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            var start = new Vector2(center.X + 20, center.Y - 35);
            var end   = new Vector2(0, 0);

            for (int i = 0; i < 6; i++)
            {
                end.X = center.X + offsets[i].X;
                end.Y = center.Y + offsets[i].Y;

                GraphicHelpers.DrawLine(start, end, Color.Black);

                start = end;
            }

            GameContent.Sb.End();
        }