IAPCtlShop.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #include "PBConfigData.hpp"
  14. class IAPConf;
  15. class IAPCtlShopUI;
  16. NS_IAP_BEGIN
  17. enum UserBuyType{
  18. NoShopping, // 无购买行为
  19. LittleShopping, // 仅购买特惠
  20. NormalShopping, // 正常消费
  21. LotShopping // 土豪
  22. };
  23. class IAPCtlShop : public cocos2d::Ref {
  24. public:
  25. // 创建一个商店控制器
  26. static IAPCtlShop* createWith();
  27. // 初始化
  28. // cfgFN 配置文件名
  29. void init(std::string& cfgFN);
  30. // 设置代理
  31. // delegate 代理的实现
  32. void setDelegate(IAPDelegate* delegate);
  33. // 设置失败时内购卡片的配置
  34. void setCfg4Failure(std::string& cfgFN);
  35. // 显示失败时的内购卡片
  36. void displayFailureCardIn(cocos2d::Node*, std::vector<std::string> cardsName);
  37. // 设置当前设备的等级
  38. // level 等级: 1 表示初级, 2 表示中级, 3 表示高级
  39. void setDeviceLevel(int level);
  40. // 添加一个商店版位
  41. // plInfo 版位信息
  42. bool addAPlacement(const IAPPlacement& plInfo);
  43. // 删除一个商店版位
  44. // id 卡片id(添加版位时的id)
  45. void removePlacement(const std::string& id);
  46. // 给某个商店版位添加卡片
  47. bool addCardToPlacement(const std::string& id, IAPCard* card);
  48. // 给某个商店版位删除卡片
  49. bool removeCardToPlacement(const std::string& id, int cardIndex = -1);
  50. // 清空活动
  51. void clearPlacement();
  52. // 获取活动礼包总数
  53. size_t getPlacementCount();
  54. // 在某个节点中显示
  55. // pParent 父节点
  56. // requirement 对商店的要求,比如说最低金币数
  57. void showInNode(cocos2d::Node* pParent, ShopRequirement& requirement);
  58. // 以滑动卡片的形式在某个节点中显示满足金币条件的所有商店卡片
  59. // pParent 父节点
  60. // stillNeedCoins 距离所需要的金币数还差多少金币
  61. void showSlideCardsByCoinsIn(cocos2d::Node* pParent, int stillNeedCoins);
  62. // 获取用户类型
  63. UserBuyType getUserBuyType();
  64. // 添加用户购买信息 并 从delegate发送购买的道具信息
  65. void addUserBuyInfo(std::string commodityID);
  66. // 清除用户购买信息
  67. void clearUserBuyInfo();
  68. // 获取用户购买过的最贵礼包金额
  69. float getUserBuyMaxAmount();
  70. private:
  71. private:
  72. static IAPCtlShop* _instance;
  73. IAPDelegate* _delegate;
  74. IAPConf* _conf;
  75. PBConfigData* _pbConf;
  76. };
  77. NS_IAP_END
  78. #endif /* IAPCtlShop_hpp */