IAPCtlShop.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 "IAPCtlShopUI.hpp"
  13. #include "IAPDelegate.hpp"
  14. #include "IAPConf.hpp"
  15. NS_IAP_BEGIN
  16. class IAPCtlShop : public cocos2d::Ref {
  17. public:
  18. // 创建一个商店控制器
  19. static IAPCtlShop* createWith();
  20. // 初始化
  21. // cfgFN 配置文件名
  22. void init(std::string& cfgFN);
  23. // 设置代理
  24. // delegate 代理的实现
  25. void setDelegate(IAPDelegate* delegate);
  26. // 设置当前设备的等级
  27. // level 等级: 1 表示初级, 2 表示中级, 3 表示高级
  28. void setDeviceLevel(int level);
  29. // 添加一个商店版位
  30. // plInfo 版位信息
  31. bool addAPlacement(const IAPPlacement& plInfo);
  32. // 删除一个商店版位
  33. // id 卡片id(添加版位时的id)
  34. void removePlacement(const std::string& id);
  35. // 在某个节点中显示
  36. // pParent 父节点
  37. // requirement 对商店的要求,比如说最低金币数
  38. void showInNode(cocos2d::Node* pParent, ShopRequirement& requirement);
  39. // 以滑动卡片的形式在某个节点中显示某些版位(适用于失败时的场景)
  40. // pParent 父节点
  41. // plIds 需要的版位id
  42. void showPlacementsInNode(cocos2d::Node* pParent, const vector<std::string>& plIds);
  43. private:
  44. static IAPCtlShop* _instance;
  45. IAPConf* _conf;
  46. IAPCtlShopUI* _shopUI;
  47. IAPDelegate* _delegate;
  48. int _level;
  49. };
  50. NS_IAP_END
  51. #endif /* IAPCtlShop_hpp */