Exemple #1
0
    /// <summary>
    /// Sets the syncable value of a GameCircle syncable number associated with this syncableNumberHelper.
    /// Also sets the metadata for that value.
    /// </summary>
    /// <param name='syncableNumber'>
    /// Syncable number.
    /// </param>
    void SetSyncableValueWithMetadata(AGSSyncableNumber syncableNumber)
    {
        if (null == syncableNumber)
        {
            return;
        }
        switch (type)
        {
        case AvailableSyncableNumberType.Int:
            syncableNumber.Set(intNumber, defaultMetadataDictionary);
            break;

        case AvailableSyncableNumberType.Double:
            syncableNumber.Set(doubleNumber, defaultMetadataDictionary);
            break;

        case AvailableSyncableNumberType.Long:
            syncableNumber.Set(longNumber, defaultMetadataDictionary);
            break;

        case AvailableSyncableNumberType.String:
            syncableNumber.Set(stringNumber, defaultMetadataDictionary);
            break;

        default:
            AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError);
            break;
        }
    }
Exemple #2
0
    /// <summary>
    /// Gets the syncable value of a GameCircle syncable number associated with this syncableNumberHelper.
    /// Stores it in the local variable that matches this syncable number helper's type.
    /// </summary>
    /// <param name='syncableNumber'>
    /// Syncable number.
    /// </param>
    void GetSyncableValue(AGSSyncableNumber syncableNumber)
    {
        if (null == syncableNumber)
        {
            return;
        }
        switch (type)
        {
        case AvailableSyncableNumberType.Int:
            intNumber = syncableNumber.AsInt();
            break;

        case AvailableSyncableNumberType.Double:
            doubleNumber = syncableNumber.AsDouble();
            break;

        case AvailableSyncableNumberType.Long:
            longNumber = syncableNumber.AsLong();
            break;

        case AvailableSyncableNumberType.String:
            stringNumber = syncableNumber.AsString();
            break;

        default:
            AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError);
            break;
        }
    }
Exemple #3
0
    /// <summary>
    /// Gets a GameCircle syncable number out of the data map.
    /// The SyncableNumber retrieved is based on the behavior of this syncable number helper.
    /// </summary>
    /// <returns>
    /// The syncable number.
    /// </returns>
    /// <param name='dataMap'>
    /// GameCircle data map.
    /// </param>
    AGSSyncableNumber GetSyncableNumber(AGSGameDataMap dataMap)
    {
        if (null == dataMap)
        {
            return(null);
        }
        // using the behavior and type is a convenient way to create variable names.
        string variableName = BehaviorAndTypeAsString();

        switch (behavior)
        {
        case SyncableNumberBehavior.Highest:
            return(dataMap.GetHighestNumber(variableName));

        case SyncableNumberBehavior.Lowest:
            return(dataMap.GetLowestNumber(variableName));

        case SyncableNumberBehavior.Latest:
            return(dataMap.GetLatestNumber(variableName));

        default:
            AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError);
            return(null);
        }
    }
    static AGSAchievementsClient()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        JavaObject = new AmazonJavaWrapper();
        using (var PluginClass = new AndroidJavaClass(PROXY_CLASS_NAME)){
            if (PluginClass.GetRawClass() == IntPtr.Zero)
            {
                AGSClient.LogGameCircleWarning(string.Format("No java class {0} present, can't use AGSAchievementsClient", PROXY_CLASS_NAME));
                return;
            }
            JavaObject.setAndroidJavaObject(PluginClass.CallStatic <AndroidJavaObject>("getInstance"));
        }
#endif
    }
    static AGSPlayerClient()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        // find the plugin instance
        JavaObject = new AmazonJavaWrapper();
        using (var PluginClass = new AndroidJavaClass(PROXY_CLASS_NAME)){
            if (PluginClass.GetRawClass() == IntPtr.Zero)
            {
                AGSClient.LogGameCircleWarning("No java class " + PROXY_CLASS_NAME + " present, can't use AGSPlayerClient");
                return;
            }
            JavaObject.setAndroidJavaObject(PluginClass.CallStatic <AndroidJavaObject>("getInstance"));
        }
#endif
    }
Exemple #6
0
    /// <summary>
    /// Initializes WhisperSync client. Calls OnInitializedEvent when finished.
    /// </summary>
    public static void InitAGSWhispersyncClient()
    {
#if UNITY_ANDROID
        javaObject = new AmazonJavaWrapper();
#if !UNITY_EDITOR
        using (var PluginClass = new AndroidJavaClass(PROXY_CLASS_NAME)){
            if (PluginClass.GetRawClass() == IntPtr.Zero)
            {
                AGSClient.LogGameCircleWarning("No java class " + PROXY_CLASS_NAME + " present, can't use AGSWhispersyncClient");
                return;
            }
            javaObject.setAndroidJavaObject(PluginClass.CallStatic <AndroidJavaObject>("getInstance"));
        }
#endif
#endif
        if (OnInitializedEvent != null)
        {
            OnInitializedEvent();
        }
    }
Exemple #7
0
    /// <summary>
    /// Draws a slider for this syncable number helper.
    /// This allows the user to select a new value for the number stored.
    /// </summary>
    void DrawSlider()
    {
        switch (type)
        {
        case AvailableSyncableNumberType.Int:
            intNumber = (int)AmazonGUIHelpers.DisplayCenteredSlider(
                (float)intNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
            break;

        case AvailableSyncableNumberType.Double:
            doubleNumber = (double)AmazonGUIHelpers.DisplayCenteredSlider(
                (float)doubleNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
            break;

        case AvailableSyncableNumberType.Long:
            longNumber = (long)AmazonGUIHelpers.DisplayCenteredSlider(
                (float)longNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
            break;

        case AvailableSyncableNumberType.String:
            // It's easiest to just use the intNumber for the string's slider display.
            if (int.TryParse(stringNumber, out intNumber))
            {
                intNumber = (int)AmazonGUIHelpers.DisplayCenteredSlider(
                    (float)intNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
                stringNumber = intNumber.ToString();
            }
            else
            {
                // if it couldn't be parsed, just display whatever value it was
                AmazonGUIHelpers.CenteredLabel(stringNumber);
            }
            break;

        default:
            AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError);
            break;
        }
    }