public IEnumerator PlayBackward() { if (!IsRun) { bool Flag = true; IsRun = true; Log LOG; do { LOG = ExecutedStack.Peek(); if (LOG.type == activityType.TURNCOLOR) { TurnColor log = (TurnColor)ExecutedStack.Pop(); if (log.restore) { Flag = false; Nodes[log.index].SetColor(log.DestinationColor); yield return(new WaitForSeconds(MoveTool.duration)); Nodes[log.index].SetColor(log.OriginColor); } else { Nodes[log.index].SetColor(log.OriginColor); } } else { Movement log = (Movement)ExecutedStack.Pop(); Nodes[log.index].MoveTo(-log.x_steps, -log.y_steps); } MyTools.QueuePushFront(DemoQueue, LOG); } while (ExecutedStack.Count > 0 && ExecutedStack.Peek().hasNext); if (Flag) { yield return(new WaitForSeconds(MoveTool.duration)); } IsRun = false; } }
public IEnumerator PlayForward() { bool flag = true; if (!IsRun) { IsRun = true; Log LOG; do { LOG = DemoQueue.Peek(); if (LOG.type == activityType.MOVE) { Movement log = (Movement)DemoQueue.Dequeue(); Nodes[log.index].MoveTo(log.x_steps, log.y_steps);; } else { TurnColor log = (TurnColor)DemoQueue.Dequeue(); Nodes[log.index].SetColor(log.DestinationColor); if (log.restore) //如果要求颜色变回去 { flag = false; yield return(new WaitForSeconds(MoveTool.duration)); Nodes[log.index].SetColor(log.OriginColor); } } ExecutedStack.Push(LOG); } while (DemoQueue.Count > 0 && LOG.hasNext); if (flag) { yield return(new WaitForSeconds(MoveTool.duration)); } IsRun = false; } }