Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / tileSetEditorCombination / leftBottom / MaskBrush.cs
  1. using Godot;
  2.  
  3. namespace UI.TileSetEditorCombination;
  4.  
  5. public partial class MaskBrush : Control
  6. {
  7. /// <summary>
  8. /// 绑定的地图纹理节点
  9. /// </summary>
  10. public TextureRect TileTexture { get; set; }
  11. /// <summary>
  12. /// 绑定的TileSet编辑区域节点
  13. /// </summary>
  14. public TileEditArea TileEditArea { get; set; }
  15.  
  16. public override void _Process(double delta)
  17. {
  18. QueueRedraw();
  19. }
  20.  
  21. public override void _Draw()
  22. {
  23. //绘制texture区域
  24. if (TileTexture.Texture != null)
  25. {
  26. var editorPanel = TileEditArea.UiNode.UiPanel.EditorPanel;
  27. DrawRect(
  28. new Rect2(Vector2.Zero, editorPanel.CellHorizontal * GameConfig.TileCellSize, editorPanel.CellVertical * GameConfig.TileCellSize),
  29. new Color(1, 1, 0, 0.5f), false,
  30. 2f / TileTexture.Scale.X
  31. );
  32. }
  33.  
  34. //绘制鼠标悬停区域
  35. if (TileTexture.IsMouseInRect())
  36. {
  37. var pos = TileEditArea.GetMouseCellPosition() * GameConfig.TileCellSize;
  38. DrawRect(
  39. new Rect2(pos,GameConfig.TileCellSizeVector2I),
  40. Colors.Green, false, 3f / TileTexture.Scale.X
  41. );
  42. }
  43. }
  44. }