summaryrefslogtreecommitdiff
path: root/Penguloon/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'Penguloon/Scenes')
-rw-r--r--Penguloon/Scenes/GameScene.cs67
1 files changed, 57 insertions, 10 deletions
diff --git a/Penguloon/Scenes/GameScene.cs b/Penguloon/Scenes/GameScene.cs
index 3ab7c28..0647539 100644
--- a/Penguloon/Scenes/GameScene.cs
+++ b/Penguloon/Scenes/GameScene.cs
@@ -3,31 +3,67 @@ using Microsoft.Xna.Framework.Input.Touch;
using Penguloon.Controls;
using Penguloon.Levels;
using Penguloon.Scenes;
+using System;
namespace Penguloon.Scenes
{
- internal class GameScene : SceneBase
+ public class GameScene : SceneBase
{
public LevelBase Level { get; set; }
- public Button StartRoundBtn { get; set; }
+ public float Speed { get; set; } = 1f;
+
+ public ButtonIngame StartRoundBtn { get; set; }
+ public SpeedButton ChangeSpeedBtn { get; set; }
+ public ButtonIngame OptionsBtn { get; set; }
+
+ public ObjectSelector ObjectSeletor { get; set; }
public GameScene(Main main, LevelBase level) : base(main)
{
this.Level = level;
this.Level.Initialize(this);
- StartRoundBtn = new Button(this,
+ StartRoundBtn = new ButtonIngame(this,
new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight),
new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), StaticUIValues.IngameUIPlayButtonHeight), "Start");
+ OptionsBtn = new ButtonIngame(this,
+ new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth),
+ new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), StaticUIValues.IngameUIPlayButtonHeight), "Options");
+
+ ChangeSpeedBtn = new SpeedButton(this,
+ new Vector2(Level.Map.MapWidth - 200, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight),
+ new Vector2(200, StaticUIValues.IngameUIPlayButtonHeight), "X1");
+
+ ChangeSpeedBtn.OnClick += ChangeSpeedBtn_OnClick;
StartRoundBtn.OnClick += StartRoundBtn_OnClick;
+
+ ObjectSeletor = new ObjectSelector(level.Map, this,
+ new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.IngameUITextAreaHeight + StaticUIValues.BorderWidth),
+ new Vector2((int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth),
+ StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUITextAreaHeight - StaticUIValues.BorderWidth - StaticUIValues.BorderWidth - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth - StaticUIValues.IngameUIPlayButtonHeight));
+
+ }
+
+ private void ChangeSpeedBtn_OnClick(object sender, ClickArgs e)
+ {
+ switch (Speed)
+ {
+ case 1f: Speed = 2f; break;
+ case 2f: Speed = 3f; break;
+ case 3f: Speed = 1f; break;
+
+ default: Speed = 1f; break;
+ }
+
+ ChangeSpeedBtn.Text = "X" + Math.Round(Speed, 0).ToString();
}
private void StartRoundBtn_OnClick(object sender, ClickArgs e)
{
Level.Map.WaveManager.StartSpawningEnemies();
- Button btn = (Button)sender;
+ ButtonIngame btn = (ButtonIngame)sender;
btn.ControlState = ControlState.Disabled;
}
@@ -49,6 +85,9 @@ namespace Penguloon.Scenes
DrawUI(deltaTime);
StartRoundBtn.Draw(deltaTime);
+ ObjectSeletor.Draw(deltaTime);
+ ChangeSpeedBtn.Draw(deltaTime);
+ OptionsBtn.Draw(deltaTime);
}
private void DrawUI(float deltaTime)
@@ -56,24 +95,29 @@ namespace Penguloon.Scenes
//background
Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/red"),
destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth,
- 0, StaticUIValues.IngameUIWidth, (int)StaticUIValues.ScreenViewport.Y));
+ 0, (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), (int)StaticUIValues.ScreenViewport.Y));
//border
Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"),
destinationRectangle: new Rectangle(Level.Map.MapWidth,
0, StaticUIValues.BorderWidth, (int)StaticUIValues.ScreenViewport.Y));
-
-
+
//border under text
Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"),
destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4,
- StaticUIValues.IngameUITextAreaHeight, StaticUIValues.IngameUIWidth, StaticUIValues.BorderWidth));
+ StaticUIValues.IngameUITextAreaHeight, (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth));
+
+ //border above options
+ Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"),
+ destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4,
+ (int)StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth,
+ (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth));
//border above button
Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"),
destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4,
(int)StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth,
- StaticUIValues.IngameUIWidth, StaticUIValues.BorderWidth));
+ (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth));
DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), "Gold: " + Level.Money,
new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, 10),
@@ -98,6 +142,9 @@ namespace Penguloon.Scenes
{
base.Update(deltaTime, touchLocations);
StartRoundBtn.Update(deltaTime, touchLocations);
+ ObjectSeletor.Update(deltaTime, touchLocations);
+ ChangeSpeedBtn.Update(deltaTime, touchLocations);
+ OptionsBtn.Update(deltaTime, touchLocations);
}
if (StartRoundBtn.ControlState == ControlState.Disabled && !Level.Map.WaveManager.RoundActive && !Level.Finished)
@@ -106,7 +153,7 @@ namespace Penguloon.Scenes
Level.Map.WaveManager.FinishRound();
}
- this.Level.Update(deltaTime, touchLocations);
+ this.Level.Update(deltaTime * Speed, touchLocations);
}
}
} \ No newline at end of file