2024-05-24 14:58:52 +00:00
|
|
|
|
using Godot;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.utils;
|
|
|
|
|
|
2024-06-05 13:38:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>TileMapUtils</para>
|
|
|
|
|
/// <para>TileMap工具</para>
|
|
|
|
|
/// </summary>
|
2024-04-28 13:55:19 +00:00
|
|
|
|
public static class TileMapUtils
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Get the layer number corresponding to LayerName in TileMap</para>
|
|
|
|
|
/// <para>在TileMap内获取LayerName所对应的图层序号</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tileMap"></param>
|
|
|
|
|
/// <param name="layerName"></param>
|
|
|
|
|
/// <returns>
|
|
|
|
|
///<para>− 1 is returned after obtaining failure</para>
|
|
|
|
|
///<para>获取失败返回-1</para>
|
|
|
|
|
/// </returns>
|
|
|
|
|
public static int GetTileMapLayer(TileMap tileMap, string layerName)
|
|
|
|
|
{
|
|
|
|
|
var count = tileMap.GetLayersCount();
|
|
|
|
|
for (var i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
var currentLayerName = tileMap.GetLayerName(i);
|
|
|
|
|
if (currentLayerName == layerName)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2024-05-24 14:58:52 +00:00
|
|
|
|
|
2024-04-28 13:55:19 +00:00
|
|
|
|
}
|