UserGameHeroModel.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * Description of UserGameHeroModel
  5. * @version
  6. * 1.0.0 Created at 2017-2-14. by --gwang
  7. * @author gwang (mail@wanggangzero.cn)
  8. * @copyright ? 2017-2-14, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  9. */
  10. /**
  11. * 玩家收集的英雄的卡牌集合
  12. */
  13. class UserGameHeroModel extends Object_ext
  14. {
  15. /**
  16. * 当前展示的英雄的UID
  17. * @var type string
  18. */
  19. public $displayHeroUID;
  20. /**
  21. * 好友支援的英雄的UID
  22. * @var type string
  23. */
  24. public $firendSupportHeroUID;
  25. /**
  26. * 当前收集卡牌的数量上限(可扩容)
  27. * @var type int
  28. */
  29. public $maxCollectCount;
  30. /**
  31. * 英雄集合
  32. * @var {}
  33. */
  34. public $collectHeros;
  35. /**
  36. * 记录一下曾经的最大UID
  37. * @var type int
  38. */
  39. public $recordMaxUID;
  40. /**
  41. *
  42. * @param CRedisUtil $mem
  43. */
  44. public function InitializeHero()
  45. {
  46. $this->displayHeroUID = null;
  47. $this->firendSupportHeroUID = null;
  48. $this->maxCollectCount = glc()->Game_CollectHero_BasicMaxCount;
  49. $this->recordMaxUID = 0;
  50. $this->collectHeros = ObjectInit();
  51. # 设置初始英雄
  52. $hids = GameConfig::primordial_data()->User_Heros;
  53. foreach ($hids as $heroModelId) {
  54. //1.检查是否存在这个英雄的模板
  55. $heroCfg = GameConfig::hero_getItem($heroModelId);
  56. if ($heroCfg) {
  57. $uid = HeroProc::CreateNewGameHeroUID($this->collectHeros, $this->recordMaxUID);
  58. $this->recordMaxUID = $uid;
  59. $hero = HeroProc::getGameHeroModelInstance($heroCfg, $heroModelId, $uid);
  60. $this->collectHeros->$uid = $hero;
  61. $this->displayHeroUID = $uid;
  62. $this->firendSupportHeroUID = $uid;
  63. }
  64. }
  65. }
  66. }