Ejemplo n.º 1
0
 public HexaPath(HexaPath other)
 {
     _path = new List <HexaPos>();
     List <HexaPos> .Enumerator e = other._path.GetEnumerator();
     while (e.MoveNext())
     {
         AddPos(e.Current);
     }
 }
Ejemplo n.º 2
0
        public void Merge(HexaPath other)
        {
            int otherLen = other.Length;

            for (int t = 0; t < otherLen; t++)
            {
                _path.Add(other[t]);
            }
        }
Ejemplo n.º 3
0
        public HexaPath SubPath(int from, int to)
        {
            HexaPath subpath = new HexaPath();

            for (int t = from; t <= to; t++)
            {
                subpath.AddPos(_path[t]);
            }
            return(subpath);
        }
Ejemplo n.º 4
0
        public HexaPath Clone()
        {
            HexaPath newPath = new HexaPath();

            List <HexaPos> .Enumerator e = _path.GetEnumerator();
            while (e.MoveNext())
            {
                newPath.AddPos(e.Current);
            }

            return(newPath);
        }
Ejemplo n.º 5
0
        public int DifferentAt(HexaPath other)
        {
            int selfLen  = Length;
            int otherLen = other.Length;

            for (int t = 0; t < selfLen && t < otherLen; t++)
            {
                if (_path[t].X != other._path[t].X ||
                    _path[t].Y != other._path[t].Y)
                {
                    return(t);
                }
            }
            return(selfLen);
        }
Ejemplo n.º 6
0
        public void DrawEnv(string filename, double[,] entropy, HexaPath path, Color pathColor, HexaPath refPath)
        {
            int width  = Convert.ToInt32(System.Math.Ceiling(map.PixelWidth));
            int height = Convert.ToInt32(System.Math.Ceiling(map.PixelHeight));

            width  += 1;
            height += 1;
            Bitmap     bitmap         = new Bitmap(width, height);
            Graphics   bitmapGraphics = Graphics.FromImage(bitmap);
            Pen        p  = new Pen(Color.Black);
            SolidBrush sb = new SolidBrush(Color.Black);

            sb = new SolidBrush(map.MapState.BackgroundColor);
            bitmapGraphics.FillRectangle(sb, 0, 0, width, height);
            for (int i = 0; i < map.Hexes.GetLength(0); i++)
            {
                for (int j = 0; j < map.Hexes.GetLength(1); j++)
                {
                    bitmapGraphics.FillPolygon(new SolidBrush(map.GetMapStateMgr().GetColor(entropy[map.Hexes[i, j].posX, map.Hexes[i, j].posY])), map.Hexes[i, j].Points);
                }
            }
            p.Color = map.MapState.GridColor;
            p.Width = map.MapState.GridPenWidth;
            for (int i = 0; i < map.Hexes.GetLength(0); i++)
            {
                for (int j = 0; j < map.Hexes.GetLength(1); j++)
                {
                    bitmapGraphics.DrawPolygon(p, map.Hexes[i, j].Points);
                }
            }

            List <Hex> .Enumerator eO = map.MapState.obstacles.hexSet.GetEnumerator();
            while (eO.MoveNext())
            {
                bitmapGraphics.FillPolygon(new SolidBrush(Color.Chocolate), eO.Current.Points);
            }

            if (refPath != null)
            {
                int pathLen = refPath.Length;

                if (pathLen > 0)
                {
                    for (int i = 0; i < pathLen; i++)
                    {
                        Hex tempHex = map.GetHex(refPath[i].X, refPath[i].Y);

                        p.Color = Color.Blue;
                        bitmapGraphics.DrawPolygon(p, tempHex.Points);
                    }
                }
            }

            if (path != null)
            {
                int pathLen = path.Length;

                if (pathLen > 0)
                {
                    for (int i = 0; i < pathLen; i++)
                    {
                        Hex tempHex = map.GetHex(path[i].X, path[i].Y);
                        p.Color = pathColor;

                        bitmapGraphics.FillPolygon(new SolidBrush(Color.FromArgb(180, 141, 182, 205)), tempHex.Points);

                        bitmapGraphics.DrawPolygon(p, tempHex.Points);
                    }
                }
            }

            bitmap.Save(filename);
        }