diff options
Diffstat (limited to 'Penguloon/Scenes/GameScene.cs')
| -rw-r--r-- | Penguloon/Scenes/GameScene.cs | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/Penguloon/Scenes/GameScene.cs b/Penguloon/Scenes/GameScene.cs index 406e784..14c2d96 100644 --- a/Penguloon/Scenes/GameScene.cs +++ b/Penguloon/Scenes/GameScene.cs @@ -10,25 +10,23 @@ namespace Penguloon.Scenes { public LevelBase Level { get; set; } - public bool RoundActive { get; set; } = false; + public Button StartRoundBtn { get; set; } public GameScene(Main main, LevelBase level) : base(main) { this.Level = level; this.Level.Initialize(this); - Button StartRoundBtn = new Button(this, - new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - 120), - new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), 120), "Start"); + StartRoundBtn = new Button(this, + new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - 120), + new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), 120), "Start"); StartRoundBtn.OnClick += StartRoundBtn_OnClick; - - Controls.Add(StartRoundBtn); } private void StartRoundBtn_OnClick(object sender, ClickArgs e) { - RoundActive = true; + Level.Map.WaveManager.StartSpawningEnemies(); Button btn = (Button)sender; btn.ControlState = ControlState.Disabled; } @@ -46,17 +44,37 @@ namespace Penguloon.Scenes base.Draw(deltaTime); + StartRoundBtn.Draw(deltaTime); + this.Level.Draw(deltaTime); + DrawUI(deltaTime); + } + + private void DrawUI(float deltaTime) + { Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"), - destinationRectangle: new Rectangle(Level.Map.MapWidth, - 0, StaticUIValues.BorderWidth, (int)StaticUIValues.ScreenViewport.Y)); + destinationRectangle: new Rectangle(Level.Map.MapWidth, + 0, StaticUIValues.BorderWidth, (int)StaticUIValues.ScreenViewport.Y)); + + DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), "Wave: " + Level.Map.WaveManager.CurrentWave.ToString(), + new Vector2(StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth, 10), + new Vector2(StaticUIValues.IngameUIWidth, 200), + TextAllignment.CenterTop, Color.White, Color.Black, 2); } public override void Update(float deltaTime, TouchLocation[] touchLocations) { base.Update(deltaTime, touchLocations); + StartRoundBtn.Update(deltaTime, touchLocations); + + if (StartRoundBtn.ControlState == ControlState.Disabled && !Level.Map.WaveManager.RoundActive) + { + StartRoundBtn.ControlState = ControlState.Idle; + Level.Map.WaveManager.FinishRound(); + } + this.Level.Update(deltaTime, touchLocations); } } |
