FINAL JAM COMMIT
This commit is contained in:
@@ -8,9 +8,11 @@ public partial class GameController : Node
|
||||
[Export] private float _ShrineStartHP;
|
||||
[Export] private Label _CurrencyLabel;
|
||||
[Export] private Label _ShrineHealthLabel;
|
||||
[Export] private Label _scoreLabel;
|
||||
|
||||
public int Wave { get; private set; }
|
||||
public int Currency { get; private set; }
|
||||
public int Score { get; private set; }
|
||||
public float ShrineHealth { get; private set; }
|
||||
|
||||
private bool _waveOnGoing = false;
|
||||
@@ -20,10 +22,11 @@ public partial class GameController : Node
|
||||
GameController.Instance = this;
|
||||
Wave = 0;
|
||||
Currency = 300;
|
||||
ShrineHealth = 100;
|
||||
|
||||
ShrineHealth = _ShrineStartHP;
|
||||
|
||||
_CurrencyLabel.Text = Currency.ToString();
|
||||
_ShrineHealthLabel.Text = $"{(100f * (ShrineHealth /_ShrineStartHP)):F1}%";
|
||||
_scoreLabel.Text = "0";
|
||||
|
||||
CallDeferred(nameof(DelayNextWave));
|
||||
}
|
||||
@@ -34,12 +37,7 @@ public partial class GameController : Node
|
||||
Wave++;
|
||||
_waveOnGoing = true;
|
||||
|
||||
int amountToSpawn = (int)Math.Round(5 * Math.Pow(Wave, 1.05));
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
// GD.Print((int)Math.Round(5 * Math.Pow(i + 1, 1.05)));
|
||||
}
|
||||
int amountToSpawn = (int)Math.Round(5 * Math.Pow(Wave, 1.025));
|
||||
|
||||
EnemySpawner.Instance.EnemiesSpawned = amountToSpawn;
|
||||
|
||||
@@ -73,7 +71,7 @@ public partial class GameController : Node
|
||||
_ShrineHealthLabel.Text = $"{(100f * (ShrineHealth /_ShrineStartHP)):F1}%";
|
||||
if (ShrineHealth <= 0)
|
||||
{
|
||||
// TODO LOSE SCENARIO
|
||||
SceneManager.Instance.ChangeScene(Scenes.End);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +79,8 @@ public partial class GameController : Node
|
||||
{
|
||||
v = Math.Abs(v);
|
||||
Currency += v;
|
||||
Score += v;
|
||||
_scoreLabel.Text = Score.ToString();
|
||||
_CurrencyLabel.Text = Currency.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PauseManager : Node
|
||||
{
|
||||
[Export] private CanvasLayer _hud;
|
||||
[Export] private CanvasLayer _pauseMenu;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Input.IsActionJustPressed("pause"))
|
||||
{
|
||||
bool paused = GetTree().Paused;
|
||||
if (!paused)
|
||||
{
|
||||
PauseGame();
|
||||
return;
|
||||
}
|
||||
ContinueGame();
|
||||
}
|
||||
}
|
||||
|
||||
public void PauseGame()
|
||||
{
|
||||
GetTree().Paused = true;
|
||||
_hud.Visible = false;
|
||||
_pauseMenu.Visible = true;
|
||||
}
|
||||
|
||||
public void ContinueGame()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
_hud.Visible = true;
|
||||
_pauseMenu.Visible = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ch2o7voah6o3o
|
||||
@@ -0,0 +1,84 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public enum Scenes
|
||||
{
|
||||
Menu,
|
||||
Game,
|
||||
End
|
||||
}
|
||||
|
||||
public partial class SceneManager : Node
|
||||
{
|
||||
public static SceneManager Instance;
|
||||
|
||||
[Export] private Node _root;
|
||||
|
||||
[Export] private PackedScene _gameScene;
|
||||
[Export] private PackedScene _menuScene;
|
||||
[Export] private PackedScene _endScene;
|
||||
|
||||
private Node _game;
|
||||
private Node _menu;
|
||||
private Node _end;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
CallDeferred(nameof(EnterMenu));
|
||||
}
|
||||
|
||||
public void ChangeScene(Scenes s)
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
switch (s)
|
||||
{
|
||||
case Scenes.Menu:
|
||||
EnterMenu();
|
||||
break;
|
||||
case Scenes.Game:
|
||||
EnterGame();
|
||||
break;
|
||||
case Scenes.End:
|
||||
EnterEnd();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(s), s, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterMenu()
|
||||
{
|
||||
RemoveScene(ref _game);
|
||||
RemoveScene(ref _end);
|
||||
AddScene(ref _menuScene, ref _menu);
|
||||
}
|
||||
|
||||
private void EnterGame()
|
||||
{
|
||||
RemoveScene(ref _menu);
|
||||
RemoveScene(ref _end);
|
||||
AddScene(ref _gameScene, ref _game);
|
||||
}
|
||||
|
||||
private void EnterEnd() // Not the Minecraft
|
||||
{
|
||||
RemoveScene(ref _game);
|
||||
RemoveScene(ref _menu);
|
||||
AddScene(ref _endScene, ref _end);
|
||||
}
|
||||
|
||||
private void RemoveScene(ref Node n)
|
||||
{
|
||||
if (n == null) return;
|
||||
n.GetParent()?.RemoveChild(n);
|
||||
n.QueueFree();
|
||||
n = null;
|
||||
}
|
||||
|
||||
private void AddScene(ref PackedScene s, ref Node n)
|
||||
{
|
||||
n = s.Instantiate();
|
||||
_root.AddChild(n);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bmdb22du7uvr1
|
||||
Reference in New Issue
Block a user