Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
3.3 kB
32
Indexable
private void Move()
    {
        Debug.Log(direction);

        //0 = LR, 1 = LRB, 2 = LRT, 3 = TB, 4 = LRTB
        //direction 1/2 = right, 3/4 = left, 5 = down
        if (currentY > 0)
        {
            if (direction == 1 || direction == 2)
            {
                //right
                if (currentX < 3)
                {
                    currentX++;
                    grid[currentX, currentY] = 0;
                    direction = Helpers.Choose<int>(1, 2, 1, 2, 5);

                    downCounter = 0;
                }
                else
                {
                    grid[currentX, currentY] = 4;

                    currentY--;

                    grid[currentX, currentY] = Helpers.Choose<int>(1, 4);

                    direction = Helpers.Choose<int>(3, 4, 5);
                }
            }
            else if (direction == 3 || direction == 4)
            {
                //left
                if (currentX > 0)
                {
                    currentX--;
                    Debug.Log("Right X: " + currentX);
                    grid[currentX, currentY] = 0;
                    direction = Helpers.Choose<int>(3, 4, 3, 4, 5);

                    downCounter = 0;
                }
                else
                {
                    grid[currentX, currentY] = 4;

                    currentY--;
                    Debug.Log("Current Y: " + currentY);

                    grid[currentX, currentY] = Helpers.Choose<int>(1, 4);

                    direction = Helpers.Choose<int>(1, 2, 5);
                }
            }
            else if (direction == 5)
            {
                //down
                if (currentY > 0)
                {
                    if(moveCounter == 0)
                    {
                        grid[currentX, currentY] = 1;
                    }
                    else
                    {
                        if (downCounter > 1)
                        {
                            grid[currentX, currentY] = Helpers.Choose<int>(3, 4);
                        }
                        else
                        {
                            grid[currentX, currentY] = 1;
                        }
                    }

                    currentY--;

                    //grid[currentX, currentY] = Helpers.Choose<int>(2, 4);
                    if(grid[currentX, currentY+1] > -1)
                    {
                        if (downCounter > 0)
                            grid[currentX, currentY] = 4;
                        else
                            grid[currentX, currentY] = 2;
                    }
                    else
                    {
                        grid[currentX, currentY] = 4;
                    }

                    downCounter++;
                    direction = Helpers.Choose<int>(1, 2, 3, 4, 5);
                }
                else
                {
                    Debug.Log("Done");
                    GameObject.Find("MiniMapCanvas").GetComponent<MiniMap>().BuildDisplay(grid);
                    generating = false;
                }
            }
        }
        else
        {
            Debug.Log("Done");
            GameObject.Find("MiniMapCanvas").GetComponent<MiniMap>().BuildDisplay(grid);
            return;
        }

        moveCounter++;
    }