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
|
|
@ -14,7 +14,11 @@ public class UIElement {
|
|||
public bool Pressable { get; set; } = false;
|
||||
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 List<TextureRegion> textures = new();
|
||||
private int currentTextureId = 0;
|
||||
|
|
@ -32,6 +36,10 @@ public class UIElement {
|
|||
private int pixelScaleMultiplier = 1;
|
||||
private void LoadPixelScaleMultiplier() {
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
@ -85,4 +93,8 @@ public class UIElement {
|
|||
textures[currentTextureId].Draw(spriteBatch, screenSpaceBounds.Item1.ToVector2(), Color.White, 0, Vector2.Zero, pixelScaleMultiplier, SpriteEffects.None, 0);
|
||||
// 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) {
|
||||
|
|
@ -126,10 +130,25 @@ public class UIManager {
|
|||
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);
|
||||
}
|
||||
|
||||
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));
|
||||
// }
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue