added lootdata loading on

This commit is contained in:
SergoDobro 2024-08-20 18:11:40 +03:00
parent fd996c732d
commit e266407935
3 changed files with 22 additions and 3 deletions

View file

@ -54,7 +54,17 @@ public class FinishingGUI : AbstractGUI
fontName = "Fonts\\Font", fontName = "Fonts\\Font",
textureName = "Textures/GUI/Button" 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); Elements.Add(ExitButton);
//player itams //player itams

View file

@ -18,6 +18,15 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
LoadPlayerData(); LoadPlayerData();
} }
public Dictionary<string, int> items = new Dictionary<string, int>(); public Dictionary<string, int> items = new Dictionary<string, int>();
public void AddLoot(string loot, int quantity)
{
if (items.ContainsKey(loot))
items[loot] += quantity;
else
items.Add(loot, quantity);
AppManager.Instance.playerData.SavePlayerData();
}
/// <summary> /// <summary>
/// Принимает тэг и крафтит этот объект /// Принимает тэг и крафтит этот объект
/// </summary> /// </summary>

View file

@ -259,10 +259,10 @@ public class Player : LivingEntity
{ {
if (entity is Enemy) if (entity is Enemy)
{ {
for (int i = 0; i < 3; i++) for (int i = 1; i <= 3; i++)
{ {
Instantiate(new Particle( Instantiate(new Particle(
((position - graphicsComponent.ObjectDrawRectangle.Location.ToVector2()) * i / 3f) + ((position) * i / 3f) +
((entity.position) * (3 - i) / 3f) ((entity.position) * (3 - i) / 3f)
)); ));