Merge pull request #92 from progtime-net/GUITextures

Inventory
This commit is contained in:
SergoDobro 2024-08-20 14:13:17 +03:00 committed by GitHub
commit f37b404cde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 135 additions and 37 deletions

View file

@ -29,6 +29,7 @@ public class ItemDisplayButton : Button
private ContentManager content;
public string discriptions1;
public Dictionary<string, int> resourcesNeededToCraft1;
public TextAligment TextAligment = TextAligment.Left;
public ItemDisplayButton(UIManager manager) : base(manager)
@ -46,7 +47,7 @@ public class ItemDisplayButton : Button
Label itemName = new Label(Manager)
{
rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2 + rectangle.Height / 3 * 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Width / 3, rectangle.Height / 3 * 2),
fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent
fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent, textAligment = TextAligment
};
Label itemCount = new Label(Manager)
{
@ -87,6 +88,10 @@ public class ItemDisplayButton : Button
{
if (presentState != hoverState)
{
if (resourcesNeededToCraft1 == null)
{
resourcesNeededToCraft1 = new Dictionary<string, int>();
}
hoverWindow = new HoverWindow(Manager)
{
rectangle = new Rectangle(Mouse.GetState().Position.X, Mouse.GetState().Position.Y, rectangle.Width, rectangle.Height * 10),

View file

@ -30,6 +30,7 @@ public class ItemDisplayLabel : DrawableUIElement
public Dictionary<string, int> resourcesNeededToCraft1;
public HoverState hoverState = HoverState.None;
private ContentManager content;
public TextAligment TextAligment = TextAligment.Left;
public ItemDisplayLabel(UIManager manager) : base(manager)
@ -47,7 +48,7 @@ public class ItemDisplayLabel : DrawableUIElement
Label itemName = new Label(Manager)
{
rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2 + rectangle.Height / 3 * 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Width / 3, rectangle.Height / 3 * 2),
fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent
fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent, textAligment = TextAligment
};
Label itemCount = new Label(Manager)
{

View file

@ -44,9 +44,6 @@
#begin MapData/TileMaps/main.tmj
/copy:MapData/TileMaps/main.tmj
#begin MapData/TileSets/bonfire.tsj
/copy:MapData/TileSets/bonfire.tsj
#begin MapData/TileSets/IconSet.tsj
/copy:MapData/TileSets/IconSet.tsj
@ -101,9 +98,6 @@
/processorParam:Quality=Best
/build:sounds/Zombi stoit.wav
#begin Textures/Animations/explosion_1.animation
/copy:Textures/Animations/explosion_1.animation
#begin Textures/Animations/player_down_idle.animation
/copy:Textures/Animations/player_down_idle.animation
@ -335,18 +329,6 @@
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Zombie/zombie_spritesheet_v2.png
#begin Textures/Effects/explosion.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/Effects/explosion.png
#begin Textures/GUI/background/base.png
/importer:TextureImporter
/processor:TextureProcessor
@ -647,6 +629,18 @@
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Ammo.png
#begin Textures/icons/Collectables/Ammo.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Ammo.png
#begin Textures/icons/Collectables/BottleOfWater.png
/importer:TextureImporter
/processor:TextureProcessor
@ -659,6 +653,30 @@
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/BottleOfWater.png
#begin Textures/icons/Collectables/BottleOfWater.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/BottleOfWater.png
#begin Textures/icons/Collectables/Peeble.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Peeble.png
#begin Textures/icons/Collectables/Peeble.png
/importer:TextureImporter
/processor:TextureProcessor
@ -683,6 +701,30 @@
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/PureBottleOfWater.png
#begin Textures/icons/Collectables/PureBottleOfWater.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/PureBottleOfWater.png
#begin Textures/icons/Collectables/RottenFlesh.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/RottenFlesh.png
#begin Textures/icons/Collectables/RottenFlesh.png
/importer:TextureImporter
/processor:TextureProcessor
@ -707,6 +749,30 @@
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Steel.png
#begin Textures/icons/Collectables/Steel.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Steel.png
#begin Textures/icons/Collectables/Wood.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Wood.png
#begin Textures/icons/Collectables/Wood.png
/importer:TextureImporter
/processor:TextureProcessor

View file

@ -249,6 +249,13 @@ namespace ZoFo.GameCore
{
UpdatePlayerHealth(update as UpdatePlayerParametrs);
}
else if (update is UpdateLoot)
{
var ent = FindEntityById(update.IdEntity);
if (ent != null)
(ent as Player).lootData.AddLoot_Client((update as UpdateLoot).lootName, (update as UpdateLoot).quantity);
}
}
public void UpdatePlayerHealth(UpdatePlayerParametrs update)

View file

@ -17,7 +17,7 @@ public class HUD : AbstractGUI
{
private Bar hpBar;
private Bar radBar;
private AbstractGUI overlayGUI;
public AbstractGUI overlayGUI;
protected override void CreateUI()
{
int width = AppManager.Instance.CurentScreenResolution.X;
@ -28,10 +28,10 @@ public class HUD : AbstractGUI
Elements.Add(pauseButton);
pauseButton.LeftButtonPressed += () =>
{
AppManager.Instance.SetGUI(new FinishingGUI());
//overlayGUI = new PauseGUI();
//overlayGUI.Initialize();
//overlayGUI.LoadContent();
//AppManager.Instance.SetGUI(new FinishingGUI());
overlayGUI = new PauseGUI();
overlayGUI.Initialize();
overlayGUI.LoadContent();
};
Button invButton = new Button(Manager)
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "inv", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width - width / 30 - width / 40, height / 15 + width / 40, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"};
@ -63,6 +63,7 @@ public class HUD : AbstractGUI
radBar.LoadTexture(AppManager.Instance.Content);
}
public override void Update(GameTime gameTime)
{
overlayGUI?.Update(gameTime);

View file

@ -62,7 +62,7 @@ public class InventoryGUI : AbstractGUI
(height / 20 + height / 80) * (buttonIndex) - height / 10,
(int)(width / 5), (int)(height / 20)),
text1 = item.Key,
scale1 = 0.4f,
scale1 = 0.3f,
count = item.Value,
itemTextureName = itemInfo.textureName,
fontColor1 = Color.White,

View file

@ -25,11 +25,15 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
public void Initialize()
{
tagItemPairs = new Dictionary<string, ItemInfo>();
tagItemPairs.Add("Ammo", new ItemInfo("Ammo", "деньги в метро", "Textures\\icons\\Collectables\\Ammo",false,null));
tagItemPairs.Add("wood", new ItemInfo("wood", "бревна кусок", "Textures\\Test\\wood",false,null));
tagItemPairs.Add("rock", new ItemInfo("rock", "пять галек", "Textures\\Test\\rock", false, null));
tagItemPairs.Add("steel", new ItemInfo("steel", "метал, метал, \nжелезо, метал", "Textures\\Test\\steel", false, null));
tagItemPairs.Add("pickaxe", new ItemInfo("steel", "прямой путь к \nстановлению каменьщиком", "Textures\\Test\\pickaxe", true, new Dictionary<string, int>()
tagItemPairs.Add("rottenflesh", new ItemInfo("rottenflesh", "БУХАТЬ", "Textures/icons/Collectables/RottenFlesh",false,null));
tagItemPairs.Add("purebottleofwater", new ItemInfo("purebottleofwater", "БУХАТЬ 2", "Textures/icons/Collectables/PureBottleOfWater",false,null));
tagItemPairs.Add("bottleofwater", new ItemInfo("bottleofwater", "БУХАТЬ", "Textures/icons/Collectables/BottleOfWater",false,null));
//tagItemPairs.Add("antiradin", new ItemInfo("antiradin", "радиацию опускает", "Textures/icons/Collectables/Ammo",false,null));
tagItemPairs.Add("ammo", new ItemInfo("ammo", "деньги в метро", "Textures/icons/Collectables/Ammo",false,null));
tagItemPairs.Add("wood", new ItemInfo("wood", "бревна кусок", "Textures/icons/Collectables/Wood",false,null));
tagItemPairs.Add("peeble", new ItemInfo("peeble", "пять галек", "Textures/icons/Collectables/Peeble", false, null));
tagItemPairs.Add("steel", new ItemInfo("steel", "метал, метал, \nжелезо, метал", "Textures/icons/Collectables/Steel", false, null));
tagItemPairs.Add("pickaxe", new ItemInfo("pickaxe", "прямой путь к \nстановлению каменьщиком", "Textures/Test/pickaxe", true, new Dictionary<string, int>()
{
{"wood", 2},
{"steel", 3}

View file

@ -54,7 +54,7 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
items = new Dictionary<string, int>();
items.Add("wood", 5);
items.Add("steel", 110);
items.Add("rock", 6);
items.Add("peeble", 6);
}
}
}

View file

@ -12,11 +12,14 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
public class UpdateLoot : UpdateData
{
public string lootName;
public int quantity;
public UpdateLoot() { UpdateType = "UpdateLoot"; }
public UpdateLoot(string lootName)
public UpdateLoot(string lootName, int quantity, int id)
{
UpdateType = "UpdateLoot";
this.lootName = lootName;
this.quantity = quantity;
IdEntity = id;
}
}
}

View file

@ -1,6 +1,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Linq;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
@ -29,9 +30,8 @@ public class Collectable : Interactable
public override void OnInteraction(GameObject sender)
{
DebugHUD.DebugLog("collected");
string lootname = this.GetType().ToString().ToLower();
(sender as Player).lootData.AddLoot(lootname, 1);
AppManager.Instance.server.AddData(new UpdateLoot(lootname));
string lootname = this.GetType().ToString().ToLower().Split('.').Last();
(sender as Player).lootData.AddLoot(lootname, 1, (sender as Player).Id);
AppManager.Instance.server.DeleteObject(this);
base.OnInteraction(sender);
}

View file

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
namespace ZoFo.GameCore.GameObjects
{
@ -10,7 +12,16 @@ namespace ZoFo.GameCore.GameObjects
{
public Dictionary<string, int> loots;
public void AddLoot(string lootName, int quantity)
public void AddLoot(string lootName, int quantity, int id)
{
AppManager.Instance.server.AddData(new UpdateLoot(lootName, quantity, id));
if (loots.ContainsKey(lootName))
loots[lootName] +=quantity;
else
loots.Add(lootName, quantity);
}
public void AddLoot_Client(string lootName, int quantity)
{
if (loots.ContainsKey(lootName))
loots[lootName] +=quantity;