コード例 #1
0
        public TileInfo GetTileAtPosition(Vector2 pos, TileLayer l)
        {
            int           x, y, tileId = -1;
            TileDirection dir = TileDirection.Up;

            if (map.GetTileAtPosition(pos, out x, out y))
            {
                tileId = map.GetTile(x, y, (int)l);
            }
            tk2dTileFlags flags = map.GetTileFlags(x, y, (int)l);

            dir = (TileFlagsToTileDirection(flags));

            TileInfo tile = new TileInfo();

            tile.worldPos = map.GetTilePosition(x, y);
            switch (tileId)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 32:
            case 33:
            case 34:
            case 35:
            case 36:
            case 64:
            case 65:
            case 66:
                tile.type = TileType.Wall;
                break;

            case 8:
                tile.type = TileType.Lava;
                break;

            default:
                tile.type = TileType.Empty;
                break;
            }
            if (tileId == spikeTile)
            {
                tile.type = TileType.Spike;
            }
            print(tile.type);
            tile.direction = dir;
            return(tile);
        }