Trying to fix spawn issues
This commit is contained in:
@@ -16,12 +16,17 @@ public partial class AreaExit : Node3D
|
||||
|
||||
private void OnExitEntered(Node3D node)
|
||||
{
|
||||
if (node.GetType() == typeof(Character1))
|
||||
_gameManager.RemoveCharacterAndAddToExit((Character1)node);
|
||||
if (node.GetType() == typeof(Character2))
|
||||
_gameManager.RemoveCharacterAndAddToExit((Character2)node);
|
||||
if (node is Character)
|
||||
{
|
||||
if (node.GetType() == typeof(Character1))
|
||||
_gameManager.RemoveCharacterAndAddToExit((Character1)node);
|
||||
if (node.GetType() == typeof(Character2))
|
||||
_gameManager.RemoveCharacterAndAddToExit((Character2)node);
|
||||
|
||||
if (!_gameManager.Players.Any(x => x.CharactersLeftOnStage.Any()))
|
||||
_gameManager.OnLevelClear();
|
||||
GD.Print("Exit reached");
|
||||
|
||||
if (!_gameManager.Players.Any(x => x.CharactersLeftOnStage.Any()))
|
||||
_gameManager.OnLevelClear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,19 +36,6 @@ public partial class GameManager : Node
|
||||
public void OnAllEnemiesDefeated()
|
||||
{
|
||||
GD.Print("All enemies defeated");
|
||||
//var remainingCharacters = Players.ElementAt(0).CharactersLeftOnStage;
|
||||
|
||||
//foreach (var player in remainingCharacters)
|
||||
// RemoveCharacterAndAddToExit((Character1)player);
|
||||
|
||||
//if (Players.Count() == 2)
|
||||
//{
|
||||
// var remainingPlayers2 = Players.ElementAt(1).CharactersLeftOnStage;
|
||||
|
||||
// foreach (var player in remainingPlayers2)
|
||||
// RemoveCharacterAndAddToExit((Character2)player);
|
||||
//}
|
||||
|
||||
OnLevelClear();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ public partial class Main : Node
|
||||
gameManagerInstance.OnHandleCharacterSelectUI(gameManagerInstance.Players.ElementAt(0));
|
||||
if (numberOfPlayers == 2)
|
||||
gameManagerInstance.OnHandleCharacterSelectUI(gameManagerInstance.Players.ElementAt(1));
|
||||
|
||||
GetTree().Paused = true;
|
||||
}
|
||||
|
||||
public void LoadNextLevel(int currentSceneIndex)
|
||||
@@ -42,6 +44,7 @@ public partial class Main : Node
|
||||
var nextScene = GD.Load<PackedScene>(sceneToAdd.ResourcePath);
|
||||
var newScene = nextScene.Instantiate();
|
||||
GetTree().Root.AddChild(newScene);
|
||||
GetTree().Paused = true;
|
||||
}
|
||||
|
||||
private void DeferredGoToScene(PackedScene sceneToAdd, PackedScene sceneToRemove)
|
||||
@@ -50,5 +53,6 @@ public partial class Main : Node
|
||||
var nextScene = GD.Load<PackedScene>(sceneToAdd.ResourcePath);
|
||||
var newScene = nextScene.Instantiate();
|
||||
GetTree().Root.AddChild(newScene);
|
||||
GetTree().Paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using static Godot.Projection;
|
||||
|
||||
public partial class StageGUI : Control
|
||||
{
|
||||
@@ -37,41 +38,39 @@ public partial class StageGUI : Control
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var playersCurrentlySelecting = _gameManager.Players.Where(x => x.IsSelectingCharacter);
|
||||
foreach (var player in playersCurrentlySelecting)
|
||||
if (_gameManager.Players.ElementAt(0).IsSelectingCharacter)
|
||||
{
|
||||
if (player == _gameManager.Players.ElementAt(0))
|
||||
{
|
||||
if (Input.IsActionJustPressed("p1_right"))
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(0));
|
||||
if (Input.IsActionJustPressed("p1_left"))
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(0));
|
||||
if (Input.IsActionJustPressed("p1_right"))
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(0));
|
||||
if (Input.IsActionJustPressed("p1_left"))
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(0));
|
||||
|
||||
if (Input.IsActionJustPressed("p1_fire"))
|
||||
{
|
||||
GD.Print("Selected character");
|
||||
_gameManager.Players.ElementAt(0).IsSelectingCharacter = false;
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
wheel1.Hide();
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(0));
|
||||
}
|
||||
if (Input.IsActionJustPressed("p1_fire"))
|
||||
{
|
||||
GD.Print("Selected character");
|
||||
_gameManager.Players.ElementAt(0).IsSelectingCharacter = false;
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
wheel1.Hide();
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(0));
|
||||
GetTree().Paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_gameManager.Players.Count() == 2 && player == _gameManager.Players.ElementAt(1))
|
||||
if (_gameManager.Players.Count() == 2 && _gameManager.Players.ElementAt(0).IsSelectingCharacter)
|
||||
{
|
||||
if (Input.IsActionJustPressed("p2_right"))
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(1));
|
||||
if (Input.IsActionJustPressed("p2_left"))
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(1));
|
||||
|
||||
if (Input.IsActionJustPressed("p2_fire"))
|
||||
{
|
||||
if (Input.IsActionJustPressed("p2_right"))
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(1));
|
||||
if (Input.IsActionJustPressed("p2_left"))
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(1));
|
||||
|
||||
if (Input.IsActionJustPressed("p2_fire"))
|
||||
{
|
||||
GD.Print("Selected character");
|
||||
_gameManager.Players.ElementAt(1).IsSelectingCharacter = false;
|
||||
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
|
||||
wheel2.Hide();
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(1));
|
||||
}
|
||||
GD.Print("Selected character");
|
||||
_gameManager.Players.ElementAt(1).IsSelectingCharacter = false;
|
||||
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
|
||||
wheel2.Hide();
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(1));
|
||||
GetTree().Paused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user