Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / tileSetEditorTerrain / right / TerrainBrush.cs
@小李xl 小李xl on 23 Dec 2023 918 bytes 编辑TileSet地形, 制作中
  1. using Godot;
  2.  
  3. namespace UI.TileSetEditorTerrain;
  4.  
  5. public partial class TerrainBrush : Control
  6. {
  7. public TextureRect TileTexture { get; set; }
  8.  
  9. public override void _Process(double delta)
  10. {
  11. QueueRedraw();
  12. }
  13.  
  14. public override void _Draw()
  15. {
  16. //绘制区域
  17. DrawRect(
  18. new Rect2(GameConfig.TileCellSizeVector2I,
  19. TileTexture.Texture.GetSize() - GameConfig.TileCellSizeVector2I * 2), new Color(1, 1, 0, 0.5f), false,
  20. 2f / TileTexture.Scale.X);
  21. //绘制鼠标悬停区域
  22. if (TileTexture.IsMouseInRect(GameConfig.TileCellSize))
  23. {
  24. var pos = Utils.GetMouseCellPosition(TileTexture) * GameConfig.TileCellSize;
  25. DrawRect(
  26. new Rect2(pos,GameConfig.TileCellSizeVector2I),
  27. Colors.Green, false, 3f / TileTexture.Scale.X
  28. );
  29. }
  30. }
  31. }