JisolGame/JNFrame2/Assets/JNGame/Sync/App/Tile/JNSSTileClientService.cs

61 lines
1.4 KiB
C#
Raw Normal View History

2024-08-17 14:27:18 +08:00
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using JNGame.Math;
namespace JNGame.Sync.State.Tile
{
/// <summary>
/// 瓦片状态同步客户端
/// </summary>
public abstract class JNSSTileClientService : JNSStateClientService
{
/// <summary>
/// 当前显示的Tile
/// </summary>
protected List<int> TileShow = new ();
/// <summary>
/// 区块索引组
/// </summary>
protected abstract int[][] Tiles { get; }
/// <summary>
/// 区块大小
/// </summary>
protected abstract int TileSize { get; }
2024-08-22 20:37:39 +08:00
2024-08-17 14:27:18 +08:00
public int GetTileIndex(LVector3 pos)
{
2024-08-22 20:37:39 +08:00
return JNSSTileTool.GetTileIndex(Tiles, TileSize, pos);
2024-08-17 14:27:18 +08:00
}
/// <summary>
/// 获取九宫格Index
/// </summary>
/// <returns></returns>
public List<int> GetTileGridIndex(LVector3 pos)
{
2024-08-22 20:37:39 +08:00
return JNSSTileTool.GetTileGridIndex(Tiles, TileSize,pos);
2024-08-17 14:27:18 +08:00
}
public void AddTileShow(int index)
{
if (!(TileShow.Contains(index)))
{
TileShow.Add(index);
}
}
public void RemoveTileShow(int index)
{
if (TileShow.Contains(index))
{
TileShow.Remove(index);
}
}
}
}