Exemple #1
0
    private void Move(int x, int y)
    {
        TileType active = placer.GetActive();

        int newX = active.X + x;
        int newY = active.Y + y;

        if (placer.GetAt(newX, newY) != null)
        {
            if (placer.GetAt(newX, newY).Type == "G")
            {
                GetComponent <GameManeger>().NextLevel();
            }
        }

        if (placer.CheckAt(newX, newY))
        {
            placer.SetActive(newX, newY);
        }
        else
        {
            placer.Show();
            placer.ToFade = 0.3f;
            errors++;
        }
    }
Exemple #2
0
    /*
     * soll sich vom start nach rechts bewegen      => beforzugt abigen richting rechts
     * nocht aus dem bilschrim kommen               => beforzugt beim abbigen reichting mitte
     * nur dei bestimmte anzual an ecken machen     => random + length / ecken
     */

    private void Generate()
    {
        placer.PlacePathHiddenAt(StartX, StartY);

        lastX = StartX;
        lastY = StartY;

        nowX = StartX;
        nowY = StartY;

        int dirX = 1, dirY = 0;

        for (lengthMade = 1; lengthMade <= maxLenght; lengthMade++)
        {
            Debug.Log(lengthMade);
            if (ToMakeTurn() && !neededForceRotate)
            {
                cornersMade++;
                Debug.Log("turn");

                if (ToTurnLeft())
                {
                    if (dirX == 1)
                    {
                        dirY = 1;
                        dirX = 0;
                    }
                    else if (dirX == -1)
                    {
                        dirY = -1;
                        dirX = 0;
                    }
                    else if (dirY == 1)
                    {
                        dirY = 0;
                        dirX = -1;
                    }
                    else if (dirY == -1)
                    {
                        dirY = 0;
                        dirX = 1;
                    }
                }
                else
                {
                    if (dirX == 1)
                    {
                        dirY = -1;
                        dirX = 0;
                    }
                    else if (dirX == -1)
                    {
                        dirY = 1;
                        dirX = 0;
                    }
                    else if (dirY == 1)
                    {
                        dirY = 0;
                        dirX = 1;
                    }
                    else if (dirY == -1)
                    {
                        dirY = 0;
                        dirX = -1;
                    }
                }
            }

            if (neededForceRotate)
            {
                neededForceRotate = false;
            }

            lastX = nowX;
            lastY = nowY;

            nowX += dirX;
            nowY += dirY;

            if (!placer.CheckBound(nowX + dirX, nowY + dirY))
            {
                neededForceRotate = true;
                Debug.Log("FUCKFFFFFFFFFFFFFFFFFFFFF");
                if (lastY == nowY)
                {
                    if (nowX < 0)
                    {
                        nowY += -1 - dirY;
                        dirY  = -1;
                    }
                    else
                    {
                        nowY += 1 - dirY;
                        dirY  = 1;
                    }

                    nowX += -dirX;
                    dirX  = 0;
                }
                else
                {
                    if (placer.CheckBound(nowX + 2, nowY - dirY))
                    {
                        nowX += 1 - dirX;
                        dirX  = 1;
                    }
                    else
                    {
                        nowX += -1 - dirX;
                        dirX  = -1;
                    }
                    nowY -= dirY;
                    dirY  = 0;
                }
            }

            placer.PlacePathHiddenAt(nowX, nowY);
        }

        placer.PalceTile(nowX, nowY, "G");
        placer.SetActive(StartX, StartY);

        placer.Show();
    }