Exemplo n.º 1
0
    private TileBase CheckGround()
    {
        //If DoGroundCast returns Vector2.zero (it's the same as Vector2(0, 0)) it means it didn't hit the ground and therefore we are not grounded.
        RaycastHit2D hit = DoGroundCast();

        if (isGrounded)
        {
            Vector3 pos = hit.point;
            pos.y -= 0.5f;
            pos.z  = 0;
            return(World.getTile_GlobalPos(pos)); // Get Tile Below
        }
        else
        {
            return(null);
        }
    }
    public bool isValidGridPos()
    {
        foreach (var pos in SolidTiles.cellBounds.allPositionsWithin)     //TODO: concatenate these?
        {
            Vector3Int localPlace = new Vector3Int(pos.x, pos.y, 0);
            Vector3    place      = getWorldCoord(localPlace);
            if (SolidTiles.HasTile(localPlace) && World.getTile_GlobalPos(place) != null)
            {
                return(false);
            }
        }

        foreach (var pos in NotSolidTiles.cellBounds.allPositionsWithin)
        {
            Vector3Int localPlace = new Vector3Int(pos.x, pos.y, 0);
            Vector3    place      = getWorldCoord(localPlace);
            if (NotSolidTiles.HasTile(localPlace) && World.getTile_GlobalPos(place) != null)
            {
                return(false);
            }
        }
        return(true);
    }