Remote dveře lze na mapě otevírat a zavírat. Office dveře hráče lze vidět na mapě (ukazují se ale pouze pro hráče 1). PlayerCommandy, které přepínají mezi dvěma stavy mají přidaný parametr state - client tudíž určuje jejich nový stav. Pokud se neshoduje stav v GameEventu se stavem odeslaným v Commandu, zobrazí se v konzoli varování. Client již nečeká na odpověď serveru při změně UI. Connectory se neklonují, oba tily používají stejnou instanci.
This commit is contained in:
parent
70b5debb22
commit
cea56112ea
14 changed files with 112 additions and 48 deletions
|
|
@ -48,11 +48,6 @@ public class UIManager {
|
|||
monitorScreen.AddElement("view-frame", new UIElement(monitorAtlas[1], new Point(62, 55)));
|
||||
monitorScreen.AddElement("map-frame", new UIElement(monitorAtlas[2], new Point(334, 135)));
|
||||
monitorScreen.AddElement("map", new UIElement(monitorAtlas[3], new Point(334, 135)));
|
||||
|
||||
// Dictionary<(int,int),string> doorPositions = new(){
|
||||
// {(0, 0),"2-5"},{ (1, 0), "2-4" }, { (1, 1), "2-3" }, { (3, 0), "2-2" }, { (3, 1), "2-1" }, { (4, 0), "2-0" }, // TODO: generate this dynamically from server map info
|
||||
// {(0, 3),"1-0"},{ (1, 3), "1-1" }, { (1, 2), "1-2" }, { (3, 3), "1-3" }, { (3, 2), "1-4" }, { (4, 3), "1-5" }
|
||||
// };
|
||||
|
||||
for (int i = 0; i < 5; i++){ // NOTE: this loop does y in reverse, y labels are inverted to match server
|
||||
for (int j = 0; j < 5; j++){
|
||||
|
|
@ -61,7 +56,7 @@ public class UIManager {
|
|||
Point point1 = new Point(336 + (32 * i), 144 + (32 * j));
|
||||
Point point2 = new Point(367 + (32 * i), 175 + (32 * j));
|
||||
monitorScreen.AddElement($"room{MapTileProjection.CoordsToId(i, 4 - j)}", new UIElement(point1, point2)
|
||||
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(i1, 4 - j1))});
|
||||
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(MapTileProjection.CoordsToId(i1, 4 - j1)))});
|
||||
//
|
||||
// if (doorPositions.ContainsKey((i, j))){
|
||||
// monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
|
||||
|
|
@ -79,24 +74,42 @@ public class UIManager {
|
|||
if (dpos.y == 1){
|
||||
int targetId = door.Tiles.tile1.GridPosition.y > door.Tiles.tile2.GridPosition.y ? door.Tiles.tile1.Id : door.Tiles.tile2.Id;
|
||||
UIElement tile = monitorScreen["room"+targetId];
|
||||
|
||||
monitorScreen.AddElement("door"+targetId+"-"+(targetId == door.Tiles.tile1.Id ? door.Tiles.tile2.Id : door.Tiles.tile1.Id), new UIElement([monitorAtlas[5], monitorAtlas[6]], tile.Bounds.Item1));
|
||||
}
|
||||
}
|
||||
|
||||
monitorScreen.AddElement("p1-office-door-left", new UIElement([monitorAtlas[7], monitorAtlas[8]], new Point(400, 272)));
|
||||
monitorScreen.AddElement("p1-office-door-centre", new UIElement([monitorAtlas[9], monitorAtlas[10]], new Point(400, 272)));
|
||||
monitorScreen.AddElement("p1-office-door-right", new UIElement([monitorAtlas[11], monitorAtlas[12]], new Point(400, 272)));
|
||||
monitorScreen.AddElement("p2-office-door-right", new UIElement([monitorAtlas[13], monitorAtlas[14]], new Point(400, 144)));
|
||||
monitorScreen.AddElement("p2-office-door-centre", new UIElement([monitorAtlas[15], monitorAtlas[16]], new Point(400, 144)));
|
||||
monitorScreen.AddElement("p2-office-door-left", new UIElement([monitorAtlas[17], monitorAtlas[18]], new Point(400, 144)));
|
||||
|
||||
}
|
||||
|
||||
public static void ChangeDoorState(Direction dir, bool state) {
|
||||
public static void ChangeDoorState(Direction dir, bool state) { // TODO: make this also change for p2
|
||||
int stateInt = state ? 1 : 0;
|
||||
|
||||
switch ((int)dir){
|
||||
case 0:
|
||||
officeScreen["office_left"].SetTexture(state ? 1 : 0);
|
||||
officeScreen["office_left"].SetTexture(stateInt);
|
||||
monitorScreen["p1-office-door-left"].SetTexture(stateInt);
|
||||
break;
|
||||
case 1:
|
||||
officeScreen["office_centre"].SetTexture(state ? 1 : 0);
|
||||
officeScreen["office_centre"].SetTexture(stateInt);
|
||||
monitorScreen["p1-office-door-centre"].SetTexture(stateInt);
|
||||
break;
|
||||
case 2:
|
||||
officeScreen["office_right"].SetTexture(state ? 1 : 0);
|
||||
officeScreen["office_right"].SetTexture(stateInt);
|
||||
monitorScreen["p1-office-door-right"].SetTexture(stateInt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangeRemoteDoorState((int, int) id, bool state) {
|
||||
monitorScreen["door"+Math.Max(id.Item1, id.Item2)+"-"+Math.Min(id.Item1, id.Item2)].SetTexture(state ? 1 : 0);
|
||||
}
|
||||
|
||||
public static void ChangeMonitorState(bool state) {
|
||||
Screen.SetScreen(state ? ScreenTypes.CAMERAS : ScreenTypes.OFFICE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue