From e2664079351ffa252a263e1c61d89efef2c54731 Mon Sep 17 00:00:00 2001 From: SergoDobro Date: Tue, 20 Aug 2024 18:11:40 +0300 Subject: [PATCH] added lootdata loading on --- ZoFo/GameCore/GUI/FinishingGUI.cs | 12 +++++++++++- ZoFo/GameCore/GameManagers/ItemManager/PlayerData.cs | 9 +++++++++ .../Entities/LivingEntities/Player/Player.cs | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ZoFo/GameCore/GUI/FinishingGUI.cs b/ZoFo/GameCore/GUI/FinishingGUI.cs index cef6a5c..008a162 100644 --- a/ZoFo/GameCore/GUI/FinishingGUI.cs +++ b/ZoFo/GameCore/GUI/FinishingGUI.cs @@ -54,7 +54,17 @@ public class FinishingGUI : AbstractGUI fontName = "Fonts\\Font", textureName = "Textures/GUI/Button" }; - ExitButton.LeftButtonPressed += () => { AppManager.Instance.SetGUI(new MainMenuGUI()); }; + ExitButton.LeftButtonPressed += () => { + + foreach (var item in AppManager.Instance.client.myPlayer.lootData.loots) + { + AppManager.Instance.playerData.AddLoot(item.Key, item.Value); + } + + + AppManager.Instance.SetGUI(new MainMenuGUI()); + + }; Elements.Add(ExitButton); //player itams diff --git a/ZoFo/GameCore/GameManagers/ItemManager/PlayerData.cs b/ZoFo/GameCore/GameManagers/ItemManager/PlayerData.cs index a4a5c0d..e00f6be 100644 --- a/ZoFo/GameCore/GameManagers/ItemManager/PlayerData.cs +++ b/ZoFo/GameCore/GameManagers/ItemManager/PlayerData.cs @@ -18,6 +18,15 @@ namespace ZoFo.GameCore.GameManagers.ItemManager LoadPlayerData(); } public Dictionary items = new Dictionary(); + public void AddLoot(string loot, int quantity) + { + if (items.ContainsKey(loot)) + items[loot] += quantity; + else + items.Add(loot, quantity); + + AppManager.Instance.playerData.SavePlayerData(); + } /// /// Принимает тэг и крафтит этот объект /// diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index ae236ec..fb95e34 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -259,10 +259,10 @@ public class Player : LivingEntity { if (entity is Enemy) { - for (int i = 0; i < 3; i++) + for (int i = 1; i <= 3; i++) { Instantiate(new Particle( - ((position - graphicsComponent.ObjectDrawRectangle.Location.ToVector2()) * i / 3f) + + ((position) * i / 3f) + ((entity.position) * (3 - i) / 3f) ));