Ejemplo n.º 1
0
		protected override void _setFastestDurationMillis(Level level, long duration) {
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniLevelStorage = new AndroidJavaClass("com.soomla.levelup.data.LevelStorage")) {
				jniLevelStorage.CallStatic("setFastestDurationMillis", level.ID, duration);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
Ejemplo n.º 2
0
		protected override long _getFastestDurationMillis(Level level) {
			long duration = 0;
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniLevelStorage = new AndroidJavaClass("com.soomla.levelup.data.LevelStorage")) {
				duration = jniLevelStorage.CallStatic<long>("getFastestDurationMillis", level.ID);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
			return duration;
		}
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieves the slowest duration for the given level.
 /// </summary>
 /// <returns>The slowest duration of the given <c>Level</c>.</returns>
 /// <param name="level"><c>Level</c> to get slowest duration.</param>
 protected virtual long _getSlowestDurationMillis(Level level)
 {
     string key = keySlowestDuration (level.ID);
     string val = KeyValueStorage.GetValue (key);
     return (string.IsNullOrEmpty(val)) ? 0 : long.Parse (val);
 }
Ejemplo n.º 4
0
		public void onLevelEnded(Level level)
		{
			onEventFired (level, System.Reflection.MethodBase.GetCurrentMethod ().Name);
		}
Ejemplo n.º 5
0
		protected override int _decTimesStarted(Level level) {
			int timesStarted = 0;
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniLevelStorage = new AndroidJavaClass("com.soomla.levelup.data.LevelStorage")) {
				timesStarted = jniLevelStorage.CallStatic<int>("decTimesStarted", level.ID);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
			return timesStarted;
		}
Ejemplo n.º 6
0
	protected override int _decTimesPlayed(Level level) {
		return levelStorage_DecTimesPlayed(level.ID);
	} 
Ejemplo n.º 7
0
	protected override long _getFastestDurationMillis(Level level) {
		return levelStorage_GetFastestDurationMillis(level.ID);
	}
Ejemplo n.º 8
0
		public static int GetTimesPlayed(Level level) {
			return instance._getTimesPlayed (level);
		}
Ejemplo n.º 9
0
		public static int GetTimesCompleted(Level level) {
			return instance._getTimesCompleted (level);
		}
Ejemplo n.º 10
0
		public static int DecTimesCompleted(Level level){
			return instance._decTimesCompleted (level);
		} 
Ejemplo n.º 11
0
 /** Unity-Editor Functions **/
 /// <summary>
 /// Sets the slowest (given) duration for the given level.
 /// </summary>
 /// <param name="level"><c>Level</c> to set slowest duration.</param>
 /// <param name="duration">Duration to set.</param>
 protected virtual void _setSlowestDurationMillis(Level level, long duration)
 {
     string key = keySlowestDuration (level.ID);
     string val = duration.ToString ();
     KeyValueStorage.SetValue (key, val);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Increases by 1 the number of times the given <c>Level</c> has been started. 
        /// </summary>
        /// <returns>The number of times started after increasing.</returns>
        /// <param name="level"><c>Level</c> to increase its times started.</param>
        protected virtual int _incTimesStarted(Level level)
        {
            int started = _getTimesStarted(level);
            if (started < 0) { /* can't be negative */
                started = 0;
            }
            string startedStr = (started + 1).ToString();
            string key = keyTimesStarted(level.ID);
            KeyValueStorage.SetValue (key, startedStr);

            // Notify level has started
            LevelUpEvents.OnLevelStarted (level);

            return started + 1;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Increases by 1 the number of times the given <c>Level</c> has been played. 
        /// </summary>
        /// <returns>The number of times played after increasing.</returns>
        /// <param name="level"><c>Level</c> to increase its times played.</param>
        protected virtual int _incTimesPlayed(Level level)
        {
            int played = _getTimesPlayed(level);
            if (played < 0) { /* can't be negative */
                played = 0;
            }
            string playedStr = (played + 1).ToString();
            string key = keyTimesPlayed(level.ID);
            KeyValueStorage.SetValue (key, playedStr);

            // Notify level has ended
            LevelUpEvents.OnLevelEnded (level);

            return played + 1;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Increases by 1 the number of times the given <c>Level</c> has been played. 
        /// </summary>
        /// <returns>The number of times played after increasing.</returns>
        /// <param name="level"><c>Level</c> to increase its times played.</param>
        protected virtual int _incTimesCompleted(Level level)
        {
            int completed = _getTimesCompleted(level);
            if (completed < 0) { /* can't be negative */
                completed = 0;
            }
            string completedStr = (completed + 1).ToString();
            string key = keyTimesCompleted(level.ID);
            KeyValueStorage.SetValue (key, completedStr);

            return completed + 1;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Retrieves the number of times this <c>Level</c> has been started. 
        /// </summary>
        /// <returns>The number of times started.</returns>
        /// <param name="level"><c>Level</c> whose times started is to be retrieved.</param>
        protected virtual int _getTimesStarted(Level level)
        {
            string key = keyTimesStarted(level.ID);
            string val = KeyValueStorage.GetValue (key);

            int started = 0;
            if (!string.IsNullOrEmpty(val)) {
                started = int.Parse(val);
            }

            return started;
        }
Ejemplo n.º 16
0
		/** LEVEL TIMES PLAYED **/

		public static int IncTimesPlayed(Level level) {
			return instance._incTimesPlayed (level);
		}
Ejemplo n.º 17
0
		public static int DecTimesPlayed(Level level){
			return instance._decTimesPlayed (level);
		} 
Ejemplo n.º 18
0
		/// <summary>
		/// Sets the fastest (given) duration for the given <c>Level</c>.
		/// </summary>
		/// <param name="level"><c>Level</c> to set fastest duration.</param>
		/// <param name="duration">Duration to set.</param>
		protected virtual void _setFastestDurationMillis(Level level, long duration) {
#if UNITY_EDITOR
			string key = keyFastestDuration (level.ID);
			string val = duration.ToString ();
			PlayerPrefs.SetString (key, val);
#endif
		}
Ejemplo n.º 19
0
	protected override void _setFastestDurationMillis(Level level, long duration) {
		levelStorage_SetFastestDurationMillis(level.ID, duration);
	}
Ejemplo n.º 20
0
		/// <summary>
		/// Gets the fastest duration for the given <c>Level</c>.
		/// </summary>
		/// <returns>The fastest duration of the given <c>Level</c>.</returns>
		/// <param name="level"><c>Level</c> to get fastest duration.</param>
		protected virtual long _getFastestDurationMillis(Level level) {
#if UNITY_EDITOR
			string key = keyFastestDuration (level.ID);
			string val = PlayerPrefs.GetString (key);
			return (string.IsNullOrEmpty(val)) ? 0 : long.Parse (val);
#else
			return 0;
#endif
		}
Ejemplo n.º 21
0
	/** Level Times Started **/
	
	protected override int _incTimesStarted(Level level) {
		return levelStorage_IncTimesStarted(level.ID);
	}
Ejemplo n.º 22
0
		/// <summary>
		/// Increases by 1 the number of times the given <c>Level</c> has been played. 
		/// </summary>
		/// <returns>The number of times played after increasing.</returns>
		/// <param name="level"><c>Level</c> to increase its times played.</param>
		protected virtual int _incTimesPlayed(Level level) {
#if UNITY_EDITOR
			int played = _getTimesPlayed(level);
			if (played < 0) { /* can't be negative */
				played = 0;
			}
			string playedStr = (played + 1).ToString();
			string key = keyTimesPlayed(level.ID);
			PlayerPrefs.SetString (key, playedStr);
			
			// Notify level has ended
			LevelUpEvents.OnLevelEnded (level);
			
			return played + 1;
#else
			return 0;
#endif
		}
Ejemplo n.º 23
0
	protected override int _getTimesPlayed(Level level) {
		return levelStorage_GetTimesPlayed(level.ID);
	}
Ejemplo n.º 24
0
		/// <summary>
		/// Decreases by 1 the number of times the given <c>Level</c> has been played. 
		/// </summary>
		/// <returns>The number of times played after decreasing.</returns>
		/// <param name="level"><c>Level</c> to decrease its times played.</param>
		protected virtual int _decTimesCompleted(Level level){
			#if UNITY_EDITOR
			int completed = _getTimesCompleted(level);
			if (completed <= 0) { /* can't be negative or zero */
				return 0;
			}
			string completedStr = (completed - 1).ToString();
			string key = keyTimesCompleted(level.ID);
			PlayerPrefs.SetString (key, completedStr);
			
			return completed - 1;
			#else
			return 0;
			#endif
		} 
Ejemplo n.º 25
0
		/// <summary>
		/// Retrieves the number of times this <c>Level</c> has been played. 
		/// </summary>
		/// <returns>The number of times played.</returns>
		/// <param name="level"><c>Level</c> whose times played is to be retrieved.</param>
		protected virtual int _getTimesCompleted(Level level) {
			#if UNITY_EDITOR
			string key = keyTimesCompleted(level.ID);
			string val = PlayerPrefs.GetString (key);
			
			int completed = 0;
			if (!string.IsNullOrEmpty(val)) {
				completed = int.Parse(val);
			}
			
			return completed;
			#else
			return 0;
			#endif
		}
Ejemplo n.º 26
0
		public static void SetFastestDurationMillis(Level level, long duration) {
			instance._setFastestDurationMillis(level, duration);
		}
Ejemplo n.º 27
0
		public override void Init()
		{
			base.Init ();
			_level = new Level(cDummyLevelID);
		}
Ejemplo n.º 28
0
		public static long GetFastestDurationMillis(Level level) {
			return instance._getFastestDurationMillis(level);
		}
Ejemplo n.º 29
0
		private void onEventFired(Level level, string eventName)
		{
			Dictionary<string, object> expected = EventQueue.Dequeue ();
			
			Assert.AreEqual(expected["handler"], eventName);
			
			Assert.AreEqual(expected["id"], level.ID);
		}
Ejemplo n.º 30
0
        /// <summary>
        /// Decreases by 1 the number of times the given <c>Level</c> has been started. 
        /// </summary>
        /// <returns>The number of times started after decreasing.</returns>
        /// <param name="level"><c>Level</c> to decrease its times started.</param>
        protected virtual int _decTimesStarted(Level level)
        {
            int started = _getTimesStarted(level);
            if (started <= 0) { /* can't be negative or zero */
                return 0;
            }
            string startedStr = (started - 1).ToString();
            string key = keyTimesStarted(level.ID);
            KeyValueStorage.SetValue (key, startedStr);

            return started - 1;
        }