Přidán indikátor právě aktivní kamery pro oba hráče. Indikátor protivníka se mění podle toho, jestli má zapnutý monitor.
This commit is contained in:
parent
3049417914
commit
4484b127c5
8 changed files with 60 additions and 9 deletions
|
|
@ -60,6 +60,7 @@ public class CommandManager {
|
||||||
|
|
||||||
public static void SendChangeCamera(int id) {
|
public static void SendChangeCamera(int id) {
|
||||||
Client.Player.state.camera = id;
|
Client.Player.state.camera = id;
|
||||||
|
UIManager.ChangeCamera(id);
|
||||||
Client.SendCommands([PlayerCommand.SWITCH_CAM(id)]);
|
Client.SendCommands([PlayerCommand.SWITCH_CAM(id)]);
|
||||||
MapTileProjection tile = ClientMapManager.Get(id);
|
MapTileProjection tile = ClientMapManager.Get(id);
|
||||||
// add UIManager switch camera
|
// add UIManager switch camera
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 5.3 KiB |
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TextureAtlas count="19">
|
<TextureAtlas count="25">
|
||||||
<Texture>images/SpriteSheet_monitor</Texture>
|
<Texture>images/SpriteSheet_monitor</Texture>
|
||||||
<Regions>
|
<Regions>
|
||||||
<Region id = "0" name="screen" x="0" y="0" width="640" height="360"/>
|
<Region id = "0" name="screen" x="0" y="0" width="640" height="360"/>
|
||||||
|
|
@ -25,6 +25,14 @@
|
||||||
<Region id = "17" name="door-office-p2-left-open" x="472" y="564" width="32" height="33"/>
|
<Region id = "17" name="door-office-p2-left-open" x="472" y="564" width="32" height="33"/>
|
||||||
<Region id = "18" name="door-office-p2-left-closed" x="504" y="564" width="32" height="33"/>
|
<Region id = "18" name="door-office-p2-left-closed" x="504" y="564" width="32" height="33"/>
|
||||||
|
|
||||||
|
<Region id = "19" name="eye-opponent-open" x="572" y="360" width="32" height="14"/>
|
||||||
|
<Region id = "20" name="eye-opponent-open" x="604" y="360" width="32" height="14"/>
|
||||||
|
<Region id = "21" name="eye-player-open" x="572" y="374" width="32" height="14"/>
|
||||||
|
|
||||||
|
<Region id = "22" name="eye-small-opponent-open" x="572" y="402" width="32" height="9"/>
|
||||||
|
<Region id = "23" name="eye-small-opponent-closed" x="604" y="402" width="32" height="9"/>
|
||||||
|
<Region id = "24" name="eye-small-player" x="572" y="411" width="32" height="9"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Regions>
|
</Regions>
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,25 @@ public class EventProcessor {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // switch cam
|
case 2: // switch cam
|
||||||
if (Client.Player.state.pid != e.Args[0]) return;
|
if (Client.Player.state.pid != e.Args[0]){
|
||||||
|
UIManager.ChangeCameraOpponent(e.Args[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (Client.Player.state.camera != e.Args[1]) Console.WriteLine("!!! DESYNC: CAMERA STATE");
|
if (Client.Player.state.camera != e.Args[1]) Console.WriteLine("!!! DESYNC: CAMERA STATE");
|
||||||
Console.WriteLine($"E: player {e.Args[0]} switched to camera {e.Args[1]}");
|
Console.WriteLine($"E: player {e.Args[0]} switched to camera {e.Args[1]}");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // toggle cam
|
case 3: // toggle cam
|
||||||
if (e.Args[0] == Client.Player.state.pid && Client.Player.state.monitorUp != (e.Args[1] == 1)) Console.WriteLine("!!! DESYNC: MONITOR STATE");
|
Console.WriteLine($"E: Player {e.Args[0]} toggled monitor {(e.Args[1] == 0 ? "off" : "on")}");
|
||||||
|
|
||||||
|
if (e.Args[0] != Client.Player.state.pid){
|
||||||
|
UIManager.ChangeMonitorStateOpponent(e.Args[1] == 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Client.Player.state.monitorUp != (e.Args[1] == 1)) Console.WriteLine("!!! DESYNC: MONITOR STATE");
|
||||||
|
|
||||||
// UIManager.ChangeMonitorState(e.Args[1] == 1);
|
// UIManager.ChangeMonitorState(e.Args[1] == 1);
|
||||||
Console.WriteLine($"E: Player {e.Args[0]} toggled monitor {(e.Args[1] == 0 ? "off" : "on")}");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // toggle door
|
case 4: // toggle door
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,11 @@ public class UIElement {
|
||||||
public bool Pressable { get; set; } = false;
|
public bool Pressable { get; set; } = false;
|
||||||
public bool Visible { get; set; } = true;
|
public bool Visible { get; set; } = true;
|
||||||
|
|
||||||
public (Point, Point) Bounds{ get; private set; } // TODO: Change this to support non-rectangular hitboxes
|
public (Point, Point) Bounds{
|
||||||
|
get;
|
||||||
|
private set { field = value; UpdateBounds(); }
|
||||||
|
} // TODO: Change this to support non-rectangular hitboxes
|
||||||
|
|
||||||
private (Point, Point) screenSpaceBounds;
|
private (Point, Point) screenSpaceBounds;
|
||||||
private List<TextureRegion> textures = new();
|
private List<TextureRegion> textures = new();
|
||||||
private int currentTextureId = 0;
|
private int currentTextureId = 0;
|
||||||
|
|
@ -32,6 +36,10 @@ public class UIElement {
|
||||||
private int pixelScaleMultiplier = 1;
|
private int pixelScaleMultiplier = 1;
|
||||||
private void LoadPixelScaleMultiplier() {
|
private void LoadPixelScaleMultiplier() {
|
||||||
pixelScaleMultiplier = (int)(UIManager.GlobalPixelMultiplier * _scaleMultiplier); // TODO: move GlobalPixelMultiplier somewhere where it would make sense
|
pixelScaleMultiplier = (int)(UIManager.GlobalPixelMultiplier * _scaleMultiplier); // TODO: move GlobalPixelMultiplier somewhere where it would make sense
|
||||||
|
UpdateBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateBounds() {
|
||||||
screenSpaceBounds = (Bounds.Item1.MultiplyByScalar(pixelScaleMultiplier), Bounds.Item2.MultiplyByScalar(pixelScaleMultiplier));
|
screenSpaceBounds = (Bounds.Item1.MultiplyByScalar(pixelScaleMultiplier), Bounds.Item2.MultiplyByScalar(pixelScaleMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,4 +93,8 @@ public class UIElement {
|
||||||
textures[currentTextureId].Draw(spriteBatch, screenSpaceBounds.Item1.ToVector2(), Color.White, 0, Vector2.Zero, pixelScaleMultiplier, SpriteEffects.None, 0);
|
textures[currentTextureId].Draw(spriteBatch, screenSpaceBounds.Item1.ToVector2(), Color.White, 0, Vector2.Zero, pixelScaleMultiplier, SpriteEffects.None, 0);
|
||||||
// texture.Draw(spriteBatch, bounds.Item1.ToVector2(), Color.White);
|
// texture.Draw(spriteBatch, bounds.Item1.ToVector2(), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetPosition(Point position) {
|
||||||
|
Bounds = (position, position + new Point(textures[0].Width, textures[0].Height));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,6 +63,10 @@ public class UIManager {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
monitorScreen.AddElement("eye-player", new UIElement(monitorAtlas[24], monitorScreen["room"+Client.Player.state.camera].Bounds.Item1));
|
||||||
|
monitorScreen.AddElement("eye-opponent", new UIElement([monitorAtlas[23], monitorAtlas[22]], monitorScreen["room"+Client.Opponent.state.camera].Bounds.Item1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SpawnDoors(TileConnectorProjection[] doors) {
|
public static void SpawnDoors(TileConnectorProjection[] doors) {
|
||||||
|
|
@ -126,10 +130,25 @@ public class UIManager {
|
||||||
public static void ChangeRemoteDoorState((int, int) id, bool state) {
|
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);
|
monitorScreen["door"+Math.Max(id.Item1, id.Item2)+"-"+Math.Min(id.Item1, id.Item2)].SetTexture(state ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ChangeMonitorState(bool state) {
|
public static void ChangeMonitorState(bool state) {
|
||||||
Screen.SetScreen(state ? ScreenTypes.CAMERAS : ScreenTypes.OFFICE);
|
Screen.SetScreen(state ? ScreenTypes.CAMERAS : ScreenTypes.OFFICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ChangeMonitorStateOpponent(bool state) {
|
||||||
|
monitorScreen["eye-opponent"].SetTexture(state ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ChangeCamera(int id) {
|
||||||
|
monitorScreen["eye-player"].SetPosition(monitorScreen["room"+id].Bounds.Item1);
|
||||||
|
}
|
||||||
|
public static void ChangeCameraOpponent(int id) {
|
||||||
|
monitorScreen["eye-opponent"].SetPosition(monitorScreen["room"+id].Bounds.Item1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// private static Point GetRoomUIPos((int x, int y) pos) {
|
||||||
|
// return new Point(336 + (32 * pos.x), 144 + (32 * pos.y));
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,6 +6,8 @@ namespace FNAF_Server;
|
||||||
|
|
||||||
public class GameLogic {
|
public class GameLogic {
|
||||||
|
|
||||||
|
public const int START_CAMERA = 12;
|
||||||
|
|
||||||
public static void Init() {
|
public static void Init() {
|
||||||
// Create map
|
// Create map
|
||||||
MapManager.InitMap();
|
MapManager.InitMap();
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class Server {
|
||||||
private static NetPacketProcessor processor;
|
private static NetPacketProcessor processor;
|
||||||
|
|
||||||
private static bool isRunning;
|
private static bool isRunning;
|
||||||
|
|
||||||
public static void Start(int port) {
|
public static void Start(int port) {
|
||||||
writer = new NetDataWriter();
|
writer = new NetDataWriter();
|
||||||
processor = new NetPacketProcessor();
|
processor = new NetPacketProcessor();
|
||||||
|
|
@ -102,7 +102,7 @@ public class Server {
|
||||||
peer = peer,
|
peer = peer,
|
||||||
state = new PlayerState {
|
state = new PlayerState {
|
||||||
pid = peer.Id,
|
pid = peer.Id,
|
||||||
camera = 0,
|
camera = GameLogic.START_CAMERA,
|
||||||
doorStates = [false, false, false]
|
doorStates = [false, false, false]
|
||||||
},
|
},
|
||||||
username = packet.username
|
username = packet.username
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue