Skip to content

Conversation

@HarounAmor
Copy link

The following code adds the function to the button when clicked

// Add a function to the continue button
ContinueButton.SetButtonAction(() =>
{
// Remove 50 gold when the player clicks the button
GameManager.Singleton.m_Coin.Value -= 50;
GameManager.Singleton.RespawnMainCharacter();
var ingameScreen = UIManager.Singleton.GetUIScreen(UIScreenInfo.IN_GAME_SCREEN);
UIManager.Singleton.OpenScreen(ingameScreen);
GameManager.Singleton.StartGame();
}
);

When the button is clicked, it uses the built-in reset function to respawn the player using the RespawnMainCharacter() function. It also subtracts 50 coins and closes the menu with StartGame()

The code below that just checks to see if the player has 50 coins and if so, set the button to active.

The following code adds the function to the button when clicked

// Add a function to the continue button
ContinueButton.SetButtonAction(() =>
{
// Remove 50 gold when the player clicks the button
GameManager.Singleton.m_Coin.Value -= 50;
GameManager.Singleton.RespawnMainCharacter();
var ingameScreen = UIManager.Singleton.GetUIScreen(UIScreenInfo.IN_GAME_SCREEN);
UIManager.Singleton.OpenScreen(ingameScreen);
GameManager.Singleton.StartGame();
}
);

When the button is clicked, it uses the built-in reset function to respawn the player using the RespawnMainCharacter() function. It also subtracts 50 coins and closes the menu with StartGame()

The code below that just checks to see if the player has 50 coins and if so, set the button to active.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant