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
|
PropertyNameCaseInsensitive = true
|
||||||
};
|
};
|
||||||
TileMap tileMap =
|
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
|
// Загрузка TileSet-ов по TileSetInfo
|
||||||
List<TileSet> tileSets = new List<TileSet>();
|
List<TileSet> tileSets = new List<TileSet>();
|
||||||
foreach (TileSetInfo tileSetInfo in tileMap.TileSets)
|
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;
|
tileSet.FirstGid = tileSetInfo.FirstGid;
|
||||||
tileSets.Add(tileSet);
|
tileSets.Add(tileSet);
|
||||||
}
|
}
|
||||||
|
@ -75,14 +75,15 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
||||||
(i / chunk.Height) * tileMap.TileHeight + chunk.Y * tileMap.TileHeight);
|
(i / chunk.Height) * tileMap.TileHeight + chunk.Y * tileMap.TileHeight);
|
||||||
|
|
||||||
Tile tile = tileSet.Tiles[number]; // По факту может быть StopObjectom, но на уровне Tiled это все в первую очередь Tile
|
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)
|
switch (tile.Type)
|
||||||
{
|
{
|
||||||
case "Tile":
|
case "Tile":
|
||||||
AppManager.Instance.server.RegisterGameObject(new MapObject(position,
|
AppManager.Instance.server.RegisterGameObject(new MapObject(position,
|
||||||
new Vector2(tileSet.TileWidth, tileSet.TileHeight),
|
new Vector2(tileSet.TileWidth, tileSet.TileHeight),
|
||||||
sourceRectangle,
|
sourceRectangle,
|
||||||
"Textures/TileSetImages/" + Path.GetFileName(tileSet.Image).Replace(".png", "")));
|
textureName));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "StopObject":
|
case "StopObject":
|
||||||
|
@ -91,7 +92,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
||||||
AppManager.Instance.server.RegisterGameObject(new StopObject(position,
|
AppManager.Instance.server.RegisterGameObject(new StopObject(position,
|
||||||
new Vector2(tileSet.TileWidth, tileSet.TileHeight),
|
new Vector2(tileSet.TileWidth, tileSet.TileHeight),
|
||||||
sourceRectangle,
|
sourceRectangle,
|
||||||
"Textures/TileSetImages/" + Path.GetFileName(tileSet.Image).Replace(".png", ""),
|
textureName,
|
||||||
collisionRectangles.ToArray()));
|
collisionRectangles.ToArray()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -24,19 +24,11 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
{
|
{
|
||||||
//List<string> sounds = AppManager.Instance.Content.Load<List<string>>("sounds/");
|
//List<string> sounds = AppManager.Instance.Content.Load<List<string>>("sounds/");
|
||||||
|
|
||||||
string a = Path.Combine("Content", "sounds");
|
string[] k = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray();
|
||||||
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();
|
|
||||||
}
|
|
||||||
if (k.Length > 0)
|
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)
|
foreach (var soundFile in soundFiles)
|
||||||
{
|
{
|
||||||
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(Path.Combine("sounds", soundFile)));
|
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(Path.Combine("sounds", soundFile)));
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
public void LoadAnimations()
|
public void LoadAnimations()
|
||||||
{
|
{
|
||||||
Animations = new List<AnimationContainer>();
|
Animations = new List<AnimationContainer>();
|
||||||
string[] animationFilesNames = Directory.GetFiles("Content/Textures/Animations");
|
string[] animationFilesNames = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Content", "Textures", "Animations"));
|
||||||
|
|
||||||
StreamReader reader;
|
StreamReader reader;
|
||||||
foreach (var fileName in animationFilesNames)
|
foreach (var fileName in animationFilesNames)
|
||||||
|
|
Loading…
Add table
Reference in a new issue