//Cube Axe_D = null; public Coin(int x, int y, int z, Direction d, Map map) { if (d.Z > 0) { Axe_X = map.FindCube(x + d.X, y, z + d.Z); Axe_Y = map.FindCube(x, y + d.Y, z + d.Z); //Axe_D = map.FindCube(x + d.X, y + d.Y, z + d.Z); } else { Axe_X = map.FindCube(x + d.X, y, z); Axe_Y = map.FindCube(x, y + d.Y, z); //Axe_D = map.FindCube(x + d.X, y + d.Y, z); } }
public virtual bool CanMoveTo(int pX, int pY, int pZ, Map map) { for (int ey = 0; ey < Width; ey++) { for (int ex = 0; ex < Width; ex++) { for (int ez = 0; ez < Height; ez++) { if (!map.Contains(pX - ex, pY - ey, pZ + ez)) { return(false); } Cube c = map.FindCube(pX - ex, pY - ey, pZ + ez); if (c != null && !c.Cross) { return(false); } Entity entity = map.FindEntity(pX - ex, pY - ey, pZ + ez); if (entity != null && !entity.Cross && entity.ID != ID) { return(false); } } } } return(true); }
//public void OnStreet(Entity entity) //{ // X = entity.X; // Y = entity.Y; // Z = entity.Z; // Map = entity.Map; // Roads = new Road[0]; // Road road = new Road(X, Y, Z); // road.Add(new Point3D(X, Y, Z)); // Add(road); // OnStreet(road, entity); //} void OnStreet(Road road, Entity entity) { road.Closed = true; Cube cube_dest; Direction direction; if (road.Street.Length < Range) { //for (int i = 1; i < 27; i++) for (int i = 0; i < 24; i++) { direction = Info.IntToDirection(i); if (Contains(road.X + direction.X, road.Y + direction.Y, road.Z + direction.Z)) { continue; } cube_dest = Map.FindCube(road.X + direction.X, road.Y + direction.Y, road.Z + direction.Z); if (cube_dest == null || !cube_dest.Cross || cube_dest.Climb) { continue; // } if (direction.X != 0 && direction.Y != 0) { Coin coin = new Coin(road.X, road.Y, road.Z, direction, Map); if (!coin.Movement()) { continue; } } if (entity != null && !entity.CanMoveTo(cube_dest.X, cube_dest.Y, cube_dest.Z, Map)) { continue; } Road next_road = new Road(cube_dest.X, cube_dest.Y, cube_dest.Z); next_road.CopyAndAdd(road, new Point3D(cube_dest.X, cube_dest.Y, cube_dest.Z)); Add(next_road); } } //for (int i = 0; i < Roads.Length; i++) // if (!Roads[i].Closed) // { OnStreet(Roads[i], entity); break; } GoToStreet(entity); }