IAPCtlShop.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // IAPCtlShop.hpp
  3. // TileManor
  4. //
  5. // Created by 徐炼新 on 2024/9/30.
  6. //
  7. #ifndef IAPCtlShop_hpp
  8. #define IAPCtlShop_hpp
  9. #include <stdio.h>
  10. #include "cocos2d.h"
  11. #include "IAPDefine.hpp"
  12. #include "IAPShopDelegate.hpp"
  13. class IAPConf;
  14. class IAPCtlShopUI;
  15. class PBConfigData;
  16. NS_IAPSHOP_BEGIN
  17. class IAPCtlShop : public cocos2d::Ref {
  18. public:
  19. // 创建一个商店控制器
  20. static IAPCtlShop* createWith();
  21. // 设置代理
  22. // delegate 代理的实现
  23. void setDelegate(IAPShopDelegate* delegate);
  24. // 初始化普通商店卡片配置
  25. // cfgFN 配置文件名
  26. void init(std::string& cfgFN);
  27. // 设置失败时内购卡片的配置
  28. // cfgFN 配置文件名
  29. void setCfg4Failure(std::string& cfgFN);
  30. // 设置当前设备的等级
  31. // level 等级: 1 表示初级, 2 表示中级, 3 表示高级 (中级目前没有设计)
  32. void setDeviceLevel(int level);
  33. // 添加一个商店版位
  34. // plInfo 版位信息
  35. bool addAPlacement(const IAPPlacement& plInfo);
  36. // 删除一个商店版位
  37. // id 添加版位时的id
  38. void removePlacement(const std::string& id);
  39. // 给某个商店版位添加卡片
  40. // id 商店版位id card 卡片信息
  41. bool addCardToPlacement(const std::string& id, IAPCard* card);
  42. // 给某个商店版位删除卡片
  43. // id 商店版位id cardIndex 卡片索引
  44. bool removeCardToPlacement(const std::string& id, int cardIndex = -1);
  45. // 清空活动
  46. void clearPlacement();
  47. // 获取活动版位总数
  48. size_t getPlacementCount();
  49. // 在某个节点中打开普通商店
  50. // pParent 父节点
  51. // requirement 对商店的要求,比如说最低金币数
  52. void showInNode(cocos2d::Node* pParent, ShopRequirement& requirement);
  53. // 显示失败时的内购卡片(失败时卡片,非普通商店卡片)
  54. // Node 父节点
  55. // cardsName 内购卡片名称
  56. void displayFailureCardIn(cocos2d::Node*, std::vector<std::string> cardsName);
  57. // 以滑动卡片的形式在某个节点中显示满足金币条件的所有 普通商店卡片(暂未使用)删除?
  58. // pParent 父节点
  59. // stillNeedCoins 距离所需要的金币数还差多少金币
  60. void showSlideCardsByCoinsIn(cocos2d::Node* pParent, int stillNeedCoins);
  61. // 添加用户购买信息 并 从delegate发送购买的道具信息
  62. // commodityID 购买的商店卡片ID
  63. void addUserBuyInfo(std::string commodityID);
  64. // 清除用户购买信息
  65. void clearUserBuyInfo();
  66. private:
  67. private:
  68. static IAPCtlShop* _instance;
  69. IAPShopDelegate* _delegate;
  70. IAPConf* _conf;
  71. PBConfigData* _pbConf;
  72. };
  73. NS_IAPSHOP_END
  74. #endif /* IAPCtlShop_hpp */