// This method is by Urho and controls the game being on the page protected override async void OnAppearing() { base.OnAppearing(); GameApp game = await surfaceGame.Show <GameApp>(new Urho.ApplicationOptions(assetsFolder: "GameData") { ResizableWindow = true, AdditionalFlags = $"{hardcore.ToString()},{continueGame.ToString()},{charClass.ToString()},{cheat.ToString()}" }); // This method is passed into the game and will be called on restart game.Restart = () => { Device.BeginInvokeOnMainThread(async() => { await game.Exit(); App.Current.MainPage = new MainPage(); App.Utilities.SetFullscreen(); }); return(false); }; // This method is passed into the game and will be called on win game.HandleWin = () => { int score = game.PlayerCharacter.Score; bool isHighscore = HighScoresManager.CheckScore(score); // Exit game Device.BeginInvokeOnMainThread(async() => { await game.Exit(); App.Current.MainPage = new Win(score, isHighscore); App.Utilities.SetFullscreen(); }); return(false); }; // This method is passed into the game and will be called on lose game.HandleLose = () => { Device.BeginInvokeOnMainThread(async() => { await game.Exit(); App.Current.MainPage = new Lose(); App.Utilities.SetFullscreen(); }); return(false); }; // Load saved game if (continueGame) { game.Load("latest.txt"); } }
//===================================================== void Awake() { instance = this; m_bScoresDownloaded = false; m_Timer = 0.0f; m_bIsWaitingForFacebookLogin = false; m_bIsWaitingForTwitterLogin = false; m_bIsWaitingForTwitterShare = false; }
void Awake() { if (deadMenu == null) { deadMenu = GetComponentInParent <UIDeadMenu>(); } highScoresManager = GameController.Instance.GetComponent <HighScoresManager>(); if (!highScoresManager.CanBeAdded(GetCurrentScore())) { ProceedToMainMenu(); } }
private void OnEnable() { ClearList(); HighScore[] scores = HighScoresManager.LoadScores(); bool hasScores = scores.Length > 0; noScoresLabel.gameObject.SetActive(!hasScores); for (int i = 0; i < scores.Length; i++) { CreateEntry(i, scores[i]); } }
public void PlayerWon() { PlayerState = PlayerStates.WON; pauseMenu.PlayerWon(); bool highScore = HighScoresManager.SaveScore( level.State.SitesDestroyed, level.State.TanksDestroyed, level.State.Deaths ); if (highScore) { pauseMenu.ShowNewHighScore(); } }
// Event handler for completion of name entry // Adds score to the leaderboard and takes them to HighScoresPage private void EntName_Completed(object sender, EventArgs e) { HighScoresManager.AddHighScore(entName.Text, score); App.Current.MainPage = new HighScoresPage(); }
public HighScoresPage() { InitializeComponent(); scores = HighScoresManager.ReadScores(); ShowHighScores(); }
void Awake() { highScoreManager = GameController.Instance.GetComponent <HighScoresManager>(); displayEntriesCount = Mathf.Min(displayEntriesCount, highScoreManager.maxEntries); }
public HighScoresView() { InitializeComponent(); ScoresTable = new HighScoresManager(ScoresTableSize); StackLayout HighscoresLayout = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, }; HighscoresLayout.Children.Add(new Label { Text = "Hall of Fame:", FontAttributes = FontAttributes.Bold, FontSize = 15 }); StackLayout ScoresTableLayout = new StackLayout(); ScoresTableLayout.HorizontalOptions = LayoutOptions.CenterAndExpand; int scoreNumber = 1; foreach (HighScore score in ScoresTable.Scores) { Image crownImage = new Image(); crownImage.HorizontalOptions = LayoutOptions.CenterAndExpand; crownImage.VerticalOptions = LayoutOptions.CenterAndExpand; if (scoreNumber <= 3) { crownImage.Source = "crown" + scoreNumber + ".png"; scoreNumber++; } Label nameLabel = new Label(); Label valueLabel = new Label(); nameLabel.BindingContext = score; valueLabel.BindingContext = score; nameLabel.SetBinding(Label.TextProperty, "Name"); valueLabel.SetBinding(Label.TextProperty, "Value"); nameLabel.HorizontalTextAlignment = TextAlignment.Start; valueLabel.HorizontalTextAlignment = TextAlignment.End; StackLayout imageLayout = new StackLayout(); imageLayout.WidthRequest = 30; imageLayout.HeightRequest = 30; imageLayout.HorizontalOptions = LayoutOptions.CenterAndExpand; imageLayout.VerticalOptions = LayoutOptions.CenterAndExpand; StackLayout nameLayout = new StackLayout(); nameLayout.HorizontalOptions = LayoutOptions.StartAndExpand; nameLayout.Padding = new Thickness(0, 0, 80, 0); nameLayout.HorizontalOptions = LayoutOptions.StartAndExpand; nameLayout.VerticalOptions = LayoutOptions.CenterAndExpand; StackLayout valueLayout = new StackLayout(); valueLayout.HorizontalOptions = LayoutOptions.EndAndExpand; valueLayout.VerticalOptions = LayoutOptions.CenterAndExpand; imageLayout.Children.Add(crownImage); nameLayout.Children.Add(nameLabel); valueLayout.Children.Add(valueLabel); StackLayout scoreLayout = new StackLayout(); scoreLayout.Orientation = StackOrientation.Horizontal; scoreLayout.Children.Add(imageLayout); scoreLayout.Children.Add(nameLayout); scoreLayout.Children.Add(valueLayout); ScoresTableLayout.Children.Add(scoreLayout); } HighscoresLayout.Children.Add(ScoresTableLayout); Content = HighscoresLayout; LoadScores(); }