Files
GameJam2023/UI/MainMenu.cs

54 lines
1.4 KiB
C#

using Godot;
public partial class MainMenu : Node2D
{
private AnimationPlayer _animationPlayer;
[Signal]
public delegate void IntroAnimationsCompletedEventHandler();
private PlayerInput _player1Input;
private PlayerInput _player2Input;
public override void _Ready()
{
GetParent().GetNode<TextureRect>("MainMenu/UIAnimations/LoreSplash").Show();
_animationPlayer = GetTree().Root.GetNode<AnimationPlayer>("/root/Main/MainMenu/UIAnimations/AnimationPlayer");
_animationPlayer.Queue("IntroLore");
var bgmPlayer = GetTree().Root.GetNode<BGMPlayer>("BgmPlayer");
bgmPlayer.SetBGMFromFilepath("Audio/BGM/TitleTheme.ogg");
bgmPlayer.PlayBGM();
_player1Input = new Player1Input();
_player2Input = new Player2Input();
}
public override void _UnhandledInput(InputEvent @event)
{
if (Input.IsActionJustPressed(_player1Input.Fire()) || Input.IsActionJustPressed(_player2Input.Fire()))
{
_animationPlayer.Seek(10);
}
}
private void OneSinglePlayerPressed()
{
Hide();
var main = GetTree().Root.GetNode<Main>("/root/Main");
main.LoadLevel(0, 1);
}
private void OnTwoPlayerPressed()
{
Hide();
var main = GetTree().Root.GetNode<Main>("/root/Main");
main.LoadLevel(0, 2);
}
private void OnQuitButtonPressed()
{
GetTree().Quit();
}
}