Fix spawn location and on hit
This commit is contained in:
@@ -2,4 +2,8 @@ using Godot;
|
||||
|
||||
public partial class Character : CharacterBody3D
|
||||
{
|
||||
public void OnHit(Node3D node)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,14 @@ public partial class GameManager : Node
|
||||
{
|
||||
var player = playerScene.Instantiate();
|
||||
Players = Players.Append((Player)player);
|
||||
GD.Print("Players added");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnHandleCharacterSelectUI(Player player)
|
||||
{
|
||||
EmitSignal(SignalName.ReselectCharacter, player);
|
||||
}
|
||||
|
||||
public void SetToNextCharacter(Player player) => _characterIndex = (++_characterIndex) % player.PlayableCharacters.Count();
|
||||
|
||||
public void SetToPreviousCharacter(Player player) => _characterIndex = _characterIndex == 0 ? player.PlayableCharacters.Count() - 1 : --_characterIndex;
|
||||
|
||||
@@ -9,12 +9,18 @@ public partial class Main : Node
|
||||
[Export]
|
||||
public PackedScene GameManager;
|
||||
|
||||
public void LoadLevel(int indexToLoad)
|
||||
public void LoadLevel(int indexToLoad, int numberOfPlayers)
|
||||
{
|
||||
var sceneToLoad = Levels.ElementAt(indexToLoad);
|
||||
CallDeferred(nameof(DeferredGoToScene), sceneToLoad);
|
||||
var gameManager = GameManager.Instantiate();
|
||||
AddChild(gameManager);
|
||||
var gameManagerInstance = (GameManager)gameManager;
|
||||
|
||||
gameManagerInstance.OnHandleCharacterSelectUI(gameManagerInstance.Players.ElementAt(0));
|
||||
|
||||
if (numberOfPlayers == 2)
|
||||
gameManagerInstance.OnHandleCharacterSelectUI(gameManagerInstance.Players.ElementAt(1));
|
||||
}
|
||||
|
||||
public void LoadNextLevel(int currentSceneIndex)
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Linq;
|
||||
|
||||
public partial class MainMenu : Node2D
|
||||
{
|
||||
private AnimationPlayer _player;
|
||||
private AnimationPlayer _animationPlayer;
|
||||
|
||||
[Signal]
|
||||
public delegate void IntroAnimationsCompletedEventHandler();
|
||||
@@ -11,26 +11,42 @@ public partial class MainMenu : Node2D
|
||||
public override void _Ready()
|
||||
{
|
||||
GetParent().GetNode<TextureRect>("MainMenu/UIAnimations/LoreSplash").Show();
|
||||
_player = GetTree().Root.GetNode<AnimationPlayer>("/root/Main/MainMenu/UIAnimations/AnimationPlayer");
|
||||
_player.Queue("IntroLore");
|
||||
_animationPlayer = GetTree().Root.GetNode<AnimationPlayer>("/root/Main/MainMenu/UIAnimations/AnimationPlayer");
|
||||
_animationPlayer.Queue("IntroLore");
|
||||
var bgmPlayer = GetTree().Root.GetNode<BGMPlayer>("BgmPlayer");
|
||||
bgmPlayer.SetBGMFromFilepath("Audio/BGM/titlemusic.wav");
|
||||
bgmPlayer.PlayBGM();
|
||||
}
|
||||
|
||||
private void OnStartButtonPressed()
|
||||
private void OnSinglePlayerPressed()
|
||||
{
|
||||
_player.Play("FirstLevel");
|
||||
_animationPlayer.Play("FirstLevel");
|
||||
Hide();
|
||||
_player.AnimationFinished += OnAnimationFinished;
|
||||
_animationPlayer.AnimationFinished += OnAnimationFinishedCallSinglePlayerStart;
|
||||
}
|
||||
|
||||
private void OnAnimationFinished(StringName animationName)
|
||||
private void OnAnimationFinishedCallSinglePlayerStart(StringName animationName)
|
||||
{
|
||||
if (animationName == "FirstLevel")
|
||||
{
|
||||
var main = GetTree().Root.GetNode<Main>("/root/Main");
|
||||
main.LoadLevel(7);
|
||||
main.LoadLevel(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTwoPlayerPressed()
|
||||
{
|
||||
_animationPlayer.Play("FirstLevel");
|
||||
Hide();
|
||||
_animationPlayer.AnimationFinished += OnAnimationFinishedCallTwoPlayerStart;
|
||||
}
|
||||
|
||||
private void OnAnimationFinishedCallTwoPlayerStart(StringName animationName)
|
||||
{
|
||||
if (animationName == "FirstLevel")
|
||||
{
|
||||
var main = GetTree().Root.GetNode<Main>("/root/Main");
|
||||
main.LoadLevel(0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,16 @@ public partial class StageGUI : Control
|
||||
if (_gameManager.IsGameOver)
|
||||
return;
|
||||
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
|
||||
|
||||
if (player == _gameManager.Players.ElementAt(0))
|
||||
{
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
wheel1.FocusMode = FocusModeEnum.All;
|
||||
wheel1.GrabFocus();
|
||||
wheel1.Visible = true;
|
||||
}
|
||||
else if (player == _gameManager.Players.ElementAt(1))
|
||||
{
|
||||
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
|
||||
wheel2.FocusMode = FocusModeEnum.All;
|
||||
wheel2.GrabFocus();
|
||||
wheel2.Visible = true;
|
||||
|
||||
Reference in New Issue
Block a user