Newer
Older
DungeonShooting / DungeonShooting_Godot / src / framework / map / serialize / tileSet / TileCombinationInfo.cs
@小李xl 小李xl on 6 Jan 2024 1 KB 读取TileSet数据, 开发中
  1.  
  2. using System.Text.Json.Serialization;
  3.  
  4. /// <summary>
  5. /// 组合图块数据
  6. /// </summary>
  7. public class TileCombinationInfo : IClone<TileCombinationInfo>
  8. {
  9. /// <summary>
  10. /// 组合唯一Id
  11. /// </summary>
  12. [JsonInclude]
  13. public string Id;
  14. /// <summary>
  15. /// 组合名称
  16. /// </summary>
  17. [JsonInclude]
  18. public string Name;
  19. /// <summary>
  20. /// 组合图块数据, 在纹理中的坐标, 单位: 像素
  21. /// </summary>
  22. [JsonInclude]
  23. public SerializeVector2[] Cells;
  24. /// <summary>
  25. /// 组合图块数据, 显示位置, 单位: 像素
  26. /// </summary>
  27. [JsonInclude]
  28. public SerializeVector2[] Positions;
  29.  
  30. public TileCombinationInfo Clone()
  31. {
  32. var combinationInfo = new TileCombinationInfo();
  33. combinationInfo.Id = Id;
  34. combinationInfo.Name = Name;
  35. if (Cells != null)
  36. {
  37. combinationInfo.Cells = new SerializeVector2[Cells.Length];
  38. for (int i = 0; i < Cells.Length; i++)
  39. {
  40. combinationInfo.Cells[i] = Cells[i].Clone();
  41. }
  42. }
  43.  
  44. if (Positions != null)
  45. {
  46. combinationInfo.Positions = new SerializeVector2[Positions.Length];
  47. for (int i = 0; i < Positions.Length; i++)
  48. {
  49. combinationInfo.Positions[i] = Positions[i].Clone();
  50. }
  51. }
  52. return combinationInfo;
  53. }
  54. }