| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 | 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<string> ServerinfoEvent;    /// <summary>    /// 支付校验回调    /// </summary>    public event Action<string> PayValidateEvent;    /// <summary>    /// 活动回调数据    /// </summary>    /*     * 回调参数示例: 获取到活动数组,自行判断开始结束时间        {         "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<string> GetActivitiesWithChannelkEvent;    /// <summary>    /// 公告回调数据    /// </summary>    /*     *{         "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<string> GameAnoncementsWithChannelEvent;    /// <summary>    /// 渠道兑换码返回数据    /// </summary>    /*     * {        "data" : {            "Goodsinfo" : "test",            "Type" : 1,            "Status" : 0            },            "code" : 200            }     */    public event Action<string> RedeemConsumeEvent;    /// <summary>    /// 反馈接口回调    /// </summary>    /*     * 成功:    {     "data" : {     },      "code" : 200    }    失败:    {      "data" : {      },      "code" : 4004    }     */    public event Action<string> MfeedBackSubmitEvent;    public event Action<string> PurchaseCallBackEvent;    public event Action<string> UserGetUserRankResponsesEvent;    public event Action<string> UserUploadScoreResponsesEvent;    public event Action<string> UserQueryOrderResponsesEvent;    public event Action<string> UserConsumeResponsesEvent;    public event Action<string> UserResumepurchaseResponsesEvent;    public event Action<string> UserOrderResponsesEvent;        public event Action<string> UserHeartbeatResponsesEvent;    public event Action<string> UserSyncResponsesEvent;    public event Action<string> UserLoginResponsesEvent;    public event Action<string> DedeemConsumeResponsesEvent;    public event Action<string> ChannelpayGetAppVersionResponsesEvent;    public event Action<string> ChannelpayOrderResponsesEvent;    public event Action<string> LoginStatusEvent;    public event Action<string> ConfigSyncResponsesEvent;            public event Action<string> RedeemUserConsumeEvent;    /* * { "code" : 200  } */    public event Action<string> GamekeyinfoUploadEvent;}
 |