69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System.Linq;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
using Milimoe.FunGame.Core.Interface.Base;
|
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
|
using Milimoe.FunGame.Core.Model;
|
|
|
|
namespace Milimoe.GodotGame
|
|
{
|
|
public class GodotMap(TileMapLayer layer) : GameMap
|
|
{
|
|
public override string Name => "GodotMap";
|
|
|
|
public override string Description => "Milimoe's Godot Map";
|
|
|
|
public override string Version => "1.0.0";
|
|
|
|
public override string Author => "Milimoe";
|
|
|
|
public override int Length => 26;
|
|
|
|
public override int Width => 10;
|
|
|
|
public override int Height => 1;
|
|
|
|
public override float Size => 16;
|
|
|
|
public TileMapLayer TileMapLayer { get; set; } = layer;
|
|
|
|
public Dictionary<long, Vector2I> GridToVector2I { get; set; } = [];
|
|
|
|
public override GameMap InitGamingQueue(IGamingQueue queue)
|
|
{
|
|
GodotMap map = new(TileMapLayer);
|
|
map.Load();
|
|
|
|
if (queue is GamingQueue gq)
|
|
{
|
|
gq.WriteLine($"地图 {map.Name} 已加载。");
|
|
}
|
|
// 绑定坐标数据
|
|
long gridId = 0;
|
|
for (int j = 5; j <= 14; j++)
|
|
{
|
|
for (int i = 89; i <= 114; i++)
|
|
{
|
|
if (Grids.ContainsKey(gridId))
|
|
{
|
|
Vector2I v = new(i, j);
|
|
GridToVector2I[gridId] = v;
|
|
}
|
|
}
|
|
}
|
|
|
|
return map;
|
|
}
|
|
|
|
public Vector2I GetVector2IByGrid(Grid grid)
|
|
{
|
|
return GridToVector2I.FirstOrDefault(kv => kv.Key == grid.Id).Value;
|
|
}
|
|
|
|
public Grid GetGridByVector2I(Vector2I vector)
|
|
{
|
|
return Grids[GridToVector2I.FirstOrDefault(kv => kv.Value.X == vector.X && kv.Value.Y == vector.Y).Key];
|
|
}
|
|
}
|
|
}
|