Пример #1
0
        public bool NearlyCompare(Vector2f v, int range)
        {
            int dX = MathUtils.Abs(X() - v.X());
            int dY = MathUtils.Abs(Y() - v.Y());

            return((dX <= range) && (dY <= range));
        }
Пример #2
0
        public void Move_multiples(int direction, int multiples)
        {
            if (multiples <= 0)
            {
                multiples = 1;
            }
            Vector2f v = Field2D.GetDirection(direction);

            Move(v.X() * multiples, v.Y() * multiples);
        }
Пример #3
0
        public int Angle(Vector2f v)
        {
            int dx  = v.X() - X();
            int dy  = v.Y() - Y();
            int adx = MathUtils.Abs(dx);
            int ady = MathUtils.Abs(dy);

            if ((dy == 0) && (dx == 0))
            {
                return(0);
            }
            if ((dy == 0) && (dx > 0))
            {
                return(0);
            }
            if ((dy == 0) && (dx < 0))
            {
                return(180);
            }
            if ((dy > 0) && (dx == 0))
            {
                return(90);
            }
            if ((dy < 0) && (dx == 0))
            {
                return(270);
            }
            float rwinkel = MathUtils.Atan(ady / adx);
            float dwinkel = 0.0f;

            if ((dx > 0) && (dy > 0))
            {
                dwinkel = MathUtils.ToDegrees(rwinkel);
            }
            else if ((dx < 0) && (dy > 0))
            {
                dwinkel = (180.0f - MathUtils.ToDegrees(rwinkel));
            }
            else if ((dx > 0) && (dy < 0))
            {
                dwinkel = (360.0f - MathUtils.ToDegrees(rwinkel));
            }
            else if ((dx < 0) && (dy < 0))
            {
                dwinkel = (180.0f + MathUtils.ToDegrees(rwinkel));
            }
            int iwinkel = (int)dwinkel;

            if (iwinkel == 360)
            {
                iwinkel = 0;
            }
            return(iwinkel);
        }
Пример #4
0
 public static List<Vector2f> Find(AStarFindHeuristic heuristic,
         Field2D maps, Vector2f start, Vector2f goal, bool flag)
 {
     return Find(heuristic, maps.GetMap(), maps.GetLimit(), start.X(),
             start.Y(), goal.X(), goal.Y(), flag);
 }
Пример #5
0
 public static List<Vector2f> Find(AStarFindHeuristic heuristic,
         int[][] maps, Vector2f start, Vector2f goal, bool flag)
 {
     return Find(heuristic, maps, start.X(), start.Y(), goal.X(), goal.Y(),
             flag);
 }
Пример #6
0
		public int Angle(Vector2f v) {
			int dx = v.X() - X();
			int dy = v.Y() - Y();
			int adx = MathUtils.Abs(dx);
			int ady = MathUtils.Abs(dy);
			if ((dy == 0) && (dx == 0)) {
				return 0;
			}
			if ((dy == 0) && (dx > 0)) {
				return 0;
			}
			if ((dy == 0) && (dx < 0)) {
				return 180;
			}
			if ((dy > 0) && (dx == 0)) {
				return 90;
			}
			if ((dy < 0) && (dx == 0)) {
				return 270;
			}
			float rwinkel = MathUtils.Atan(ady / adx);
			float dwinkel = 0.0f;
			if ((dx > 0) && (dy > 0)) {
				dwinkel = MathUtils.ToDegrees(rwinkel);
			} else if ((dx < 0) && (dy > 0)) {
				dwinkel = (180.0f - MathUtils.ToDegrees(rwinkel));
			} else if ((dx > 0) && (dy < 0)) {
				dwinkel = (360.0f - MathUtils.ToDegrees(rwinkel));
			} else if ((dx < 0) && (dy < 0)) {
				dwinkel = (180.0f + MathUtils.ToDegrees(rwinkel));
			}
			int iwinkel = (int) dwinkel;
			if (iwinkel == 360) {
				iwinkel = 0;
			}
			return iwinkel;
		}
Пример #7
0
		public bool NearlyCompare(Vector2f v, int range) {
			int dX = MathUtils.Abs(X() - v.X());
			int dY = MathUtils.Abs(Y() - v.Y());
			return (dX <= range) && (dY <= range);
		}
Пример #8
0
 private int Get(int[][] data, Vector2f point)
 {
     try
     {
         if (point.X() >= 0 && point.X() < width && point.Y() >= 0
                 && point.Y() < height)
         {
             return data[point.Y()][point.X()];
         }
         else
         {
             return -1;
         }
     }
     catch (Exception)
     {
         return -1;
     }
 }
Пример #9
0
 public List<Vector2f> Neighbors(Vector2f pos, bool flag)
 {
     if (result == null)
     {
         result = new List<Vector2f>(8);
     }
     else
     {
         CollectionUtils.Clear(result);
     }
     int x = pos.X();
     int y = pos.Y();
     CollectionUtils.Add(result, new Vector2f(x, y - 1));
     CollectionUtils.Add(result, new Vector2f(x + 1, y));
     CollectionUtils.Add(result, new Vector2f(x, y + 1));
     CollectionUtils.Add(result, new Vector2f(x - 1, y));
     if (flag)
     {
         CollectionUtils.Add(result, new Vector2f(x - 1, y - 1));
         CollectionUtils.Add(result, new Vector2f(x + 1, y - 1));
         CollectionUtils.Add(result, new Vector2f(x + 1, y + 1));
         CollectionUtils.Add(result, new Vector2f(x - 1, y + 1));
     }
     return result;
 }
Пример #10
0
 public MoveTo(Field2D map, Vector2f pos, bool flag_0)
     : this(map, pos.X(), pos.Y(), flag_0)
 {
 }