/** 激活收费过程 */ public void OpenPlayerPayMoney(int payid, GameCenterEviroment.RechargePayCallback backFuntion) { LastPayId = payid; currentPayBackFuntion = backFuntion; #if !UNITY_EDITOR && !PLATFORM_COMMON && UNITY_ANDROID using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity")) { //标记为合理挂起,这样,网络不会被断开 NetInputDefine.Rational_Hang_Up = true; jo.Call("OpenPlayerPayMoney", payid); } } #else PlayerPayMoneyCallBack(""); #endif //UNITY_ANDROID }
/** 收费返回 */ public void PlayerPayMoneyCallBack(string s) { int payid; bool isPaySucceed = false; #if !UNITY_EDITOR && !PLATFORM_COMMON && UNITY_ANDROID using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity")) { payid = jo.GetStatic <int>("LastPayId"); isPaySucceed = jo.GetStatic <bool>("IsPaySucceed"); //关闭合理挂起 NetInputDefine.Rational_Hang_Up = false; } } #else payid = LastPayId; isPaySucceed = CheckPlayerPayMoneyIsSucceedDevelop(payid); #endif //UNITY_ANDROID //忽略默认付费提升 #if __AbsentUpDefBuyItemId #else if (isPaySucceed == true && payid > ((IGamerProfile)(IGameCenterEviroment.currentGamerProfile)).playerdata.defBuyItemId) { ((IGamerProfile)(IGameCenterEviroment.currentGamerProfile)).playerdata.defBuyItemId = payid; ((IGamerProfile)(IGameCenterEviroment.currentGamerProfile)).SaveGamerProfileToServer(); } #endif // __AbsentUpDefBuyItemId if (currentPayBackFuntion != null) { currentPayBackFuntion(payid, isPaySucceed); currentPayBackFuntion = null; } }