// // IAPCtlShop.hpp // TileManor // // Created by 徐炼新 on 2024/9/30. // #ifndef IAPCtlShop_hpp #define IAPCtlShop_hpp #include #include "cocos2d.h" #include "IAPDefine.hpp" #include "IAPDelegate.hpp" #include "PBConfigData.hpp" class IAPConf; class IAPCtlShopUI; NS_IAP_BEGIN enum UserBuyType{ NoShopping, // 无购买行为 LittleShopping, // 仅购买特惠 NormalShopping, // 正常消费 LotShopping // 土豪 }; class IAPCtlShop : public cocos2d::Ref { public: // 创建一个商店控制器 static IAPCtlShop* createWith(); // 初始化 // cfgFN 配置文件名 void init(std::string& cfgFN); // 设置代理 // delegate 代理的实现 void setDelegate(IAPDelegate* delegate); // 设置失败时内购卡片的配置 void setCfg4Failure(std::string& cfgFN); // 显示失败时的内购卡片 void displayFailureCardIn(cocos2d::Node*, std::vector cardsName); // 设置当前设备的等级 // level 等级: 1 表示初级, 2 表示中级, 3 表示高级 void setDeviceLevel(int level); // 添加一个商店版位 // plInfo 版位信息 bool addAPlacement(const IAPPlacement& plInfo); // 删除一个商店版位 // id 卡片id(添加版位时的id) void removePlacement(const std::string& id); // 给某个商店版位添加卡片 bool addCardToPlacement(const std::string& id, IAPCard* card); // 给某个商店版位删除卡片 bool removeCardToPlacement(const std::string& id, int cardIndex = -1); // 清空活动 void clearPlacement(); // 获取活动礼包总数 size_t getPlacementCount(); // 在某个节点中显示 // pParent 父节点 // requirement 对商店的要求,比如说最低金币数 void showInNode(cocos2d::Node* pParent, ShopRequirement& requirement); // 以滑动卡片的形式在某个节点中显示满足金币条件的所有商店卡片 // pParent 父节点 // stillNeedCoins 距离所需要的金币数还差多少金币 void showSlideCardsByCoinsIn(cocos2d::Node* pParent, int stillNeedCoins); // 获取用户类型 UserBuyType getUserBuyType(); // 添加用户购买信息 并 从delegate发送购买的道具信息 void addUserBuyInfo(std::string commodityID); // 清除用户购买信息 void clearUserBuyInfo(); // 获取用户购买过的最贵礼包金额 float getUserBuyMaxAmount(); private: private: static IAPCtlShop* _instance; IAPDelegate* _delegate; IAPConf* _conf; PBConfigData* _pbConf; }; NS_IAP_END #endif /* IAPCtlShop_hpp */