Merge pull request #67 from progtime-net/fix-paths
Fix paths to run game without sources
This commit is contained in:
commit
97cd62759c
3 changed files with 9 additions and 16 deletions
|
@ -33,13 +33,13 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
|||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
TileMap tileMap =
|
||||
JsonSerializer.Deserialize<TileMap>(File.ReadAllText(string.Format(_templatePath, mapName)), options);
|
||||
JsonSerializer.Deserialize<TileMap>(File.ReadAllText(Path.Combine(AppContext.BaseDirectory, string.Format(_templatePath, mapName))), options);
|
||||
|
||||
// Загрузка TileSet-ов по TileSetInfo
|
||||
List<TileSet> tileSets = new List<TileSet>();
|
||||
foreach (TileSetInfo tileSetInfo in tileMap.TileSets)
|
||||
{
|
||||
TileSet tileSet = LoadTileSet(Path.Combine("Content", "MapData", "TileMaps", tileSetInfo.Source));
|
||||
TileSet tileSet = LoadTileSet(Path.Combine(AppContext.BaseDirectory, "Content", "MapData", "TileMaps", tileSetInfo.Source));
|
||||
tileSet.FirstGid = tileSetInfo.FirstGid;
|
||||
tileSets.Add(tileSet);
|
||||
}
|
||||
|
@ -75,14 +75,15 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
|||
(i / chunk.Height) * tileMap.TileHeight + chunk.Y * tileMap.TileHeight);
|
||||
|
||||
Tile tile = tileSet.Tiles[number]; // По факту может быть StopObjectom, но на уровне Tiled это все в первую очередь Tile
|
||||
|
||||
string textureName = Path.Combine(AppContext.BaseDirectory, "Content", "Textures", "TileSetImages",
|
||||
Path.GetFileName(tileSet.Image).Replace(".png", ""));
|
||||
switch (tile.Type)
|
||||
{
|
||||
case "Tile":
|
||||
AppManager.Instance.server.RegisterGameObject(new MapObject(position,
|
||||
new Vector2(tileSet.TileWidth, tileSet.TileHeight),
|
||||
sourceRectangle,
|
||||
"Textures/TileSetImages/" + Path.GetFileName(tileSet.Image).Replace(".png", "")));
|
||||
textureName));
|
||||
break;
|
||||
|
||||
case "StopObject":
|
||||
|
@ -91,7 +92,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
|||
AppManager.Instance.server.RegisterGameObject(new StopObject(position,
|
||||
new Vector2(tileSet.TileWidth, tileSet.TileHeight),
|
||||
sourceRectangle,
|
||||
"Textures/TileSetImages/" + Path.GetFileName(tileSet.Image).Replace(".png", ""),
|
||||
textureName,
|
||||
collisionRectangles.ToArray()));
|
||||
break;
|
||||
|
||||
|
|
|
@ -24,19 +24,11 @@ namespace ZoFo.GameCore.GameManagers
|
|||
{
|
||||
//List<string> sounds = AppManager.Instance.Content.Load<List<string>>("sounds/");
|
||||
|
||||
string a = Path.Combine("Content", "sounds");
|
||||
string[] k;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
k = Directory.GetFiles(Path.Combine("bin", "Debug", "net8.0", "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray();
|
||||
}
|
||||
else{
|
||||
k = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray();
|
||||
}
|
||||
string[] k = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray();
|
||||
if (k.Length > 0)
|
||||
{
|
||||
|
||||
string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".xnb", "")).ToArray();// папка со звуками там где exe
|
||||
string[] soundFiles = k.Select(x => x.Split("/").Last().Replace(".xnb", "")).ToArray();// папка со звуками там где exe
|
||||
foreach (var soundFile in soundFiles)
|
||||
{
|
||||
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(Path.Combine("sounds", soundFile)));
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ZoFo.GameCore.Graphics
|
|||
public void LoadAnimations()
|
||||
{
|
||||
Animations = new List<AnimationContainer>();
|
||||
string[] animationFilesNames = Directory.GetFiles("Content/Textures/Animations");
|
||||
string[] animationFilesNames = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Content", "Textures", "Animations"));
|
||||
|
||||
StreamReader reader;
|
||||
foreach (var fileName in animationFilesNames)
|
||||
|
|
Loading…
Add table
Reference in a new issue