Esempio n. 1
0
    public static bool isNextJunction(int[] pos, Directions direction)      //returns true if the next cell (based on given movement direction) is a junction
    {
        int[] checkPos = GetNext(pos, (int)direction);

        if (checkPos[0] >= LevelGenerator.GetRows() || checkPos[1] >= LevelGenerator.GetCols())
        {
            return(false);
        }
        else if (MapUtility.GetMapCell(checkPos) == 3)
        {
            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    public static bool CanMoveLeft(int[] coordinates)       //gets game object, returns true if object can move left one cell on the grid
    {
        int[] leftCoordinates = new int[] { coordinates[0], coordinates[1] - 1 };

        if (coordinates [1] == 0)
        {
            return(false);
        }
        else if (MapUtility.GetMapCell(leftCoordinates) == 1)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Esempio n. 3
0
    public static bool CanMoveUp(GameObject obj)       //gets game object, returns true if object can move up one cell on the grid
    {
        int[] coordinates   = MapUtility.TranslateWorldToMapCoordinates(obj);
        int[] upCoordinates = new int[] { coordinates[0] - 1, coordinates[1] };

        if (coordinates [0] == 0)
        {
            return(false);
        }
        else if (MapUtility.GetMapCell(upCoordinates) != 1)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 4
0
    public static bool CanMoveRight(int[] coordinates)        //gets game object, returns true if object can move right one cell on the grid
    {
        int[] leftCoordinates = new int[] { coordinates[0], coordinates[1] + 1 };

        if (leftCoordinates[1] >= LevelGenerator.GetCols())
        {
            return(false);
        }


        if (MapUtility.GetMapCell(leftCoordinates) == 1)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Esempio n. 5
0
    public static bool CanMoveDown(int[] coordinates)        //gets coordinates, returns true if object can move down one cell on the grid
    {
        int[] downCoordinates = new int[] { coordinates[0] + 1, coordinates[1] };

        if (downCoordinates[0] >= LevelGenerator.GetRows())
        {
            return(false);
        }


        if (MapUtility.GetMapCell(downCoordinates) == 1)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Esempio n. 6
0
    public static bool CanMoveUp(int[] coordinates)        //gets game object, returns true if object can move up one cell on the grid
    {
        int[] upCoordinates = new int[] { coordinates[0] - 1, coordinates[1] };

        if (upCoordinates[0] <= 0)
        {
            return(false);
        }


        if (MapUtility.GetMapCell(upCoordinates) == 1)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Esempio n. 7
0
    public static bool isNextWall(int[] pos, int currentDirection)       //returns true if next cell in the current movement direction is a wall
    {
        int[] checkPos = new int[2];

        switch (currentDirection)
        {
        case 0:
            checkPos[0] = pos[0];
            checkPos[1] = pos[1] + 1;
            break;

        case 1:
            checkPos[0] = pos[0];
            checkPos[1] = pos[1] - 1;
            break;

        case 2:
            checkPos[0] = pos[0] - 1;
            checkPos[1] = pos[1];
            break;

        case 3:
            checkPos[0] = pos[0] + 1;
            checkPos[1] = pos[1];
            break;
        }

        if (checkPos[0] >= LevelGenerator.GetRows() || checkPos[1] >= LevelGenerator.GetCols())
        {
            return(false);
        }
        else if (MapUtility.GetMapCell(checkPos) == 1)
        {
            return(true);
        }

        return(false);
    }
Esempio n. 8
0
    public static bool CanMoveRight(GameObject obj)       //gets game object, returns true if object can move right one cell on the grid
    {
        int[] coordinates     = MapUtility.TranslateWorldToMapCoordinates(obj);
        int[] leftCoordinates = new int[] { coordinates[0], coordinates[1] + 1 };

        if (leftCoordinates[1] >= LevelGenerator.GetCols())
        {
            return(false);
        }

        if (coordinates [1] == (LevelGenerator.GetRows() - 1))
        {
            return(false);
        }
        else if (MapUtility.GetMapCell(leftCoordinates) == 1)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Esempio n. 9
0
    public static bool CanMoveDown(GameObject obj)        //gets game object, returns true if object can move down one cell on the grid
    {
        int[] coordinates     = MapUtility.TranslateWorldToMapCoordinates(obj);
        int[] downCoordinates = new int[] { coordinates[0] + 1, coordinates[1] };

        if (downCoordinates[0] >= LevelGenerator.GetRows())
        {
            return(false);
        }

        if (coordinates [0] == (LevelGenerator.GetRows() - 1))
        {
            return(false);
        }
        else if (MapUtility.GetMapCell(downCoordinates) != 1)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }