From c5ac15987c70255d5382197e2b866cf324f52ac3 Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Sat, 17 Aug 2024 10:04:53 +0300 Subject: [PATCH 1/2] Add Door, reverse play of animation --- ZoFo/GameCore/GameObjects/Entities/Entity.cs | 2 +- .../Entities/Interactables/Door.cs | 18 ++++++- .../Entities/Interactables/Interactable.cs | 2 +- ZoFo/GameCore/GameObjects/GameObject.cs | 10 ++-- .../GameObjects/MapObjects/MapObject.cs | 2 +- .../ZoFo_grafics/GraphicsComponent.cs | 50 +++++++++++++------ 6 files changed, 61 insertions(+), 23 deletions(-) diff --git a/ZoFo/GameCore/GameObjects/Entities/Entity.cs b/ZoFo/GameCore/GameObjects/Entities/Entity.cs index a9e8670..26eb6c0 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Entity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Entity.cs @@ -10,7 +10,7 @@ namespace ZoFo.GameCore.GameObjects.Entities { public abstract class Entity : GameObject { - public override GraphicsComponent graphicsComponent => null; + protected override GraphicsComponent graphicsComponent => null; public CollisionComponent collisionComponent { get; protected set; } public int Id { get; set; } protected Entity(Vector2 position) : base(position) diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs index 06bdec5..58d61ca 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs @@ -1,8 +1,24 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using ZoFo.GameCore.ZoFo_graphics; + namespace ZoFo.GameCore.GameObjects.Entities.Interactables; -public class Door +public class Door : Interactable { public bool isOpened; + + protected override GraphicsComponent graphicsComponent { get; } = new(new List { "DoorInteraction" }, "DoorInteraction"); + + public Door(Vector2 position) : base(position) + { + graphicsComponent.actionOfAnimationEnd += _ => { isOpened = !isOpened; }; + } + + public override void OnInteraction() + { + graphicsComponent.StartAnimation("DoorInteraction", isOpened); + } } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs index 6299155..9bf0fa5 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs @@ -19,7 +19,7 @@ public class Interactable : Entity AppManager.Instance.server.AddData(new UpdateInteractionReady((sender as Player).Id, isReady)); } - public void OnInteraction() + public virtual void OnInteraction() { } diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index 14c306f..6037843 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -13,7 +13,7 @@ public abstract class GameObject public Vector2 position; public Vector2 rotation; //вектор направления объекта - public abstract GraphicsComponent graphicsComponent { get; } + protected abstract GraphicsComponent graphicsComponent { get; } #region ServerSide public GameObject(Vector2 position) @@ -84,10 +84,10 @@ public abstract class GameObject if (color is null) color = new Color(1, 0, 0, 0.25f); if (color.Value.A == 255) color = new Color(color.Value, 0.25f); //spriteBatch.Draw(debugTexture, - // new Rectangle((_rectangle.X - GraphicsComponent.CameraPosition.X) * GraphicsComponent.scaling, - // (_rectangle.Y - GraphicsComponent.CameraPosition.Y) * GraphicsComponent.scaling, - // _rectangle.Width * GraphicsComponent.scaling, - // _rectangle.Height * GraphicsComponent.scaling), color.Value); + // new Rectangle((_rectangle.X - graphicsComponent.CameraPosition.X) * graphicsComponent.scaling, + // (_rectangle.Y - graphicsComponent.CameraPosition.Y) * graphicsComponent.scaling, + // _rectangle.Width * graphicsComponent.scaling, + // _rectangle.Height * graphicsComponent.scaling), color.Value); //TODO: debugTexture } diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs index 5a5748c..b551483 100644 --- a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs +++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs @@ -15,7 +15,7 @@ namespace ZoFo.GameCore.GameObjects.MapObjects { public virtual bool IsColliderOn { get; protected set; } = true;//Who added that? public Rectangle sourceRectangle; - public override GraphicsComponent graphicsComponent { get; } = new(); + protected override GraphicsComponent graphicsComponent { get; } = new(); /// /// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры diff --git a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs index f10b40a..34037ec 100644 --- a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs +++ b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs @@ -26,6 +26,7 @@ namespace ZoFo.GameCore.ZoFo_graphics private AnimationContainer currentAnimation; static public int scaling = 5; public int parentId; + public bool reverse; public AnimationContainer CurrentAnimation { 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) @@ -138,8 +139,13 @@ namespace ZoFo.GameCore.ZoFo_graphics } } */ - currentFrame = 0; + this.reverse = reverse; + currentAnimation = animations.Find(x => x.Id == startedanimationId); + if (reverse) + currentFrame = currentAnimation.FramesCount; + else + currentFrame = 0; buildSourceRectangle(); SetInterval(); @@ -154,6 +160,21 @@ namespace ZoFo.GameCore.ZoFo_graphics SetInterval(); } + private void AnimationEnd() + { + if (!currentAnimation.IsCycle) + { + if (actionOfAnimationEnd != null) + { + actionOfAnimationEnd(currentAnimation.Id); + } + currentAnimation = neitralAnimation; + + } + + currentFrame = 0; + } + public void Update() { if (currentAnimation is null) @@ -162,21 +183,22 @@ namespace ZoFo.GameCore.ZoFo_graphics } if (interval == 0) { - currentFrame++; - if (currentAnimation.FramesCount <= currentFrame) + if (reverse) { - if (!currentAnimation.IsCycle) + currentFrame--; + if (currentFrame <= 0) { - if (actionOfAnimationEnd != null) - { - actionOfAnimationEnd(currentAnimation.Id); - } - currentAnimation = neitralAnimation; - + AnimationEnd(); + reverse = false; + } + } + else + { + currentFrame++; + if (currentAnimation.FramesCount <= currentFrame) + { + AnimationEnd(); } - - currentFrame = 0; - } buildSourceRectangle(); From 0abca86e035fdbd8f72627d892a470ac8eaf17aa Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Sat, 17 Aug 2024 10:32:48 +0300 Subject: [PATCH 2/2] Fix paths --- MonogameLibrary/UI/Elements/CheckBox.cs | 6 ++-- MonogameLibrary/UI/Elements/Slider.cs | 2 +- ZoFo/GameCore/GUI/AbstractGUI.cs | 2 +- ZoFo/GameCore/GUI/DebugHUD.cs | 2 +- ZoFo/GameCore/GUI/MainMenuGUI.cs | 10 +++---- ZoFo/GameCore/GUI/OptionsGUI.cs | 28 +++++++++---------- ZoFo/GameCore/GUI/SelectModeMenu.cs | 10 +++---- ZoFo/GameCore/GUI/SelectingServerGUI.cs | 12 ++++---- ZoFo/GameCore/GUI/WaitingForPlayersGUI.cs | 8 +++--- .../GameManagers/MapManager/MapManager.cs | 2 +- ZoFo/GameCore/GameObjects/Entities/Entity.cs | 2 +- .../Entities/Interactables/Door.cs | 2 +- ZoFo/GameCore/GameObjects/GameObject.cs | 2 +- .../GameObjects/MapObjects/MapObject.cs | 2 +- 14 files changed, 45 insertions(+), 45 deletions(-) diff --git a/MonogameLibrary/UI/Elements/CheckBox.cs b/MonogameLibrary/UI/Elements/CheckBox.cs index b8eec17..47ac44e 100644 --- a/MonogameLibrary/UI/Elements/CheckBox.cs +++ b/MonogameLibrary/UI/Elements/CheckBox.cs @@ -53,9 +53,9 @@ namespace MonogameLibrary.UI.Elements public override void LoadTexture(ContentManager content) { - texture1 = content.Load("Textures\\GUI\\checkboxs_off"); - texture2 = content.Load("Textures\\GUI\\checkboxs_off-on"); - texture3 = content.Load("Textures\\GUI\\checkboxs_on"); + texture1 = content.Load("Textures/GUI/checkboxs_off"); + texture2 = content.Load("Textures/GUI/checkboxs_off-on"); + texture3 = content.Load("Textures/GUI/checkboxs_on"); base.LoadTexture(content); } public override void Draw(SpriteBatch _spriteBatch) diff --git a/MonogameLibrary/UI/Elements/Slider.cs b/MonogameLibrary/UI/Elements/Slider.cs index 0e3b784..0525666 100644 --- a/MonogameLibrary/UI/Elements/Slider.cs +++ b/MonogameLibrary/UI/Elements/Slider.cs @@ -59,7 +59,7 @@ namespace MonogameLibrary.UI.Elements public override void LoadTexture(ContentManager content) { - texture2 = content.Load("Textures\\GUI\\switch"); + texture2 = content.Load("Textures/GUI/switch"); base.LoadTexture(content); } diff --git a/ZoFo/GameCore/GUI/AbstractGUI.cs b/ZoFo/GameCore/GUI/AbstractGUI.cs index bdc4d60..0134477 100644 --- a/ZoFo/GameCore/GUI/AbstractGUI.cs +++ b/ZoFo/GameCore/GUI/AbstractGUI.cs @@ -39,7 +39,7 @@ public abstract class AbstractGUI public virtual void LoadContent() { Manager.LoadContent(AppManager.Instance.Content, "Font"); - mouse = AppManager.Instance.Content.Load("Textures\\GUI\\mouse"); + mouse = AppManager.Instance.Content.Load("Textures/GUI/mouse"); } public virtual void Update(GameTime gameTime) diff --git a/ZoFo/GameCore/GUI/DebugHUD.cs b/ZoFo/GameCore/GUI/DebugHUD.cs index de4a587..fdc5371 100644 --- a/ZoFo/GameCore/GUI/DebugHUD.cs +++ b/ZoFo/GameCore/GUI/DebugHUD.cs @@ -20,7 +20,7 @@ public class DebugHUD public void LoadContent() { - _spriteFont = AppManager.Instance.Content.Load("Fonts\\Font2"); + _spriteFont = AppManager.Instance.Content.Load("Fonts/Font2"); } public void Update(GameTime gameTime) diff --git a/ZoFo/GameCore/GUI/MainMenuGUI.cs b/ZoFo/GameCore/GUI/MainMenuGUI.cs index 8ebfd74..e0d0c15 100644 --- a/ZoFo/GameCore/GUI/MainMenuGUI.cs +++ b/ZoFo/GameCore/GUI/MainMenuGUI.cs @@ -22,11 +22,11 @@ public class MainMenuGUI : AbstractGUI int width = AppManager.Instance.CurentScreenResolution.X; 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); 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) @@ -36,7 +36,7 @@ public class MainMenuGUI : AbstractGUI scale = 0.2f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; playButton.LeftButtonPressed += () => { @@ -50,7 +50,7 @@ public class MainMenuGUI : AbstractGUI scale = 0.2f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; optionButton.LeftButtonPressed += () => { @@ -64,7 +64,7 @@ public class MainMenuGUI : AbstractGUI scale = 0.2f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; exitButton.LeftButtonPressed += () => { diff --git a/ZoFo/GameCore/GUI/OptionsGUI.cs b/ZoFo/GameCore/GUI/OptionsGUI.cs index d2fbf92..464da7d 100644 --- a/ZoFo/GameCore/GUI/OptionsGUI.cs +++ b/ZoFo/GameCore/GUI/OptionsGUI.cs @@ -21,24 +21,24 @@ public class OptionsGUI : AbstractGUI int width = AppManager.Instance.CurentScreenResolution.X; 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); 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) - { 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); 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); 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.SliderChanged += (newVal) => { @@ -50,15 +50,15 @@ public class OptionsGUI : AbstractGUI //-------------------------------------- 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); 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); 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.SliderChanged += (newVal) => { @@ -70,15 +70,15 @@ public class OptionsGUI : AbstractGUI //-------------------------------------- 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); 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); 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.SliderChanged += (newVal) => { @@ -90,7 +90,7 @@ public class OptionsGUI : AbstractGUI //-------------------------------------- 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); //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) - { 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); 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) - { 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); bTExit.LeftButtonPressed += () => { diff --git a/ZoFo/GameCore/GUI/SelectModeMenu.cs b/ZoFo/GameCore/GUI/SelectModeMenu.cs index af3dad0..ad4db7f 100644 --- a/ZoFo/GameCore/GUI/SelectModeMenu.cs +++ b/ZoFo/GameCore/GUI/SelectModeMenu.cs @@ -21,11 +21,11 @@ public class SelectModeMenu : AbstractGUI int width = AppManager.Instance.CurentScreenResolution.X; 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); 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) { @@ -34,7 +34,7 @@ public class SelectModeMenu : AbstractGUI scale = 0.3f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; singleButton.LeftButtonPressed += () => { @@ -65,7 +65,7 @@ public class SelectModeMenu : AbstractGUI scale = 0.3f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; optionButton.LeftButtonPressed += () => { @@ -84,7 +84,7 @@ public class SelectModeMenu : AbstractGUI Elements.Add(optionButton); 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); bTExit.LeftButtonPressed += () => { diff --git a/ZoFo/GameCore/GUI/SelectingServerGUI.cs b/ZoFo/GameCore/GUI/SelectingServerGUI.cs index a108a29..5553946 100644 --- a/ZoFo/GameCore/GUI/SelectingServerGUI.cs +++ b/ZoFo/GameCore/GUI/SelectingServerGUI.cs @@ -21,11 +21,11 @@ public class SelectingServerGUI : AbstractGUI int width = AppManager.Instance.CurentScreenResolution.X; 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); 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) { @@ -35,7 +35,7 @@ public class SelectingServerGUI : AbstractGUI fontColor = Color.White, mainColor = Color.Gray, textAligment = MonogameLibrary.UI.Enums.TextAligment.Left, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; ipBox.TextChanged += input => { if (input == "ip") @@ -58,7 +58,7 @@ public class SelectingServerGUI : AbstractGUI scale = 0.3f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; joinButton.LeftButtonPressed += () => { @@ -75,7 +75,7 @@ public class SelectingServerGUI : AbstractGUI scale = 0.3f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; hostButton.LeftButtonPressed += () => { @@ -87,7 +87,7 @@ public class SelectingServerGUI : AbstractGUI Elements.Add(hostButton); 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); bTExit.LeftButtonPressed += () => { diff --git a/ZoFo/GameCore/GUI/WaitingForPlayersGUI.cs b/ZoFo/GameCore/GUI/WaitingForPlayersGUI.cs index 5c9250d..08d80eb 100644 --- a/ZoFo/GameCore/GUI/WaitingForPlayersGUI.cs +++ b/ZoFo/GameCore/GUI/WaitingForPlayersGUI.cs @@ -27,11 +27,11 @@ public class WaitingForPlayersGUI : AbstractGUI int width = AppManager.Instance.CurentScreenResolution.X; 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); 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) { @@ -42,7 +42,7 @@ public class WaitingForPlayersGUI : AbstractGUI scale = 0.3f, fontColor = Color.White, mainColor = Color.Gray, - fontName = "Fonts\\Font" + fontName = "Fonts/Font" }; startButton.LeftButtonPressed += () => { @@ -54,7 +54,7 @@ public class WaitingForPlayersGUI : AbstractGUI } 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); bTExit.LeftButtonPressed += () => { diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs index fd67cd1..ed7cd03 100644 --- a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs +++ b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs @@ -66,7 +66,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager switch (layer.Class) { case "Tile": - AppManager.Instance.server.RegisterGameObject(new MapObject(position, new Vector2(tileSet.TileWidth * _scale, tileSet.TileHeight * _scale), sourceRectangle, "Textures\\TileSets\\"+tileSet.Name)); //fix naming + AppManager.Instance.server.RegisterGameObject(new MapObject(position, new Vector2(tileSet.TileWidth * _scale, tileSet.TileHeight * _scale), sourceRectangle, "Textures/TileSets/"+tileSet.Name)); //fix naming break; case "StopObject": // new StopObject(position, new Vector2(tileSet.TileWidth * _scale, tileSet.TileHeight * _scale), sourceRectangle, tileSet.Name); diff --git a/ZoFo/GameCore/GameObjects/Entities/Entity.cs b/ZoFo/GameCore/GameObjects/Entities/Entity.cs index 26eb6c0..a9e8670 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Entity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Entity.cs @@ -10,7 +10,7 @@ namespace ZoFo.GameCore.GameObjects.Entities { public abstract class Entity : GameObject { - protected override GraphicsComponent graphicsComponent => null; + public override GraphicsComponent graphicsComponent => null; public CollisionComponent collisionComponent { get; protected set; } public int Id { get; set; } protected Entity(Vector2 position) : base(position) diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs index 58d61ca..f82fe12 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs @@ -8,7 +8,7 @@ public class Door : Interactable { public bool isOpened; - protected override GraphicsComponent graphicsComponent { get; } = new(new List { "DoorInteraction" }, "DoorInteraction"); + public override GraphicsComponent graphicsComponent { get; } = new(new List { "DoorInteraction" }, "DoorInteraction"); public Door(Vector2 position) : base(position) { diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index 6037843..4ad9cee 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -13,7 +13,7 @@ public abstract class GameObject public Vector2 position; public Vector2 rotation; //вектор направления объекта - protected abstract GraphicsComponent graphicsComponent { get; } + public abstract GraphicsComponent graphicsComponent { get; } #region ServerSide public GameObject(Vector2 position) diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs index b551483..5a5748c 100644 --- a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs +++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs @@ -15,7 +15,7 @@ namespace ZoFo.GameCore.GameObjects.MapObjects { public virtual bool IsColliderOn { get; protected set; } = true;//Who added that? public Rectangle sourceRectangle; - protected override GraphicsComponent graphicsComponent { get; } = new(); + public override GraphicsComponent graphicsComponent { get; } = new(); /// /// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры