예제 #1
0
 // Wrapper für paintblock, damit die blöcke an der untersten position platziert werden, der spieler gewechselt wird und geprüft wird ob das spiel nach dem zug gewonnen ist.
 public void paintblockw(int x)
 {
     if ((x >= GameSettings.GameAreaX) || (x < 0))
     {
         return;
     }
     if ((GameSettings.GameAreaX == 3) && (GameSettings.GameAreaY == 3))
     {
         paintblockwttt(x); return;
     }
     // An der untersten Stelle beginnen und bis zum nächsten leeren feld hochgehen
     for (int i = GameSettings.GameAreaY - 1; i >= 0; i--)
     {
         if (blockarr[x, i] == 0)
         {
             //      col row
             blockarr[x, i] = color;
             paintblock(x, i);
             if (!istutorial)
             {
                 color = changeplayer(color);
             }
             if (GameLogic.check(x, i, blockarr))
             {
                 loop = false;
             }
             tries--;
             if (tries == 0)
             {
                 loop = false;
             }
             break;
         }
     }
 }
예제 #2
0
파일: Game.cs 프로젝트: weareblank/ainf-1
 // Wrapper für paintblock, damit die blöcke an der untersten position platziert werden, der spieler gewechselt wird und geprüft wird ob das spiel nach dem zug gewonnen ist.
 public void paintblockw(int x)
 {
     if ((x >= 7) || (x < 0))
     {
         return;
     }
     // An der untersten Stelle beginnen und bis zum nächsten leeren feld hochgehen
     for (int i = 5; i >= 0; i--)
     {
         if (blockarr[x, i] == 0)
         {
             //      col row
             blockarr[x, i] = color;
             paintblock(x, i);
             color = changeplayer(color);
             if (GameLogic.check(x, i, blockarr))
             {
                 loop = false;
             }
             tries--;
             if (tries == 0)
             {
                 loop = false;
             }
             break;
         }
     }
 }
예제 #3
0
        // tick-tack-toe painblock wrapper

        //todo: overwrite paintblockw with this when we are in "ttt mode"
        private void paintblockwttt(int x)
        {
            //todo: code cleanup & find bug that causes out of bounds & fix ai
            var tmpc = color;
            var lp   = true;
            var y    = 0;

            while (lp)
            {
                //gefärbte blöcke überspringen; return wenn keine felder mehr frei sind
                color = 3;
                if (blockarr[x, y] == 0)
                {
                    paintblock(x, y);
                }
                else if (y == 2)
                {
                    return;
                }
                else
                {
                    y++; continue;
                }

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey(true);
                    switch (key.Key)
                    {
                    case ConsoleKey.UpArrow:
                        if ((y > 0) && (blockarr[x, y - 1] == 0))
                        {
                            color = 0;
                            paintblock(x, y);
                            y--;
                        }
                        else if ((y == 2) && (blockarr[x, y - 2] == 0))
                        {
                            color = 0;
                            paintblock(x, y);
                            y -= 2;
                        }
                        break;

                    case ConsoleKey.DownArrow:
                        if (y < 2 && (blockarr[x, y + 1] == 0))
                        {
                            color = 0;
                            paintblock(x, y);
                            y++;
                        }
                        else if ((y == 0) && (blockarr[x, y + 2] == 0))
                        {
                            color = 0;
                            paintblock(x, y);
                            y += 2;
                        }
                        break;

                    case ConsoleKey.Enter:
                        lp    = false;
                        color = tmpc;
                        paintblock(x, y);
                        blockarr[x, y] = tmpc;
                        continue;
                    }
                    color = 3;
                    paintblock(x, y);
                }
            }
            color = changeplayer(tmpc);
            if (GameLogic.check(x, y, blockarr))
            {
                loop = false;
            }
            return;
        }