Na začátku hry se mapa na serveru synchronizuje s mapou u clienta. Rozšířen spritesheet monitoru o remote dveře. Přidána GlobalClassLib pro kód sdílený mezi clientem a serverem. Základ pro implementaci ovládání remote dveří.

This commit is contained in:
Perry 2026-02-14 14:35:29 +01:00
parent 8801a7c919
commit 7e6b3d724b
25 changed files with 374 additions and 67 deletions

View file

@ -0,0 +1,9 @@
namespace GlobalClassLib;
public enum ConnectorType {
HALL = 0,
DOOR_REMOTE = 1,
DOOR_OFFICE = 2,
VENT = 3
}

View file

@ -0,0 +1,8 @@
namespace GlobalClassLib;
public enum Direction {
EAST = 0,
NORTH = 1,
WEST = 2,
SOUTH = 3
}

View file

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,43 @@
namespace GlobalClassLib;
public abstract class GlobalMapTile<TCon, TTile> where TCon : GlobalTileConnector<TTile, TCon> where TTile : GlobalMapTile<TCon, TTile> { // TTile should be the inheriting class
public int Id { get; private set; }
public bool Lit { get; set; } = false;
private List<TCon> connectors = new();
public GlobalMapTile(int id) {
Id = id;
}
public void AddConnector(TCon connector) { // tile1 is ignored when provided
connector.Tiles.tile1 = (TTile)this;
connectors.Add(connector);
connector.Tiles.tile2._AddConnectorNoRepeat(connector.Clone());
// connectors.Add(new TCon(this, tile, type));
// tile.connectors.Add(new GlobalTileConnector(tile, this, type));
}
private void _AddConnectorNoRepeat(TCon connector) {
(connector.Tiles.tile1, connector.Tiles.tile2) = (connector.Tiles.tile2, connector.Tiles.tile1);
connectors.Add(connector);
}
public void AddConnectors(TCon[] connectors) =>
Array.ForEach(connectors, AddConnector);
public override string ToString() => $"{PositionAsString} -> {string.Join(", ", connectors.Select(c => c.Tiles.Item2.PositionAsString))}";
public string PositionAsString => $"[{Id}]"; // for debug purposes
public TCon? GetConnector(int id) {
foreach (var con in connectors){
if (con.Tiles.Item2.Id == id) return con;
}
return null;
}
public TCon[] GetAllConnectors() => connectors.ToArray();
public static int CoordsToId(int x, int y) => x * 5 + y;
public static (int, int) IdToCoords(int id) => (id % 5, id / 5);
}

View file

@ -0,0 +1,28 @@
namespace GlobalClassLib;
public abstract class GlobalTileConnector<TTile, TCon> where TTile : GlobalMapTile<TCon,TTile> where TCon : GlobalTileConnector<TTile, TCon> {
// private readonly TTile _tile1;
// private readonly TTile _tile2;
public GlobalTileConnector(TTile tile1, TTile tile2, ConnectorType type) {
Tiles.tile1 = tile1;
Tiles.tile2 = tile2;
Type = type;
}
public GlobalTileConnector(TTile tile2, ConnectorType type) {
Tiles.tile2 = tile2;
Type = type;
}
public (TTile tile1, TTile tile2) Tiles;
public (int, int) Id => (Tiles.tile1.Id, Tiles.tile2.Id);
public ConnectorType Type { get; set; }
public TTile OtherTile(TTile tile) => Tiles.Item1 == tile ? Tiles.Item2 : Tiles.Item1;
public override string ToString() => $"Con ({Tiles.Item1.PositionAsString} -> {Tiles.Item2.PositionAsString})";
public abstract TCon Clone();
}