Beispiel #1
0
    public static bool CanMove(GameObject obj, int checkDirection)       //returns true if movement of given object to given direction is possible
    {
        int[] coordinates = MapUtility.TranslateWorldToMapCoordinates(obj);
        bool  rValue      = false;

        switch (checkDirection)
        {
        case 0:
            rValue = MapUtility.CanMoveRight(coordinates);
            break;

        case 1:
            rValue = MapUtility.CanMoveLeft(coordinates);
            break;

        case 2:
            rValue = MapUtility.CanMoveUp(coordinates);
            break;

        case 3:
            rValue = MapUtility.CanMoveDown(coordinates);
            break;
        }

        return(rValue);
    }
Beispiel #2
0
    public static bool CanMove(int[] coordinates, int checkDirection)       //returns true if movement from given cell to given direction is possible
    {
        bool rValue = false;

        switch (checkDirection)
        {
        case 0:
            rValue = MapUtility.CanMoveRight(coordinates);
            break;

        case 1:
            rValue = MapUtility.CanMoveLeft(coordinates);
            break;

        case 2:
            rValue = MapUtility.CanMoveUp(coordinates);
            break;

        case 3:
            rValue = MapUtility.CanMoveDown(coordinates);
            break;
        }

        return(rValue);
    }
Beispiel #3
0
    public static bool[] checkMoves(int[] coordinates)       //checks which directions from the given coordinates can moved in
    {
        bool[] canMove = new bool[4];

        canMove [0] = MapUtility.CanMoveRight(coordinates);
        canMove [1] = MapUtility.CanMoveLeft(coordinates);
        canMove [2] = MapUtility.CanMoveUp(coordinates);
        canMove [3] = MapUtility.CanMoveDown(coordinates);

        return(canMove);
    }
Beispiel #4
0
    public static bool[] checkMoves(GameObject obj)       //
    {
        bool[] canMove = new bool[4];

        canMove [0] = MapUtility.CanMoveRight(obj.transform.gameObject);
        canMove [1] = MapUtility.CanMoveLeft(obj.transform.gameObject);
        canMove [2] = MapUtility.CanMoveUp(obj.transform.gameObject);
        canMove [3] = MapUtility.CanMoveDown(obj.transform.gameObject);

        return(canMove);
    }