GearDisplay2.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using FairyGUI.Utils;
  3. namespace FairyGUI
  4. {
  5. /// <summary>
  6. /// Gear is a connection between object and controller.
  7. /// </summary>
  8. public class GearDisplay2 : GearBase
  9. {
  10. /// <summary>
  11. /// Pages involed in this gear.
  12. /// </summary>
  13. public string[] pages { get; set; }
  14. public int condition;
  15. int _visible;
  16. public GearDisplay2(GObject owner)
  17. : base(owner)
  18. {
  19. }
  20. override protected void AddStatus(string pageId, ByteBuffer buffer)
  21. {
  22. }
  23. override protected void Init()
  24. {
  25. pages = null;
  26. }
  27. override public void Apply()
  28. {
  29. if (pages == null || pages.Length == 0
  30. || Array.IndexOf(pages, _controller.selectedPageId) != -1)
  31. _visible = 1;
  32. else
  33. _visible = 0;
  34. }
  35. override public void UpdateState()
  36. {
  37. }
  38. public bool Evaluate(bool connected)
  39. {
  40. bool v = _controller == null || _visible > 0;
  41. if (this.condition == 0)
  42. v = v && connected;
  43. else
  44. v = v || connected;
  45. return v;
  46. }
  47. }
  48. }