From 9e00e4d05d8dc1dac33fe35dd36a8fd8489b9833 Mon Sep 17 00:00:00 2001 From: Kaktus200020 Date: Sat, 17 Aug 2024 19:36:30 +0300 Subject: [PATCH 1/3] LootData --- .../GameObjects/Entities/LivingEntities/Player/LootData.cs | 7 ++++--- .../GameObjects/Entities/LivingEntities/Player/Player.cs | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/LootData.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/LootData.cs index 5336e7b..2d86531 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/LootData.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/LootData.cs @@ -6,12 +6,13 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player { - internal class LootData + class LootData { public Dictionary loots; - public void AddLoot(object lootObject, int quantity) - { + public void AddLoot(string lootName, int quantity) + { + loots.Add(lootName, quantity); } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index 026a746..3078de9 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -20,6 +20,7 @@ public class Player : LivingEntity public bool IsTryingToShoot { get; set; } private float speed; private int health; + private LootData lootData; public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List { "player_running_top_rotate" }, "player_running_top_rotate"); public Player(Vector2 position) : base(position) { From 85b55f6f41fcf4d353595d67a48292e4abc4904c Mon Sep 17 00:00:00 2001 From: Kaktus200020 Date: Sat, 17 Aug 2024 22:26:02 +0300 Subject: [PATCH 2/3] addCollectable --- .../Collectables/BottleOfWater.cs | 21 +++++++++++++++++++ .../Interactables/Collectables/Peeble.cs | 21 +++++++++++++++++++ .../Collectables/PureBottleOfWater.cs | 19 +++++++++++++++++ .../Interactables/Collectables/Steel.cs | 19 +++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs create mode 100644 ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs create mode 100644 ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs create mode 100644 ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs new file mode 100644 index 0000000..b38fda7 --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.Graphics; + +using Microsoft.Xna.Framework; + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables +{ + public class BottleOfWater : Collectable + { + public override GraphicsComponent graphicsComponent { get; } = new(new List { "BottleOfWater" }, "BottleOfWater"); + public BottleOfWater(Vector2 position) : base(position) + { + + } + + } +} diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs new file mode 100644 index 0000000..c2126eb --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.Graphics; +using Microsoft.Xna.Framework; + + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables +{ + public class Peeble:Collectable + { + public override GraphicsComponent graphicsComponent { get; } = new(new List { "Peeble" }, "Peeble"); + + public Peeble(Vector2 position) : base(position) + { + + } + } +} diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs new file mode 100644 index 0000000..299860a --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.Graphics; + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables +{ + class PureBottleOfWater:Collectable + { + public override GraphicsComponent graphicsComponent { get; } = new(new List { "PureBottleOfWater" }, "PureBottleOfWater"); + + public PureBottleOfWater(Vector2 position) : base(position) + { + } + } +} diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs new file mode 100644 index 0000000..899d8d0 --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.Graphics; + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables +{ + class Steel:Collectable + { + public override GraphicsComponent graphicsComponent { get; } = new(new List { "Steel" }, "Steel"); + + public Steel(Vector2 position) : base(position) + { + } + } +} From 8eab09980aa62d511c596db0f8ab93021dc953ec Mon Sep 17 00:00:00 2001 From: Kaktus200020 Date: Sun, 18 Aug 2024 00:31:53 +0300 Subject: [PATCH 3/3] updateLoot --- .../GameManagers/ItemManager/ItemManager.cs | 6 ++--- .../Updates/ServerToClient/UpdateLoot.cs | 8 +++++- .../Interactables/Collectables/Ammo.cs | 27 +++++++++++++++++++ .../Interactables/Collectables/Antiradine.cs | 27 +++++++++++++++++++ .../Collectables/BottleOfWater.cs | 9 ++++++- .../Interactables/Collectables/Peeble.cs | 8 ++++++ .../Collectables/PureBottleOfWater.cs | 8 ++++++ .../Interactables/Collectables/RottenFlesh.cs | 27 +++++++++++++++++++ .../Interactables/Collectables/Steel.cs | 8 ++++++ .../Interactables/Collectables/Wood.cs | 9 +++++++ 10 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Ammo.cs create mode 100644 ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Antiradine.cs create mode 100644 ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/RottenFlesh.cs diff --git a/ZoFo/GameCore/GameManagers/ItemManager/ItemManager.cs b/ZoFo/GameCore/GameManagers/ItemManager/ItemManager.cs index 6d00e0c..9f7c724 100644 --- a/ZoFo/GameCore/GameManagers/ItemManager/ItemManager.cs +++ b/ZoFo/GameCore/GameManagers/ItemManager/ItemManager.cs @@ -24,9 +24,9 @@ namespace ZoFo.GameCore.GameManagers.ItemManager } void Initialize() { - tagItemPairs.Add("wood", new ItemInfo("wood","wood",false,null)); - tagItemPairs.Add("rock", new ItemInfo("rock", "rock", false, null)); - tagItemPairs.Add("steel", new ItemInfo("steel", "steel", false, null)); + tagItemPairs.Add("Wood", new ItemInfo("Wood","Wood",false,null)); + tagItemPairs.Add("Peeble", new ItemInfo("Peeble", "Peeble", false, null)); + tagItemPairs.Add("Steel", new ItemInfo("Steel", "Steel", false, null)); } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs index 2337f74..b69a860 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs @@ -11,6 +11,12 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient /// public class UpdateLoot : UpdateData { - public UpdateLoot() { UpdateType = "UpdateLoot"; } + public string lootName; + public UpdateLoot() { UpdateType = "UpdateLoot"; } + public UpdateLoot(string lootName) + { + UpdateType = "UpdateLoot"; + this.lootName = lootName; + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Ammo.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Ammo.cs new file mode 100644 index 0000000..040e461 --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Ammo.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.Graphics; + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables +{ + class Ammo:Collectable + { + public override GraphicsComponent graphicsComponent { get; } = new(new List { "Ammo" }, "Ammo"); + public Ammo(Vector2 position) : base(position) + { + + } + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("Ammo")); + AppManager.Instance.server.DeleteObject(this); + } + } +} diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Antiradine.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Antiradine.cs new file mode 100644 index 0000000..e575538 --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Antiradine.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.Graphics; + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables +{ + class Antiradine:Collectable + { + public override GraphicsComponent graphicsComponent { get; } = new(new List { "Antiradine" }, "Antiradine"); + public Antiradine(Vector2 position) : base(position) + { + + } + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("Antiradine")); + AppManager.Instance.server.DeleteObject(this); + } + } +} diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs index b38fda7..4b51206 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/BottleOfWater.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; using ZoFo.GameCore.Graphics; using Microsoft.Xna.Framework; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameManagers; namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables { @@ -16,6 +19,10 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables { } - + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("BottleOfWater")); + AppManager.Instance.server.DeleteObject(this); + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs index c2126eb..8623b76 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Peeble.cs @@ -5,6 +5,9 @@ using System.Text; using System.Threading.Tasks; using ZoFo.GameCore.Graphics; using Microsoft.Xna.Framework; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameManagers; namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables @@ -17,5 +20,10 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables { } + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("Peeble")); + AppManager.Instance.server.DeleteObject(this); + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs index 299860a..2a55323 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/PureBottleOfWater.cs @@ -4,6 +4,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables @@ -15,5 +18,10 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables public PureBottleOfWater(Vector2 position) : base(position) { } + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("PureBottleOfWater")); + AppManager.Instance.server.DeleteObject(this); + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/RottenFlesh.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/RottenFlesh.cs new file mode 100644 index 0000000..5649f5a --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/RottenFlesh.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.Graphics; + +namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables +{ + class RottenFlesh:Collectable + { + public override GraphicsComponent graphicsComponent { get; } = new(new List { "RottenFlesh" }, "RottenFlesh"); + public RottenFlesh(Vector2 position) : base(position) + { + + } + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("RottenFlesh")); + AppManager.Instance.server.DeleteObject(this); + } + } +} diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs index 899d8d0..41d73ed 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Steel.cs @@ -4,6 +4,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables @@ -15,5 +18,10 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables public Steel(Vector2 position) : base(position) { } + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("Steel")); + AppManager.Instance.server.DeleteObject(this); + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Wood.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Wood.cs index 2c6b0b8..e79ba5c 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Wood.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Wood.cs @@ -1,5 +1,8 @@ using System.Collections.Generic; using Microsoft.Xna.Framework; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables; @@ -10,5 +13,11 @@ public class Wood : Collectable public Wood(Vector2 position) : base(position) { + + } + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateLoot("Wood")); + AppManager.Instance.server.DeleteObject(this); } } \ No newline at end of file