protected override void DoGUI() { Invitation inv = InvitationManager.Instance.Invitation; if (inv == null) { gameObject.GetComponent <MainMenuGui>().MakeActive(); return; } string inviterName = null; inviterName = (inv.Inviter == null || inv.Inviter.DisplayName == null) ? "Someone" : inv.Inviter.DisplayName; GuiLabel(CenterLabelCfg, inviterName + " is challenging you to a quiz race!"); if (GuiButton(AcceptButtonCfg)) { InvitationManager.Instance.Clear(); RaceManager.AcceptInvitation(inv.InvitationId); gameObject.GetComponent <RaceGui>().MakeActive(); } else if (GuiButton(DeclineButtonCfg)) { InvitationManager.Instance.DeclineInvitation(); gameObject.GetComponent <MainMenuGui>().MakeActive(); } }
// Handle detecting incoming invitations. public void UpdateInvitation() { if (InvitationManager.Instance == null) { return; } // if an invitation arrived, switch to the "invitation incoming" GUI // or directly to the game, if the invitation came from the notification Invitation inv = InvitationManager.Instance.Invitation; if (inv != null) { if (InvitationManager.Instance.ShouldAutoAccept) { // jump straight into the game, since the user already indicated // they want to accept the invitation! InvitationManager.Instance.Clear(); RaceManager.AcceptInvitation(inv.InvitationId); NavigationUtil.ShowPlayingPanel(); } else { // show the "incoming invitation" screen NavigationUtil.ShowInvitationPanel(); } } }
// Handler script for the Accept button. This method should be added // to the On Click list for the accept button. public void OnAccept() { if (processed) { return; } processed = true; InvitationManager.Instance.Clear(); RaceManager.AcceptInvitation(inv.InvitationId); Debug.Log("Accepted! RaceManager state is now " + RaceManager.Instance.State); }
public void Update() { // if an invitation arrived, switch to the "invitation incoming" GUI // or directly to the game, if the invitation came from the notification Invitation inv = InvitationManager.Instance.Invitation; if (inv != null) { if (InvitationManager.Instance.ShouldAutoAccept) { // jump straight into the game, since the user already indicated // they want to accept the invitation! InvitationManager.Instance.Clear(); RaceManager.AcceptInvitation(inv.InvitationId); gameObject.GetComponent <RaceGui>().MakeActive(); } else { // show the "incoming invitation" screen gameObject.GetComponent <IncomingInvitationGui>().MakeActive(); } } }