Newer
Older
DungeonShooting / DungeonShooting_Godot / src / framework / map / fog / RoomFogMask.cs
@小李xl 小李xl on 22 Sep 2023 714 bytes 地牢迷雾,开发中
  1.  
  2. using Godot;
  3.  
  4. public partial class RoomFogMask : PointLight2D, IDestroy
  5. {
  6. public bool IsDestroyed { get; private set; }
  7. private bool _init = false;
  8. public void Init(RoomInfo roomInfo, Rect2I rect2)
  9. {
  10. if (_init)
  11. {
  12. return;
  13. }
  14. GlobalPosition = rect2.Position + rect2.Size / 2;
  15. //创建光纹理
  16. var img = Image.Create(rect2.Size.X, rect2.Size.Y, false, Image.Format.Rgba8);
  17. img.Fill(Colors.White);
  18. Texture = ImageTexture.CreateFromImage(img);
  19. }
  20. public void Destroy()
  21. {
  22. if (IsDestroyed)
  23. {
  24. return;
  25. }
  26.  
  27. IsDestroyed = true;
  28. QueueFree();
  29. }
  30. }