diff options
| author | aldrikboy <aldrikboy@gmail.com> | 2017-12-12 18:27:50 +0100 |
|---|---|---|
| committer | aldrikboy <aldrikboy@gmail.com> | 2017-12-12 18:27:50 +0100 |
| commit | 60e8e48047e774a711fee35dfc58a7be993c3d88 (patch) | |
| tree | 272285ccd8730960db823d83e42d4985d34db69a /Penguloon/Scenes/GameScene.cs | |
| parent | b0a3f57a68a39c2b027158cdfc9384ddb84dfa38 (diff) | |
yos
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); } } |
