Beispiel #1
0
        public static void tr()
        {
            CalcHelper   c = new CalcHelper(Map);
            List <Point> p = c.CalcShortestPath(new Point(1, 2), new Point(6, 5));

            for (int i = 0; i < p.Count; i++)
            {
                Map[p[i].X, p[i].Y].ContaintID = i + 1;
            }
            DrawMap();
        }
Beispiel #2
0
        private Point GetApprochablePoint(bool[,] map, Point t)
        {
            CHelper = new CalcHelper(Engine.Map);
            List <Point> ES = CHelper.GetEmptyAround(t);

            if (ES.Count != 0)
            {
                List <Point> Accesible = new List <Point>();
                for (int i = 0; i < ES.Count; i++)
                {
                    if (CHelper.CalcShortestPath(Position, ES[i]) != null)
                    {
                        Accesible.Add(ES[i]);
                    }
                }
                if (Accesible.Count != 0)
                {
                    return(Accesible[Engine.rnd.Next(Accesible.Count)]);
                }
            }
            else
            {
                map[t.X, t.Y] = true;
                if (t.X - 1 >= 0 && !map[t.X - 1, t.Y])
                {
                    GetApprochablePoint(map, new Point(t.X - 1, t.Y));
                }
                if (t.Y - 1 >= 0 && !map[t.X, t.Y - 1])
                {
                    GetApprochablePoint(map, new Point(t.X, t.Y - 1));
                }
                if (t.X + 1 < Engine.MapSize && !map[t.X + 1, t.Y])
                {
                    GetApprochablePoint(map, new Point(t.X + 1, t.Y));
                }
                if (t.Y + 1 < Engine.MapSize && !map[t.X, t.Y + 1])
                {
                    GetApprochablePoint(map, new Point(t.X, t.Y + 1));
                }
            }
            return(new Point(0, 0));
        }
Beispiel #3
0
 public void GetShortestPath(Point TargetLocation)
 {
     Path    = new List <Point>();
     CHelper = new CalcHelper(Engine.Map);
     Path    = CHelper.CalcShortestPath(this.Position, TargetLocation);
 }
Beispiel #4
0
        public List <Point> GetReachebleNearNotVisible()
        {
            CHelper = new CalcHelper(Engine.Map);
            List <Point> TilesToGo = new List <Point>();

            for (int i = 0; i < Engine.MapSize; i++)
            {
                for (int j = 0; j < Engine.MapSize; j++)
                {
                    if (Engine.Visible[i, j] == false)
                    {
                        List <Point> aux = CHelper.GetEmptyAround(new Point(i, j));
                        for (int q = 0; q < aux.Count; q++)
                        {
                            if (!TilesToGo.Contains(aux[q]) && aux[q] != this.Position && CHelper.CalcShortestPath(this.Position, aux[q]) != null)
                            {
                                TilesToGo.Add(aux[q]);
                            }
                        }
                    }
                }
            }
            return(TilesToGo);
        }