Exemple #1
0
        // @
        // CUSTOM YIELDS


        /// <summary>
        /// IEnumerator that waits the completion of a TeaTime.
        /// </summary>
        private IEnumerator WaitForCompletion(TeaTime tt)
        {
            while (!tt.IsCompleted)
            {
                yield return(null);
            }
        }
Exemple #2
0
 /// <summary>
 /// Appends a TeaTime to wait after the current callback execution that
 /// is also affected by the queue .Stop() and .Reset().
 /// </summary>
 public void Wait(TeaTime tt)
 {
     // A reference to the waiting list
     if (!self._waiting.Contains(tt))
     {
         self._waiting.Add(tt);
         Wait(tt.WaitForCompletion());
     }
 }
Exemple #3
0
        /// <summary>
        /// Appends a TeaTime to wait after the current callback execution that
        /// is also affected by .Stop() and .Reset().
        /// </summary>
        public void Wait(TeaTime tt)
        {
            // Currently waiting
            if (!self._waiting.Contains(tt))
            {
                self._waiting.Add(tt);
            }

            Wait(tt.WaitForCompletion());
        }
	void Start()
	{
		queue = this.tt().Pause().Add(1, () =>
		{
			Debug.Log("step 1 " + Time.time);
		})
		.Add(1, () =>
		{
			Debug.Log("step 2 " + Time.time);
		})
		.Add(1, (ttHandler t) =>
		{
			Debug.Log("step 3 " + Time.time);
			t.WaitFor(1);
		})
		.Add(() =>
		{
			Debug.Log("step 4 " + Time.time);
		})
		.Loop(1, (ttHandler t) =>
		{
			transform.position = Vector3.Lerp(transform.position, new Vector3(10, 10, 10), t.deltaTime);
		})
		.Add(() =>
		{
			Debug.Log("step 5 " + Time.time);
		})
		.Loop((ttHandler t) =>
		{
			transform.position = Vector3.Lerp(transform.position, Vector3.zero, t.deltaTime);

			if (t.timeSinceStart >= 1)
				t.Break();
		})
		.Add(() =>
		{
			Debug.Log("step 6 " + Time.time);
		})
		.Add(new WaitForSeconds(1), () =>
		{
			Debug.Log("step 7 " + Time.time);
		})
		.Loop(0, (ttHandler t) =>
		{
			// Ignorable loop
		})
		.Add(1, () =>
		{
			Debug.Log("step 8 " + Time.time);
		})
		.Wait();
	}
Exemple #5
0
        /// <summary>
        /// Returns a TeaTime queue bounded to his name, unique per
        /// MonoBehaviour instance, new on the first call. This allows you to
        /// access queues without a formal definition. Dark magic, be careful.
        /// </summary>
        public static TeaTime tt(this MonoBehaviour instance, string queueName)
        {
            // #todo ttRegister will (probably) need an auto clean up from
            // time to time if this technique is used in volatile GameObjects.

            // First time
            if (ttRegister == null)
            {
                ttRegister = new Dictionary <MonoBehaviour, Dictionary <string, TeaTime> >();
            }

            if (!ttRegister.ContainsKey(instance))
            {
                ttRegister[instance] = new Dictionary <string, TeaTime>();
            }

            if (!ttRegister[instance].ContainsKey(queueName))
            {
                ttRegister[instance][queueName] = new TeaTime(instance);
            }


            return(ttRegister[instance][queueName]);
        }
Exemple #6
0
 public ttWaitForCompletion(TeaTime tt)
 {
     this.tt = tt;
 }
	void Start()
	{
		// Instantiate
		queue = new TeaTime(this);
		// or you can use this shortcut: 'queue = this.tt();' (special MonoBehaviour extension)
	}
Exemple #8
0
		/// <summary>
		/// Returns a TeaTime queue bounded to his name, unique per
		/// MonoBehaviour instance, new on the first call. This allows you to
		/// access queues without a formal definition. Dark magic.
		/// </summary>
		public static TeaTime tt(this MonoBehaviour instance, string queueName)
		{
			// #todo ttRegister will (probably) need an auto clean up from
			// time to time if this technique is used in volatile GameObjects.

			// First time
			if (ttRegister == null)
				ttRegister = new Dictionary<MonoBehaviour, Dictionary<string, TeaTime>>();

			if (!ttRegister.ContainsKey(instance))
				ttRegister[instance] = new Dictionary<string, TeaTime>();

			if (!ttRegister[instance].ContainsKey(queueName))
				ttRegister[instance][queueName] = new TeaTime(instance);


			return ttRegister[instance][queueName];
		}