Přidány sprity pro kancelář a monitor. Graficky viditelné zavírání a otevírání dveří, zapínání a vypínání monitoru. Podpora pouze pro specifická rozlišení.
This commit is contained in:
parent
952aae10de
commit
2cd215cc33
13 changed files with 202 additions and 41 deletions
|
|
@ -1,21 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoGameLibrary;
|
||||
using MonoGameLibrary.Graphics;
|
||||
using MonoGameLibrary.Input;
|
||||
|
||||
namespace FNAF_Clone.GUI;
|
||||
|
||||
public class UIElement {
|
||||
|
||||
public bool Active { get; set; } = false;
|
||||
public bool Pressable { get; set; } = false;
|
||||
|
||||
private (Point, Point) bounds; // TODO: Change this to support non-rectangular hitboxes
|
||||
private TextureRegion texture;
|
||||
private List<TextureRegion> textures = new();
|
||||
private int currentTextureId = 0;
|
||||
|
||||
private float _scaleMultiplier = 1;
|
||||
public float ScaleMultiplier{
|
||||
get{
|
||||
return _scaleMultiplier;
|
||||
}
|
||||
set{
|
||||
_scaleMultiplier = value;
|
||||
LoadPixelScaleMultiplier();
|
||||
}
|
||||
}
|
||||
private float pixelScaleMultiplier = 1;
|
||||
private void LoadPixelScaleMultiplier() {
|
||||
pixelScaleMultiplier = UIManager.GlobalPixelMultiplier * _scaleMultiplier;
|
||||
}
|
||||
|
||||
public UIElement(TextureRegion texture, Point position) {
|
||||
this.texture = texture;
|
||||
textures.Add(texture);
|
||||
bounds = (position, position + new Point(texture.Width, texture.Height));
|
||||
LoadPixelScaleMultiplier();
|
||||
}
|
||||
public UIElement(TextureRegion[] textures, Point position) {
|
||||
this.textures.AddRange(textures);
|
||||
bounds = (position, position + new Point(textures[0].Width, textures[0].Height));
|
||||
LoadPixelScaleMultiplier();
|
||||
}
|
||||
|
||||
|
||||
public void SetTexture(int textureId) {
|
||||
if (textureId >= textures.Count){
|
||||
Console.WriteLine($"WARNING: TEXTURE {textureId} OUT OF BOUNDS");
|
||||
return;
|
||||
}
|
||||
|
||||
currentTextureId = textureId;
|
||||
}
|
||||
public void Update() {
|
||||
|
||||
|
|
@ -35,6 +70,7 @@ public class UIElement {
|
|||
public virtual void OnMouseHold() { }
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch) {
|
||||
texture.Draw(spriteBatch, bounds.Item1.ToVector2(), Color.White);
|
||||
textures[currentTextureId].Draw(spriteBatch, bounds.Item1.ToVector2(), Color.White, 0, Vector2.Zero, pixelScaleMultiplier, SpriteEffects.None, 0);
|
||||
// texture.Draw(spriteBatch, bounds.Item1.ToVector2(), Color.White);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue