Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / tileSetEditorCombination / leftBottom / MaskRectCell.cs
  1. using Godot;
  2.  
  3. namespace UI.TileSetEditorCombination;
  4.  
  5. public class MaskRectCell : UiCell<TileSetEditorCombination.MaskRect, bool>
  6. {
  7. public override void OnInit()
  8. {
  9. CellNode.Instance.Draw += OnDraw;
  10. }
  11.  
  12. public override void OnSetData(bool data)
  13. {
  14. //选择当前cell时显示透明颜色
  15. CellNode.Instance.Color = data ? new Color(0, 0, 0, 0) : new Color(0, 0, 0, 0.7f);
  16. }
  17.  
  18. public override void Process(float delta)
  19. {
  20. if (Data)
  21. {
  22. CellNode.Instance.QueueRedraw();
  23. }
  24. }
  25.  
  26. private void OnDraw()
  27. {
  28. if (Data)
  29. {
  30. //选中时绘制轮廓
  31. CellNode.Instance.DrawRect(
  32. new Rect2(Vector2.Zero, CellNode.Instance.Size),
  33. new Color(0, 1, 1), false, 2f / CellNode.UiPanel.S_TileTexture.Instance.Scale.X
  34. );
  35. }
  36. }
  37. }