private void CreatePath(Point start, Point end, MapEntityFactory.MAP_ENTITY path_type) { int mapWidthBorder = MAP_WIDTH_BORDER / MapEntity.MAP_ENTITY_BASE_SIZE, mapHeightBorder = MAP_HEIGHT_BORDER / MapEntity.MAP_ENTITY_BASE_SIZE; double value = 0; while (Math.Abs(start.X - end.X) >= CLEAR_AREA_LENGTH/2 || Math.Abs(start.Y - end.Y) >= CLEAR_AREA_LENGTH/2) { this.contentLayers[(int)LAYERS.GROUND][start.X][start.Y] = this.CreateMapEntity(path_type, start.X, start.Y); value = rand.NextDouble(); if(value < .25 && start.X+1 < this.contentLayers[0].Length - mapWidthBorder) { start.X++; } else if (value < .5 && start.X-1 >= mapWidthBorder) { start.X--; } else if (value < .75 && start.Y+1 < this.contentLayers[0][0].Length - mapHeightBorder) { start.Y++; } else if (start.Y-1 >= mapHeightBorder) { start.Y--; } } }
private MapEntity CreateMapEntity(MapEntityFactory.MAP_ENTITY type, int x, int y) { return MapEntityFactory.GetInstance().CreateMapEntity(type, new Vector2(x * MapEntity.MAP_ENTITY_BASE_SIZE, y * MapEntity.MAP_ENTITY_BASE_SIZE)); }