DealerMaid.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.IO;
  3. public class DealerMaid
  4. {
  5. public Maid Maid
  6. {
  7. get
  8. {
  9. return this.m_DealerMaid;
  10. }
  11. }
  12. private void Init(bool is_active)
  13. {
  14. if (this.m_DealerMaid)
  15. {
  16. return;
  17. }
  18. int num = (!is_active) ? GameMain.Instance.CharacterMgr.GetStockMaidCount() : GameMain.Instance.CharacterMgr.GetMaidCount();
  19. for (int i = 0; i < num; i++)
  20. {
  21. Maid maid;
  22. if (is_active)
  23. {
  24. maid = GameMain.Instance.CharacterMgr.GetMaid(i);
  25. }
  26. else
  27. {
  28. maid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
  29. }
  30. if (maid)
  31. {
  32. bool flag = maid.status.personal.uniqueName == "Muku" && maid.status.mainChara;
  33. if (flag)
  34. {
  35. this.m_DealerMaid = maid;
  36. if (is_active)
  37. {
  38. this.m_ActiveNo = maid.ActiveSlotNo;
  39. this.m_StockNo = -1;
  40. }
  41. else
  42. {
  43. this.m_ActiveNo = -1;
  44. this.m_StockNo = i;
  45. }
  46. break;
  47. }
  48. }
  49. }
  50. }
  51. public void Init()
  52. {
  53. if (this.m_DealerMaid)
  54. {
  55. this.SetDealerMaid(this.m_DealerMaid);
  56. }
  57. else
  58. {
  59. this.Init(true);
  60. this.Init(false);
  61. }
  62. }
  63. public void SetDealerMaid(Maid maid)
  64. {
  65. this.m_DealerMaid = maid;
  66. this.m_ActiveNo = maid.ActiveSlotNo;
  67. if (this.m_ActiveNo >= 0)
  68. {
  69. this.m_StockNo = -1;
  70. }
  71. else
  72. {
  73. for (int i = 0; i < GameMain.Instance.CharacterMgr.GetStockMaidCount(); i++)
  74. {
  75. if (maid == GameMain.Instance.CharacterMgr.GetStockMaid(i))
  76. {
  77. this.m_StockNo = i;
  78. break;
  79. }
  80. }
  81. }
  82. }
  83. public void Serialize(BinaryWriter bw)
  84. {
  85. this.Init();
  86. bw.Write(this.m_ActiveNo);
  87. bw.Write(this.m_StockNo);
  88. }
  89. public void Deserialize(BinaryReader br)
  90. {
  91. this.m_ActiveNo = br.ReadInt32();
  92. this.m_StockNo = br.ReadInt32();
  93. this.m_DealerMaid = null;
  94. if (this.m_ActiveNo >= 0)
  95. {
  96. this.m_DealerMaid = GameMain.Instance.CharacterMgr.GetMaid(this.m_ActiveNo);
  97. }
  98. else if (this.m_StockNo >= 0)
  99. {
  100. this.m_DealerMaid = GameMain.Instance.CharacterMgr.GetStockMaid(this.m_StockNo);
  101. }
  102. this.Init();
  103. }
  104. private int m_ActiveNo = -1;
  105. private int m_StockNo = -1;
  106. private Maid m_DealerMaid;
  107. }