Merge pull request #38 from progtime-net/Interactable

Interactable
This commit is contained in:
Andrey 2024-08-17 10:34:22 +03:00 committed by GitHub
commit 79c5213c1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 98 additions and 60 deletions

View file

@ -53,9 +53,9 @@ namespace MonogameLibrary.UI.Elements
public override void LoadTexture(ContentManager content) public override void LoadTexture(ContentManager content)
{ {
texture1 = content.Load<Texture2D>("Textures\\GUI\\checkboxs_off"); texture1 = content.Load<Texture2D>("Textures/GUI/checkboxs_off");
texture2 = content.Load<Texture2D>("Textures\\GUI\\checkboxs_off-on"); texture2 = content.Load<Texture2D>("Textures/GUI/checkboxs_off-on");
texture3 = content.Load<Texture2D>("Textures\\GUI\\checkboxs_on"); texture3 = content.Load<Texture2D>("Textures/GUI/checkboxs_on");
base.LoadTexture(content); base.LoadTexture(content);
} }
public override void Draw(SpriteBatch _spriteBatch) public override void Draw(SpriteBatch _spriteBatch)

View file

@ -59,7 +59,7 @@ namespace MonogameLibrary.UI.Elements
public override void LoadTexture(ContentManager content) public override void LoadTexture(ContentManager content)
{ {
texture2 = content.Load<Texture2D>("Textures\\GUI\\switch"); texture2 = content.Load<Texture2D>("Textures/GUI/switch");
base.LoadTexture(content); base.LoadTexture(content);
} }

View file

@ -39,7 +39,7 @@ public abstract class AbstractGUI
public virtual void LoadContent() public virtual void LoadContent()
{ {
Manager.LoadContent(AppManager.Instance.Content, "Font"); Manager.LoadContent(AppManager.Instance.Content, "Font");
mouse = AppManager.Instance.Content.Load<Texture2D>("Textures\\GUI\\mouse"); mouse = AppManager.Instance.Content.Load<Texture2D>("Textures/GUI/mouse");
} }
public virtual void Update(GameTime gameTime) public virtual void Update(GameTime gameTime)

View file

@ -20,7 +20,7 @@ public class DebugHUD
public void LoadContent() public void LoadContent()
{ {
_spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Fonts\\Font2"); _spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Fonts/Font2");
} }
public void Update(GameTime gameTime) public void Update(GameTime gameTime)

View file

@ -22,11 +22,11 @@ public class MainMenuGUI : AbstractGUI
int width = AppManager.Instance.CurentScreenResolution.X; int width = AppManager.Instance.CurentScreenResolution.X;
int height = AppManager.Instance.CurentScreenResolution.Y; int height = AppManager.Instance.CurentScreenResolution.Y;
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures\\GUI\\background\\mainMenu" }; menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/mainMenu" };
Elements.Add(menuBackground); Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content); menuBackground.LoadTexture(AppManager.Instance.Content);
Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 5, (int)(width / 4), (int)(height / 20)), text = "ZoFo", fontColor = Color.Black, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font"}); Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 5, (int)(width / 4), (int)(height / 20)), text = "ZoFo", fontColor = Color.Black, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts/Font"});
Button playButton = new Button(Manager) Button playButton = new Button(Manager)
@ -36,7 +36,7 @@ public class MainMenuGUI : AbstractGUI
scale = 0.2f, scale = 0.2f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
playButton.LeftButtonPressed += () => playButton.LeftButtonPressed += () =>
{ {
@ -50,7 +50,7 @@ public class MainMenuGUI : AbstractGUI
scale = 0.2f, scale = 0.2f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
optionButton.LeftButtonPressed += () => optionButton.LeftButtonPressed += () =>
{ {
@ -64,7 +64,7 @@ public class MainMenuGUI : AbstractGUI
scale = 0.2f, scale = 0.2f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
exitButton.LeftButtonPressed += () => exitButton.LeftButtonPressed += () =>
{ {

View file

@ -21,24 +21,24 @@ public class OptionsGUI : AbstractGUI
int width = AppManager.Instance.CurentScreenResolution.X; int width = AppManager.Instance.CurentScreenResolution.X;
int height = AppManager.Instance.CurentScreenResolution.Y; int height = AppManager.Instance.CurentScreenResolution.Y;
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures\\GUI\\background\\options" }; menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/options" };
Elements.Add(menuBackground); Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content); menuBackground.LoadTexture(AppManager.Instance.Content);
Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 5, (int)(width / 4), (int)(height / 20)), text = "Options", fontColor = Color.Black, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font"}); Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 5, (int)(width / 4), (int)(height / 20)), text = "Options", fontColor = Color.Black, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts/Font"});
Label label_OverallVolume = new Label(Manager) Label label_OverallVolume = new Label(Manager)
{ fontName = "Fonts\\Font", scale = 0.2f, text = "All Volume", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font", scale = 0.2f, text = "All Volume", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(label_OverallVolume); Elements.Add(label_OverallVolume);
Label label_OverallVolume_Percent = new Label(Manager) Label label_OverallVolume_Percent = new Label(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "", fontColor = Color.Black, rectangle = new Rectangle(width / 2 + width / 10, height / 3, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font3", scale = 0.4f, text = "", fontColor = Color.Black, rectangle = new Rectangle(width / 2 + width / 10, height / 3, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(label_OverallVolume_Percent); Elements.Add(label_OverallVolume_Percent);
var slider_OverallVolume = new Slider(Manager) var slider_OverallVolume = new Slider(Manager)
{ rectangle = new Rectangle(width / 2, height / 3, width / 10, height / 20), indentation = 7, textureName = "Textures\\GUI\\Switch_backgrownd", MinValue = 0, MaxValue = 1 }; { rectangle = new Rectangle(width / 2, height / 3, width / 10, height / 20), indentation = 7, textureName = "Textures/GUI/Switch_backgrownd", MinValue = 0, MaxValue = 1 };
slider_OverallVolume.SetValue(AppManager.Instance.SettingsManager.MainVolume); slider_OverallVolume.SetValue(AppManager.Instance.SettingsManager.MainVolume);
slider_OverallVolume.SliderChanged += (newVal) => slider_OverallVolume.SliderChanged += (newVal) =>
{ {
@ -50,15 +50,15 @@ public class OptionsGUI : AbstractGUI
//-------------------------------------- //--------------------------------------
Label label_MusicVolume = new Label(Manager) Label label_MusicVolume = new Label(Manager)
{ fontName = "Fonts\\Font", scale = 0.2f, text = "Music Volume", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 1, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font", scale = 0.2f, text = "Music Volume", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 1, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(label_MusicVolume); Elements.Add(label_MusicVolume);
Label label_MusicVolume_Percent = new Label(Manager) Label label_MusicVolume_Percent = new Label(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "", fontColor = Color.Black, rectangle = new Rectangle(width / 2 + width / 10, height / 3 + (height / 20 + height / 40) * 1, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font3", scale = 0.4f, text = "", fontColor = Color.Black, rectangle = new Rectangle(width / 2 + width / 10, height / 3 + (height / 20 + height / 40) * 1, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(label_MusicVolume_Percent); Elements.Add(label_MusicVolume_Percent);
var slider_MusicVolume = new Slider(Manager) var slider_MusicVolume = new Slider(Manager)
{ rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 1, width / 10, height / 20), indentation = 7, textureName = "Textures\\GUI\\Switch_backgrownd", MinValue = 0, MaxValue = 1 }; { rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 1, width / 10, height / 20), indentation = 7, textureName = "Textures/GUI/Switch_backgrownd", MinValue = 0, MaxValue = 1 };
slider_MusicVolume.SetValue(AppManager.Instance.SettingsManager.MusicVolume); slider_MusicVolume.SetValue(AppManager.Instance.SettingsManager.MusicVolume);
slider_MusicVolume.SliderChanged += (newVal) => slider_MusicVolume.SliderChanged += (newVal) =>
{ {
@ -70,15 +70,15 @@ public class OptionsGUI : AbstractGUI
//-------------------------------------- //--------------------------------------
Label label_EffectsVolume = new Label(Manager) Label label_EffectsVolume = new Label(Manager)
{ fontName = "Fonts\\Font", scale = 0.2f, text = "Effects Volume", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 2, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font", scale = 0.2f, text = "Effects Volume", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 2, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(label_EffectsVolume); Elements.Add(label_EffectsVolume);
Label label_EffectsVolume_Percent = new Label(Manager) Label label_EffectsVolume_Percent = new Label(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "", fontColor = Color.Black, rectangle = new Rectangle(width / 2 + width / 10, height / 3 + (height / 20 + height / 40) * 2, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font3", scale = 0.4f, text = "", fontColor = Color.Black, rectangle = new Rectangle(width / 2 + width / 10, height / 3 + (height / 20 + height / 40) * 2, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(label_EffectsVolume_Percent); Elements.Add(label_EffectsVolume_Percent);
var slider_EffectsVolume = new Slider(Manager) var slider_EffectsVolume = new Slider(Manager)
{ rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 2, width / 10, height / 20), indentation = 7, textureName = "Textures\\GUI\\Switch_backgrownd", MinValue = 0, MaxValue = 1 }; { rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 2, width / 10, height / 20), indentation = 7, textureName = "Textures/GUI/Switch_backgrownd", MinValue = 0, MaxValue = 1 };
slider_EffectsVolume.SetValue(AppManager.Instance.SettingsManager.SoundEffectsVolume); slider_EffectsVolume.SetValue(AppManager.Instance.SettingsManager.SoundEffectsVolume);
slider_EffectsVolume.SliderChanged += (newVal) => slider_EffectsVolume.SliderChanged += (newVal) =>
{ {
@ -90,7 +90,7 @@ public class OptionsGUI : AbstractGUI
//-------------------------------------- //--------------------------------------
Label lblSwitchMode = new Label(Manager) Label lblSwitchMode = new Label(Manager)
{ fontName = "Fonts\\Font", scale = 0.2f, text = "Resolution set", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 3, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font", scale = 0.2f, text = "Resolution set", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 3, width / 40, height / 20), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(lblSwitchMode); Elements.Add(lblSwitchMode);
//var button_left_right_mode = new CheckBox(Manager) { rectangle = new Rectangle(rightBorder - checkboxlength, lblSwitchMode.rectangle.Y - 12, checkboxlength, checkboxlength) }; //var button_left_right_mode = new CheckBox(Manager) { rectangle = new Rectangle(rightBorder - checkboxlength, lblSwitchMode.rectangle.Y - 12, checkboxlength, checkboxlength) };
@ -99,7 +99,7 @@ public class OptionsGUI : AbstractGUI
Label label_IsFullScreen = new Label(Manager) Label label_IsFullScreen = new Label(Manager)
{ fontName = "Fonts\\Font", scale = 0.2f, text = "Full Screen", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 4, width / 40, width / 40), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left }; { fontName = "Fonts/Font", scale = 0.2f, text = "Full Screen", fontColor = Color.Black, rectangle = new Rectangle(width / 3, height / 3 + (height / 20 + height / 40) * 4, width / 40, width / 40), mainColor = Color.Transparent, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left };
Elements.Add(label_IsFullScreen); Elements.Add(label_IsFullScreen);
var button_FullScreen = new CheckBox(Manager) { rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 4, width / 40, width / 40) }; var button_FullScreen = new CheckBox(Manager) { rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 4, width / 40, width / 40) };
@ -113,7 +113,7 @@ public class OptionsGUI : AbstractGUI
//-------------------------------------- //--------------------------------------
Button bTExit = new Button(Manager) Button bTExit = new Button(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"}; { fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off"};
Elements.Add(bTExit); Elements.Add(bTExit);
bTExit.LeftButtonPressed += () => bTExit.LeftButtonPressed += () =>
{ {

View file

@ -21,11 +21,11 @@ public class SelectModeMenu : AbstractGUI
int width = AppManager.Instance.CurentScreenResolution.X; int width = AppManager.Instance.CurentScreenResolution.X;
int height = AppManager.Instance.CurentScreenResolution.Y; int height = AppManager.Instance.CurentScreenResolution.Y;
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures\\GUI\\background\\selectMode" }; menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/selectMode" };
Elements.Add(menuBackground); Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content); menuBackground.LoadTexture(AppManager.Instance.Content);
Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 6, (int)(width / 4), (int)(height / 20)), text = "Select mode", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font"}); Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 6, (int)(width / 4), (int)(height / 20)), text = "Select mode", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts/Font"});
Button singleButton = new Button(Manager) Button singleButton = new Button(Manager)
{ {
@ -34,7 +34,7 @@ public class SelectModeMenu : AbstractGUI
scale = 0.3f, scale = 0.3f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
singleButton.LeftButtonPressed += () => singleButton.LeftButtonPressed += () =>
{ {
@ -65,7 +65,7 @@ public class SelectModeMenu : AbstractGUI
scale = 0.3f, scale = 0.3f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
optionButton.LeftButtonPressed += () => optionButton.LeftButtonPressed += () =>
{ {
@ -84,7 +84,7 @@ public class SelectModeMenu : AbstractGUI
Elements.Add(optionButton); Elements.Add(optionButton);
Button bTExit = new Button(Manager) Button bTExit = new Button(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"}; { fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off"};
Elements.Add(bTExit); Elements.Add(bTExit);
bTExit.LeftButtonPressed += () => bTExit.LeftButtonPressed += () =>
{ {

View file

@ -21,11 +21,11 @@ public class SelectingServerGUI : AbstractGUI
int width = AppManager.Instance.CurentScreenResolution.X; int width = AppManager.Instance.CurentScreenResolution.X;
int height = AppManager.Instance.CurentScreenResolution.Y; int height = AppManager.Instance.CurentScreenResolution.Y;
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures\\GUI\\background\\join" }; menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/join" };
Elements.Add(menuBackground); Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content); menuBackground.LoadTexture(AppManager.Instance.Content);
Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = "Select server", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font"}); Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = "Select server", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts/Font"});
TextBox ipBox = new TextBox(Manager) TextBox ipBox = new TextBox(Manager)
{ {
@ -35,7 +35,7 @@ public class SelectingServerGUI : AbstractGUI
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
textAligment = MonogameLibrary.UI.Enums.TextAligment.Left, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
ipBox.TextChanged += input => { ipBox.TextChanged += input => {
if (input == "ip") if (input == "ip")
@ -58,7 +58,7 @@ public class SelectingServerGUI : AbstractGUI
scale = 0.3f, scale = 0.3f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
joinButton.LeftButtonPressed += () => joinButton.LeftButtonPressed += () =>
{ {
@ -75,7 +75,7 @@ public class SelectingServerGUI : AbstractGUI
scale = 0.3f, scale = 0.3f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
hostButton.LeftButtonPressed += () => hostButton.LeftButtonPressed += () =>
{ {
@ -87,7 +87,7 @@ public class SelectingServerGUI : AbstractGUI
Elements.Add(hostButton); Elements.Add(hostButton);
Button bTExit = new Button(Manager) Button bTExit = new Button(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"}; { fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off"};
Elements.Add(bTExit); Elements.Add(bTExit);
bTExit.LeftButtonPressed += () => bTExit.LeftButtonPressed += () =>
{ {

View file

@ -27,11 +27,11 @@ public class WaitingForPlayersGUI : AbstractGUI
int width = AppManager.Instance.CurentScreenResolution.X; int width = AppManager.Instance.CurentScreenResolution.X;
int height = AppManager.Instance.CurentScreenResolution.Y; int height = AppManager.Instance.CurentScreenResolution.Y;
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures\\GUI\\background\\Waiting" }; menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/Waiting" };
Elements.Add(menuBackground); Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content); menuBackground.LoadTexture(AppManager.Instance.Content);
Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = "Waiting", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font"}); Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = "Waiting", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts/Font"});
if (isHost) if (isHost)
{ {
@ -42,7 +42,7 @@ public class WaitingForPlayersGUI : AbstractGUI
scale = 0.3f, scale = 0.3f,
fontColor = Color.White, fontColor = Color.White,
mainColor = Color.Gray, mainColor = Color.Gray,
fontName = "Fonts\\Font" fontName = "Fonts/Font"
}; };
startButton.LeftButtonPressed += () => startButton.LeftButtonPressed += () =>
{ {
@ -54,7 +54,7 @@ public class WaitingForPlayersGUI : AbstractGUI
} }
Button bTExit = new Button(Manager) Button bTExit = new Button(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"}; { fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off"};
Elements.Add(bTExit); Elements.Add(bTExit);
bTExit.LeftButtonPressed += () => bTExit.LeftButtonPressed += () =>
{ {

View file

@ -1,8 +1,24 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using ZoFo.GameCore.ZoFo_graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables; namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
public class Door public class Door : Interactable
{ {
public bool isOpened; public bool isOpened;
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "DoorInteraction" }, "DoorInteraction");
public Door(Vector2 position) : base(position)
{
graphicsComponent.actionOfAnimationEnd += _ => { isOpened = !isOpened; };
}
public override void OnInteraction()
{
graphicsComponent.StartAnimation("DoorInteraction", isOpened);
}
} }

View file

@ -22,7 +22,7 @@ public class Interactable : Entity
AppManager.Instance.server.AddData(new UpdateInteractionReady((sender as Player).Id, isReady)); AppManager.Instance.server.AddData(new UpdateInteractionReady((sender as Player).Id, isReady));
} }
public void OnInteraction() public virtual void OnInteraction()
{ {
} }

View file

@ -86,10 +86,10 @@ public abstract class GameObject
if (color is null) color = new Color(1, 0, 0, 0.25f); if (color is null) color = new Color(1, 0, 0, 0.25f);
if (color.Value.A == 255) color = new Color(color.Value, 0.25f); if (color.Value.A == 255) color = new Color(color.Value, 0.25f);
//spriteBatch.Draw(debugTexture, //spriteBatch.Draw(debugTexture,
// new Rectangle((_rectangle.X - GraphicsComponent.CameraPosition.X) * GraphicsComponent.scaling, // new Rectangle((_rectangle.X - graphicsComponent.CameraPosition.X) * graphicsComponent.scaling,
// (_rectangle.Y - GraphicsComponent.CameraPosition.Y) * GraphicsComponent.scaling, // (_rectangle.Y - graphicsComponent.CameraPosition.Y) * graphicsComponent.scaling,
// _rectangle.Width * GraphicsComponent.scaling, // _rectangle.Width * graphicsComponent.scaling,
// _rectangle.Height * GraphicsComponent.scaling), color.Value); // _rectangle.Height * graphicsComponent.scaling), color.Value);
//TODO: debugTexture //TODO: debugTexture
} }

View file

@ -26,6 +26,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
private AnimationContainer currentAnimation; private AnimationContainer currentAnimation;
static public int scaling = 1; static public int scaling = 1;
public int parentId; public int parentId;
public bool reverse;
public AnimationContainer CurrentAnimation public AnimationContainer CurrentAnimation
{ {
get get
@ -126,7 +127,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
} }
} }
public void StartAnimation(string startedanimationId) public void StartAnimation(string startedanimationId, bool reverse = false)
{ {
/* /*
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
@ -138,8 +139,13 @@ namespace ZoFo.GameCore.ZoFo_graphics
} }
} }
*/ */
currentFrame = 0; this.reverse = reverse;
currentAnimation = animations.Find(x => x.Id == startedanimationId); currentAnimation = animations.Find(x => x.Id == startedanimationId);
if (reverse)
currentFrame = currentAnimation.FramesCount;
else
currentFrame = 0;
buildSourceRectangle(); buildSourceRectangle();
SetInterval(); SetInterval();
@ -154,6 +160,21 @@ namespace ZoFo.GameCore.ZoFo_graphics
SetInterval(); SetInterval();
} }
private void AnimationEnd()
{
if (!currentAnimation.IsCycle)
{
if (actionOfAnimationEnd != null)
{
actionOfAnimationEnd(currentAnimation.Id);
}
currentAnimation = neitralAnimation;
}
currentFrame = 0;
}
public void Update() public void Update()
{ {
if (currentAnimation is null) if (currentAnimation is null)
@ -162,21 +183,22 @@ namespace ZoFo.GameCore.ZoFo_graphics
} }
if (interval == 0) if (interval == 0)
{ {
currentFrame++; if (reverse)
if (currentAnimation.FramesCount <= currentFrame)
{ {
if (!currentAnimation.IsCycle) currentFrame--;
if (currentFrame <= 0)
{ {
if (actionOfAnimationEnd != null) AnimationEnd();
{ reverse = false;
actionOfAnimationEnd(currentAnimation.Id); }
} }
currentAnimation = neitralAnimation; else
{
currentFrame++;
if (currentAnimation.FramesCount <= currentFrame)
{
AnimationEnd();
} }
currentFrame = 0;
} }
buildSourceRectangle(); buildSourceRectangle();