• 大小: 3.52MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-06
  • 语言: Html/CSS
  • 标签: Android_sdk  

资源简介

本例子只是游戏开发SDK接入的代码实现 具体看参看http://www.miui.com/thread-1878060-1-1.html[实例教程] unity3D接入小米盒子SDK

资源截图

代码片段和文件信息

package com.lingyou.sdk;

import android.os.Bundle;

import com.unity3d.player.UnityPlayerActivity;
import com.unity3d.player.UnityPlayer;
import com.xiaomi.gamecenter.sdk.GameInfoField;
import com.xiaomi.gamecenter.sdk.MiCommplatform;
import com.xiaomi.gamecenter.sdk.MiErrorCode;
import com.xiaomi.gamecenter.sdk.OnLoginProcessListener;
import com.xiaomi.gamecenter.sdk.OnPayProcessListener;
import com.xiaomi.gamecenter.sdk.entry.MiAccountInfo;
import com.xiaomi.gamecenter.sdk.entry.MiAppInfo;
import com.xiaomi.gamecenter.sdk.entry.MiBuyInfo;

// !< 所有的SDK都务必继承实现的类型
public class UnitySDKNativeActivity extends UnityPlayerActivity implements OnLoginProcessListener OnPayProcessListener
{
// !< 游戏内的接收事件对象名称
String mGameobjectName;
public static MiAppInfo mAppInfo;

private void SendMessage(String func String param)
{
UnityPlayer.UnitySendMessage(mGameobjectName func param);
}
/*
 * 继承实现的接口
 * **/
@Override
public void finishLoginProcess(int arg0 MiAccountInfo arg1)
{
if (MiErrorCode.MI_XIAOMI_GAMECENTER_SUCCESS == arg0)
{
SendMessage(“OnLoginSuccess“ arg1.getUid() + “:“  + arg1.getNikename());
}
else if (MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_LOGINOUT_SUCCESS == arg0)
{
SendMessage(“OnLoginFailed“ “MI_XIAOMI_GAMECENTER_ERROR_LOGINOUT_SUCCESS“);
}
else if (MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_LOGINOUT_FAIL == arg0)
{
SendMessage(“OnLoginFailed“ “MI_XIAOMI_GAMECENTER_ERROR_LOGINOUT_FAIL“);
}
else if (MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_ACTION_EXECUTED == arg0)
{
SendMessage(“OnLoginFailed“ “MI_XIAOMI_GAMECENTER_ERROR_ACTION_EXECUTED“);
}
else
{
SendMessage(“OnLoginFailed“ “else...“);
}
}

@Override
public void finishPayProcess(int arg0)
{
if (arg0 == MiErrorCode.MI_XIAOMI_GAMECENTER_SUCCESS)// 成功
{
SendMessage(“OnPayResultSuccess“ ““);
}
else if (arg0 == MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_CANCEL
|| arg0 == MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_PAY_CANCEL)// 取消
{
SendMessage(“OnPayResultFailed“ ““ + arg0);
}
else if (arg0 == MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_PAY_FAILURE)// 失败
{
SendMessage(“OnPayResultFailed“ ““ + arg0);
}
else if (arg0 == MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_PAY_REPEAT)
{
SendMessage(“OnPayResultFailed“ ““ + arg0);
}
else if (MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_ACTION_EXECUTED == arg0)
{
SendMessage(“OnPayResultFailed“ ““ + arg0);
}
else if (arg0 == MiErrorCode.MI_XIAOMI_GAMECENTER_ERROR_LOGIN_FAIL)
{
SendMessage(“OnPayResultFailed“ ““ + arg0);
}
}

// !< 设置对象名称
public void SetReceiver(String name)
{
 this.mGameobjectName = name;
}

// !< 初始化
public void Initialize(String appid String appkey)
{
/** SDK初始化 */
mAppInfo = new MiAppInfo();
mAppInfo.setAppId( appid );
mAppInfo.setAppKey( appkey );
MiCommplatform.Init( this mAppInfo );
}

// !< 登录接口
public void Log

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    I.A....       475  2015-08-14 17:58  src\.classpath

    I.A....       815  2015-08-14 17:58  src\.project

    I.A....        57  2015-08-14 17:58  src\.settings\org.eclipse.core.resources.prefs

    I.A....       598  2015-08-14 17:58  src\.settings\org.eclipse.jdt.core.prefs

    I.A....       868  2015-08-14 17:58  src\AndroidManifest.xml

    I.A....       790  2015-08-14 17:58  src\ant.properties

    I.A....   5101536  2015-08-14 17:58  src\assets\MiGameCenterSDKService.apk

    I.A....      3936  2015-08-14 17:58  src\build.xml

    I.A....      1185  2015-08-14 17:58  src\game.key

    I.A....     69279  2015-08-14 17:58  src\libs\classes.jar

    I.A....     78832  2015-08-14 17:58  src\libs\SDK_TY_4.3.9.jar

    I.A....       592  2015-08-14 17:58  src\project.properties

    I.A....      9397  2015-08-14 17:58  src\res\drawable-hdpi\ic_launcher.png

    I.A....     14383  2015-08-14 17:58  src\res\drawable-xhdpi\ic_launcher.png

    I.A....      6147  2015-08-14 17:58  src\res\layout\activity_main.xml

    I.A....       660  2015-08-14 17:58  src\res\layout\gamlayout.xml

    I.A....      6854  2015-08-14 17:58  src\res\layout\gam_layout.xml

    I.A....      3420  2015-08-14 17:58  src\res\layout\payment.xml

    I.A....      2297  2015-08-14 17:58  src\res\layout-hdpi\friend_item.xml

    I.A....      2513  2015-08-14 17:58  src\res\layout-hdpi\friend_list_activity.xml

    I.A....       746  2015-08-14 17:58  src\res\layout-hdpi\function_item.xml

    I.A....      3021  2015-08-14 17:58  src\res\layout-hdpi\game_friend_item.xml

    I.A....      2828  2015-08-14 17:58  src\res\layout-hdpi\game_friend_list_activity.xml

    I.A....       876  2015-08-14 17:58  src\res\layout-hdpi\game_messages_activity.xml

    I.A....       405  2015-08-14 17:58  src\res\layout-hdpi\leaderboard_list_activity.xml

    I.A....      1880  2015-08-14 17:58  src\res\layout-hdpi\leaderboard_list_item.xml

    I.A....      1297  2015-08-14 17:58  src\res\layout-hdpi\message_item.xml

    I.A....      1446  2015-08-14 17:58  src\res\layout-hdpi\user_info_activity.xml

    I.A....      1624  2015-08-14 17:58  src\res\layout-hdpi\user_info_scores_item.xml

    I.A....       137  2015-08-14 17:58  src\res\values\colors.xml

............此处省略25个文件信息

评论

共有 条评论

相关资源