Info_Gates.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace loyalsoft;
  8. /**
  9. * Description of Info_Gates
  10. *
  11. * @author c'y'zhao
  12. */
  13. class Info_Gates extends Object_ext {
  14. /**
  15. * 当前剧情选择的关卡
  16. */
  17. public $CurrentGateId = 0;
  18. /**
  19. * 已解锁剧情关卡的最大id
  20. * @var type
  21. */
  22. public $UnlockedGatesMaxId = 0;
  23. /**
  24. * 章节列表
  25. * @var Ins_GateInfo
  26. */
  27. public $GateList = null;
  28. /**
  29. * 挑战功能领取记录
  30. * @var type
  31. */
  32. public $GatesChallengeRecord = null;
  33. /**
  34. * 进化解锁记录
  35. * @var type
  36. */
  37. #[ArrayType]
  38. public $evolveUnlockRecord = array();
  39. /**
  40. * 巡逻领取奖励的时间
  41. * @var int
  42. */
  43. public $xunluo_StartTs = 0;
  44. /**
  45. * 快速巡逻的购买记录
  46. * @var int
  47. */
  48. public $xunluo_quick_buyRecord = 0;
  49. /**
  50. * 进化左边解锁最大值得记录
  51. * @var type
  52. */
  53. public $evolveMaxId_left = 0;
  54. /**
  55. * 进化右边解锁最大值得记录
  56. * @var type
  57. */
  58. public $evolveMaxId_right = 0;
  59. public function initialize() {
  60. $startId = 10010121;
  61. $this->CurrentGateId = $startId;
  62. $this->UnlockedGatesMaxId = $startId;
  63. $this->GateList = new \stdClass();
  64. $Ins_GateInfo = new Ins_GateInfo();
  65. $Ins_GateInfo->GateId = $this->CurrentGateId;
  66. $this->GateList->$startId = $Ins_GateInfo;
  67. $this->GatesChallengeRecord = new \stdClass();
  68. $this->xunluo_StartTs = now();
  69. }
  70. public function __construct($arg = null) {
  71. if ($arg == null) {
  72. if ($this->CurrentGateId == 0) {
  73. $startId = 1;
  74. $this->CurrentGateId = $startId;
  75. $this->UnlockedGatesMaxId = $startId;
  76. $this->GateList = new \stdClass();
  77. $Ins_GateInfo = new Ins_GateInfo();
  78. $Ins_GateInfo->GateId = $this->CurrentGateId;
  79. $this->GateList->$startId = $Ins_GateInfo;
  80. }
  81. $this->GatesChallengeRecord = new \stdClass();
  82. $this->xunluo_StartTs = now();
  83. } else {
  84. parent::__construct($arg);
  85. }
  86. }
  87. /**
  88. * 当前关卡信息
  89. * @return Ins_GateInfo
  90. */
  91. public function CurGateInfo() {
  92. $gateId = $this->CurrentGateId;
  93. my_Assert(StlUtil::dictHasProperty($this->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo);
  94. $gateInfo = ctx()->gates->GateList->$gateId;
  95. return $gateInfo;
  96. }
  97. /**
  98. * @return 解锁下一剧情关卡
  99. */
  100. public function UnlockNextPlotGate() {
  101. $nextId = $this->CurrentGateId;
  102. foreach (GameConfig::gate() as $k => $v) {
  103. isEditor() and $v = new \sm_gate();
  104. if ($v->unlockGateId == $this->CurrentGateId) {
  105. $nextId = $v->gateId;
  106. }
  107. }
  108. if (!StlUtil::dictHasProperty($this->GateList, $nextId)) {
  109. $this->CurrentGateId = $nextId;
  110. $this->UnlockedGatesMaxId = $nextId;
  111. $gate = new Ins_GateInfo();
  112. $gate->GateId = $nextId;
  113. $this->GateList->$nextId = $gate;
  114. }
  115. return $nextId;
  116. }
  117. }