IAPCtlShop.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 "IAPDelegate.hpp"
  13. class IAPConf;
  14. class IAPCtlShopUI;
  15. class PBConfigData;
  16. NS_IAP_BEGIN
  17. class IAPCtlShop : public cocos2d::Ref {
  18. public:
  19. // 创建一个商店控制器
  20. static IAPCtlShop* createWith();
  21. // 设置代理
  22. // delegate 代理的实现
  23. void setDelegate(IAPDelegate* 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(添加版位时的id)
  38. void removePlacement(const std::string& id);
  39. // 给某个商店版位添加卡片
  40. bool addCardToPlacement(const std::string& id, IAPCard* card);
  41. // 给某个商店版位删除卡片
  42. bool removeCardToPlacement(const std::string& id, int cardIndex = -1);
  43. // 清空活动
  44. void clearPlacement();
  45. // 获取活动版位总数
  46. size_t getPlacementCount();
  47. // 在某个节点中打开普通商店
  48. // pParent 父节点
  49. // requirement 对商店的要求,比如说最低金币数
  50. void showInNode(cocos2d::Node* pParent, ShopRequirement& requirement);
  51. // 显示失败时的内购卡片(失败时卡片,非普通商店卡片)
  52. // Node 父节点
  53. // cardsName 内购卡片名称
  54. void displayFailureCardIn(cocos2d::Node*, std::vector<std::string> cardsName);
  55. // 以滑动卡片的形式在某个节点中显示满足金币条件的所有 普通商店卡片(暂未使用)删除?
  56. // pParent 父节点
  57. // stillNeedCoins 距离所需要的金币数还差多少金币
  58. void showSlideCardsByCoinsIn(cocos2d::Node* pParent, int stillNeedCoins);
  59. // 添加用户购买信息 并 从delegate发送购买的道具信息
  60. void addUserBuyInfo(std::string commodityID);
  61. // 清除用户购买信息
  62. void clearUserBuyInfo();
  63. private:
  64. private:
  65. static IAPCtlShop* _instance;
  66. IAPDelegate* _delegate;
  67. IAPConf* _conf;
  68. PBConfigData* _pbConf;
  69. };
  70. NS_IAP_END
  71. #endif /* IAPCtlShop_hpp */