IAPCtlShop.hpp 2.3 KB

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