menu ui rework
This commit is contained in:
parent
465fc40562
commit
25ecea60f8
6 changed files with 65 additions and 14 deletions
|
@ -19,8 +19,7 @@ public abstract class AbstractGui : IDrawableObject
|
|||
private GraphicsDevice graphicsDevice;
|
||||
public virtual void Initialize()
|
||||
{
|
||||
Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
||||
CreateUI();
|
||||
}
|
||||
|
||||
|
@ -31,7 +30,7 @@ public abstract class AbstractGui : IDrawableObject
|
|||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
Manager.Update();
|
||||
Manager.Update(gameTime);
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
|
|
|
@ -31,8 +31,9 @@ internal class MenuGUI : AbstractGui
|
|||
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 200, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1.35f - 0.05f * i * i / 10, fontName = "Font2", fontColor = colors[i] });
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 220, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1.35f - 0.05f * i * i / 10, fontName = "Font2", fontColor = colors[i] });
|
||||
MainLetterLabels.Add(Elements.Last() as Label);
|
||||
MainLetterPositions.Add(new Vector2(Elements.Last().rectangle.X, Elements.Last().rectangle.Y));
|
||||
}
|
||||
|
||||
int dx = 50;
|
||||
|
@ -40,6 +41,7 @@ internal class MenuGUI : AbstractGui
|
|||
{
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 480 + dx - i * i, 260 - i * i / 5, 50, 50), text = "D", mainColor = Color.Transparent, scale = 2.15f - 0.05f * i * i / 5, fontName = "Font2", fontColor = colors[i] });
|
||||
BigLetterLabels.Add(Elements.Last() as Label);
|
||||
BigLetterPositions.Add(new Vector2(Elements.Last().rectangle.X, Elements.Last().rectangle.Y));
|
||||
}
|
||||
|
||||
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(300 * 2.4)) / 2, 350, (int)(300 * 2.4), (int)(50 * 2.4)), text = "Singleplayer", scale = 1.2f, fontName = "ButtonFont" };
|
||||
|
@ -77,10 +79,21 @@ internal class MenuGUI : AbstractGui
|
|||
{
|
||||
for (int i = 0; i < MainLetterLabels.Count; i++)
|
||||
{
|
||||
MainLetterLabels[i].fontColor = Color.FromNonPremultiplied(colors[i].ToVector4() * (float)((Math.Sin(gameTime.TotalGameTime.TotalSeconds*2) + 1) / 2f + 0.5f)
|
||||
MainLetterLabels[i].fontColor = Color.FromNonPremultiplied(colors[i].ToVector4() *
|
||||
(float)(((Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4) + 1) / 2f) * 0.3 + 0.8f)
|
||||
);
|
||||
BigLetterLabels[i].fontColor = Color.FromNonPremultiplied(colors[i].ToVector4() * (float)((Math.Sin(gameTime.TotalGameTime.TotalSeconds * 2) + 1) / 2f + 0.5f)
|
||||
BigLetterLabels[i].fontColor = Color.FromNonPremultiplied(colors[i].ToVector4()
|
||||
* (float)(((Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4 - Math.PI) + 1) / 2f) * 0.3 + 0.8f)
|
||||
);
|
||||
MainLetterLabels[i].fontColor.A = 255;
|
||||
BigLetterLabels[i].fontColor.A = 255;
|
||||
MainLetterLabels[i].rectangle.Y = (int)(MainLetterPositions[i].Y +
|
||||
(20 * (Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4) + 1) / 2f * 0.25) * (i - MainLetterLabels.Count / 2)
|
||||
);
|
||||
BigLetterLabels[i].rectangle.Y = (int)(BigLetterPositions[i].Y +
|
||||
(20 * (Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4 - Math.PI) + 1) / 2f * 0.25) * (i - MainLetterLabels.Count / 2)
|
||||
);
|
||||
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
public void Death(string monsterName)
|
||||
{
|
||||
return;
|
||||
return; //godmode
|
||||
isAttacked = true;
|
||||
if(monsterName == "Zombie")
|
||||
{
|
||||
|
|
|
@ -51,8 +51,10 @@ namespace MonogameLibrary.UI.Base
|
|||
}
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
public GameTime gameTime;
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
this.gameTime = gameTime;
|
||||
try
|
||||
{
|
||||
keyboardState = Keyboard.GetState();
|
||||
|
|
|
@ -16,22 +16,57 @@ namespace MonogameLibrary.UI.Elements
|
|||
public ButtonText(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||
{
|
||||
}
|
||||
float gameTime = 0;
|
||||
public override bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
gameTime += (float)Manager.gameTime.ElapsedGameTime.TotalSeconds;
|
||||
return base.InteractUpdate(mouseState, prevmouseState);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
{
|
||||
fontColor = Color.White;
|
||||
var d = (float)(((Math.Sin(gameTime * 2 - Math.PI) + 1) / 2f) * 0.1 + 0.7f);
|
||||
fontColor = Color.FromNonPremultiplied(new Vector4(0.8f,0.15f, 0.15f, 1) * d
|
||||
);
|
||||
}
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
{
|
||||
fontColor = new Color(211, 211, 211);
|
||||
{
|
||||
var d2 = (float)(((Math.Sin(gameTime * 2 - Math.PI) + 1) / 2f) * 0.1 + 0.7f);
|
||||
fontColor = Color.FromNonPremultiplied(new Vector4(0.8f, 0.15f, 0.15f, 1) * d2
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
fontColor = new Color(112, 128, 144);
|
||||
//fontColor = new Color(112, 128, 144);
|
||||
fontColor = new Color(212, 228, 244);
|
||||
}
|
||||
|
||||
DrawText(_spriteBatch);
|
||||
if (hoverState == HoverState.Hovering)
|
||||
{
|
||||
int kk = 50;
|
||||
scale += 0.005f;
|
||||
var d = (float)(((Math.Sin(gameTime * 1 - Math.PI) + 1) / 2f) * 0.1 + 1f);
|
||||
Color oldColor = fontColor;
|
||||
fontColor = Color.FromNonPremultiplied(new Vector4(252 / 255f, 231 / 255f, 124 / 255f, 1) * d
|
||||
);
|
||||
DrawText(_spriteBatch);
|
||||
fontColor = oldColor;
|
||||
fontColor.A = 255;
|
||||
scale -= 0.005f;
|
||||
scale -= 0.0002f;
|
||||
}
|
||||
if (hoverState == HoverState.Pressing)
|
||||
{
|
||||
scale -= 0.025f;
|
||||
DrawText(_spriteBatch);
|
||||
scale += 0.025f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ namespace MonogameLibrary.UI.Elements
|
|||
}
|
||||
protected HoverState hoverState = HoverState.None;
|
||||
|
||||
float gameTime = 0;
|
||||
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
gameTime += (float)Manager.gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||
{
|
||||
if (mouseState.LeftButton == ButtonState.Pressed)
|
||||
|
|
Loading…
Add table
Reference in a new issue