예제 #1
0
            /// <summary>
            /// Shows an alert dialog with 2 buttons.
            /// </summary>
            /// <returns>The two buttons alert.</returns>
            /// <param name="title">Title.</param>
            /// <param name="message">Message.</param>
            /// <param name="button1">Button1.</param>
            /// <param name="button2">Button2.</param>
            internal static AlertPopup ShowTwoButtonAlert(string title, string message, string button1, string button2)
            {
                #if UNITY_EDITOR
                Debug.Log("Show 2-button alert with message: " + message);
                return(null);
                #elif UNITY_IOS
                if (Instance != null)
                {
                    return(null);    // only allow one alert at a time
                }
                // Create a Unity game object to receive messages from native side
                Instance = new GameObject(ALERT_GAMEOBJECT).AddComponent <AlertPopup>();

                // Show iOS 2-button alert
                iOSNativeAlert.ShowTwoButtonsAlert(title, message, button1, button2);

                return(Instance);
                #elif UNITY_ANDROID
                if (Instance != null)
                {
                    return(null); // only allow one alert at a time
                }
                // Create a Unity game object to receive messages from native side
                Instance = new GameObject(ALERT_GAMEOBJECT).AddComponent <AlertPopup>();

                // Show Android 2-button alert
                AndroidNativeAlert.ShowTwoButtonsAlert(title, message, button1, button2);

                return(Instance);
                #else
                Debug.Log("Native alert is not supported on this platform.");
                return(null);
                #endif
            }
예제 #2
0
//TODO
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
        //FOLLOWING METHODS SHOULD BE IMPLEMENTED ELSEWHERE
//TODO

//STATICS

        public static AlertPopup ShowChallengePopup(string title, string message, Action callbackYes, Action callbackNo)
        {
            AlertPopup alert = null;

            Action OnAcceptButtonAction = () => {
                callbackYes();
                alert.ScheduleCloseButtonPressed(-1);
                M3Utils.Instance.CloseAllPopups();
            };

            Action OnDeclineButtonAction = () => {
                callbackNo();
                alert.ScheduleCloseButtonPressed(-1);
                alert.HideAndDestroy();
            };

            alert = AlertPopup.GetAlertPopup(AlertPopup.PopupType.Normal,
                                             title,
                                             message,
                                             LocalizationManager.Instance.GetString(LocalizationKeys.ACCEPT),
                                             LocalizationManager.Instance.GetString(LocalizationKeys.DECLINE),
                                             OnAcceptButtonAction,
                                             OnDeclineButtonAction,
                                             OnDeclineButtonAction,
                                             true, true);

            alert.ScheduleCloseButtonPressed(Mathf.Clamp(ServerConfigurableValues.Instance.BattleChallengeRoomWait, 10, ServerConfigurableValues.Instance.LoadingFailureTime - 5));
            alert.Show();
            return(alert);
        }
예제 #3
0
        protected void DoTryToJoinRoomWithUserId(string userId)
        {
            UserProfile up = GameState.Instance.Player.profile;

            if (up.UserId == userId) //Challenging self
            //why'd you like to do that?
            {
                Helpers.Utility.LogMessage("DoTryToJoinRoomWithUserId: Challenging own user?? Why would someone do that?" + this.GetType().ToString());
                popup = EventListenerForPrivateChallenge.ShowCannotChallengeSelfPopup(up.Nick);
                StateMachine.Instance.MakeTransition(typeof(StateWaitForChallenge));
            }
            else
            {
                if (ConnectionController.Instance.insideLobby)
                {
                    DoSearch(userId);
                }
                else
                {
                    joinLobbyAfterLeave  = true;
                    searchAfterJoinLobby = true;
                    ConnectionController.Instance.LeaveRoom();
                }
            }
        }
예제 #4
0
        void _onPhotonRandomJoinFailed(object[] codeAndMsg)
        {
            if (UserPrefHelper.IsLogEnabled)
            {
                Helpers.Utility.LogMessage(this.GetType().ToString(), "_onPhotonRandomJoinedFailed", codeAndMsg[0] + " " + codeAndMsg[1]);
            }

            System.Action HideVersusScreen = () => {
                DoHideVersusScreen();
            };

            string code = codeAndMsg[0].ToString();

            switch (code)
            {
            case M3Constants.PUN_ERROR_CODE_SLOT_EXCEED_MAX_PLAYERS:
            case M3Constants.PUN_ERROR_CODE_EXPECTED_USERS:
            case M3Constants.PUN_ERROR_CODE_GAME_CLOSED:
            case M3Constants.PUN_ERROR_CODE_GAME_FULL:
            case M3Constants.PUN_ERROR_CODE_USER_NOT_EXPECTED:
            case M3Constants.PUN_ERROR_CODE_USER_EXCLUDED:
                //This user was not expected to Join
                popup = EventListenerForPrivateChallenge.ShowUserIsBusyPopup(privateChallengeArgs.OpponentNickName, HideVersusScreen);
                break;

            case M3Constants.PUN_ERROR_CODE_NO_RANDOM_MATCH:
            case M3Constants.PUN_ERROR_CODE_ROOM_DOESNT_EXIST:
            default:
                popup = EventListenerForPrivateChallenge.ShowUserIsNotAvailablePopup(privateChallengeArgs.OpponentNickName, HideVersusScreen);

                break;
            }

            DoGoBackToWaitState();
        }
예제 #5
0
 private void WillReset()
 {
     this.m_dialog = null;
     this.ClearReconnectData();
     this.m_timeoutListeners.Clear();
     this.m_pendingReconnectNotice = null;
 }
예제 #6
0
 private void HideDialog()
 {
     if (this.m_dialog != null)
     {
         this.m_dialog.Hide();
         this.m_dialog = null;
     }
 }
예제 #7
0
 public void HideFriendChallengeWaitingForOpponentDialog()
 {
     if (this.m_friendChallengeWaitingPopup != null)
     {
         this.m_friendChallengeWaitingPopup.Hide();
         this.m_friendChallengeWaitingPopup = null;
     }
 }
예제 #8
0
 private bool OnGameplayDialogProcessed(DialogBase dialog, object userData)
 {
     this.m_dialog = (AlertPopup)dialog;
     SceneMgr.Mode mode = (SceneMgr.Mode)((int)userData);
     SceneMgr.Get().SetNextMode(mode);
     SceneMgr.Get().RegisterSceneLoadedEvent(new SceneMgr.SceneLoadedCallback(this.OnSceneLoaded));
     return(true);
 }
예제 #9
0
        public async Task ShowSuccessMessageAsync(string message, string acceptButtonText)
        {
            var tcs   = new TaskCompletionSource <bool>();
            var alert = new AlertPopup(tcs, NotificationType.Success, message, acceptButtonText);
            await PopupNavigation.PushAsync(alert);

            await tcs.Task;
            await PopupNavigation.RemovePageAsync(alert);
        }
예제 #10
0
    public override void Unload()
    {
        base.Unload();

        AlertPopup.OkClicked     -= OnOkClicked;
        AlertPopup.CancelClicked -= OnCancelClicked;

        AlertPopup.Hide();
    }
예제 #11
0
        /// <summary>
        /// Shows the error list async.
        /// </summary>
        /// <returns>The error list async.</returns>
        /// <param name="errorList">Error list.</param>
        /// <param name="acceptButtonText">Accept button text.</param>
        public async Task ShowErrorListAsync(IList <string> errorList, string acceptButtonText)
        {
            var tcs   = new TaskCompletionSource <bool>();
            var alert = new AlertPopup(tcs, NotificationType.Error, ToErrorString(errorList), acceptButtonText);
            await PopupNavigation.PushAsync(alert);

            await tcs.Task;
            await PopupNavigation.RemovePageAsync(alert);
        }
예제 #12
0
            public void Release()
            {
                // Release the singleton instance so a new alert can be created.
                Instance = null;

                // Destroy the used object
                Destroy(gameObject);

                OnNativeAlertCallback("");
            }
예제 #13
0
            // Alert callback to be called from native side with UnitySendMessage
            private void OnNativeAlertCallback(string buttonIndex)
            {
                // Release the singleton instance so a new alert can be created.
                Instance = null;

                // Fire event
                OnComplete(Convert.ToInt16(buttonIndex));

                // Destroy the used object
                Destroy(gameObject);
            }
예제 #14
0
    public override void Load()
    {
        base.Load();

        AlertPopup.OkClicked     += OnOkClicked;
        AlertPopup.CancelClicked += OnCancelClicked;

        AlertPopup.SetText(Text);

        AlertPopup.Show();
    }
예제 #15
0
    public bool TryStartGame(int currentRate)
    {
        if (!Mediator.Instance.ResourcesStorage.Chips.TrySpendResources(currentRate))
        {
            AlertPopup alertPopup = Mediator.Instance.PopupsManager.CreatePopup <AlertPopup>();
            alertPopup.Init(AlertType.Lack_Chips, "Установите ставку меньше!");

            return(false);
        }

        return(true);
    }
예제 #16
0
 private void UpdateChallengeSentDialog()
 {
     if ((this.m_partyId != null) && (this.m_challengeDialog != null))
     {
         AlertPopup           challengeDialog = (AlertPopup)this.m_challengeDialog;
         AlertPopup.PopupInfo info            = challengeDialog.GetInfo();
         if (info != null)
         {
             info.m_responseDisplay = AlertPopup.ResponseDisplay.CANCEL;
             challengeDialog.UpdateInfo(info);
         }
     }
 }
예제 #17
0
 private bool OnReconnectingDialogProcessed(DialogBase dialog, object userData)
 {
     if (!this.IsReconnecting())
     {
         return(false);
     }
     this.m_dialog = (AlertPopup)dialog;
     if (this.IsStartingReconnectGame())
     {
         this.ChangeDialogToReconnected();
     }
     return(true);
 }
예제 #18
0
        void DoTimeOutChallenge(float t = 0)
        {
            CancelInvoke("DoTimeOutChallenge");

            if (t == 0)
            {
                popup = EventListenerForPrivateChallenge.ShowUserIsBusyPopup(privateChallengeArgs.OpponentNickName);
                DoGoBackToWaitState();
            }
            else if (t > 0)
            {
                Invoke("DoTimeOutChallenge", t);
            }
        }
예제 #19
0
 private bool OnFriendChallengeWaitingForOpponentDialogProcessed(DialogBase dialog, object userData)
 {
     if (!FriendChallengeMgr.Get().HasChallenge())
     {
         return(false);
     }
     if (FriendChallengeMgr.Get().DidOpponentSelectDeck())
     {
         this.WaitForFriendChallengeToStart();
         return(false);
     }
     this.m_friendChallengeWaitingPopup = (AlertPopup)dialog;
     return(true);
 }
예제 #20
0
 private void OnTimeoutDialogResponse(AlertPopup.Response response, object userData)
 {
     this.m_dialog = null;
     if (!Network.IsLoggedIn())
     {
         if (ApplicationMgr.AllowResetFromFatalError != null)
         {
             ApplicationMgr.Get().Reset();
         }
         else
         {
             ApplicationMgr.Get().Exit();
         }
     }
 }
예제 #21
0
        void DoTimeOutChallenge(float t = 0)
        {
            CancelInvoke("DoTimeOutChallenge");

            if (t == 0)
            {
                popup = EventListenerForPrivateChallenge.ShowUserIsBusyPopup(privateChallengeArgs.OpponentNickName);
                VersusScreen.Instance.HideCancelButton();
                VersusScreen.Instance.StopAnimation();
                if (ConnectionController.Instance.inRoom)
                {
                    ConnectionController.Instance.LeaveRoom();
                }
                else
                {
                    _onConnectedToMaster();
                }
            }
            else if (t > 0)
            {
                Invoke("DoTimeOutChallenge", t);
            }
        }
예제 #22
0
        public static AlertPopup ShowPopupWithMessageAndCallback(string title, string message, Action callback = null)
        {
            AlertPopup alert = null;

            Action OnOkayButtonAction = () => {
                if (callback != null)
                {
                    callback();
                }
                alert.HideAndDestroy();
            };

            Action OnCloseButtonAction = OnOkayButtonAction;

            alert = AlertPopup.GetAlertPopup(AlertPopup.PopupType.Critical,
                                             title,
                                             message,
                                             LocalizationManager.Instance.GetString(LocalizationKeys.OK),
                                             OnOkayButtonAction,
                                             OnCloseButtonAction,
                                             true, true);
            alert.Show();
            return(alert);
        }
예제 #23
0
 void _onPlayerDisconnected(PhotonPlayer otherPlayer)
 {
     popup = EventListenerForPrivateChallenge.ShowUserIsNotAvailablePopup(privateChallengeArgs.OpponentNickName);
     DoGoBackToWaitState();
 }
예제 #24
0
 void DoShowDeclinedPopupAndGoBack()
 {
     DoTimeOutChallenge(-1);
     popup = EventListenerForPrivateChallenge.ShowUserDeclinedPopup(privateChallengeArgs.OpponentNickName);
     DoGoBackToWaitState();
 }
예제 #25
0
 private void OnGameplayDialogResponse(AlertPopup.Response response, object userData)
 {
     this.m_dialog = null;
 }
예제 #26
0
 private void OnReconnectingDialogResponse(AlertPopup.Response response, object userData)
 {
     this.m_dialog = null;
     ApplicationMgr.Get().Exit();
 }
예제 #27
0
 /// <summary>
 /// Shows an alert with 2 buttons.
 /// </summary>
 /// <returns>The two buttons alert.</returns>
 /// <param name="title">Title.</param>
 /// <param name="message">Message.</param>
 /// <param name="button1">Button1.</param>
 /// <param name="button2">Button2.</param>
 public static AlertPopup ShowTwoButtonAlert(string title, string message, string button1, string button2)
 {
     return(AlertPopup.ShowTwoButtonAlert(title, message, button1, button2));
 }
예제 #28
0
 /// <summary>
 /// Shows a toast message (Android only).
 /// </summary>
 /// <param name="message">Message.</param>
 /// <param name="isLongToast">If set to <c>true</c> use long-length toast, otherwise use short-length toast.</param>
 public static void ShowToast(string message, bool isLongToast = false)
 {
     AlertPopup.ShowToast(message, isLongToast);
 }
예제 #29
0
 /// <summary>
 /// Shows a one-button alert with the default "OK" button.
 /// </summary>
 /// <returns>The alert.</returns>
 /// <param name="title">Title.</param>
 /// <param name="message">Message.</param>
 public static AlertPopup Alert(string title, string message)
 {
     return(AlertPopup.Alert(title, message));
 }
예제 #30
0
 /// <summary>
 /// Shows a one-button alert with a custom button label.
 /// </summary>
 /// <returns>The one button alert.</returns>
 /// <param name="title">Title.</param>
 /// <param name="message">Message.</param>
 /// <param name="button">Button.</param>
 public static AlertPopup Alert(string title, string message, string button)
 {
     return(AlertPopup.ShowOneButtonAlert(title, message, button));
 }