commit
06ce01e3a3
11 changed files with 408 additions and 54 deletions
91
MonogameLibrary/UI/Elements/HoverWindow.cs
Normal file
91
MonogameLibrary/UI/Elements/HoverWindow.cs
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
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 HoverWindow : DrawableUIElement
|
||||||
|
{
|
||||||
|
public string tagItem;
|
||||||
|
public string discriptions;
|
||||||
|
public Dictionary<string, int> resourcesNeededToCraft;
|
||||||
|
private List<Label> Labels = new List<Label>();
|
||||||
|
public float scale2;
|
||||||
|
public string fontName2;
|
||||||
|
public Color fontColor2;
|
||||||
|
public string itemTextureName1;
|
||||||
|
private DrawableUIElement icon;
|
||||||
|
private Label itemName;
|
||||||
|
private Label discription;
|
||||||
|
private int labelIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public HoverWindow(UIManager manager, int layerIndex = 0, string textureName = "") : base(manager, layerIndex, textureName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(ContentManager content)
|
||||||
|
{
|
||||||
|
icon = new DrawableUIElement(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 20, rectangle.Y + rectangle.Width / 20, rectangle.Width / 5, rectangle.Width / 5),
|
||||||
|
mainColor = Color.White, textureName = itemTextureName1
|
||||||
|
};
|
||||||
|
icon.LoadTexture(content);
|
||||||
|
itemName = new Label(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20, rectangle.Y + rectangle.Width / 10, rectangle.Width / 3 * 2, rectangle.Width / 5 ),
|
||||||
|
fontColor = fontColor2, text = tagItem, scale = scale2, fontName = fontName2, mainColor = Color.Transparent, textAligment = TextAligment.Left
|
||||||
|
};
|
||||||
|
itemName.LoadTexture(content);
|
||||||
|
discription = new Label(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 20, rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20, rectangle.Width / 5, rectangle.Width / 5),
|
||||||
|
fontColor = fontColor2, text = discriptions, scale = scale2 / 1.5f, fontName = fontName2, mainColor = Color.Transparent, textAligment = TextAligment.Left
|
||||||
|
};
|
||||||
|
discription.LoadTexture(content);
|
||||||
|
foreach (var resource in resourcesNeededToCraft)
|
||||||
|
{
|
||||||
|
Label res = new Label(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 2 - rectangle.Width / 3 / 2, rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 5 + rectangle.Width / 20 + (rectangle.Width / 10 + rectangle.Width / 40) * labelIndex, rectangle.Width / 3, rectangle.Width / 10),
|
||||||
|
fontColor = fontColor2, text = resource.Key + " " + resource.Value, scale = scale2, fontName = fontName2, mainColor = Color.Transparent
|
||||||
|
};
|
||||||
|
res.LoadTexture(content);
|
||||||
|
Labels.Add(res);
|
||||||
|
labelIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void LoadTexture(ContentManager content)
|
||||||
|
{
|
||||||
|
base.LoadTexture(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
labelIndex = 0;
|
||||||
|
icon.rectangle = new Rectangle(rectangle.X + rectangle.Width / 20, rectangle.Y + rectangle.Width / 20, rectangle.Width / 5, rectangle.Width / 5);
|
||||||
|
itemName.rectangle = new Rectangle(rectangle.X + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20,
|
||||||
|
rectangle.Y + rectangle.Width / 10, rectangle.Width / 3 * 2, rectangle.Width / 5);
|
||||||
|
discription.rectangle = new Rectangle(rectangle.X + rectangle.Width / 20,
|
||||||
|
rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20, rectangle.Width / 5,
|
||||||
|
rectangle.Width / 5);
|
||||||
|
foreach (var label in Labels)
|
||||||
|
{
|
||||||
|
label.rectangle = new Rectangle(rectangle.X + rectangle.Width / 2 - rectangle.Width / 3 / 2,
|
||||||
|
rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 5 + rectangle.Width / 20 +
|
||||||
|
(rectangle.Width / 10 + rectangle.Width / 40) * labelIndex, rectangle.Width / 3, rectangle.Width / 10);
|
||||||
|
labelIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,10 +9,11 @@ using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
namespace MonogameLibrary.UI.Elements;
|
namespace MonogameLibrary.UI.Elements;
|
||||||
|
|
||||||
public class ItemDisplayButton : DrawableUIElement
|
public class ItemDisplayButton : Button
|
||||||
{
|
{
|
||||||
public int count;
|
public int count;
|
||||||
public string itemTextureName;
|
public string itemTextureName;
|
||||||
|
@ -23,6 +24,11 @@ public class ItemDisplayButton : DrawableUIElement
|
||||||
public string text1;
|
public string text1;
|
||||||
public float scale1;
|
public float scale1;
|
||||||
private DrawableUIElement icon;
|
private DrawableUIElement icon;
|
||||||
|
private HoverState presentState = HoverState.None;
|
||||||
|
private HoverWindow hoverWindow = null;
|
||||||
|
private ContentManager content;
|
||||||
|
public string discriptions1;
|
||||||
|
public Dictionary<string, int> resourcesNeededToCraft1;
|
||||||
|
|
||||||
|
|
||||||
public ItemDisplayButton(UIManager manager) : base(manager)
|
public ItemDisplayButton(UIManager manager) : base(manager)
|
||||||
|
@ -51,6 +57,7 @@ public class ItemDisplayButton : DrawableUIElement
|
||||||
|
|
||||||
public override void LoadTexture(ContentManager content)
|
public override void LoadTexture(ContentManager content)
|
||||||
{
|
{
|
||||||
|
this.content = content;
|
||||||
icon.LoadTexture(content);
|
icon.LoadTexture(content);
|
||||||
base.LoadTexture(content);
|
base.LoadTexture(content);
|
||||||
if (itemTextureName == "")
|
if (itemTextureName == "")
|
||||||
|
@ -72,6 +79,47 @@ public class ItemDisplayButton : DrawableUIElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (hoverState == HoverState.Hovering)
|
||||||
|
{
|
||||||
|
if (presentState != hoverState)
|
||||||
|
{
|
||||||
|
hoverWindow = new HoverWindow(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(Mouse.GetState().Position.X, Mouse.GetState().Position.Y, rectangle.Width, rectangle.Height * 10),
|
||||||
|
mainColor = Color.Gray,
|
||||||
|
tagItem = text1,
|
||||||
|
discriptions = discriptions1,
|
||||||
|
resourcesNeededToCraft = resourcesNeededToCraft1,
|
||||||
|
fontColor2 = fontColor1,
|
||||||
|
fontName2 = fontName1,
|
||||||
|
scale2 = scale1,
|
||||||
|
itemTextureName1 = itemTextureName
|
||||||
|
};
|
||||||
|
hoverWindow.Initialize(content);
|
||||||
|
hoverWindow.LoadTexture(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
hoverWindow.rectangle.X = Mouse.GetState().Position.X;
|
||||||
|
hoverWindow.rectangle.Y = Mouse.GetState().Position.Y;
|
||||||
|
hoverWindow.Update(gameTime);
|
||||||
|
}
|
||||||
|
else if (hoverState == HoverState.None)
|
||||||
|
{
|
||||||
|
if (presentState != hoverState)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
presentState = hoverState;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch _spriteBatch)
|
public override void Draw(SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
base.Draw(_spriteBatch);
|
base.Draw(_spriteBatch);
|
|
@ -9,6 +9,7 @@ using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
namespace MonogameLibrary.UI.Elements;
|
namespace MonogameLibrary.UI.Elements;
|
||||||
|
|
||||||
|
@ -23,6 +24,12 @@ public class ItemDisplayLabel : DrawableUIElement
|
||||||
public string text1;
|
public string text1;
|
||||||
public float scale1;
|
public float scale1;
|
||||||
private DrawableUIElement icon;
|
private DrawableUIElement icon;
|
||||||
|
private HoverState presentState = HoverState.None;
|
||||||
|
private HoverWindow hoverWindow = null;
|
||||||
|
public string discriptions1;
|
||||||
|
public Dictionary<string, int> resourcesNeededToCraft1;
|
||||||
|
public HoverState hoverState = HoverState.None;
|
||||||
|
private ContentManager content;
|
||||||
|
|
||||||
|
|
||||||
public ItemDisplayLabel(UIManager manager) : base(manager)
|
public ItemDisplayLabel(UIManager manager) : base(manager)
|
||||||
|
@ -51,6 +58,7 @@ public class ItemDisplayLabel : DrawableUIElement
|
||||||
|
|
||||||
public override void LoadTexture(ContentManager content)
|
public override void LoadTexture(ContentManager content)
|
||||||
{
|
{
|
||||||
|
this.content = content;
|
||||||
icon.LoadTexture(content);
|
icon.LoadTexture(content);
|
||||||
base.LoadTexture(content);
|
base.LoadTexture(content);
|
||||||
if (itemTextureName == "")
|
if (itemTextureName == "")
|
||||||
|
@ -72,8 +80,71 @@ public class ItemDisplayLabel : DrawableUIElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
if (rectangle.Intersects(new Rectangle(Mouse.GetState().Position, Point.Zero)))
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Hovering;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hoverState = HoverState.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hoverState == HoverState.Hovering)
|
||||||
|
{
|
||||||
|
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),
|
||||||
|
mainColor = Color.Gray,
|
||||||
|
tagItem = text1,
|
||||||
|
discriptions = discriptions1,
|
||||||
|
resourcesNeededToCraft = resourcesNeededToCraft1,
|
||||||
|
fontColor2 = fontColor1,
|
||||||
|
fontName2 = fontName1,
|
||||||
|
scale2 = scale1,
|
||||||
|
itemTextureName1 = itemTextureName
|
||||||
|
};
|
||||||
|
hoverWindow.Initialize(content);
|
||||||
|
hoverWindow.LoadTexture(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
hoverWindow.rectangle.X = Mouse.GetState().Position.X;
|
||||||
|
hoverWindow.rectangle.Y = Mouse.GetState().Position.Y;
|
||||||
|
hoverWindow.Update(gameTime);
|
||||||
|
}
|
||||||
|
else if (hoverState == HoverState.None)
|
||||||
|
{
|
||||||
|
if (presentState != hoverState)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
presentState = hoverState;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch _spriteBatch)
|
public override void Draw(SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (hoverState == HoverState.None)
|
||||||
|
{
|
||||||
|
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||||
|
}
|
||||||
|
else if (hoverState == HoverState.Hovering)
|
||||||
|
{
|
||||||
|
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
||||||
|
}
|
||||||
base.Draw(_spriteBatch);
|
base.Draw(_spriteBatch);
|
||||||
|
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,6 +34,13 @@
|
||||||
/processorParam:TextureFormat=Compressed
|
/processorParam:TextureFormat=Compressed
|
||||||
/build:Fonts/Font3.spritefont
|
/build:Fonts/Font3.spritefont
|
||||||
|
|
||||||
|
#begin Fonts/Font4.spritefont
|
||||||
|
/importer:FontDescriptionImporter
|
||||||
|
/processor:FontDescriptionProcessor
|
||||||
|
/processorParam:PremultiplyAlpha=True
|
||||||
|
/processorParam:TextureFormat=Compressed
|
||||||
|
/build:Fonts/Font4.spritefont
|
||||||
|
|
||||||
#begin MapData/TileMaps/main.tmj
|
#begin MapData/TileMaps/main.tmj
|
||||||
/copy:MapData/TileMaps/main.tmj
|
/copy:MapData/TileMaps/main.tmj
|
||||||
|
|
||||||
|
|
64
ZoFo/Content/Fonts/Font4.spritefont
Normal file
64
ZoFo/Content/Fonts/Font4.spritefont
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
This file contains an xml description of a font, and will be read by the XNA
|
||||||
|
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||||
|
of the font in your game, and to change the characters which are available to draw
|
||||||
|
with.
|
||||||
|
-->
|
||||||
|
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||||
|
<Asset Type="Graphics:FontDescription">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Modify this string to change the font that will be imported.
|
||||||
|
-->
|
||||||
|
<FontName>Troubleside-lgjxX.ttf</FontName>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Size is a float value, measured in points. Modify this value to change
|
||||||
|
the size of the font.
|
||||||
|
-->
|
||||||
|
<Size>50</Size>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Spacing is a float value, measured in pixels. Modify this value to change
|
||||||
|
the amount of spacing in between characters.
|
||||||
|
-->
|
||||||
|
<Spacing>0</Spacing>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||||
|
will be used when placing characters.
|
||||||
|
-->
|
||||||
|
<UseKerning>true</UseKerning>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||||
|
and "Bold, Italic", and are case sensitive.
|
||||||
|
-->
|
||||||
|
<Style>Regular</Style>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If you uncomment this line, the default character will be substituted if you draw
|
||||||
|
or measure text that contains characters which were not included in the font.
|
||||||
|
-->
|
||||||
|
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
CharacterRegions control what letters are available in the font. Every
|
||||||
|
character from Start to End will be built and made available for drawing. The
|
||||||
|
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||||
|
character set. The characters are ordered according to the Unicode standard.
|
||||||
|
See the documentation for more information.
|
||||||
|
-->
|
||||||
|
<CharacterRegions>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start>32</Start>
|
||||||
|
<End>127</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start>А</Start>
|
||||||
|
<End>ј</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
</CharacterRegions>
|
||||||
|
</Asset>
|
||||||
|
</XnaContent>
|
BIN
ZoFo/Content/Fonts/Troubleside-lgjxX.ttf
Normal file
BIN
ZoFo/Content/Fonts/Troubleside-lgjxX.ttf
Normal file
Binary file not shown.
|
@ -19,17 +19,20 @@ namespace ZoFo.GameCore.GUI;
|
||||||
public class BaseGUI : AbstractGUI
|
public class BaseGUI : AbstractGUI
|
||||||
{
|
{
|
||||||
private DrawableUIElement menuBackground;
|
private DrawableUIElement menuBackground;
|
||||||
private List<ItemDisplayLabel> ItemDisplayButtonsList;
|
private List<ItemDisplayLabel> ItemDisplayLabelsList;
|
||||||
|
private List<ItemDisplayButton> ItemDisplayButtonsList;
|
||||||
private int buttonIndex = 0;
|
private int buttonIndex = 0;
|
||||||
private string textureName;
|
private string textureName;
|
||||||
|
|
||||||
protected override void CreateUI()
|
protected override void CreateUI()
|
||||||
{
|
{
|
||||||
ItemDisplayButtonsList = new List<ItemDisplayLabel>();
|
ItemDisplayLabelsList = new List<ItemDisplayLabel>();
|
||||||
|
ItemDisplayButtonsList = new List<ItemDisplayButton>();
|
||||||
int width = AppManager.Instance.CurentScreenResolution.X;
|
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||||
Dictionary<string, int> playerItems = AppManager.Instance.playerData.items;
|
Dictionary<string, int> playerItems = AppManager.Instance.playerData.items;
|
||||||
Dictionary<string, ItemInfo> items = AppManager.Instance.ItemManager.tagItemPairs;
|
Dictionary<string, ItemInfo> items = AppManager.Instance.ItemManager.tagItemPairs;
|
||||||
|
int numberCraftItem = 0;
|
||||||
|
|
||||||
menuBackground = new DrawableUIElement(Manager)
|
menuBackground = new DrawableUIElement(Manager)
|
||||||
{
|
{
|
||||||
|
@ -46,67 +49,110 @@ public class BaseGUI : AbstractGUI
|
||||||
fontName = "Fonts\\Font"
|
fontName = "Fonts\\Font"
|
||||||
});
|
});
|
||||||
|
|
||||||
DrawableUIElement baseHudBack = new DrawableUIElement(Manager)
|
DrawableUIElement baseItemBack = new DrawableUIElement(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2, height / 2 - (int)(height / 1.5) / 2,
|
rectangle = new Rectangle(width / 2 - (height / 16 + (int)(width / 2.5)) / 2,
|
||||||
(int)(width / 1.5), (int)(height / 1.5)),
|
height / 2 - (int)(height / 1.5) / 2,
|
||||||
|
height / 40 + width / 5, (int)(height / 1.5)),
|
||||||
mainColor = Color.LightGray
|
mainColor = Color.LightGray
|
||||||
};
|
};
|
||||||
Elements.Add(baseHudBack);
|
Elements.Add(baseItemBack);
|
||||||
|
DrawableUIElement baseCraftBack = new DrawableUIElement(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(width / 2 + height / 160, height / 2 - (int)(height / 1.5) / 2,
|
||||||
|
height / 40 + width / 5, (int)(height / 1.5)),
|
||||||
|
mainColor = Color.LightGray
|
||||||
|
};
|
||||||
|
Elements.Add(baseCraftBack);
|
||||||
|
|
||||||
//player itams
|
//player itams
|
||||||
foreach (var item in playerItems)
|
foreach (var item in playerItems)
|
||||||
{
|
{
|
||||||
textureName = AppManager.Instance.ItemManager.GetItemInfo(item.Key).textureName;
|
if (item.Value > 0)
|
||||||
var temp = new ItemDisplayLabel(Manager)
|
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2 + height / 80,
|
ItemInfo itemInfo = AppManager.Instance.ItemManager.GetItemInfo(item.Key);
|
||||||
height / 2 - (int)(height / 1.5) / 2 + height / 80 + (height / 20 + height / 80) * (buttonIndex),
|
var temp = new ItemDisplayLabel(Manager)
|
||||||
(int)(width / 5), (int)(height / 20)),
|
{
|
||||||
text1 = item.Key,
|
rectangle = new Rectangle(width / 2 - (height / 16 + (int)(width / 2.5)) / 2 + height / 80,
|
||||||
scale1 = 0.4f,
|
height / 2 - (int)(height / 1.5) / 2 + height / 80 +
|
||||||
count = item.Value,
|
(height / 20 + height / 80) * (buttonIndex),
|
||||||
itemTextureName = textureName,
|
(int)(width / 5), (int)(height / 20)),
|
||||||
fontColor1 = Color.White,
|
text1 = item.Key,
|
||||||
mainColor = Color.Gray,
|
scale1 = 0.4f,
|
||||||
fontName1 = "Fonts\\Font3"
|
count = item.Value,
|
||||||
};
|
itemTextureName = itemInfo.textureName,
|
||||||
Elements.Add(temp);
|
fontColor1 = Color.White,
|
||||||
temp.Initialize();
|
mainColor = Color.Gray,
|
||||||
temp.LoadTexture(AppManager.Instance.Content);
|
fontName1 = "Fonts\\Font4",
|
||||||
ItemDisplayButtonsList.Add(temp);
|
discriptions1 = itemInfo.description,
|
||||||
|
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft
|
||||||
|
};
|
||||||
|
Elements.Add(temp);
|
||||||
|
temp.Initialize();
|
||||||
|
temp.LoadTexture(AppManager.Instance.Content);
|
||||||
|
ItemDisplayLabelsList.Add(temp);
|
||||||
|
|
||||||
buttonIndex++;
|
buttonIndex++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// craftable items
|
// craftable items
|
||||||
buttonIndex = 0;
|
buttonIndex = 0;
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
ItemInfo itemInfo = AppManager.Instance.ItemManager.GetItemInfo(item.Key);
|
try
|
||||||
|
|
||||||
if (itemInfo.isCraftable)
|
|
||||||
{
|
{
|
||||||
var temp = new ItemDisplayLabel(Manager)
|
ItemInfo itemInfo = AppManager.Instance.ItemManager.GetItemInfo(item.Key);
|
||||||
|
if (itemInfo.isCraftable)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2 + height / 40 + width / 5,
|
Dictionary<string, int> needToCraft =
|
||||||
height / 2 - (int)(height / 1.5) / 2 + height / 80 +
|
AppManager.Instance.ItemManager.GetItemInfo(item.Key).resourcesNeededToCraft;
|
||||||
(height / 20 + height / 80) * (buttonIndex),
|
numberCraftItem = playerItems[needToCraft.Keys.First()] / needToCraft.Values.First();
|
||||||
(int)(width / 5), (int)(height / 20)),
|
foreach (var itemNeedToCraft in needToCraft)
|
||||||
text1 = item.Key,
|
{
|
||||||
scale1 = 0.4f,
|
int xValue = playerItems[itemNeedToCraft.Key] / itemNeedToCraft.Value;
|
||||||
count = 0,
|
if (numberCraftItem > xValue)
|
||||||
itemTextureName = itemInfo.textureName,
|
{
|
||||||
fontColor1 = Color.White,
|
numberCraftItem = xValue;
|
||||||
mainColor = Color.Gray,
|
}
|
||||||
fontName1 = "Fonts\\Font3"
|
}
|
||||||
};
|
|
||||||
Elements.Add(temp);
|
if (numberCraftItem > 0)
|
||||||
temp.Initialize();
|
{
|
||||||
temp.LoadTexture(AppManager.Instance.Content);
|
var temp = new ItemDisplayButton(Manager)
|
||||||
ItemDisplayButtonsList.Add(temp);
|
{
|
||||||
|
rectangle = new Rectangle(
|
||||||
|
width / 2 - (height / 16 + (int)(width / 2.5)) / 2 + height / 20 + 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 = numberCraftItem,
|
||||||
|
itemTextureName = itemInfo.textureName,
|
||||||
|
fontColor1 = Color.White,
|
||||||
|
mainColor = Color.Gray,
|
||||||
|
fontName1 = "Fonts\\Font4",
|
||||||
|
discriptions1 = itemInfo.description,
|
||||||
|
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft
|
||||||
|
};
|
||||||
|
Elements.Add(temp);
|
||||||
|
temp.Initialize();
|
||||||
|
temp.LoadTexture(AppManager.Instance.Content);
|
||||||
|
ItemDisplayButtonsList.Add(temp);
|
||||||
|
temp.LeftButtonPressed += () =>
|
||||||
|
{
|
||||||
|
AppManager.Instance.playerData.CraftItem(item.Key);
|
||||||
|
AppManager.Instance.SetGUI(new BaseGUI());
|
||||||
|
};
|
||||||
|
|
||||||
|
buttonIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
buttonIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,5 +169,19 @@ public class BaseGUI : AbstractGUI
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
|
foreach (var item in ItemDisplayButtonsList)
|
||||||
|
{
|
||||||
|
if (item.Update(gameTime))
|
||||||
|
{
|
||||||
|
AppManager.Instance.SetGUI(new BaseGUI());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var item in ItemDisplayLabelsList)
|
||||||
|
{
|
||||||
|
if (item.Update(gameTime))
|
||||||
|
{
|
||||||
|
AppManager.Instance.SetGUI(new BaseGUI());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,6 +56,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
Content.RootDirectory = "Content";
|
Content.RootDirectory = "Content";
|
||||||
IsMouseVisible = true;
|
IsMouseVisible = true;
|
||||||
|
|
||||||
|
server = new Server();
|
||||||
playerData = new PlayerData();
|
playerData = new PlayerData();
|
||||||
ItemManager = new ItemManager.ItemManager();
|
ItemManager = new ItemManager.ItemManager();
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
|
@ -14,16 +14,18 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||||
public string textureName;
|
public string textureName;
|
||||||
Texture2D itemTexture;
|
Texture2D itemTexture;
|
||||||
public bool isCraftable;
|
public bool isCraftable;
|
||||||
|
public string description;
|
||||||
public Dictionary<string, int> resourcesNeededToCraft;
|
public Dictionary<string, int> resourcesNeededToCraft;
|
||||||
public ItemInfo (string tag)
|
public ItemInfo (string tag)
|
||||||
{
|
{
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
}
|
}
|
||||||
public ItemInfo(string tag,string textureName,bool isCraftable, Dictionary<string, int> resourcesNeededToCraft)
|
public ItemInfo(string tag, string description, string textureName, bool isCraftable, Dictionary<string, int> resourcesNeededToCraft)
|
||||||
{
|
{
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.textureName = textureName;
|
this.textureName = textureName;
|
||||||
|
|
||||||
|
this.description = description;
|
||||||
this.isCraftable = isCraftable;
|
this.isCraftable = isCraftable;
|
||||||
this.resourcesNeededToCraft = resourcesNeededToCraft;
|
this.resourcesNeededToCraft = resourcesNeededToCraft;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
tagItemPairs = new Dictionary<string, ItemInfo>();
|
tagItemPairs = new Dictionary<string, ItemInfo>();
|
||||||
tagItemPairs.Add("wood", new ItemInfo("wood","Textures\\Test\\wood",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("rock", new ItemInfo("rock", "пять галек", "Textures\\Test\\rock", false, null));
|
||||||
tagItemPairs.Add("steel", new ItemInfo("steel", "Textures\\Test\\steel", false, null));
|
tagItemPairs.Add("steel", new ItemInfo("steel", "метал, метал, \nжелезо, метал", "Textures\\Test\\steel", false, null));
|
||||||
tagItemPairs.Add("pickaxe", new ItemInfo("steel", "Textures\\Test\\pickaxe", true, new Dictionary<string, int>()
|
tagItemPairs.Add("pickaxe", new ItemInfo("steel", "прямой путь к \nстановлению каменьщиком", "Textures\\Test\\pickaxe", true, new Dictionary<string, int>()
|
||||||
{
|
{
|
||||||
{"wood", 2},
|
{"wood", 2},
|
||||||
{"Steel", 3}
|
{"steel", 3}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,24 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||||
{
|
{
|
||||||
items[item.Key] -= item.Value;
|
items[item.Key] -= item.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (items.Keys.Contains(itemTag))
|
||||||
|
{
|
||||||
|
items[itemTag] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
items.Add(itemTag, 1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void LoadPlayerData()
|
public void LoadPlayerData()
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
items = new Dictionary<string, int>();
|
items = new Dictionary<string, int>();
|
||||||
items.Add("wood", 2);
|
items.Add("wood", 5);
|
||||||
items.Add("steel", 110);
|
items.Add("steel", 110);
|
||||||
items.Add("rock", 6);
|
items.Add("rock", 6);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue