From 11d224414f02fe094aa58bad4f12a9ba93d138c9 Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Sun, 18 Aug 2024 23:38:49 +0300 Subject: [PATCH 01/10] Add AssetManager.cs --- .../GameManagers/AssetsManager/AssetContainer.cs | 9 +++++++++ .../GameManagers/AssetsManager/AssetManager.cs | 16 ++++++++++++++++ .../Entities/LivingEntities/Enemies/Zombie.cs | 3 ++- .../Entities/LivingEntities/Player/Player.cs | 3 ++- .../Graphics/AnimatedGraphicsComponent.cs | 11 +++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 ZoFo/GameCore/GameManagers/AssetsManager/AssetContainer.cs create mode 100644 ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs diff --git a/ZoFo/GameCore/GameManagers/AssetsManager/AssetContainer.cs b/ZoFo/GameCore/GameManagers/AssetsManager/AssetContainer.cs new file mode 100644 index 0000000..45a83ee --- /dev/null +++ b/ZoFo/GameCore/GameManagers/AssetsManager/AssetContainer.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace ZoFo.GameCore.GameManagers.AssetsManager; + +public class AssetContainer +{ + public List Animations; + public string IdleAnimation; +} \ No newline at end of file diff --git a/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs b/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs new file mode 100644 index 0000000..85623f9 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs @@ -0,0 +1,16 @@ +namespace ZoFo.GameCore.GameManagers.AssetsManager; + +public static class AssetManager +{ + public static AssetContainer Zombie = new() + { + Animations = { "zombie_damaged", "zombie_walk", "zombie_idle", "zombie_attack", "zombie_death" }, + IdleAnimation = "zombie_walk" + }; + + public static AssetContainer Player = new() + { + Animations = { "player_look_down" }, + IdleAnimation = "player_look_down" + }; +} \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs index 4e2ce66..77b84b9 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs @@ -5,13 +5,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.AssetsManager; using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies { class Zombie : Enemy { - public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List { "zombie_damaged","zombie_walk","zombie_idle","zombie_attack","zombie_death" }, "zombie_walk"); + public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AssetManager.Zombie); public Zombie(Vector2 position) : base(position) { health = 5; diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index 84d3e74..c7e5215 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Input; using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.AssetsManager; using ZoFo.GameCore.GameManagers.CollisionManager; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; @@ -21,7 +22,7 @@ public class Player : LivingEntity public bool IsTryingToShoot { get; set; } private float speed; private int health; - public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List { "player_look_down" }, "player_look_down"); + public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AssetManager.Player); private LootData lootData; public Player(Vector2 position) : base(position) { diff --git a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs index b6b7d45..f93e9f8 100644 --- a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs +++ b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs @@ -4,6 +4,7 @@ using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.AssetsManager; using ZoFo.GameCore.GUI; namespace ZoFo.GameCore.Graphics @@ -60,7 +61,17 @@ namespace ZoFo.GameCore.Graphics private int interval; private int lastInterval; private Rectangle sourceRectangle; + public AnimatedGraphicsComponent(AssetContainer asset) + { + Build(asset.Animations, asset.IdleAnimation); + } + public AnimatedGraphicsComponent(List animationsId, string neitralAnimationId) + { + Build(animationsId, neitralAnimationId); + } + + private void Build(List animationsId, string neitralAnimationId) { //this._spriteBatch = _spriteBatch; currentFrame = 0; From 7590907b203583f187d934984a9050bf9262adef Mon Sep 17 00:00:00 2001 From: dvaer Date: Mon, 19 Aug 2024 01:10:57 +0300 Subject: [PATCH 02/10] base --- MonogameLibrary/UI/Elements/HoverWindow.cs | 91 ++++++++++++++ ...mDisplayButton.cs => ItemDisplayButton.cs} | 50 +++++++- .../UI/Elements/ItemDisplayLabel.cs | 1 + ZoFo/Content/Content.mgcb | 7 ++ ZoFo/Content/Fonts/Font4.spritefont | 64 ++++++++++ ZoFo/Content/Fonts/Troubleside-lgjxX.ttf | Bin 0 -> 370264 bytes ZoFo/GameCore/GUI/BaseGUI.cs | 118 ++++++++++++------ ZoFo/GameCore/GameManagers/AppManager.cs | 1 + .../GameManagers/ItemManager/ItemInfo.cs | 6 +- .../GameManagers/ItemManager/ItemManager.cs | 10 +- .../GameManagers/ItemManager/PlayerData.cs | 6 +- 11 files changed, 306 insertions(+), 48 deletions(-) create mode 100644 MonogameLibrary/UI/Elements/HoverWindow.cs rename MonogameLibrary/UI/Elements/{itemDisplayButton.cs => ItemDisplayButton.cs} (61%) create mode 100644 ZoFo/Content/Fonts/Font4.spritefont create mode 100644 ZoFo/Content/Fonts/Troubleside-lgjxX.ttf diff --git a/MonogameLibrary/UI/Elements/HoverWindow.cs b/MonogameLibrary/UI/Elements/HoverWindow.cs new file mode 100644 index 0000000..d6efed9 --- /dev/null +++ b/MonogameLibrary/UI/Elements/HoverWindow.cs @@ -0,0 +1,91 @@ +using Microsoft.Xna.Framework.Graphics; +using MonogameLibrary.UI.Base; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using MonogameLibrary.UI.Enums; +using System; +using System.Collections.Generic; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading; +using Microsoft.Xna.Framework.Content; + +namespace MonogameLibrary.UI.Elements; + +public class HoverWindow : DrawableUIElement +{ + public string tagItem; + public string discriptions; + public Dictionary resourcesNeededToCraft; + private List