using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class PottingMobileServicesManger : MonoBehaviour { // Singleton. public static PottingMobileServicesManger Instance { get; protected set; } // Start is called before the first frame update void Start() { if (Instance == this) { } } // Update is called once per frame void Update() { } void Awake() { if (Instance == null) Instance = this; if (transform.parent == null) DontDestroyOnLoad(gameObject); } //对于需要登录的接口,我们做了简单处理,用户登录的时候我们会保存用户的userId和token, //当我们查询到本地保存的userId或token为空时,给unity发以下消息并return, //游戏端需要提示用户登录或其他操作 public void LoginStatus(string code) { Debug.Log("LoginStatus"); var evt = LoginStatusEvent; if (evt != null) evt(code); } /** * 渠道下单接口,根据不同渠道需要的数据不同 * 返回的数据结构不同,前端需要根据情况解析 * */ public void ChannelpayOrder(string data) { Debug.Log("ChannelpayOrder"); var evt = ChannelpayOrderResponsesEvent; if (evt != null) evt(data); } /** * 获取当前游戏,渠道的最新版本 * 返回结果无加密 */ public void ChannelpayGetAppVersion(string data) { Debug.Log("ChannelpayGetAppVersion"); var evt = ChannelpayGetAppVersionResponsesEvent; if (evt != null) evt(data); } /** * 获取服务器配置 * appver:如果不需要根据版本判断可以串0 * lastver:每次全新获取传0 */ public void ConfigSync(string data) { Debug.Log("ConfigSync"); var evt = ConfigSyncResponsesEvent; if (evt != null) evt(data); } /** * 兑换码兑换接口 * */ public void DedeemConsume(string data) { Debug.Log("DedeemConsume"); var evt = DedeemConsumeResponsesEvent; if (evt != null) evt(data); } /** * 登录接口 */ public void UserLogin(string data) { Debug.Log("UserLogin"); var evt = UserLoginResponsesEvent; if (evt != null) evt(data); } /** * 获取(提交)存档到服务器 * 1.每次启动游戏优先获取存档 * 2.当有需要更新的存档时提交服务器 * 提交存档时服务器会默认覆盖以前的存档不会做其他判断 * 请求需要签名,返回数据有加密 */ public void UserSync(string data) { Debug.Log("userSync"); var evt = UserSyncResponsesEvent; if (evt != null) evt(data); } /** * 心跳检测,判断当前客户端登陆是否有效 * 请求需要签名,返回数据无加密 */ public void UserHeartbeat(string data) { Debug.Log("UserHeartbeat"); var evt = UserHeartbeatResponsesEvent; if (evt != null) evt(data); } /** * 用户下订接口,下单成功之后返回支付链接 * -跳转支付页面 * * @param goodsid 商品ID */ public void UserOrder(string data) { Debug.Log("UserOrder"); var evt = UserOrderResponsesEvent; if (evt != null) evt(data); } /** * 恢复购买,查看已完成的所有订单,以及消耗状态 * 请求需要签名,返回结果有加密 */ public void UserResumepurchase(string data) { Debug.Log("UserResumepurchase"); var evt = UserResumepurchaseResponsesEvent; if (evt != null) evt(data); } /** * 订单消耗 * 请求需要签名,返回结果有加密 */ public void UserConsume(string data) { Debug.Log("UserConsume"); var evt = UserConsumeResponsesEvent; if (evt != null) evt(data); } /** * 查询单个订单的状态 * 用来处理非消耗性商品,判断订单是否支付完成 * 返回结果有加密 */ public void UserQueryOrder(string data) { Debug.Log("UserQueryOrder"); var evt = UserQueryOrderResponsesEvent; if (evt != null) evt(data); } /** * 提交用户分数 * 返回用户排行榜信息,返回结果无加密 */ public void UserUploadScore(string data) { Debug.Log("UserUploadScore"); var evt = UserUploadScoreResponsesEvent; if (evt != null) evt(data); } /** * 获取用户自己的排名 */ public void UserGetUserRank(string data) { Debug.Log("UserGetUserRank"); var evt = UserGetUserRankResponsesEvent; if (evt != null) evt(data); } //用户支付结果 public void PurchaseCallBack(string data) { Debug.Log("PurchaseCallBack"); var evt = PurchaseCallBackEvent; if (evt != null) evt(data); } public void GetActivitiesWithChannel(string data) { var evt = GetActivitiesWithChannelkEvent; if (evt != null) evt(data); } public void GameAnoncementsWithChannel(string data) { var evt = GameAnoncementsWithChannelEvent; if (evt != null) evt(data); } public void RedeemConsume(string data) { var evt = RedeemConsumeEvent; if (evt != null) evt(data); } public void RedeemUserConsume(string data) { var evt = RedeemUserConsumeEvent; if (evt != null) evt(data); } public void feedBackSubmitComplected(string json) { var evt = MfeedBackSubmitEvent; if (evt != null) evt(json); } public void GoogleValidate(string json) { var evt = PayValidateEvent; if (evt != null) evt(json); } public void OverseaPayAppleValidate(string json) { var evt = PayValidateEvent; if (evt != null) evt(json); } public void GamekeyinfoUpload(string json) { var evt = GamekeyinfoUploadEvent; if (evt != null) evt(json); } public void Serverinfo(string json) { var evt = ServerinfoEvent; if (evt != null) evt(json); } /* * { "timestamp": 0 } */ public event Action ServerinfoEvent; /// /// 支付校验回调 /// public event Action PayValidateEvent; /// /// 活动回调数据 /// /* * 回调参数示例: 获取到活动数组,自行判断开始结束时间 { "data" : [ { "starttime" : 1591113600, "priceid" : "90647029-07d6-4abf-af59-b4cc04306500", "activityinfo" : "第十二次营救测试一个碎片情况", "price" : "1", "title" : "第十二次营救测试", "gameitems" : [ { "iteminfo" : "{\"goodId\":\"2\",\"goodType\":\"6\"}", "itemname" : "玛丽安娜碎片", "num" : 1, "itemid" : "906475eb-9770-4131-af2d-0a6fe727576a" }, { "iteminfo" : "{\"goodId\":\"10000\",\"goodType\":\"0\"}", "itemname" : "钻石", "num" : 100000, "itemid" : "906475eb-9842-4f7b-91de-580dad60f6d2" } ], "originalprice" : "5", "extradata" : "", "endtime" : 1591200000, "activityid" : "90b725fd-3faa-40ed-8880-d08e01a469f2" } ] } */ public event Action GetActivitiesWithChannelkEvent; /// /// 公告回调数据 /// /* *{ "data" : [ { "anoncementinfo" : "tefdfsdfsdfds", "title" : "test", "channels" : "0,3", "anoncementid" : "90b756b9-38ae-4ae7-bdeb-bd1c330c630e", "gameitems" : [ { "iteminfo" : "{\"goodId\":\"2\",\"goodType\":\"6\"}", "itemname" : "玛丽安娜碎片", "num" : 1, "itemid" : "906475eb-9770-4131-af2d-0a6fe727576a" } ] } ], "code" : 200 } * */ public event Action GameAnoncementsWithChannelEvent; /// /// 渠道兑换码返回数据 /// /* * { "data" : { "Goodsinfo" : "test", "Type" : 1, "Status" : 0 }, "code" : 200 } */ public event Action RedeemConsumeEvent; /// /// 反馈接口回调 /// /* * 成功: { "data" : { }, "code" : 200 } 失败: { "data" : { }, "code" : 4004 } */ public event Action MfeedBackSubmitEvent; public event Action PurchaseCallBackEvent; public event Action UserGetUserRankResponsesEvent; public event Action UserUploadScoreResponsesEvent; public event Action UserQueryOrderResponsesEvent; public event Action UserConsumeResponsesEvent; public event Action UserResumepurchaseResponsesEvent; public event Action UserOrderResponsesEvent; public event Action UserHeartbeatResponsesEvent; public event Action UserSyncResponsesEvent; public event Action UserLoginResponsesEvent; public event Action DedeemConsumeResponsesEvent; public event Action ChannelpayGetAppVersionResponsesEvent; public event Action ChannelpayOrderResponsesEvent; public event Action LoginStatusEvent; public event Action ConfigSyncResponsesEvent; public event Action RedeemUserConsumeEvent; /* * { "code" : 200 } */ public event Action GamekeyinfoUploadEvent; }