summaryrefslogtreecommitdiff
path: root/Penguloon/Controls
diff options
context:
space:
mode:
Diffstat (limited to 'Penguloon/Controls')
-rw-r--r--Penguloon/Controls/Alert.cs99
-rw-r--r--Penguloon/Controls/LevelSelector.cs1
2 files changed, 100 insertions, 0 deletions
diff --git a/Penguloon/Controls/Alert.cs b/Penguloon/Controls/Alert.cs
new file mode 100644
index 0000000..21870d8
--- /dev/null
+++ b/Penguloon/Controls/Alert.cs
@@ -0,0 +1,99 @@
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using Penguloon.Scenes;
+using System;
+
+namespace Penguloon.Controls
+{
+ public static class Alert
+ {
+ static Texture2D background;
+
+ private static bool active = false;
+
+ private static float posY = 0f;
+
+ private static string text_;
+
+ private const int maxY = 50;
+
+ private const int speed = 3000;
+
+ private static float posX = 0;
+
+ private static SceneBase scene_;
+
+ private static bool movingUp = false;
+ private static bool bottomReached = false;
+ private static DateTime bottomReachedTime;
+
+ private static int displayTimeMS_ = 0;
+
+ private static SpriteFont font;
+
+ public static void Show(string text, int displayTimeMS, SceneBase scene)
+ {
+ text_ = text;
+ scene_ = scene;
+ displayTimeMS_ = displayTimeMS;
+
+ font = ContentManager.GetFont(StaticUIValues.MenuFont);
+ posX = (StaticUIValues.ScreenViewport.X / 2) - (StaticUIValues.AlertSize.X / 2);
+ background = ContentManager.GetTexture("UI/alertBackground");
+ posY = -StaticUIValues.AlertSize.Y;
+
+ active = true;
+ }
+
+ public static void Draw(float deltaTime)
+ {
+ if (!active) return;
+
+ scene_.Main.SpriteBatch.Draw(background, destinationRectangle:
+ new Microsoft.Xna.Framework.Rectangle((int)posX, (int)posY, (int)StaticUIValues.AlertSize.X, (int)StaticUIValues.AlertSize.Y));
+
+ scene_.DrawText(font, text_, new Vector2(posX, posY), StaticUIValues.AlertSize,
+ TextAllignment.CenterMiddle, Color.White, Color.Black, 2);
+ }
+
+ public static void Update(float deltaTime)
+ {
+ if (!active) return;
+
+ if (movingUp)
+ {
+ posY -= (speed * deltaTime);
+
+ // we done here
+ if (posY < -StaticUIValues.AlertSize.Y)
+ {
+ movingUp = false;
+ bottomReached = false;
+ active = false;
+ }
+
+ return;
+ }
+
+ if (bottomReached)
+ {
+ if ((DateTime.Now - bottomReachedTime).TotalMilliseconds > displayTimeMS_)
+ {
+ movingUp = true;
+ }
+
+ return;
+ }
+
+ if (posY < maxY)
+ {
+ posY += (speed * deltaTime);
+ }
+ else
+ {
+ bottomReachedTime = DateTime.Now;
+ bottomReached = true;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Penguloon/Controls/LevelSelector.cs b/Penguloon/Controls/LevelSelector.cs
index 0309b68..3e06968 100644
--- a/Penguloon/Controls/LevelSelector.cs
+++ b/Penguloon/Controls/LevelSelector.cs
@@ -105,6 +105,7 @@ namespace Penguloon.Controls
{
Levels.Add(new IceLevel());
Levels.Add(new IceLevel2());
+ Levels.Add(new IceLevel3());
}
public override void Draw(float deltaTime)