Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respawn feature #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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