void Update() { // Exit on Android Back button #if UNITY_ANDROID && EASY_MOBILE if (Input.GetKeyUp(KeyCode.Escape)) { MobileNativeAlert alert = MobileNativeUI.ShowTwoButtonAlert( "Exit Game", "Are you sure you want to exit?", "Yes", "No"); if (alert != null) { alert.OnComplete += (int button) => { switch (button) { case 0: // Yes Application.Quit(); break; case 1: // No break; } }; } } #endif }
void Update() { // Exit on Android Back button if (Input.GetKeyUp(KeyCode.Escape)) { MobileNativeAlert alert = MobileNativeUI.ShowTwoButtonAlert( title, message, yesButton, noButton ); if (alert != null) { alert.OnComplete += (int button) => { switch (button) { case 0: // Yes Application.Quit(); break; case 1: // No break; } }; } } }
public void ShowOneButtonAlert() { MobileNativeAlert alert = MobileNativeUI.Alert("Sample Alert", "This is a simple (1-button) alert."); if (alert != null) { alert.OnComplete += OnAlertComplete; } }
public void ShowTwoButtonsAlert() { MobileNativeAlert alert = MobileNativeUI.ShowTwoButtonAlert("Sample Alert", "This is a 2-button alert.", "Button 1", "Button 2"); if (alert != null) { alert.OnComplete += OnAlertComplete; } }
public void RestorePurchases() { if (IAPManager.Instance.IsInitialized()) { IAPManager.Instance.RestorePurchases(); } else { MobileNativeAlert.CreateOneButtonAlert("Service Unavailable", "Please check your internet connection.", "OK"); } }
public void Purchase(string productName) { if (IAPManager.Instance.IsInitialized()) { IAPManager.Instance.PurchaseWithName(productName); } else { MobileNativeAlert.CreateOneButtonAlert("Service Unavailable", "Please check your internet connection.", "OK"); } }
void Update() { #if UNITY_ANDROID if (Input.GetKeyUp(KeyCode.Escape)) { // Ask if user wants to exit MobileNativeAlert alert = MobileNativeUI.ShowTwoButtonAlert("Exit App", "Do you want to exit?", "Yes", "No"); if (alert != null) { alert.OnComplete += delegate(int button) { if (button == 0) { Application.Quit(); } } } ; } #endif } // Push notification opened handler void NotificationManager_NotificationOpened(string message, string actionID, Dictionary <string, object> additionalData, bool isAppInFocus) { Debug.Log("Push notification received!"); Debug.Log("Message: " + message); Debug.Log("isAppInFocus: " + isAppInFocus.ToString()); if (additionalData != null) { Debug.Log("AdditionalData:"); foreach (KeyValuePair <string, object> item in additionalData) { Debug.Log("Key: " + item.Key + " - Value: " + item.Value.ToString()); } if (additionalData.ContainsKey("newUpdate")) { if (!isAppInFocus) { Debug.Log("New update available! Should open the update page now."); } } } } }
public void ShowAchievementUI() { if (GameServiceManager.Instance.IsInitialized) { GameServiceManager.Instance.ShowAchievementsUI(); } else { #if UNITY_IOS MobileNativeAlert.CreateOneButtonAlert("Service Unavailable", "The player is not signed in to Game Center.", "OK"); #elif UNITY_ANDROID GameServiceManager.Instance.Init(); #endif } }
void Update() { // Exit on Android Back button #if UNITY_ANDROID if (Input.GetKeyUp(KeyCode.Escape)) { MobileNativeAlert alert = MobileNativeAlert.CreateTwoButtonsAlert( "Exit Game", "Are you sure you want to exit?", "Yes", "No"); if (alert != null) { alert.OnComplete += OnExitAlertClose; } } #endif if (!UIManager.firstLoad && !gameStarted) { gameStarted = true; if (!SoundManager.Instance.IsMusicOff()) { SoundManager.Instance.PlayMusic(SoundManager.Instance.background); } // Fire event NewGameEvent(GameEvent.Start); } // Check if game is about to end if (!isPreGameOver) { if (playerController.IsGoingOutOfScreen()) { SetPreGameOver(); } } }
// RestoreCompleted event is only fired on iOS devices. void OnRestoreCompleted() { MobileNativeAlert.CreateOneButtonAlert("Restore Completed", "Your purchases were restored successfully.", "OK"); }
// Update is called once per frame void Update() { // Exit on Android Back button #if UNITY_ANDROID && EASY_MOBILE if (Input.GetKeyUp(KeyCode.Escape)) { MobileNativeAlert alert = MobileNativeUI.ShowTwoButtonAlert( "Exit Game", "Are you sure you want to exit?", "Yes", "No"); if (alert != null) { alert.OnComplete += (int button) => { switch (button) { case 0: // Yes Application.Quit(); break; case 1: // No break; } }; } } #endif if (playerController.isRunning && !gameOver) //Not game over { if (Input.GetMouseButtonDown(0)) { if (listIndex < listMovingPlane.Count) //Make sure the the listIndex not run out of the list { if (listMovingPlane[listIndex].GetComponent <PlaneController>().isVisible) //This moving plane is visible { listMovingPlane[listIndex].GetComponent <PlaneController>().stopMoving = true; //Stop moving plane GameObject currentPlane = listMovingPlane[listIndex]; Vector3 point = new Vector3(0, yPlaneScale / 2, 0); //Draw raycast from this point if (currentPlane.transform.rotation == Quaternion.Euler(0, -90, 0)) { Ray rayRight = new Ray(currentPlane.transform.position + point, Vector3.right); RaycastHit hit; if (Physics.Raycast(rayRight, out hit, zPlaneScale)) //Draw raycast with length is zPlaneScale { PlaneController planeController = hit.collider.GetComponent <PlaneController>(); if (planeController != null) { if (planeController.isMove) //This plane is normal plane { checkPosition = hit.transform.position.z; //Remember z position of this plane } } float distance = Mathf.Abs(currentPlane.transform.position.z - checkPosition); if (distance <= minDeviation)//distance is less than minDeviation -> bonus coin { currentPlane.transform.position = new Vector3(currentPlane.transform.position.x, currentPlane.transform.position.y, checkPosition); CreateGold(currentPlane, 1); //Bonus coin ScoreManager.Instance.AddScore(2); // Bonus score SoundManager.Instance.PlaySound(SoundManager.Instance.placeUp); } else { SoundManager.Instance.PlaySound(SoundManager.Instance.place); } } } else { Ray rayBack = new Ray(currentPlane.transform.position + point, Vector3.back); RaycastHit hit; if (Physics.Raycast(rayBack, out hit, zPlaneScale)) { PlaneController planeController = hit.collider.GetComponent <PlaneController>(); if (planeController != null) { if (!planeController.isMove) //This is normal plane { checkPosition = hit.transform.position.x; //Remember x position of this plane } } float distance = Mathf.Abs(currentPlane.transform.position.x - checkPosition); if (distance <= minDeviation)//distance is less than minDeviation -> bonus coin { currentPlane.transform.position = new Vector3(checkPosition, currentPlane.transform.position.y, currentPlane.transform.position.z); CreateGold(currentPlane, 1); //Bonus coin ScoreManager.Instance.AddScore(2); // Bonus score SoundManager.Instance.PlaySound(SoundManager.Instance.placeUp); } else { SoundManager.Instance.PlaySound(SoundManager.Instance.place); } } } listIndex++; //Next moving plane } } } } }