Ejemplo n.º 1
0
    bool CanMoveRight()
    {
        fruitCurrentPos = GameSceneManagers.Spawn.GetFruitCurrentPos();

        //Sağ tarafı yoksa return
        if (fruitCurrentPos.y == GameSceneManagers.Spawn.grid.GetLength(1) - 1)
        {
            return(false);
        }
        //Sağ tarafı boşsa return
        if (GameSceneManagers.Spawn.grid[fruitCurrentPos.x, fruitCurrentPos.y + 1].blockType == BlockType.Empty)
        {
            return(false);
        }
        //Sağ tarafı engelse return
        if (GameSceneManagers.Spawn.grid[fruitCurrentPos.x, fruitCurrentPos.y + 1].blockType == BlockType.Obstacle)
        {
            return(false);
        }

        //1 kare sağdaki kare, o karenin altındakileri kontrol et. Engel varsa return
        if (fruitCurrentPos.x + 1 != GameSceneManagers.Spawn.grid.GetLength(0))
        {
            if (GameSceneManagers.Spawn.grid[fruitCurrentPos.x + 1, fruitCurrentPos.y + 1].blockType == BlockType.Obstacle)
            {
                return(false);
            }
        }
        return(true);
    }
Ejemplo n.º 2
0
    public FruitCurrentPos GetFruitCurrentPos()
    {
        FruitCurrentPos fruitCurrentPos = new FruitCurrentPos();

        for (int i = 0; i < grid.GetLength(0); i++)
        {
            for (int j = 0; j < grid.GetLength(1); j++)
            {
                if (grid[i, j].isPuzzleOnGround)
                {
                    fruitCurrentPos.x = i;
                    fruitCurrentPos.y = j;
                }
            }
        }
        return(fruitCurrentPos);
    }
Ejemplo n.º 3
0
 bool CanMoveForward()
 {
     fruitCurrentPos = GameSceneManagers.Spawn.GetFruitCurrentPos();
     //Önü yoksa return
     if (fruitCurrentPos.x == 0)
     {
         return(false);
     }
     //Önü boşsa return
     if (GameSceneManagers.Spawn.grid[fruitCurrentPos.x - 1, fruitCurrentPos.y].blockType == BlockType.Empty)
     {
         return(false);
     }
     //Önü engelse return
     if (GameSceneManagers.Spawn.grid[fruitCurrentPos.x - 1, fruitCurrentPos.y].blockType == BlockType.Obstacle)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
    bool CanMoveBack()
    {
        fruitCurrentPos = GameSceneManagers.Spawn.GetFruitCurrentPos();

        //Arkası yoksa return
        if (fruitCurrentPos.x == GameSceneManagers.Spawn.grid.GetLength(0) - 1)
        {
            return(false);
        }

        //Arkası boşsa return
        if (GameSceneManagers.Spawn.grid[fruitCurrentPos.x + 1, fruitCurrentPos.y].blockType == BlockType.Empty)
        {
            return(false);
        }

        //Arkası engelse return
        if (GameSceneManagers.Spawn.grid[fruitCurrentPos.x + 1, fruitCurrentPos.y].blockType == BlockType.Obstacle)
        {
            return(false);
        }
        return(true);
    }