-
-
Save IneonInoodle/9ab6ae7d1144417e939d7755446e3db0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class Command | |
{ | |
public static Queue<Command> CommandQueue = new Queue<Command>(); | |
public static bool playingQueue = false; | |
public virtual void AddToQueue() | |
{ | |
CommandQueue.Enqueue(this); | |
if (!playingQueue) | |
PlayFirstCommandFromQueue(); | |
} | |
public virtual void StartCommandExecution() | |
{ | |
// list of everything that we have to do with this command (move, delete, show a message, show a effect, etc...) | |
// there are 2 options of timing : | |
// 1) use tween sequences and call CommandExecutionComplete in OnComplete() | |
// 2) use coroutines (IEnumerator) and WaitFor... to introduce delays, call CommandExecutionComplete() in the end of coroutine | |
} | |
public static void CommandExecutionComplete() | |
{ | |
if (CommandQueue.Count > 0) | |
PlayFirstCommandFromQueue(); | |
else | |
playingQueue = false; | |
if (TurnManager.Instance.whoseTurn != null) | |
TurnManager.Instance.whoseTurn.HighlightPlayableCards(); | |
} | |
public static void PlayFirstCommandFromQueue() | |
{ | |
playingQueue = true; | |
CommandQueue.Dequeue().StartCommandExecution(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment