private void PopulateWordGames(int amount)
 {
     wordList = new List <WordGame>();
     for (int i = 0; i < amount; i++)
     {
         WordGame x = new WordGame();
         x.Show();
         wordList.Add(x);
     }
 }
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            tick++;
            for (int i = 0; i < cutList.Count(); i++)
            {
                if (cutList[i].IsComplete)
                {
                    cutList[i].Stop();
                    score++;
                }
            }
            for (int i = 0; i < sandList.Count(); i++)
            {
                if (sandList[i].IsComplete)
                {
                    sandList[i].Stop();
                    score++;
                }
            }
            bool endAll = false;

            for (int i = 0; i < cutList.Count(); i++)
            {
                cutList[i].Update(tick);
            }
            for (int i = 0; i < sandList.Count(); i++)
            {
                sandList[i].Update(tick);
            }
            for (int i = 0; i < wordList.Count(); i++)
            {
                wordList[i].Update(tick);
            }
            for (int i = 0; i < numList.Count(); i++)
            {
                numList[i].update(tick);
            }
            for (int i = 0; i < cutList.Count(); i++)
            {
                if (cutList[i].IsGameOver)
                {
                    endAll = true;
                }
            }
            for (int i = 0; i < sandList.Count(); i++)
            {
                if (sandList[i].IsGameOver)
                {
                    endAll = true;
                }
            }
            for (int i = 0; i < wordList.Count(); i++)
            {
                if (wordList[i].IsGameOver)
                {
                    endAll = true;
                }
            }
            for (int i = 0; i < numList.Count(); i++)
            {
                if (numList[i].IsGameOver)
                {
                    endAll = true;
                }
            }
            if (endAll)
            {
                EndAll();
                return;
            }
            for (int i = 0; i < cutList.Count(); i++)
            {
                if (cutList[i].IsComplete)
                {
                    cutList[i].Stop();
                    score++;
                }
            }
            for (int i = 0; i < sandList.Count(); i++)
            {
                if (sandList[i].IsComplete)
                {
                    sandList[i].Stop();
                    score++;
                }
            }
            for (int i = 0; i < numList.Count(); i++)
            {
                if (numList[i].IsComplete)
                {
                    numList[i].Stop();
                    score++;
                }
            }
            for (int i = 0; i < wordList.Count(); i++)
            {
                if (wordList[i].IsComplete)
                {
                    wordList[i].Stop();
                    score++;
                }
            }
            if (gameDelay > 0)
            {
                gameDelay--;
                return;
            }
            if (AllActive())
            {
                return;
            }

DecideGame:
            object syncLock = new object();
            int nextGame = -1;

            lock (syncLock)
            {
                nextGame = random.Next() % 4;
            }
            if (lastGame == nextGame)
            {
                goto DecideGame;
            }
            if (nextGame == 0)
            {
                int nextWindow;
                if (cutList.Count == 1)
                {
                    if (cutList[0].IsActive)
                    {
                        goto DecideGame;
                    }
                    nextWindow = 0;
                }
                else
                {
DecideWindow1:
                    object syncLoc = new object();
                    lock (syncLoc)
                    {
                        nextWindow = random.Next() % cutList.Count;
                    }
                    if (nextWindow == lastCut)
                    {
                        return;
                    }
                }
                CutWire x = cutList[nextWindow];
                if (x.IsActive)
                {
                    return;
                }
                x.Start(tick);
                lastCut = nextWindow;
            }
            if (nextGame == 1)
            {
                int nextWindow;
                if (sandList.Count == 1)
                {
                    if (sandList[0].IsActive)
                    {
                        goto DecideGame;
                    }
                    nextWindow = 0;
                }
                else
                {
DecideWindow1:
                    object syncLoc = new object();
                    lock (syncLoc)
                    {
                        nextWindow = random.Next() % sandList.Count;
                    }
                    if (nextWindow == lastSand)
                    {
                        return;
                    }
                }
                MakeSandwich x = sandList[nextWindow];
                if (x.IsActive)
                {
                    return;
                }
                x.Start(tick);
                lastSand = nextWindow;
            }
            if (nextGame == 2)
            {
                if (numList.Count == 0)
                {
                    return;
                }
                int nextWindow;
                if (numList.Count == 1)
                {
                    if (numList[0].IsActive)
                    {
                        goto DecideGame;
                    }
                    nextWindow = 0;
                }
                else
                {
DecideWindow1:
                    object syncLoc = new object();
                    lock (syncLoc)
                    {
                        nextWindow = random.Next() % numList.Count;
                    }
                    if (nextWindow == lastNum)
                    {
                        return;
                    }
                }
                OrderNumbers x = numList[nextWindow];
                if (x.IsActive)
                {
                    return;
                }
                x.start(tick);

                lastNum = nextWindow;
            }
            if (nextGame == 3)
            {
                int nextWindow;
                if (wordList.Count == 1)
                {
                    if (wordList[0].IsActive)
                    {
                        goto DecideGame;
                    }
                    nextWindow = 0;
                }
                else
                {
DecideWindow1:
                    object syncLoc = new object();
                    lock (syncLoc)
                    {
                        nextWindow = random.Next() % wordList.Count;
                    }
                    if (nextWindow == lastWord)
                    {
                        return;
                    }
                }
                WordGame x = wordList[nextWindow];
                if (x.IsActive)
                {
                    return;
                }
                x.Start(tick);

                lastNum = nextWindow;
            }
            lastGame   = nextGame;
            pauseTime -= 2;
            gameDelay  = pauseTime;
        }