Пример #1
0
 public void remoteNotificationAtLauch(IDictionary obj)
 {
     if (obj.Contains("message"))
     {
         string title   = "Thông báo từ hệ thống";
         string message = obj ["message"].ToString();
         if (obj.Contains("title"))
         {
             title = obj ["title"].ToString();
         }
         if (obj.Contains("action"))
         {
             string action = obj ["action"].ToString();
             string url    = obj ["url"].ToString();
             NotificationView.ShowConfirm(title, message, delegate() {
                 Application.OpenURL(url);
                 Debug.Log("open url");
             }, null);
         }
         else
         {
             ServerMessagesView.MessageServer(title, message, 5f);
         }
     }
     EtceteraBinding.setBadgeCount(0);
 }
Пример #2
0
    public void PostScore(string newScore, string nameOfGame, string appStoreAddress = null, string appImagePath = null)
    {
        if (AppStoreAddress != null && appStoreAddress == null)
        {
            appStoreAddress = AppStoreAddress;
        }

        if (AppImagePath != null && appImagePath == null)
        {
            appImagePath = AppImagePath;
        }

        if (IsFacebookComposerSupported())
        {
            if (CanUserUseFacebookComposer())
            {
                if (appImagePath == null)
                {
                    ShowFacebookComposer("I just scored " + newScore + " in " + nameOfGame + "! " + appStoreAddress);
                }
                else
                {
                    ShowFacebookComposer("I just scored " + newScore + " in " + nameOfGame + "! ", appImagePath, appStoreAddress);
                }
            }
        }
        else
        {
            EtceteraBinding.showAlertWithTitleMessageAndButtons("Error", "Posting to Facebook not supported in your version of iOS", new string[] { "OK" });
        }
    }
    public void textureLoadFailed(string error)
    {
        var buttons = new string[] { "OK" };

        EtceteraBinding.showAlertWithTitleMessageAndButtons("Error Loading Texture.  Did you choose a photo first?", error, buttons);
        Debug.Log("textureLoadFailed: " + error);
    }
Пример #4
0
    public IEnumerator ShowPopup(string title, string message, string[] buttons, System.Action <string> pressed)
    {
        HideSpinner();

        this._buttonPressed = "none";
        if (buttons.Length > 2)
        {
            Debug.LogWarning("UIPopup.ShowPopup can only show 2 buttons.", gameObject);
            yield return(null);
        }
                #if UNITY_IOS && !UNITY_EDITOR
        EtceteraBinding.showAlertWithTitleMessageAndButtons(title, message, buttons);
                #elif UNITY_ANDROID && !UNITY_EDITOR
        if (buttons.Length < 2)
        {
            EtceteraAndroid.showAlert(title, message, buttons[0]);
        }
        else
        {
            EtceteraAndroid.showAlert(title, message, buttons[0], buttons[1]);
        }
                #else
        cam.enabled = true;
        customAlert.Show(title, message, buttons);
                #endif
        while (this._buttonPressed == "none")
        {
            yield return(new WaitForEndOfFrame());
        }

        pressed(_buttonPressed);
    }
Пример #5
0
 public void Slika()
 {
     //Debug.Log ("SLIKA");
     #if UNITY_IPHONE
     EtceteraBinding.promptForPhoto(1f, PhotoPromptType.Camera);
     #endif
 }
Пример #6
0
    /// <summary>
    /// Hàm chạy ngay khi GameManager được khởi tạo
    /// </summary>
    void Init()
    {
#if UNITY_WEBPLAYER
        if (!Security.PrefetchSocketPolicy(CServer.HOST_NAME, System.Convert.ToInt32(CServer.PORT), 999))
        {
            Debug.LogError("Security Exception. Policy file load failed!");
        }
#elif UNITY_ANDROID
        GCM.Register(GCM.SENDER_IDS);
#elif UNITY_IPHONE
        EtceteraBinding.registerForRemoteNotifcations(P31RemoteNotificationType.Alert | P31RemoteNotificationType.Badge | P31RemoteNotificationType.Sound);
#endif
        Debug.LogWarning("GameManager: Init()");
        mInfo           = new User();
        channelRoom     = new RoomInfo();
        currentRoom     = new RoomInfo();
        selectedChannel = new RoomInfo();
        selectedLobby   = new RoomInfo();

        Setting.Init();
        applicationStart = new ApplicationStart();
                #if UNITY_ANDROID || UNITY_IPHONE
        if (!FB.IsLoggedIn)
        {
            FB.Init(onInitComplete, onHideUnity);
        }
                #endif
    }
Пример #7
0
    /// <summary>
    /// Khi thoát ứng dụng (tắt ứng dụng).
    /// </summary>
    void Start()
    {
        if (Application.platform == RuntimePlatform.WindowsPlayer)
        {
            Setting.IsFullScreen = true;
        }

        Application.runInBackground = true;

        //cu 3s kiem tra connect internet mot lan
        //StartCoroutine(checkConnection());

                #if UNITY_IPHONE
        EtceteraManager.remoteNotificationReceivedAtLaunchEvent += remoteNotificationAtLauch;
        EtceteraManager.remoteNotificationReceivedEvent         += remoteNotification;
        EtceteraManager.remoteRegistrationSucceededEvent        += remoteRegistrationSucceeded;
        EtceteraManager.remoteRegistrationFailedEvent           += remoteRegistrationFailed;
        if (EtceteraBinding.getBadgeCount() != 0)
        {
            EtceteraBinding.setBadgeCount(0);
        }
        #elif UNITY_ANDROID
        GCMReceiver._onRegistered   += remoteRegistrationSucceeded;
        GCMReceiver._onUnregistered += remoteRegistrationFailed;
        GCMReceiver._onMessage      += gcmReceiverMessage;
                #endif
    }
Пример #8
0
    public IEnumerator TakeScreenShot()
    {
        yield return(new WaitForEndOfFrame());

        screenWidth  = Screen.width;
        screenHeight = Screen.height;
        screenShotImage.Resize(screenWidth, screenHeight);
        screenShotImage.ReadPixels(new Rect(0, 0, screenWidth, screenHeight), 0, 0);
        screenShotImage.Apply();
        bytes = screenShotImage.EncodeToPNG();
        if (File.Exists(screenShotFile))
        {
            File.Delete(screenShotFile);
        }
        File.WriteAllBytes(screenShotFile, bytes);
        fileSaved = false;
        while (!fileSaved)
        {
            if (File.Exists(screenShotFile))
            {
                fileSaved = true;
                yield return(null);
            }
        }
        EtceteraBinding.saveImageToPhotoAlbum(screenShotFile);
    }
Пример #9
0
    // Mostra uma mensagem na tela com um botao
    public override void showMessage(string title = "", string message = "", string button = "")
    {
        if (title.IsEmpty())
        {
            title = Flow.messageOkDialog.transform.FindChild("BackgroundBorder").FindChild("BackgroundTitle").FindChild("TitlePanel").FindChild("Title").GetComponent <SpriteText>().Text;
        }

        if (message.IsEmpty())
        {
            message = Flow.messageOkDialog.transform.FindChild("BackgroundBorder").FindChild("BackgroundBody").FindChild("MessagePanel").FindChild("Message").GetComponent <SpriteText>().Text;
        }

        if (button.IsEmpty())
        {
            try
            {
                button = Flow.messageOkDialog.transform.FindChild("BackgroundBorder").FindChild("BackgroundBody").FindChild("ConfirmButtonPanel").FindChild("ConfirmButton").FindChild("control_text").GetComponent <SpriteText>().Text;
            }
            catch
            {
                button = default_ok_button;
            }
        }

        EtceteraBinding.showAlertWithTitleMessageAndButtons(title, filterMessage(message), new string[] { button });
    }
Пример #10
0
    // Obtem a imagem e chama os eventos com o resultado
    private IEnumerator handleGetImage(string path)
    {
        if (actionPhotoPicked == null)
        {
            yield break;
        }

        Vector2 size = EtceteraBinding.getImageSize(path);

        if (size.x < size.y)
        {
            size.x *= PHOTO_HEIGHT / size.y;
            size.y  = PHOTO_HEIGHT;
        }
        else
        {
            size.y *= PHOTO_WIDTH / size.x;
            size.x  = PHOTO_WIDTH;
        }

        EtceteraBinding.resizeImageAtPath(path, size.x, size.y);

        WWW conn = new WWW("file://" + path);

        yield return(conn);

        actionPhotoPicked(path, conn.texture);
    }
Пример #11
0
    void purchaseSuccessfulEvent(StoreKitTransaction transaction)
    {
        switch (transaction.productIdentifier)
        {
        case MainMenuController.GOLD_200:
            DBAccess.instance.userPrefs.Gold += 200;
            DBAccess.instance.userPrefs.CommitToDB(true);
            break;

        case MainMenuController.GOLD_500:
            DBAccess.instance.userPrefs.Gold += 500;
            DBAccess.instance.userPrefs.CommitToDB(true);
            break;

        case MainMenuController.GOLD_4000:
            DBAccess.instance.userPrefs.Gold += 4000;
            DBAccess.instance.userPrefs.CommitToDB(true);
            break;

        default:
            break;
        }

        EtceteraBinding.hideActivityView();
        tweenOut();
    }
Пример #12
0
    // Mostra o loading com uma mensagem
    public override void loadingMessage(string title = "", string message = "")
    {
        if (message.IsEmpty())
        {
            message = Flow.loadingDialog.transform.FindChild("BackgroundBorder").FindChild("BackgroundBody").FindChild("MessagePanel").FindChild("Message").GetComponent <SpriteText>().Text;
        }

        EtceteraBinding.showBezelActivityViewWithLabel(message);
    }
Пример #13
0
 public void askForReview(string appName, string bundleId, int launchCount, int hoursBetweenPrompts)
 {
     #if UNITY_ANDROID
     EtceteraAndroid.askForReview(3, 0, 3, "Review " + appName + "!", "Review " + appName + " if you like it.", false);
     #elif UNITY_IPHONE
     EtceteraBinding.askForReview(launchCount, hoursBetweenPrompts,
                                  "Review " + appName + "!", "Review " + appName + " if you like it.", bundleId);
     #endif
 }
Пример #14
0
 public void showReviewPage()
 {
     #if UNITY_ANDROID
     bool isAmazon = AppConfigs.platformIsAmazon;
     EtceteraAndroid.openReviewPageInPlayStore(isAmazon);
     #elif UNITY_IPHONE
     EtceteraBinding.openAppStoreReviewPage(AppConfigs.appStoreId);
     #endif
 }
Пример #15
0
    public void askForReview(string appName, string bundleId)
    {
#if UNITY_ANDROID
        EtceteraAndroid.askForReviewNow("Review " + appName + "!", "Review " + appName + " if you like it.");
#elif UNITY_IPHONE
        //EtceteraBinding.openAppStoreReviewPage(AppConfigs.pu
        EtceteraBinding.askForReview("Review " + appName + "!", "Review " + appName + " if you like it.", bundleId);
#endif
    }
Пример #16
0
        public override string ToString()
        {
#if UNITY_IPHONE
            return(EtceteraBinding.getMemoryStatistic());
#else
            return(string.Format("{0}",
                                 System.GC.GetTotalMemory(true) / 1024 / 1024));
#endif
        }
Пример #17
0
    private void handleBadgeReset(string error, IJSonObject data)
    {
        if (error != null)
        {
            return;
        }

        EtceteraBinding.setBadgeCount(0);
    }
Пример #18
0
    public void ShowSpinner()
    {
        eventSystem.enabled = false;
#if UNITY_IOS
        EtceteraBinding.showActivityView();
#endif
#if UNITY_ANDROID
        EtceteraAndroid.showProgressDialog("", "");
#endif
    }
        protected void ClearLocalNotifications()
        {
            LocalNotification localNotification = new LocalNotification();

            localNotification.applicationIconBadgeNumber = -1;
            NotificationServices.PresentLocalNotificationNow(localNotification);
            NotificationServices.CancelAllLocalNotifications();
            NotificationServices.ClearLocalNotifications();
            EtceteraBinding.setBadgeCount(0);
        }
Пример #20
0
    // Abre a tela para o usuario escolher uma foto
    public override void cameraRoll(float x, float y, string photo_name)
    {
        //x *= GameGUI.components.scale;
        //y *= GameGUI.components.yscale * GameGUI.components.scale;

        this.photo_name = photo_name;

        EtceteraBinding.setPopoverPoint(x, y);
        EtceteraBinding.promptForPhoto(1f, PhotoPromptType.CameraAndAlbum);
    }
Пример #21
0
 public void Open()
 {
             #if UNITY_EDITOR
     UniFileBrowser.use.OpenFileWindow(ImageUploadAlert.Instance.OpenFile);
             #elif UNITY_IPHONE
     EtceteraBinding.promptForPhoto(0.2f);
             #elif UNITY_ANDROID
     EtceteraAndroid.promptForPictureFromAlbum("");
             #endif
 }
Пример #22
0
    public void saveImageToLibrary(string name, string fileToSave)
    {
#if UNITY_IPHONE
        EtceteraBinding.saveImageToPhotoAlbum(fileToSave);
#elif UNITY_ANDROID
        EtceteraAndroid.saveImageToGallery(fileToSave, name);
#else
        // TODO save to server on web
        // TODO save to desktop photos
#endif
    }
Пример #23
0
 void hitByRayCast()
 {
     if (GameCenterBinding.isPlayerAuthenticated())
     {
         GameCenterBinding.showLeaderboardWithTimeScope(GameCenterLeaderboardTimeScope.AllTime);
     }
     else
     {
         EtceteraBinding.showAlertWithTitleMessageAndButtons("Oops!", "You have to be logged into Game Center to do that!", new string[] { "OK" });
     }
 }
Пример #24
0
 void ClearLocalNotifications()
 {
 #if UNITY_IOS
     UnityEngine.iOS.LocalNotification m_LocalNotification = new UnityEngine.iOS.LocalNotification();
     m_LocalNotification.applicationIconBadgeNumber = -1;
     UnityEngine.iOS.NotificationServices.PresentLocalNotificationNow(m_LocalNotification);
     UnityEngine.iOS.NotificationServices.CancelAllLocalNotifications();
     UnityEngine.iOS.NotificationServices.ClearLocalNotifications();
     EtceteraBinding.setBadgeCount(0);
 #endif
 }
Пример #25
0
    void Awake()
    {
        P31Prefs.setInt("level1", 1);
        mainCamera = this.gameObject;

#if UNITY_ANDROID
        EtceteraAndroid.askForReview(1, 1, 2, "Do you like this game?", "Please review the game if you do!", false);
#endif
#if UNITY_IOS
        EtceteraBinding.askForReview(1, 0.5f, "Do you like this game?", "Please review the game if you do!", "950049277");
#endif
    }
Пример #26
0
    /// <summary>
    /// Hiện prompt chọn album ảnh từ native
    /// </summary>
    public void PromptPictureFromAlbum(DelegateChooseImageDone whenDone)
    {
        onChooseImageDone = whenDone;

#if UNITY_ANDROID
        EtceteraAndroid.promptForPictureFromAlbum(512, 512, "esimoAvatar.jpg");
#elif UNITY_IPHONE
        EtceteraBinding.promptForPhoto(0.25f, PhotoPromptType.Album);
#else
        NotificationView.ShowMessage("Hiện chỉ hỗ trợ đổi ảnh trên mobile", 2f);
#endif
    }
Пример #27
0
    public void showWebView(string title, string url)
    {
#if UNITY_EDITOR
        Application.OpenURL(url);
#elif UNITY_ANDROID
        EtceteraAndroid.showWebView(url);
#elif UNITY_IPHONE
        EtceteraBinding.showWebPage(url, false);
#else
        Application.OpenURL(url);
#endif
    }
Пример #28
0
    void SavePhotoImage()
    {
        //Save image
        if (imagePath == null)
        {
            var buttons = new string[] { "OK" };
            EtceteraBinding.showAlertWithTitleMessageAndButtons("Load Photo Texture Error", "You have to choose a photo before loading", buttons);
            return;
        }

        EtceteraBinding.saveImageToPhotoAlbum(imagePath);
    }
Пример #29
0
    public void HideSpinner()
    {
                #if UNITY_IOS
        EtceteraBinding.hideActivityView();
                #endif
                #if UNITY_ANDROID
        EtceteraAndroid.hideProgressDialog();
                #endif


        eventSystem.enabled = true;
    }
Пример #30
0
        private static string GetLocaleCode()
    {
        // Default locale
        string localeVal = "pt_BR";

#if UNITY_IPHONE
        localeVal = EtceteraBinding.getCurrentLocale();
        string langVal = EtceteraBinding.getCurrentLanguage();
        if( langVal != null )
        {
            if( langVal.Length == 5 )
            {
                localeVal = langVal;
            }
            else
            {
                if( ( langVal.Length == 2 ) && ( localeVal.Length == 5 ) )
                {
                    localeVal = localeVal.Substring( 2 , 3 );
                    localeVal = langVal + localeVal;
                }
            }
        }
#endif

#if UNITY_ANDROID
        using (AndroidJavaClass cls = new AndroidJavaClass("java.util.Locale"))
        {
            if (cls != null)
            {
                using (AndroidJavaObject locale = cls.CallStatic<AndroidJavaObject>("getDefault"))
                {
                    if (locale != null)
                    {
                        localeVal = locale.Call<string>("getLanguage") + "_" + locale.Call<string>("getCountry");
                        Debug.Log("Android lang: " + localeVal);
                    }
                    else
                    {
                        Debug.Log("locale null");
                    }
                }
            }
            else
            {
                Debug.Log("cls null");
            }
        }
#endif
        Debug.Log("Locale: " + localeVal);
        return (localeVal);
    }