79
MonogameLibrary/UI/Elements/ItemDisplayLabel.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
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 ItemDisplayLabel : DrawableUIElement
|
||||
{
|
||||
public int count;
|
||||
public string itemTextureName;
|
||||
private Texture2D itemTexture;
|
||||
public Color fontColor1;
|
||||
protected UIManager Manager;
|
||||
public string fontName1;
|
||||
public string text1;
|
||||
public float scale1;
|
||||
private DrawableUIElement icon;
|
||||
|
||||
|
||||
public ItemDisplayLabel(UIManager manager) : base(manager)
|
||||
{
|
||||
Manager = manager;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
icon = new DrawableUIElement(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Height / 3 * 2, rectangle.Height / 3 * 2),
|
||||
mainColor = Color.White, textureName = itemTextureName
|
||||
};
|
||||
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
|
||||
};
|
||||
Label itemCount = new Label(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(rectangle.X + rectangle.Width - (int)(rectangle.Height / 3 * 2.5), rectangle.Y + rectangle.Height / 3 / 2, rectangle.Height / 3 * 2, rectangle.Height / 3 * 2),
|
||||
fontColor = fontColor1, text = count.ToString(), scale = scale1, fontName = fontName1, mainColor = Color.Transparent
|
||||
};
|
||||
}
|
||||
|
||||
public override void LoadTexture(ContentManager content)
|
||||
{
|
||||
icon.LoadTexture(content);
|
||||
base.LoadTexture(content);
|
||||
if (itemTextureName == "")
|
||||
{
|
||||
itemTexture = new Texture2D(Manager.GraphicsDevice, 1, 1);
|
||||
itemTexture.SetData<Color>(new Color[] { mainColor });
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
itemTexture = content.Load<Texture2D>(itemTextureName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
itemTexture = new Texture2D(Manager.GraphicsDevice, 1, 1);
|
||||
itemTexture.SetData<Color>(new Color[] { mainColor });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
base.Draw(_spriteBatch);
|
||||
}
|
||||
}
|
79
MonogameLibrary/UI/Elements/itemDisplayButton.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
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 ItemDisplayButton : DrawableUIElement
|
||||
{
|
||||
public int count;
|
||||
public string itemTextureName;
|
||||
private Texture2D itemTexture;
|
||||
public Color fontColor1;
|
||||
protected UIManager Manager;
|
||||
public string fontName1;
|
||||
public string text1;
|
||||
public float scale1;
|
||||
private DrawableUIElement icon;
|
||||
|
||||
|
||||
public ItemDisplayButton(UIManager manager) : base(manager)
|
||||
{
|
||||
Manager = manager;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
icon = new DrawableUIElement(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Height / 3 * 2, rectangle.Height / 3 * 2),
|
||||
mainColor = Color.White, textureName = itemTextureName
|
||||
};
|
||||
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
|
||||
};
|
||||
Label itemCount = new Label(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(rectangle.X + rectangle.Width - (int)(rectangle.Height / 3 * 2.5), rectangle.Y + rectangle.Height / 3 / 2, rectangle.Height / 3 * 2, rectangle.Height / 3 * 2),
|
||||
fontColor = fontColor1, text = count.ToString(), scale = scale1, fontName = fontName1, mainColor = Color.Transparent
|
||||
};
|
||||
}
|
||||
|
||||
public override void LoadTexture(ContentManager content)
|
||||
{
|
||||
icon.LoadTexture(content);
|
||||
base.LoadTexture(content);
|
||||
if (itemTextureName == "")
|
||||
{
|
||||
itemTexture = new Texture2D(Manager.GraphicsDevice, 1, 1);
|
||||
itemTexture.SetData<Color>(new Color[] { mainColor });
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
itemTexture = content.Load<Texture2D>(itemTextureName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
itemTexture = new Texture2D(Manager.GraphicsDevice, 1, 1);
|
||||
itemTexture.SetData<Color>(new Color[] { mainColor });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
base.Draw(_spriteBatch);
|
||||
}
|
||||
}
|
|
@ -351,8 +351,8 @@
|
|||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/switch.png
|
||||
|
||||
#begin Textures/icons/12.png
|
||||
|
||||
#begin Textures/Test/pickaxe.webp
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
|
@ -362,9 +362,10 @@
|
|||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/icons/12.png
|
||||
|
||||
#begin Textures/icons/13.png
|
||||
/build:Textures/Test/pickaxe.webp
|
||||
|
||||
#begin Textures/Test/rock.jpg
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
|
@ -374,9 +375,11 @@
|
|||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/icons/13.png
|
||||
|
||||
#begin Textures/icons/14.png
|
||||
/build:Textures/Test/rock.jpg
|
||||
|
||||
#begin Textures/Test/steel.png
|
||||
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
|
@ -386,9 +389,11 @@
|
|||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/icons/14.png
|
||||
|
||||
#begin Textures/icons/21.png
|
||||
/build:Textures/Test/steel.png
|
||||
|
||||
#begin Textures/Test/wood.jpg
|
||||
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
|
@ -398,9 +403,11 @@
|
|||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/icons/21.png
|
||||
|
||||
#begin Textures/icons/22.png
|
||||
/build:Textures/Test/wood.jpg
|
||||
|
||||
#begin Textures/TileSets/TilesetFloor.png
|
||||
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
|
@ -410,125 +417,7 @@
|
|||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/icons/22.png
|
||||
|
||||
#begin Textures/icons/5.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/5.png
|
||||
/build:Textures/TileSets/TilesetFloor.png
|
||||
|
||||
#begin Textures/icons/6.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/6.png
|
||||
|
||||
#begin Textures/icons/7.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/7.png
|
||||
|
||||
#begin Textures/icons/8.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/8.png
|
||||
|
||||
#begin Textures/icons/9.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/9.png
|
||||
|
||||
#begin Textures/TileSetImages/Tilelist1.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/TileSetImages/Tilelist1.png
|
||||
|
||||
#begin Textures/TileSetImages/Tilelist2.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/TileSetImages/Tilelist2.png
|
||||
|
||||
#begin Textures/TileSetImages/Tilelist3.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/TileSetImages/Tilelist3.png
|
||||
|
||||
#begin Textures/TileSetImages/Tilelist4.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/TileSetImages/Tilelist4.png
|
||||
|
||||
#begin Textures/TileSetImages/TilesetFloor.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/TileSetImages/TilesetFloor.png
|
||||
|
||||
|
|
Before Width: | Height: | Size: 648 KiB After Width: | Height: | Size: 9.2 MiB |
Before Width: | Height: | Size: 4.6 MiB After Width: | Height: | Size: 5.7 MiB |
Before Width: | Height: | Size: 508 KiB After Width: | Height: | Size: 7.1 MiB |
BIN
ZoFo/Content/Textures/Test/pickaxe.webp
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
ZoFo/Content/Textures/Test/rock.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
ZoFo/Content/Textures/Test/steel.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
ZoFo/Content/Textures/Test/wood.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
|
@ -9,20 +10,118 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
using ZoFo.GameCore.GameManagers.ItemManager;
|
||||
|
||||
|
||||
namespace ZoFo.GameCore.GUI;
|
||||
|
||||
public class BaseGUI : AbstractGUI
|
||||
{
|
||||
private DrawableUIElement menuBackground;
|
||||
private List<ItemDisplayLabel> ItemDisplayButtonsList;
|
||||
private int buttonIndex = 0;
|
||||
private string textureName;
|
||||
|
||||
protected override void CreateUI()
|
||||
{
|
||||
// int width = AppManager.Instance.inGameHUDHelperResolution.X;
|
||||
// int height = AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
ItemDisplayButtonsList = new List<ItemDisplayLabel>();
|
||||
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||
Dictionary<string, int> playerItems = AppManager.Instance.playerData.items;
|
||||
Dictionary<string, ItemInfo> items = AppManager.Instance.ItemManager.tagItemPairs;
|
||||
|
||||
menuBackground = new DrawableUIElement(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White,
|
||||
textureName = "Textures\\GUI\\background\\base"
|
||||
};
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
Elements.Add(new Label(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 15, (int)(width / 4), (int)(height / 20)),
|
||||
text = "Base", fontColor = Color.Black, mainColor = Color.Transparent, scale = 0.9f,
|
||||
fontName = "Fonts\\Font"
|
||||
});
|
||||
|
||||
DrawableUIElement baseHudBack = new DrawableUIElement(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2, height / 2 - (int)(height / 1.5) / 2,
|
||||
(int)(width / 1.5), (int)(height / 1.5)),
|
||||
mainColor = Color.LightGray
|
||||
};
|
||||
Elements.Add(baseHudBack);
|
||||
|
||||
//player itams
|
||||
foreach (var item in playerItems)
|
||||
{
|
||||
textureName = AppManager.Instance.ItemManager.GetItemInfo(item.Key).textureName;
|
||||
var temp = new ItemDisplayLabel(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2 + height / 80,
|
||||
height / 2 - (int)(height / 1.5) / 2 + height / 80 + (height / 20 + height / 80) * (buttonIndex),
|
||||
(int)(width / 5), (int)(height / 20)),
|
||||
text1 = item.Key,
|
||||
scale1 = 0.4f,
|
||||
count = item.Value,
|
||||
itemTextureName = textureName,
|
||||
fontColor1 = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName1 = "Fonts\\Font3"
|
||||
};
|
||||
Elements.Add(temp);
|
||||
temp.Initialize();
|
||||
temp.LoadTexture(AppManager.Instance.Content);
|
||||
ItemDisplayButtonsList.Add(temp);
|
||||
|
||||
buttonIndex++;
|
||||
}
|
||||
|
||||
// craftable items
|
||||
buttonIndex = 0;
|
||||
foreach (var item in items)
|
||||
{
|
||||
ItemInfo itemInfo = AppManager.Instance.ItemManager.GetItemInfo(item.Key);
|
||||
|
||||
if (itemInfo.isCraftable)
|
||||
{
|
||||
var temp = new ItemDisplayLabel(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2 + height / 40 + width / 5,
|
||||
height / 2 - (int)(height / 1.5) / 2 + height / 80 +
|
||||
(height / 20 + height / 80) * (buttonIndex),
|
||||
(int)(width / 5), (int)(height / 20)),
|
||||
text1 = item.Key,
|
||||
scale1 = 0.4f,
|
||||
count = 0,
|
||||
itemTextureName = itemInfo.textureName,
|
||||
fontColor1 = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName1 = "Fonts\\Font3"
|
||||
};
|
||||
Elements.Add(temp);
|
||||
temp.Initialize();
|
||||
temp.LoadTexture(AppManager.Instance.Content);
|
||||
ItemDisplayButtonsList.Add(temp);
|
||||
|
||||
buttonIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
Button bTExit = new Button(Manager)
|
||||
{
|
||||
fontName = "Fonts\\Font3", scale = 0.4f, text = "<-", fontColor = Color.Black,
|
||||
mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40),
|
||||
textureName = "Textures\\GUI\\checkboxs_off"
|
||||
};
|
||||
Elements.Add(bTExit);
|
||||
bTExit.LeftButtonPressed += () => { AppManager.Instance.SetGUI(new MainMenuGUI()); };
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -9,34 +9,27 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
|
||||
namespace ZoFo.GameCore.GUI;
|
||||
|
||||
public class HUD : AbstractGUI
|
||||
{
|
||||
|
||||
private GraphicsDevice graphicsDevice;
|
||||
public virtual void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void LoadContent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
//Manager.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public class HUD : AbstractGUI
|
||||
{
|
||||
protected override void CreateUI()
|
||||
{
|
||||
{
|
||||
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||
|
||||
Button pauseButton = new Button(Manager)
|
||||
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "| |", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"};
|
||||
Elements.Add(pauseButton);
|
||||
pauseButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SetGUI(new PauseGUI());
|
||||
};
|
||||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -44,9 +44,23 @@ public class MainMenuGUI : AbstractGUI
|
|||
AppManager.Instance.SetGUI(new SelectModeMenu());
|
||||
};
|
||||
Elements.Add(playButton);
|
||||
Button optionButton = new Button(Manager)
|
||||
Button baseButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 2, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Base",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
baseButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SetGUI(new BaseGUI());
|
||||
};
|
||||
Elements.Add(baseButton);
|
||||
Button optionButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 3, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Options",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
|
@ -61,7 +75,7 @@ public class MainMenuGUI : AbstractGUI
|
|||
Elements.Add(optionButton);
|
||||
Button exitButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 3, (int)(width / 5), (int)(height / 20)),
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 4, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Exit",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
|
|
|
@ -40,6 +40,7 @@ public class OptionsGUI : AbstractGUI
|
|||
var slider_OverallVolume = new Slider(Manager)
|
||||
{ rectangle = new Rectangle(width / 2, height / 3, width / 10, height / 20), indentation = 7, textureName = "Textures/GUI/Switch_backgrownd", MinValue = 0, MaxValue = 1 };
|
||||
slider_OverallVolume.SetValue(AppManager.Instance.SettingsManager.MainVolume);
|
||||
label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%";
|
||||
slider_OverallVolume.SliderChanged += (newVal) =>
|
||||
{
|
||||
label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%";
|
||||
|
@ -60,6 +61,7 @@ public class OptionsGUI : AbstractGUI
|
|||
var slider_MusicVolume = new Slider(Manager)
|
||||
{ rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 1, width / 10, height / 20), indentation = 7, textureName = "Textures/GUI/Switch_backgrownd", MinValue = 0, MaxValue = 1 };
|
||||
slider_MusicVolume.SetValue(AppManager.Instance.SettingsManager.MusicVolume);
|
||||
label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%";
|
||||
slider_MusicVolume.SliderChanged += (newVal) =>
|
||||
{
|
||||
label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%";
|
||||
|
@ -80,6 +82,7 @@ public class OptionsGUI : AbstractGUI
|
|||
var slider_EffectsVolume = new Slider(Manager)
|
||||
{ rectangle = new Rectangle(width / 2, height / 3 + (height / 20 + height / 40) * 2, width / 10, height / 20), indentation = 7, textureName = "Textures/GUI/Switch_backgrownd", MinValue = 0, MaxValue = 1 };
|
||||
slider_EffectsVolume.SetValue(AppManager.Instance.SettingsManager.SoundEffectsVolume);
|
||||
label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%";
|
||||
slider_EffectsVolume.SliderChanged += (newVal) =>
|
||||
{
|
||||
label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%";
|
||||
|
|
57
ZoFo/GameCore/GUI/PauseGUI.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
|
||||
namespace ZoFo.GameCore.GUI;
|
||||
|
||||
public class PauseGUI : AbstractGUI
|
||||
{
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||
|
||||
Button continueButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + height / 20 + height / 40, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Continue",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
continueButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SetGUI(new HUD());
|
||||
};
|
||||
Elements.Add(continueButton);
|
||||
Button exitButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 2, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Exit",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
exitButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SetGUI(new MainMenuGUI());
|
||||
};
|
||||
Elements.Add(exitButton);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -28,9 +28,10 @@ namespace ZoFo.GameCore.GameManagers
|
|||
public GameState gamestate;
|
||||
public AbstractGUI currentGUI;
|
||||
public DebugHUD debugHud;
|
||||
public Point CurentScreenResolution = new Point(1920, 1080);
|
||||
public Point CurentScreenResolution;
|
||||
public Client client;
|
||||
public Server server;
|
||||
public PlayerData playerData;
|
||||
|
||||
|
||||
#region Managers
|
||||
|
@ -46,14 +47,17 @@ namespace ZoFo.GameCore.GameManagers
|
|||
|
||||
public AppManager()
|
||||
{
|
||||
_graphics = new GraphicsDeviceManager(this);
|
||||
_graphics = new GraphicsDeviceManager(this);
|
||||
CurentScreenResolution = new Point(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
|
||||
SetResolution(CurentScreenResolution.X, CurentScreenResolution.Y);
|
||||
// FulscrreenSwitch();
|
||||
//FulscrreenSwitch();
|
||||
|
||||
|
||||
Content.RootDirectory = "Content";
|
||||
IsMouseVisible = true;
|
||||
|
||||
playerData = new PlayerData();
|
||||
ItemManager = new ItemManager.ItemManager();
|
||||
Instance = this;
|
||||
InputManager = new InputManager();
|
||||
SettingsManager = new SettingsManager();
|
||||
|
@ -71,7 +75,9 @@ namespace ZoFo.GameCore.GameManagers
|
|||
protected override void Initialize()
|
||||
{
|
||||
currentGUI.Initialize();
|
||||
debugHud.Initialize();
|
||||
|
||||
debugHud.Initialize();
|
||||
ItemManager.Initialize();
|
||||
|
||||
|
||||
base.Initialize();
|
||||
|
@ -81,11 +87,15 @@ namespace ZoFo.GameCore.GameManagers
|
|||
{
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
debugHud.LoadContent();
|
||||
currentGUI.LoadContent();
|
||||
currentGUI.LoadContent();
|
||||
ItemManager.LoadItemTextures();
|
||||
|
||||
|
||||
|
||||
animationBuilder = new AnimationBuilder();
|
||||
animationBuilder.LoadAnimations();
|
||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||
GameObject.debugTexture.SetData(new Color[] { Color.White });
|
||||
GameObject.debugTexture.SetData(new Color[] { Color.White });
|
||||
}
|
||||
|
||||
protected override void Update(GameTime gameTime)
|
||||
|
@ -119,11 +129,10 @@ namespace ZoFo.GameCore.GameManagers
|
|||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
|
||||
|
||||
|
||||
// Pointwrap
|
||||
_spriteBatch.Begin(samplerState: SamplerState.PointWrap);
|
||||
_spriteBatch.Begin(samplerState: SamplerState.PointWrap);
|
||||
switch (gamestate)
|
||||
{
|
||||
case GameState.ClientPlaying:
|
||||
|
@ -135,7 +144,7 @@ namespace ZoFo.GameCore.GameManagers
|
|||
break;
|
||||
}
|
||||
|
||||
_spriteBatch.End();
|
||||
_spriteBatch.End();
|
||||
currentGUI.Draw(_spriteBatch);
|
||||
debugHud.Draw(_spriteBatch);
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
{
|
||||
//поля
|
||||
string tag;
|
||||
string textureName;
|
||||
public string textureName;
|
||||
Texture2D itemTexture;
|
||||
bool isCraftable;
|
||||
Dictionary<string, int> resourcesNeededToCraft;
|
||||
public bool isCraftable;
|
||||
public Dictionary<string, int> resourcesNeededToCraft;
|
||||
public ItemInfo (string tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
|
|
|
@ -9,24 +9,30 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
public class ItemManager
|
||||
{
|
||||
//поля
|
||||
Dictionary<string, ItemInfo> tagItemPairs;
|
||||
public Dictionary<string, ItemInfo> tagItemPairs;
|
||||
//методы
|
||||
ItemInfo GetItemInfo(string tag)
|
||||
public ItemInfo GetItemInfo(string tag)
|
||||
{
|
||||
return tagItemPairs.GetValueOrDefault(tag);
|
||||
return tagItemPairs[tag];
|
||||
}
|
||||
void LoadItemTextures()
|
||||
public void LoadItemTextures()
|
||||
{
|
||||
foreach (var item in tagItemPairs)
|
||||
{
|
||||
item.Value.LoadTexture();
|
||||
}
|
||||
}
|
||||
void Initialize()
|
||||
{
|
||||
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));
|
||||
public void Initialize()
|
||||
{
|
||||
tagItemPairs = new Dictionary<string, ItemInfo>();
|
||||
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", "Textures\\Test\\steel", false, null));
|
||||
tagItemPairs.Add("pickaxe", new ItemInfo("steel", "Textures\\Test\\pickaxe", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"wood", 2},
|
||||
{"Steel", 3}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,16 +9,42 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
/// <summary>
|
||||
/// Класс хранит информацю о количестве ресурсов у игрока
|
||||
/// </summary>
|
||||
internal class PlayerData
|
||||
public class PlayerData
|
||||
{
|
||||
Dictionary<string, int> items;
|
||||
public PlayerData()
|
||||
{
|
||||
LoadPlayerData();
|
||||
}
|
||||
public Dictionary<string, int> items;
|
||||
/// <summary>
|
||||
/// Принимает тэг и крафтит этот объект
|
||||
/// </summary>
|
||||
/// <param name="itemTag"></param>
|
||||
public void CraftItem(string itemTag)
|
||||
public bool CraftItem(string itemTag)
|
||||
{
|
||||
Dictionary<string, int> needToCraft = AppManager.Instance.ItemManager.GetItemInfo(itemTag).resourcesNeededToCraft;
|
||||
foreach (var item in needToCraft)
|
||||
{
|
||||
if (items[item.Key] < item.Value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in needToCraft)
|
||||
{
|
||||
items[item.Key] -= item.Value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void LoadPlayerData()
|
||||
{
|
||||
//TODO
|
||||
items = new Dictionary<string, int>();
|
||||
items.Add("wood", 2);
|
||||
items.Add("steel", 110);
|
||||
items.Add("rock", 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|