Exemplo n.º 1
0
    /// <summary>
    /// Gibt die neue Position eines Blockes im Grid zurück.
    /// </summary>
    /// <param name="direction"></param>
    /// <param name="gameBlock"></param>
    /// <returns></returns>
    private Vector2 GetNewPosition(Direction direction, Playstone gameBlock)
    {
        Vector2 expectedPosition = new Vector2(gameBlock.Position.x, gameBlock.Position.y);

        if (direction == Direction.DOWN)
        {
            expectedPosition += new Vector2(0, -1);
        }
        else if (direction == Direction.LEFT)
        {
            expectedPosition += new Vector2(-1, 0);
        }
        else
        {
            expectedPosition += new Vector2(1, 0);
        }

        int expectedPositionY = (int)Math.Round(expectedPosition.y);
        int expectedPositionX = (int)Math.Round(expectedPosition.x);

        if (GameController.IsValidPosition(expectedPositionY, expectedPositionX))
        {
            return(expectedPosition);
        }
        else
        {
            return(new Vector2(gameBlock.Position.x, gameBlock.Position.y));
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        GameOverScreen.enabled = false;
        // Initialisierung des Spielfeldes
        grid = new Playstone[h][];

        for (int y = 0; y < h; y++)
        {
            grid[y] = new Playstone[w];
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Setzt alle Reihen oberhalt von above um eine Reihe nach unten
    /// </summary>
    /// <param name="above">y-Koordinate ab der Reihen nach unten verschoben werden</param>
    private void DecreaseAllRowsAbove(int above)
    {
        for (int x = above; x < h - 1; x++)
        {
            grid[x]     = grid[x + 1];
            grid[x + 1] = new Playstone[w];

            for (int y = 0; y < w; y++)
            {
                if (grid[x][y] != null)
                {
                    grid[x][y].DecreasedTimes += 1;
                }
            }
        }
    }