Advertisement
Graf_Rav

Untitled

Feb 11th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class MoveManager:MonoBehaviour{
  6.     Queue <Action> queue=new Queue<Action>();
  7.  
  8.     public void AddToQueue(Action act){
  9.         queue.Enqueue(act);
  10.         if(queue.Count==1){
  11.             StartCoroutine(queueChecker());
  12.         }
  13.     }
  14.  
  15.     private IEnumerator queueChecker(){
  16.         while(queue.Count!=0){
  17.             yield return StartCoroutine(queue.Peek().ActionCor());
  18.             queue.Dequeue();
  19.         }
  20.     }
  21. }
  22.  
  23. public abstract class Action{
  24.     public abstract IEnumerator ActionCor();
  25. }
  26.  
  27. public class Move:Action{
  28.     private int test;
  29.  
  30.     public Move(int _test){
  31.         test=_test;
  32.     }
  33.  
  34.     public override IEnumerator ActionCor(){
  35.         yield return new WaitForSeconds(1);
  36.         Debug.Log(test);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement