Exemple #1
0
 public static Predicate <ASCase> byPos(ASPoint point)
 {
     return(delegate(ASCase o)
     {
         return o.Point == point;
     });
 }
Exemple #2
0
 public bool inMap(ASPoint point)
 {
     return
         ((point.X >= 0) &&
          (point.Y >= 0) &&
          (point.X < _lignes) &&
          (point.Y < _colonnes));
 }
Exemple #3
0
 public static Predicate <ASCase> Proche(ASPoint point, int distance)
 {
     return(delegate(ASCase o)
     {
         int deltaX = Math.Abs(o.Point.X - point.X);
         int deltaY = Math.Abs(o.Point.Y - point.Y);
         return (deltaX + deltaY) < distance;
     });
 }
Exemple #4
0
        public override bool Equals(object obj)
        {
            if (!(obj is ASPoint))
            {
                return(false);
            }
            ASPoint pt = (ASPoint)obj;

            return(pt == this);
        }
Exemple #5
0
 public bool MovementFree(ASPoint point)
 {
     return(!_obstacles.Exists(ASCase.byPos(point)));
 }
Exemple #6
0
 public bool NearMovementFree(ASPoint point)
 {
     return(MovementFree(point) && NearFree(point));
 }
Exemple #7
0
 public bool NearFree(ASPoint point)
 {
     return(!_obstacles.Exists(ASCase.Proche(point, 1)));
 }
Exemple #8
0
 public ASCase getCase(ASPoint p)
 {
     return(_map[p.X, p.Y]);
 }
Exemple #9
0
        public List <ASCase> getAdjCase(ASCase current, bool bdiagonales = false)
        {
            List <ASCase> list  = new List <ASCase>();
            ASPoint       Point = new ASPoint();

            // Haut
            Point.X = current.Point.X;
            Point.Y = current.Point.Y + 1;
            if (inMap(Point) && NearMovementFree(Point))
            {
                ASCase Case = new ASCase(Point.Clone(), current);
                Case.CalculH(_end);
                Case.G = current.G + 1;
                list.Add(Case);
            }

            // Droite
            Point.X = current.Point.X + 1;
            Point.Y = current.Point.Y;
            if (inMap(Point) && NearMovementFree(Point))
            {
                ASCase Case = new ASCase(Point.Clone(), current);
                Case.CalculH(_end);
                Case.G = current.G + 1;
                list.Add(Case);
            }

            // Gauche
            Point.X = current.Point.X - 1;
            Point.Y = current.Point.Y;
            if (inMap(Point) && NearMovementFree(Point))
            {
                ASCase Case = new ASCase(Point.Clone(), current);
                Case.CalculH(_end);
                Case.G = current.G + 1;
                list.Add(Case);
            }

            // Bas
            Point.X = current.Point.X;
            Point.Y = current.Point.Y - 1;
            if (inMap(Point) && NearMovementFree(Point))
            {
                ASCase Case = new ASCase(Point.Clone(), current);
                Case.CalculH(_end);
                Case.G = current.G + 1;
                list.Add(Case);
            }

            if (bdiagonales)
            {
                // Haut gauche
                Point.X = current.Point.X - 1;
                Point.Y = current.Point.Y + 1;
                if (inMap(Point) && MovementFree(Point))
                {
                    ASCase Case = new ASCase(Point.Clone(), current);
                    Case.CalculH(_end);
                    Case.G = current.G + 2;
                    list.Add(Case);
                }

                // Haut Droite
                Point.X = current.Point.X + 1;
                Point.Y = current.Point.Y + 1;
                if (inMap(Point) && MovementFree(Point))
                {
                    ASCase Case = new ASCase(Point.Clone(), current);
                    Case.CalculH(_end);
                    Case.G = current.G + 2;
                    list.Add(Case);
                }

                // Bas Gauche
                Point.X = current.Point.X - 1;
                Point.Y = current.Point.Y - 1;
                if (inMap(Point) && MovementFree(Point))
                {
                    ASCase Case = new ASCase(Point.Clone(), current);
                    Case.CalculH(_end);
                    Case.G = current.G + 2;
                    list.Add(Case);
                }

                // Bas Droite
                Point.X = current.Point.X + 1;
                Point.Y = current.Point.Y - 1;
                if (inMap(Point) && MovementFree(Point))
                {
                    ASCase Case = new ASCase(Point.Clone(), current);
                    Case.CalculH(_end);
                    Case.G = current.G + 2;
                    list.Add(Case);
                }
            }

            return(list);
        }
Exemple #10
0
 static public int SquareDistanceTo(ASPoint pointA, ASPoint pointB)
 {
     return
         ((int)Math.Pow(pointA.X - pointB.X, 2) +
          (int)Math.Pow(pointA.Y - pointB.Y, 2));
 }
Exemple #11
0
 public ASCase(ASPoint point, ASCase parent)
 {
     this.Point  = point;
     this.Parent = parent;
 }
Exemple #12
0
 public ASCase(int X, int Y)
 {
     this.Point = new ASPoint(X, Y);
 }