//...

    // Call this method when a player has completed his turn and wants to
    // go onto the next player, which may be himself.
    public void playTurn()
    {
        int    rand = Random.Range(0, 2);
        string nextParticipantId = mMatch.Participants[0].id; //string.Empty;

        if (nextParticipantId == mMatch.PendingParticipantId)
        {
            nextParticipantId = mMatch.Participants[1].id;
        }


        // Get the next participant in the game-defined way, possibly round-robin.
        //nextParticipantId = getNextParticipantId();


        // Get the updated state. In this example, we simply use a
        // a pre-defined string. In your game, there may be more complicated state.
        string mTurnData = "1";

        // At this point, you might want to show a waiting dialog so that
        // the current player does not try to submit turn actions twice.
        AndroidNativeUtility.ShowPreloader("Loading..", "Sending the tunr data next is " + nextParticipantId);

        // Invoke the next turn. We are converting our data to a byte array.

        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
        byte[] byteArray = encoding.GetBytes(mTurnData);

        GooglePlayTBM.Instance.TakeTrun(mMatch.Id, byteArray, nextParticipantId);
    }
    private void ActionAvailableGameSavesLoaded(GooglePlayResult res)
    {
        GooglePlaySavedGamesManager.ActionAvailableGameSavesLoaded -= ActionAvailableGameSavesLoaded;
        if (res.IsSucceeded)
        {
            try
            {
                foreach (GP_SnapshotMeta meta in GooglePlaySavedGamesManager.Instance.AvailableGameSaves)
                {
                    Debug.Log("Meta.Title: " + meta.Title);
                    Debug.Log("Meta.Description: " + meta.Description);
                    Debug.Log("Meta.CoverImageUrl): " + meta.CoverImageUrl);
                    Debug.Log("Meta.LastModifiedTimestamp: " + meta.LastModifiedTimestamp);
                    Debug.Log("Meta.TotalPlayedTime" + meta.TotalPlayedTime);
                }

                if (GooglePlaySavedGamesManager.Instance.AvailableGameSaves.Count > 0)
                {
                    GP_SnapshotMeta s = GooglePlaySavedGamesManager.Instance.AvailableGameSaves[0];
                    GooglePlaySavedGamesManager.Instance.LoadSpanshotByName(s.Title);
                }
            }
            catch (Exception e)
            {
                Debug.Log("ActionAvailableGameSavesLoaded Exception: " + e.Message);
                AndroidNativeUtility.HidePreloader();
            }
        }
        else
        {
            AndroidNativeUtility.HidePreloader();
            AndroidMessage.Create("\nGame\n", "Failed to load game data from Cloud in Internet.\n\nPlease, check your Internet connection and try again.");
        }
    }
Пример #3
0
    public void HidePreloader()
    {
                #if DEBUG_INFO
        Debug.Log("AndroidManager: attempting to hide preloader");
                #endif

                #if UNITY_ANDROID
        AndroidNativeUtility.HidePreloader();
                #endif
    }
Пример #4
0
    public void ShowPreloader()
    {
                #if DEBUG_INFO
        Debug.Log("AndroidManager: attempting to show preloader");
                #endif

                #if UNITY_ANDROID
        AndroidNativeUtility.ShowPreloader("Loading", "Please wait...");
                #endif
    }
 public void SaveGame()
 {
     AndroidNativeUtility.ShowPreloader("\"Game\"", "Saving Game...\n\nPlease, wait!");
     try
     {
         StartCoroutine(MakeScreenshotAndSaveGameData());
     }
     catch (Exception e)
     {
         Debug.Log("SaveGame Exception: " + e.Message);
         AndroidNativeUtility.HidePreloader();
     }
 }
 public void LoadGame()
 {
     AndroidNativeUtility.ShowPreloader("\"Game\"", "Loading Game...\n\nPlease, wait!");
     GooglePlaySavedGamesManager.ActionAvailableGameSavesLoaded += ActionAvailableGameSavesLoaded;
     try
     {
         GooglePlaySavedGamesManager.Instance.LoadAvailableSavedGames();
     }
     catch (Exception e)
     {
         Debug.Log("LoadGame Exception: " + e.Message);
         AndroidNativeUtility.HidePreloader();
     }
 }
    private void ActionGameSaveResult(GP_SpanshotLoadResult result)
    {
        GooglePlaySavedGamesManager.ActionGameSaveResult -= ActionGameSaveResult;
        Debug.Log("ActionGameSaveResult: " + result.Message);

        AndroidNativeUtility.HidePreloader();
        if (result.IsSucceeded)
        {
            AndroidMessage.Create("Game saved", "Data: " + result.Snapshot.stringData);
        }
        else
        {
            Debug.Log("ActionGameSaveResult Error : Games Save Failed");
            AndroidMessage.Create("\"City Car Run\" Error", "Game Data Save Failed");
        }
    }
    private void ActionGameSaveLoaded(GP_SpanshotLoadResult result)
    {
        Debug.Log("ActionGameSaveLoaded: " + result.Message);
        if (result.IsSucceeded)
        {
            Debug.Log("Snapshot.Title: " + result.Snapshot.meta.Title);
            Debug.Log("Snapshot.Description: " + result.Snapshot.meta.Description);
            Debug.Log("Snapshot.CoverImageUrl): " + result.Snapshot.meta.CoverImageUrl);
            Debug.Log("Snapshot.LastModifiedTimestamp: " + result.Snapshot.meta.LastModifiedTimestamp);

            Debug.Log("Snapshot.stringData: " + result.Snapshot.stringData);
            Debug.Log("Snapshot.bytes.Length: " + result.Snapshot.bytes.Length);

            AndroidNativeUtility.HidePreloader();
            AndroidMessage.Create("Snapshot Loaded", "Data: " + result.Snapshot.stringData);
        }
    }
    public static void HidePreloader()
    {
        if (TimeOutTask != null)
        {
            TimeOutTask.Cancel();
            TimeOutTask = null;
        }

        if (Application.platform == RuntimePlatform.Android)
        {
            AndroidNativeUtility.HidePreloader();
        }

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            IOSNativeUtility.HidePreloader();
        }
    }
    public static void ShowPreloader()
    {
        if (TimeOutTask != null)
        {
            return;
        }

        TimeOutTask = MultiplayerPreloaderTimeoutTask.Create();


        if (Application.platform == RuntimePlatform.Android)
        {
            AndroidNativeUtility.ShowPreloader("", "");
        }

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            IOSNativeUtility.ShowPreloader();
        }
    }
    //...

    // Call this method when a player has completed his turn and wants to
    // go onto the next player, which may be himself.
    public void playTurn()
    {
        //Before we play turn, lets update the data based on changes I have made.
        Common.playerInformation.ChangeGameDataValuesAccordingToMyData();
        bool   isAllready        = Common.roundInformation.AllReady();
        string nextParticipantId = "";

        if (!isAllready)
        {
            nextParticipantId = Common.roundInformation.GetNextPlayerID(); //TODO SELVITÄ HALUTAANKOplayerID vai ID
        }
        else
        {
            Common.roundInformation.ChangeGameState();
            nextParticipantId = Common.roundInformation.gameData.playerIDS[Common.roundInformation.gameData.roundDeciderPID]; //Common.roundInformation.GetNextPlayerID();
        }
        // Get the next participant in the game-defined way, possibly round-robin.
        //nextParticipantId = getNextParticipantId();


        // Get the updated state. In this example, we simply use a
        // a pre-defined string. In your game, there may be more complicated state.
        //string mTurnData = "My turn data sample";

        // At this point, you might want to show a waiting dialog so that
        // the current player does not try to submit turn actions twice.



        // Invoke the next turn. We are converting our data to a byte array.

        //System.Text.UTF8Encoding  encoding = new System.Text.UTF8Encoding();
        AndroidNativeUtility.ShowPreloader("Loading..", "Sending the turn data newxt player " + nextParticipantId + " matchis " + mMatch.Id);
        byte[] byteArray = Common.roundInformation.GetData();

        unShowTurnUI();
        Invoke("unShowLoadingPopUp", 4f);

        GooglePlayTBM.Instance.TakeTrun(mMatch.Id, byteArray, nextParticipantId);
    }
Пример #12
0
 void RateMeOnPlayStore()
 {
     AndroidNativeUtility.OpenAppRatingPage(rateUrl);
 }
 void unShowLoadingPopUp()
 {
     AndroidNativeUtility.HidePreloader();
 }
Пример #14
0
 private void OpenRatingPage()
 {
     AndroidNativeUtility.OpenAppRatingPage(rateUrl);
 }
Пример #15
0
 private void HidePreloader()
 {
     AndroidNativeUtility.HidePreloader();
 }
Пример #16
0
 private void ShowPreloader()
 {
     Invoke("HidePreloader", 2f);
     AndroidNativeUtility.ShowPreloader("Loading", "Wait 2 seconds please");
 }
 public void RunApp()
 {
     AndroidNativeUtility.OpenSettingsPage(AN_SettingsActivityAction.ACTION_APPLICATION_DETAILS_SETTINGS);
     //AndroidNativeUtility.instance.RunPackage("com.google.android.youtube");
 }
Пример #18
0
        private static void DoRequestRating(RatingDialogContent content, Action <UserAction> callback)
        {
            if (!CanRequestRating())
            {
                Debug.Log("Could not display the rating request popup because it was disabled, " +
                          "or one or more display constraints are not satisfied.");
                return;
            }

            // If no custom content was provided, use the default one.
            if (content == null)
            {
                content = EM_Settings.RatingRequest.DefaultRatingDialogContent;
            }

            // Callback register
            customBehaviour = callback;

            #if UNITY_EDITOR
            Debug.Log("Request review is only available on iOS and Android devices.");
            #elif UNITY_IOS
            if (iOSNativeUtility.CanUseBuiltinRequestReview())
            {
                // iOS 10.3+.
                iOSNativeUtility.RequestReview();
            }
            else
            {
                // iOS before 10.3.
                MobileNativeAlert alert = MobileNativeAlert.ShowThreeButtonAlert(
                    content.Title.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName),
                    content.Message.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName),
                    content.RefuseButtonText,
                    content.PostponeButtonText,
                    content.RateButtonText
                    );

                if (alert != null)
                {
                    alert.OnComplete += OnIosRatingDialogCallback;
                }
            }

            if (!IsDisplayConstraintIgnored())
            {
                // Increment the number of requests used this year.
                SetAnnualUsedRequests(DateTime.Now.Year, GetAnnualUsedRequests(DateTime.Now.Year) + 1);

                // Store the request timestamp
                Helper.StoreTime(LAST_REQUEST_TIMESTAMP_PPKEY, DateTime.Now);
            }
            #elif UNITY_ANDROID
            if (Instance != null)
            {
                return;    // only allow one alert at a time
            }
            // Create a Unity game object to receive messages from native side
            Instance = new GameObject(RATING_DIALOG_GAMEOBJECT).AddComponent <MobileNativeRatingRequest>();

            // Replace placeholder texts if any.
            var texts = new RatingDialogContent(
                content.Title.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName),
                content.Message.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName),
                content.LowRatingMessage.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName),
                content.HighRatingMessage.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName),
                content.PostponeButtonText,
                content.RefuseButtonText,
                content.RateButtonText,
                content.CancelButtonText,
                content.FeedbackButtonText
                );

            // Show the Android rating request
            AndroidNativeUtility.RequestRating(texts, EM_Settings.RatingRequest);

            if (!IsDisplayConstraintIgnored())
            {
                // Increment the number of requests used this year.
                SetAnnualUsedRequests(DateTime.Now.Year, GetAnnualUsedRequests(DateTime.Now.Year) + 1);

                // Store the request timestamp
                Helper.StoreTime(LAST_REQUEST_TIMESTAMP_PPKEY, DateTime.Now);
            }
            #else
            Debug.Log("Request review is not supported on this platform.");
            #endif
        }
 public void HidePreloader()
 {
     AndroidNativeUtility.HidePreloader();
 }
Пример #20
0
 public void RateButton()
 {
     AndroidNativeUtility.OpenAppRatingPage("market://details?id=com.Dreamup.Swapper");
 }
 private void AddNewFriends()
 {
     Debug.Log("AddNewFriends");
     AndroidNativeUtility.InvitePlusFriends();
 }