Rozsvěcení a zhasínání světel, sprity pro místnosti, indikátory rozsvícených světel, po konci hry je hráč vrácen do hlavního menu
This commit is contained in:
parent
25a62af483
commit
55fd052072
27 changed files with 338 additions and 113 deletions
|
|
@ -1,7 +1,11 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.JavaScript;
|
||||
using FNAF_Clone.GUI;
|
||||
using GlobalClassLib;
|
||||
using PacketLib;
|
||||
|
||||
namespace FNAF_Clone.Map;
|
||||
|
||||
|
|
@ -11,11 +15,18 @@ public class ClientMapManager {
|
|||
public static MapTileProjection Get(int tileId) => Get(IdToCoords(tileId));
|
||||
|
||||
private static bool inverted;
|
||||
public static void InitMap(bool invert = false) {
|
||||
inverted = invert;
|
||||
public static void InitMap(int[] connectors, int[] yourTiles, int[] opponentTiles, int[] litTiles, bool upsideDown ) {
|
||||
|
||||
IdToCoords = invert ? _IdToCoordsInverse : _IdToCoords;
|
||||
CoordsToId = invert ? _CoordsToIdInverse : _CoordsToId;
|
||||
(int id1, int id2, ConnectorType type, ClientPlayer? owner)[] connectorsData = new (int, int , ConnectorType, ClientPlayer?)[connectors.Length / 4];
|
||||
for (int i = 0; i < connectors.Length / 4; i++){
|
||||
connectorsData[i] = (connectors[i * 4], connectors[i * 4 + 1], (ConnectorType)connectors[i * 4 + 2], connectors[i * 4 + 3] == -1 ? null : Client.GetPlayer(connectors[i * 4 + 3]));
|
||||
}
|
||||
// ClientMapManager.InitMap(upsideDown);
|
||||
|
||||
inverted = upsideDown;
|
||||
|
||||
IdToCoords = upsideDown ? _IdToCoordsInverse : _IdToCoords;
|
||||
CoordsToId = upsideDown ? _CoordsToIdInverse : _CoordsToId;
|
||||
|
||||
for (int i = 0; i < 5; i++){
|
||||
for (int j = 0; j < 2; j++){
|
||||
|
|
@ -27,6 +38,26 @@ public class ClientMapManager {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var tileId in yourTiles){
|
||||
Get(tileId).Owner = Client.Player;
|
||||
}
|
||||
|
||||
foreach (var tileId in opponentTiles){
|
||||
Get(tileId).Owner = Client.Opponent;
|
||||
}
|
||||
|
||||
foreach (var tileId in litTiles){
|
||||
Get(tileId).Lit = true;
|
||||
}
|
||||
|
||||
|
||||
TileConnectorProjection[] connectorProjections = connectorsData.Select(c => new TileConnectorProjection(Get(c.id1), Get(c.id2), c.type){Owner = c.owner}).ToArray();
|
||||
InitConnectors(connectorProjections);
|
||||
|
||||
UIManager.SpawnMapElements(connectorProjections.Where(c => c.Type == ConnectorType.DOOR_REMOTE).ToArray());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void InitConnectors(TileConnectorProjection[] connectors) {
|
||||
|
|
@ -58,12 +89,21 @@ public class ClientMapManager {
|
|||
}
|
||||
|
||||
|
||||
public const int ID_X_OFFSET = 5; // map grid height
|
||||
public const int MAP_SIDE_LENGTH = 5; // map grid height
|
||||
public static Func<int, int, int> CoordsToId{ get; private set; }
|
||||
public static Func<int, (int x, int y)> IdToCoords{ get; private set; }
|
||||
|
||||
private static Func<int, (int x, int y)> _IdToCoords = id => (id / ID_X_OFFSET, id % ID_X_OFFSET);
|
||||
private static Func<int, (int x, int y)> _IdToCoordsInverse = id => (ID_X_OFFSET - 1 - (id / ID_X_OFFSET), ID_X_OFFSET - 1 - (id % ID_X_OFFSET));
|
||||
private static Func<int, int, int> _CoordsToId = (x, y) => x * ID_X_OFFSET + y;
|
||||
private static Func<int, int, int> _CoordsToIdInverse = (x, y) => (ID_X_OFFSET - 1 - x) * ID_X_OFFSET + (ID_X_OFFSET - 1 - y);
|
||||
private static Func<int, (int x, int y)> _IdToCoords = id => (id / MAP_SIDE_LENGTH, id % MAP_SIDE_LENGTH);
|
||||
private static Func<int, (int x, int y)> _IdToCoordsInverse = id => (MAP_SIDE_LENGTH - 1 - (id / MAP_SIDE_LENGTH), MAP_SIDE_LENGTH - 1 - (id % MAP_SIDE_LENGTH));
|
||||
private static Func<int, int, int> _CoordsToId = (x, y) => x * MAP_SIDE_LENGTH + y;
|
||||
private static Func<int, int, int> _CoordsToIdInverse = (x, y) => (MAP_SIDE_LENGTH - 1 - x) * MAP_SIDE_LENGTH + (MAP_SIDE_LENGTH - 1 - y);
|
||||
|
||||
public static MapTileProjection[] GetAllTiles() {
|
||||
List<MapTileProjection> tiles = new();
|
||||
foreach (var tile in map){
|
||||
tiles.Add(tile);
|
||||
}
|
||||
|
||||
return tiles.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ namespace FNAF_Clone.Map;
|
|||
|
||||
public class MapTileProjection : GlobalMapTile<TileConnectorProjection, MapTileProjection> {
|
||||
public ClientPlayer? Owner { get; set; }
|
||||
|
||||
public MapTileProjection(int id) : base(id, ClientMapManager.IdToCoords(id)) {
|
||||
Lit = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue