修复在直播间内跳转自己的直播间问题
This commit is contained in:
parent
d1edf6bdd8
commit
9b301eba25
@ -179,7 +179,7 @@ dependencies {
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
api 'com.jakewharton.rxbinding3:rxbinding:3.1.0'
|
||||
//loading样式库
|
||||
api 'com.wang.avi:library:2.1.3'
|
||||
api 'com.wang.avi:library:2.1.3'
|
||||
api 'com.google.firebase:firebase-messaging:23.0.6'
|
||||
api 'com.google.firebase:firebase-analytics:21.1.0'
|
||||
// api 'com.huawei.hms:push:4.0.2.300'
|
||||
@ -197,7 +197,13 @@ dependencies {
|
||||
//自定义圆角图片
|
||||
api 'com.makeramen:roundedimageview:2.3.0'
|
||||
// 友盟统计SDK
|
||||
api 'com.umeng.umsdk:common:9.6.3'// 必选
|
||||
api 'com.umeng.umsdk:asms:1.8.0'// 必选
|
||||
api 'com.umeng.umsdk:uyumao:1.1.2' //高级运营分析功能依赖库,使用卸载分析、开启反作弊能力请务必集成,以免影响高级功能使用。common需搭配v9.6.3及以上版本,asms需搭配v1.7.0及以上版本。需更新隐私声明。
|
||||
api 'com.umeng.umsdk:common:9.6.3'// 必选
|
||||
api 'com.umeng.umsdk:asms:1.8.0'// 必选
|
||||
api 'com.umeng.umsdk:uyumao:1.1.2'
|
||||
//高级运营分析功能依赖库,使用卸载分析、开启反作弊能力请务必集成,以免影响高级功能使用。common需搭配v9.6.3及以上版本,asms需搭配v1.7.0及以上版本。需更新隐私声明。
|
||||
// 标准版本SudMGP SDK
|
||||
api 'tech.sud.mgp:SudMGP:1.3.3.1158'
|
||||
|
||||
// 多语言语音识别扩展库(可选)
|
||||
api 'tech.sud.mgp:SudASR:1.3.3.1158'
|
||||
}
|
||||
|
@ -0,0 +1,432 @@
|
||||
package com.yunbao.common.sud;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import com.yunbao.common.sud.decorator.SudFSMMGCache;
|
||||
import com.yunbao.common.sud.decorator.SudFSMMGDecorator;
|
||||
import com.yunbao.common.sud.decorator.SudFSMMGListener;
|
||||
import com.yunbao.common.sud.decorator.SudFSTAPPDecorator;
|
||||
import com.yunbao.common.sud.model.GameConfigModel;
|
||||
import com.yunbao.common.sud.model.GameViewInfoModel;
|
||||
import com.yunbao.common.sud.state.MGStateResponse;
|
||||
import com.yunbao.common.utils.SudJsonUtils;
|
||||
|
||||
import tech.sud.mgp.core.ISudFSMStateHandle;
|
||||
import tech.sud.mgp.core.ISudFSTAPP;
|
||||
import tech.sud.mgp.core.ISudListenerInitSDK;
|
||||
import tech.sud.mgp.core.SudMGP;
|
||||
|
||||
/**
|
||||
* 游戏业务逻辑抽象类
|
||||
* 1.定自义ViewModel继承此类,实现对应方法。(注意:onAddGameView()与onRemoveGameView()与页面有交互)
|
||||
* 2.外部调用switchGame()方法启动游戏
|
||||
* 3.页面销毁时调用onDestroy()
|
||||
*/
|
||||
public abstract class BaseGameViewModel implements SudFSMMGListener {
|
||||
|
||||
private String gameRoomId; // 游戏房间id
|
||||
private long playingGameId; // 当前使用的游戏id
|
||||
public final SudFSTAPPDecorator sudFSTAPPDecorator = new SudFSTAPPDecorator(); // app调用sdk的封装类
|
||||
private final SudFSMMGDecorator sudFSMMGDecorator = new SudFSMMGDecorator(); // 用于处理游戏SDK部分回调业务
|
||||
|
||||
private boolean isRunning = true; // 业务是否还在运行
|
||||
public View gameView; // 游戏View
|
||||
public GameConfigModel gameConfigModel = new GameConfigModel(); // 游戏配置
|
||||
protected final Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
/**
|
||||
* 外部调用切换游戏,传不同的gameId即可加载不同的游戏
|
||||
* gameId传0 等同于关闭游戏
|
||||
*
|
||||
* @param activity 游戏所在页面,用作于生命周期判断
|
||||
* @param gameRoomId 游戏房间id,房间隔离,同一房间才能一起游戏
|
||||
* @param gameId 游戏id,传入不同的游戏id,即可加载不同的游戏,传0等同于关闭游戏
|
||||
*/
|
||||
public void switchGame(Activity activity, String gameRoomId, long gameId) {
|
||||
if (TextUtils.isEmpty(gameRoomId)) {
|
||||
Toast.makeText(activity, "gameRoomId can not be empty", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (!isRunning) {
|
||||
return;
|
||||
}
|
||||
if (playingGameId == gameId && gameRoomId.equals(this.gameRoomId)) {
|
||||
return;
|
||||
}
|
||||
destroyMG();
|
||||
this.gameRoomId = gameRoomId;
|
||||
playingGameId = gameId;
|
||||
login(activity, gameId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 第1步,获取短期令牌code,用于换取游戏Server访问APP Server的长期ssToken
|
||||
* 接入方客户端 调用 接入方服务端 login 获取 短期令牌code
|
||||
* 参考文档时序图:sud-mgp-doc(https://docs.sud.tech/zh-CN/app/Client/StartUp-Android.html)
|
||||
*
|
||||
* @param activity 游戏所在页面
|
||||
* @param gameId 游戏id
|
||||
*/
|
||||
private void login(Activity activity, long gameId) {
|
||||
if (activity.isDestroyed() || gameId <= 0) {
|
||||
return;
|
||||
}
|
||||
// 请求登录code
|
||||
getCode(activity, getUserId(), getAppId(), new GameGetCodeListener() {
|
||||
@Override
|
||||
public void onSuccess(String code) {
|
||||
if (!isRunning || gameId != playingGameId) {
|
||||
return;
|
||||
}
|
||||
initSdk(activity, gameId, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed() {
|
||||
delayLoadGame(activity, gameId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 第2步,初始化SudMGP sdk
|
||||
*
|
||||
* @param activity 游戏所在页面
|
||||
* @param gameId 游戏id
|
||||
* @param code 令牌
|
||||
*/
|
||||
private void initSdk(Activity activity, long gameId, String code) {
|
||||
String appId = getAppId();
|
||||
String appKey = getAppKey();
|
||||
// 初始化sdk
|
||||
SudMGP.initSDK(activity, appId, appKey, isTestEnv(), new ISudListenerInitSDK() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
loadGame(activity, code, gameId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int errCode, String errMsg) {
|
||||
// TODO: 2022/6/13 下面toast可以根据业务需要决定是否保留
|
||||
if (isTestEnv()) {
|
||||
Toast.makeText(activity, "initSDK onFailure:" + errMsg + "(" + errCode + ")", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
delayLoadGame(activity, gameId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 第3步,加载游戏
|
||||
* APP和游戏的相互调用
|
||||
* ISudFSTAPP:APP调用游戏的接口
|
||||
* ISudFSMMG:游戏调APP的响应回调
|
||||
*
|
||||
* @param activity 游戏所在页面
|
||||
* @param code 登录令牌
|
||||
* @param gameId 游戏id
|
||||
*/
|
||||
private void loadGame(Activity activity, String code, long gameId) {
|
||||
if (activity.isDestroyed() || !isRunning || gameId != playingGameId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 给装饰类设置回调
|
||||
sudFSMMGDecorator.setSudFSMMGListener(this);
|
||||
|
||||
// 调用游戏sdk加载游戏
|
||||
ISudFSTAPP iSudFSTAPP = SudMGP.loadMG(activity, getUserId(), gameRoomId, code, gameId, getLanguageCode(), sudFSMMGDecorator);
|
||||
|
||||
// 如果返回空,则代表参数问题或者非主线程
|
||||
if (iSudFSTAPP == null) {
|
||||
Toast.makeText(activity, "loadMG params error", Toast.LENGTH_LONG).show();
|
||||
delayLoadGame(activity, gameId);
|
||||
return;
|
||||
}
|
||||
|
||||
// APP调用游戏接口的装饰类设置
|
||||
sudFSTAPPDecorator.setISudFSTAPP(iSudFSTAPP);
|
||||
|
||||
// 获取游戏视图,将其抛回Activity进行展示
|
||||
// Activity调用:gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
||||
gameView = iSudFSTAPP.getGameView();
|
||||
onAddGameView(gameView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏加载失败的时候,延迟一会再重新加载
|
||||
*
|
||||
* @param activity 游戏所在页面
|
||||
* @param gameId 游戏id
|
||||
*/
|
||||
private void delayLoadGame(Activity activity, long gameId) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
login(activity, gameId);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// region 生命周期相关
|
||||
|
||||
/** 页面销毁的时候调用 */
|
||||
public void onDestroy() {
|
||||
isRunning = false;
|
||||
destroyMG();
|
||||
}
|
||||
// endregion 生命周期相关
|
||||
|
||||
|
||||
/** 销毁游戏 */
|
||||
private void destroyMG() {
|
||||
if (playingGameId > 0) {
|
||||
sudFSTAPPDecorator.destroyMG();
|
||||
sudFSMMGDecorator.destroyMG();
|
||||
playingGameId = 0;
|
||||
gameView = null;
|
||||
onRemoveGameView();
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取当前游戏房id */
|
||||
public String getGameRoomId() {
|
||||
return gameRoomId;
|
||||
}
|
||||
|
||||
// region 子类需要实现的方法
|
||||
|
||||
/**
|
||||
* 向接入方服务器获取code
|
||||
*/
|
||||
protected abstract void getCode(Activity activity, String userId, String appId, GameGetCodeListener listener);
|
||||
|
||||
/**
|
||||
* 设置当前用户id(接入方定义)
|
||||
*
|
||||
* @return 返回用户id
|
||||
*/
|
||||
protected abstract String getUserId();
|
||||
|
||||
/**
|
||||
* 设置游戏所用的appId
|
||||
*
|
||||
* @return 返回游戏服务appId
|
||||
*/
|
||||
protected abstract String getAppId();
|
||||
|
||||
/**
|
||||
* 设置游戏所用的appKey
|
||||
*
|
||||
* @return 返回游戏服务appKey
|
||||
*/
|
||||
protected abstract String getAppKey();
|
||||
|
||||
/**
|
||||
* 设置游戏的语言代码
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/Languages/
|
||||
*
|
||||
* @return 返回语言代码
|
||||
*/
|
||||
protected abstract String getLanguageCode();
|
||||
|
||||
/**
|
||||
* 设置游戏的安全操作区域
|
||||
*
|
||||
* @param gameViewInfoModel 游戏视图大小
|
||||
*/
|
||||
protected abstract void getGameRect(GameViewInfoModel gameViewInfoModel);
|
||||
|
||||
/**
|
||||
* true 加载游戏时为测试环境
|
||||
* false 加载游戏时为生产环境
|
||||
*/
|
||||
protected abstract boolean isTestEnv();
|
||||
|
||||
/**
|
||||
* 将游戏View添加到页面中
|
||||
*
|
||||
* @param gameView
|
||||
*/
|
||||
protected abstract void onAddGameView(View gameView);
|
||||
|
||||
/**
|
||||
* 将页面中的游戏View移除
|
||||
*/
|
||||
protected abstract void onRemoveGameView();
|
||||
|
||||
// endregion 子类需要实现的方法
|
||||
|
||||
// region 游戏侧回调
|
||||
|
||||
/**
|
||||
* 游戏日志
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
@Override
|
||||
public void onGameLog(String str) {
|
||||
SudFSMMGListener.super.onGameLog(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏开始
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
@Override
|
||||
public void onGameStarted() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏销毁
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
@Override
|
||||
public void onGameDestroyed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Code过期,需要实现
|
||||
* APP接入方需要调用handle.success或handle.fail
|
||||
*
|
||||
* @param dataJson {"code":"value"}
|
||||
*/
|
||||
@Override
|
||||
public void onExpireCode(ISudFSMStateHandle handle, String dataJson) {
|
||||
processOnExpireCode(sudFSTAPPDecorator, handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏View信息,需要实现
|
||||
* APP接入方需要调用handle.success或handle.fail
|
||||
*
|
||||
* @param handle handle
|
||||
* @param dataJson {}
|
||||
*/
|
||||
@Override
|
||||
public void onGetGameViewInfo(ISudFSMStateHandle handle, String dataJson) {
|
||||
processOnGetGameViewInfo(gameView, handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏Config,需要实现
|
||||
* APP接入方需要调用handle.success或handle.fail
|
||||
*
|
||||
* @param handle handle
|
||||
* @param dataJson {}
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
@Override
|
||||
public void onGetGameCfg(ISudFSMStateHandle handle, String dataJson) {
|
||||
processOnGetGameCfg(handle, dataJson);
|
||||
}
|
||||
// endregion 游戏侧回调
|
||||
|
||||
|
||||
/** 处理code过期 */
|
||||
public void processOnExpireCode(SudFSTAPPDecorator sudFSTAPPDecorator, ISudFSMStateHandle handle) {
|
||||
// code过期,刷新code
|
||||
getCode(null, getUserId(), getAppId(), new GameGetCodeListener() {
|
||||
@Override
|
||||
public void onSuccess(String code) {
|
||||
if (!isRunning) return;
|
||||
MGStateResponse mgStateResponse = new MGStateResponse();
|
||||
mgStateResponse.ret_code = MGStateResponse.SUCCESS;
|
||||
sudFSTAPPDecorator.updateCode(code, null);
|
||||
handle.success(SudJsonUtils.toJson(mgStateResponse));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed() {
|
||||
MGStateResponse mgStateResponse = new MGStateResponse();
|
||||
mgStateResponse.ret_code = -1;
|
||||
handle.failure(SudJsonUtils.toJson(mgStateResponse));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理游戏视图信息(游戏安全区)
|
||||
* 文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG/onGetGameViewInfo.html
|
||||
*/
|
||||
public void processOnGetGameViewInfo(View gameView, ISudFSMStateHandle handle) {
|
||||
//拿到游戏View的宽高
|
||||
int gameViewWidth = gameView.getMeasuredWidth();
|
||||
int gameViewHeight = gameView.getMeasuredHeight();
|
||||
if (gameViewWidth > 0 && gameViewHeight > 0) {
|
||||
notifyGameViewInfo(handle, gameViewWidth, gameViewHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
//如果游戏View未加载完成,则监听加载完成时回调
|
||||
gameView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
gameView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
int width = gameView.getMeasuredWidth();
|
||||
int height = gameView.getMeasuredHeight();
|
||||
notifyGameViewInfo(handle, width, height);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 通知游戏,游戏视图信息 */
|
||||
private void notifyGameViewInfo(ISudFSMStateHandle handle, int gameViewWidth, int gameViewHeight) {
|
||||
GameViewInfoModel gameViewInfoModel = new GameViewInfoModel();
|
||||
gameViewInfoModel.ret_code = 0;
|
||||
// 游戏View大小
|
||||
gameViewInfoModel.view_size.width = gameViewWidth;
|
||||
gameViewInfoModel.view_size.height = gameViewHeight;
|
||||
|
||||
// 游戏安全操作区域
|
||||
getGameRect(gameViewInfoModel);
|
||||
|
||||
// 给游戏侧进行返回
|
||||
String json = SudJsonUtils.toJson(gameViewInfoModel);
|
||||
// 如果设置安全区有疑问,可将下面的日志打印出来,分析json数据
|
||||
// 正确的格式为:{"ret_code":0,"view_game_rect":{"bottom":156,"left":0,"right":0,"top":196},"view_size":{"height":1920,"width":1080}}
|
||||
// 如果发生debug版本游戏正常,release版本游戏不正常,请检查是否混淆了GameViewInfoModel类,导致json序列化类的成员发生了变化
|
||||
// Log.d("SudBaseGameViewModel", "notifyGameViewInfo:" + json);
|
||||
handle.success(json);
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
// playMG和pauseMG要配对
|
||||
sudFSTAPPDecorator.pauseMG();
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
// playMG和pauseMG要配对
|
||||
sudFSTAPPDecorator.playMG();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理游戏配置
|
||||
* 文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG/onGetGameCfg.html
|
||||
*/
|
||||
public void processOnGetGameCfg(ISudFSMStateHandle handle, String dataJson) {
|
||||
handle.success(SudJsonUtils.toJson(gameConfigModel));
|
||||
}
|
||||
|
||||
/** 游戏login(getCode)监听 */
|
||||
public interface GameGetCodeListener {
|
||||
/** 成功 */
|
||||
void onSuccess(String code);
|
||||
|
||||
/** 失败 */
|
||||
void onFailed();
|
||||
}
|
||||
|
||||
/** 获取游戏状态缓存 */
|
||||
public SudFSMMGCache getSudFSMMGCache() {
|
||||
return sudFSMMGDecorator.getSudFSMMGCache();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
package com.yunbao.common.sud;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.yunbao.common.sud.model.GameConfigModel;
|
||||
import com.yunbao.common.sud.model.GameViewInfoModel;
|
||||
import com.yunbao.common.sud.state.MGStateResponse;
|
||||
import com.yunbao.common.sud.state.SudMGPMGState;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
import tech.sud.mgp.core.ISudFSMMG;
|
||||
import tech.sud.mgp.core.ISudFSMStateHandle;
|
||||
|
||||
/**
|
||||
* 游戏业务逻辑
|
||||
* 1.自定义ViewModel继承此类,实现对应方法。(注意:onAddGameView()与onRemoveGameView()与页面有交互)
|
||||
* 2.外部调用switchGame(activity,gameRoomId,gameId)方法启动游戏,参数定义可查看方法注释。
|
||||
* 3.页面销毁时调用onDestroy()
|
||||
*/
|
||||
public class QuickStartGameViewModel extends BaseGameViewModel {
|
||||
|
||||
/** Sud平台申请的appId */
|
||||
public static String SudMGP_APP_ID = "1701178631292395522";
|
||||
/** Sud平台申请的appKey */
|
||||
public static String SudMGP_APP_KEY = "E3Eokfq58ZklwR8fM7iKWYGzarbIOkyh";
|
||||
/** true 加载游戏时为测试环境 false 加载游戏时为生产环境 */
|
||||
public static final boolean GAME_IS_TEST_ENV = true;
|
||||
|
||||
/** 使用的UserId。这里随机生成作演示,开发者将其修改为业务使用的唯一userId */
|
||||
public static String userId = QuickStartUtils.genUserID();
|
||||
|
||||
/** 游戏自定义安全操作区域 */
|
||||
public GameViewInfoModel.GameViewRectModel gameViewRectModel;
|
||||
|
||||
/** 游戏的语言代码 */
|
||||
public String languageCode = "zh-CN";
|
||||
|
||||
public final MutableLiveData<View> gameViewLiveData = new MutableLiveData<>(); // 游戏View回调
|
||||
|
||||
/** 向接入方服务器获取code */
|
||||
@Override
|
||||
protected void getCode(Activity activity, String userId, String appId, GameGetCodeListener listener) {
|
||||
// TODO: 2022/6/10 注意,这里是演示使用OkHttpClient请求hello-sud服务
|
||||
// TODO: 2022/6/10 开发者在与后端联调时需将其改成自己的网络请求方式向自己的服务器获取code
|
||||
// OkHttpClient client = new OkHttpClient();
|
||||
// String req;
|
||||
// try {
|
||||
// JSONObject reqJsonObj = new JSONObject();
|
||||
// reqJsonObj.put("user_id", userId);
|
||||
// req = reqJsonObj.toString();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// req = "";
|
||||
// }
|
||||
//
|
||||
// RequestBody body = RequestBody.create(req, MediaType.get("application/json; charset=utf-8"));
|
||||
// Request request = new Request.Builder()
|
||||
// .url("https://mgp-hello.sudden.ltd/login/v3")
|
||||
// .post(body)
|
||||
// .build();
|
||||
// client.newCall(request).enqueue(new Callback() {
|
||||
// @Override
|
||||
// public void onFailure(Call call, IOException e) {
|
||||
// handler.post(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// listener.onFailed();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(Call call, Response response) {
|
||||
// try {
|
||||
// String dataJson = Objects.requireNonNull(response.body()).string();
|
||||
// JSONObject jsonObject = new JSONObject(dataJson);
|
||||
// int ret_code = jsonObject.getInt("ret_code");
|
||||
// JSONObject dataObject = jsonObject.getJSONObject("data");
|
||||
// String code = dataObject.getString("code");
|
||||
// handler.post(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (ret_code == MGStateResponse.SUCCESS) {
|
||||
// listener.onSuccess(code);
|
||||
// } else {
|
||||
// listener.onFailed();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// handler.post(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// listener.onFailed();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/** 设置当前用户id(接入方定义) */
|
||||
@Override
|
||||
protected String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/** 设置Sud平台申请的appId */
|
||||
@Override
|
||||
protected String getAppId() {
|
||||
return SudMGP_APP_ID;
|
||||
}
|
||||
|
||||
/** 设置Sud平台申请的appKey */
|
||||
@Override
|
||||
protected String getAppKey() {
|
||||
return SudMGP_APP_KEY;
|
||||
}
|
||||
|
||||
/** 设置游戏的语言代码 */
|
||||
@Override
|
||||
protected String getLanguageCode() {
|
||||
return languageCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置游戏的安全操作区域,{@link ISudFSMMG}.onGetGameViewInfo()的实现。
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG/onGetGameViewInfo.html
|
||||
*
|
||||
* @param gameViewInfoModel 游戏视图模型
|
||||
*/
|
||||
@Override
|
||||
protected void getGameRect(GameViewInfoModel gameViewInfoModel) {
|
||||
// 相对于view_size(左、上、右、下)边框偏移(单位像素)
|
||||
// 开发者可自定义gameViewRectModel来控制安全区域
|
||||
if (gameViewRectModel != null) {
|
||||
gameViewInfoModel.view_game_rect = gameViewRectModel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏配置对象,{@link ISudFSMMG}.onGetGameCfg()的实现。
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG/onGetGameCfg.html
|
||||
* 开发者拿到此对象之后,可修改自己需要的配置
|
||||
* 注意:在加载游戏之前配置才有效
|
||||
*
|
||||
* @return 游戏配置对象
|
||||
*/
|
||||
public GameConfigModel getGameConfigModel() {
|
||||
return gameConfigModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* true 加载游戏时为测试环境
|
||||
* false 加载游戏时为生产环境
|
||||
*/
|
||||
@Override
|
||||
protected boolean isTestEnv() {
|
||||
return GAME_IS_TEST_ENV;
|
||||
}
|
||||
|
||||
/** 将游戏View添加到页面中 */
|
||||
@Override
|
||||
protected void onAddGameView(View gameView) {
|
||||
gameViewLiveData.setValue(gameView);
|
||||
}
|
||||
|
||||
/** 将页面中的游戏View移除 */
|
||||
@Override
|
||||
protected void onRemoveGameView() {
|
||||
gameViewLiveData.setValue(null);
|
||||
}
|
||||
|
||||
// ************ 上面是基础能力以及必要配置,下面讲解状态交互
|
||||
// ************ 主要有:1.App向游戏发送状态;2.游戏向App回调状态
|
||||
|
||||
/**
|
||||
* 1.App向游戏发送状态
|
||||
* 这里演示的是发送:1. 加入状态;
|
||||
* 开发者可自由定义方法,能发送的状态都封装在{@link SudFSTAPPDecorator}
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/APPFST/
|
||||
* 注意:
|
||||
* 1,App向游戏发送状态,因为需要走网络,所以向游戏发送状态之后,不能马上销毁游戏或者finish Activity,否则状态无法发送成功。
|
||||
* 2,要保证状态能到达,可以发送之后,delay 500ms再销毁游戏或者finish Activity。
|
||||
*/
|
||||
public void notifyAPPCommonSelfIn(boolean isIn, int seatIndex, boolean isSeatRandom, int teamId) {
|
||||
sudFSTAPPDecorator.notifyAPPCommonSelfIn(isIn, seatIndex, isSeatRandom, teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.游戏向App回调状态
|
||||
* 这里演示的是接收游戏回调状态:10. 游戏状态 mg_common_game_state
|
||||
* 游戏回调的每个状态都对应着一个方法,方法定义在:{@link SudFSMMGListener}
|
||||
*/
|
||||
@Override
|
||||
public void onGameMGCommonGameState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameState model) {
|
||||
super.onGameMGCommonGameState(handle, model);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.yunbao.common.sud;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuickStartUtils {
|
||||
|
||||
/** 随机生成一个userId,用于演示 */
|
||||
public static String genUserID() {
|
||||
return md5Hex8(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
public static String md5Hex8(String plainText) {
|
||||
byte[] secretBytes;
|
||||
try {
|
||||
secretBytes = MessageDigest.getInstance("md5").digest(plainText.getBytes());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return plainText;
|
||||
}
|
||||
String md5code = new BigInteger(1, secretBytes).toString(16);
|
||||
for (int i = 0; i < 32 - md5code.length(); i++) {
|
||||
md5code = String.format("0%s", md5code);
|
||||
}
|
||||
|
||||
return md5code.substring(8, 16);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright © Sud.Tech
|
||||
* https://sud.tech
|
||||
*/
|
||||
|
||||
package com.yunbao.common.sud.decorator;
|
||||
|
||||
import com.yunbao.common.sud.state.SudMGPMGState;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* 游戏回调数据缓存
|
||||
*/
|
||||
public class SudFSMMGCache {
|
||||
|
||||
private String captainUserId; // 记录当前队长的用户id
|
||||
private SudMGPMGState.MGCommonGameState mgCommonGameStateModel; // 全局游戏状态
|
||||
private boolean isHitBomb = false; // 是否数字炸弹
|
||||
private final HashSet<String> playerInSet = new HashSet<>(); // 记录已经加入了游戏的玩家
|
||||
private final HashSet<String> playerReadySet = new HashSet<>(); // 记录已经准备好的游戏玩家
|
||||
private final HashMap<String, SudMGPMGState.MGCommonPlayerPlaying> playerPlayingMap = new HashMap<>(); // 记录玩家的游戏状态
|
||||
|
||||
// 队长状态 处理
|
||||
public void onPlayerMGCommonPlayerCaptain(String userId, SudMGPMGState.MGCommonPlayerCaptain model) {
|
||||
if (model != null) {
|
||||
if (model.isCaptain) {
|
||||
captainUserId = userId;
|
||||
} else {
|
||||
if (Objects.equals(captainUserId, userId)) {
|
||||
captainUserId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 游戏状态 处理
|
||||
public void onGameMGCommonGameState(SudMGPMGState.MGCommonGameState model) {
|
||||
mgCommonGameStateModel = model;
|
||||
}
|
||||
|
||||
// 玩家加入状态处理
|
||||
public void onPlayerMGCommonPlayerIn(String userId, SudMGPMGState.MGCommonPlayerIn model) {
|
||||
if (model != null) {
|
||||
if (model.isIn) {
|
||||
playerInSet.add(userId);
|
||||
} else {
|
||||
playerInSet.remove(userId);
|
||||
playerReadySet.remove(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 玩家准备状态
|
||||
public void onPlayerMGCommonPlayerReady(String userId, SudMGPMGState.MGCommonPlayerReady model) {
|
||||
if (model != null) {
|
||||
if (model.isReady) {
|
||||
playerReadySet.add(userId);
|
||||
} else {
|
||||
playerReadySet.remove(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 玩家游戏状态
|
||||
public void onPlayerMGCommonPlayerPlaying(String userId, SudMGPMGState.MGCommonPlayerPlaying model) {
|
||||
if (model != null) {
|
||||
playerPlayingMap.put(userId, model);
|
||||
}
|
||||
}
|
||||
|
||||
// 关键词状态
|
||||
public void onGameMGCommonKeyWordToHit(SudMGPMGState.MGCommonKeyWordToHit model) {
|
||||
if (model != null) {
|
||||
isHitBomb = model.wordType.equals("number");
|
||||
}
|
||||
}
|
||||
|
||||
// 返回该玩家是否正在游戏中
|
||||
public boolean playerIsPlaying(String userId) {
|
||||
SudMGPMGState.MGCommonPlayerPlaying mgCommonPlayerPlaying = playerPlayingMap.get(userId);
|
||||
if (mgCommonPlayerPlaying != null) {
|
||||
return mgCommonPlayerPlaying.isPlaying;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 返回该玩家是否已准备
|
||||
public boolean playerIsReady(String userId) {
|
||||
return playerReadySet.contains(userId);
|
||||
}
|
||||
|
||||
// 返回该玩家是否已加入了游戏
|
||||
public boolean playerIsIn(String userId) {
|
||||
return playerInSet.contains(userId);
|
||||
}
|
||||
|
||||
// 获取当前游戏中的人数
|
||||
public int getPlayerInNumber() {
|
||||
return playerInSet.size();
|
||||
}
|
||||
|
||||
// 是否数字炸弹
|
||||
public boolean isHitBomb() {
|
||||
return isHitBomb;
|
||||
}
|
||||
|
||||
// 销毁游戏
|
||||
public void destroyMG() {
|
||||
captainUserId = null;
|
||||
mgCommonGameStateModel = null;
|
||||
isHitBomb = false;
|
||||
playerInSet.clear();
|
||||
playerReadySet.clear();
|
||||
playerPlayingMap.clear();
|
||||
}
|
||||
|
||||
/** 获取队长userId */
|
||||
public String getCaptainUserId() {
|
||||
return captainUserId;
|
||||
}
|
||||
|
||||
/** 获取当前已加入游戏的玩家集合 */
|
||||
public HashSet<String> getPlayerInSet() {
|
||||
return new HashSet<>(playerInSet);
|
||||
}
|
||||
|
||||
/** 获取当前已准备的玩家集合 */
|
||||
public HashSet<String> getPlayerReadySet() {
|
||||
return new HashSet<>(playerReadySet);
|
||||
}
|
||||
|
||||
/** 获取玩家游戏状态集合 */
|
||||
public HashMap<String, SudMGPMGState.MGCommonPlayerPlaying> getPlayerPlayingMap() {
|
||||
return new HashMap<>(playerPlayingMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前游戏的状态,数值参数{@link SudMGPMGState.MGCommonGameState}
|
||||
*/
|
||||
public int getGameState() {
|
||||
if (mgCommonGameStateModel != null) {
|
||||
return mgCommonGameStateModel.gameState;
|
||||
}
|
||||
return SudMGPMGState.MGCommonGameState.UNKNOW;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,901 @@
|
||||
/*
|
||||
* Copyright © Sud.Tech
|
||||
* https://sud.tech
|
||||
*/
|
||||
|
||||
package com.yunbao.common.sud.decorator;
|
||||
|
||||
import com.yunbao.common.sud.state.SudMGPMGState;
|
||||
import com.yunbao.common.utils.ISudFSMStateHandleUtils;
|
||||
|
||||
import tech.sud.mgp.core.ISudFSMStateHandle;
|
||||
|
||||
/**
|
||||
* {@link SudFSMMGDecorator} 回调定义
|
||||
*/
|
||||
public interface SudFSMMGListener {
|
||||
|
||||
/**
|
||||
* 游戏日志
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
default void onGameLog(String str) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏加载进度
|
||||
*
|
||||
* @param stage 阶段:start=1,loading=2,end=3
|
||||
* @param retCode 错误码:0成功
|
||||
* @param progress 进度:[0, 100]
|
||||
*/
|
||||
default void onGameLoadingProgress(int stage, int retCode, int progress) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏开始,需要实现
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
void onGameStarted();
|
||||
|
||||
/**
|
||||
* 游戏销毁,需要实现
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
void onGameDestroyed();
|
||||
|
||||
/**
|
||||
* Code过期,需要实现
|
||||
* APP接入方需要调用handle.success或handle.fail
|
||||
*
|
||||
* @param dataJson {"code":"value"}
|
||||
*/
|
||||
void onExpireCode(ISudFSMStateHandle handle, String dataJson);
|
||||
|
||||
/**
|
||||
* 获取游戏View信息,需要实现
|
||||
* APP接入方需要调用handle.success或handle.fail
|
||||
*
|
||||
* @param handle
|
||||
* @param dataJson {}
|
||||
*/
|
||||
void onGetGameViewInfo(ISudFSMStateHandle handle, String dataJson);
|
||||
|
||||
/**
|
||||
* 获取游戏Config,需要实现
|
||||
* APP接入方需要调用handle.success或handle.fail
|
||||
*
|
||||
* @param handle
|
||||
* @param dataJson {}
|
||||
* 最低版本:v1.1.30.xx
|
||||
*/
|
||||
void onGetGameCfg(ISudFSMStateHandle handle, String dataJson);
|
||||
|
||||
// region 游戏回调APP 通用状态
|
||||
// 参考文档:https://github.com/SudTechnology/sud-mgp-doc/blob/main/Client/MG%20FSM/%E9%80%9A%E7%94%A8%E7%8A%B6%E6%80%81-%E7%8E%A9%E5%AE%B6.md
|
||||
|
||||
/**
|
||||
* 1.游戏公屏消息
|
||||
* mg_common_public_message
|
||||
*/
|
||||
default void onGameMGCommonPublicMessage(ISudFSMStateHandle handle, SudMGPMGState.MGCommonPublicMessage model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. 关键词状态
|
||||
* mg_common_key_word_to_hit
|
||||
*/
|
||||
default void onGameMGCommonKeyWordToHit(ISudFSMStateHandle handle, SudMGPMGState.MGCommonKeyWordToHit model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. 游戏结算状态
|
||||
* mg_common_game_settle
|
||||
*/
|
||||
default void onGameMGCommonGameSettle(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSettle model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. 加入游戏按钮点击状态
|
||||
* mg_common_self_click_join_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickJoinBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickJoinBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. 取消加入(退出)游戏按钮点击状态
|
||||
* mg_common_self_click_cancel_join_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickCancelJoinBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickCancelJoinBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 6. 准备按钮点击状态
|
||||
* mg_common_self_click_ready_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickReadyBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickReadyBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 7. 取消准备按钮点击状态
|
||||
* mg_common_self_click_cancel_ready_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickCancelReadyBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickCancelReadyBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8. 开始游戏按钮点击状态
|
||||
* mg_common_self_click_start_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickStartBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickStartBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 9. 分享按钮点击状态
|
||||
* mg_common_self_click_share_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickShareBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickShareBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 10. 游戏状态
|
||||
* mg_common_game_state
|
||||
*/
|
||||
default void onGameMGCommonGameState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameState model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 11. 结算界面关闭按钮点击状态(2021-12-27新增)
|
||||
* mg_common_self_click_game_settle_close_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickGameSettleCloseBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickGameSettleCloseBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 12. 结算界面再来一局按钮点击状态(2021-12-27新增)
|
||||
* mg_common_self_click_game_settle_again_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickGameSettleAgainBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickGameSettleAgainBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 13. 游戏上报游戏中的声音列表(2021-12-30新增,现在只支持碰碰我最强)
|
||||
* mg_common_game_sound_list
|
||||
*/
|
||||
default void onGameMGCommonGameSoundList(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSoundList model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 14. 游通知app层播放声音(2021-12-30新增,现在只支持碰碰我最强)
|
||||
* mg_common_game_sound
|
||||
*/
|
||||
default void onGameMGCommonGameSound(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSound model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 15. 游戏通知app层播放背景音乐状态(2022-01-07新增,现在只支持碰碰我最强)
|
||||
* mg_common_game_bg_music_state
|
||||
*/
|
||||
default void onGameMGCommonGameBgMusicState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameBgMusicState model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 16. 游戏通知app层播放音效的状态(2022-01-07新增,现在只支持碰碰我最强)
|
||||
* mg_common_game_sound_state
|
||||
*/
|
||||
default void onGameMGCommonGameSoundState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSoundState model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 17. ASR状态(开启和关闭语音识别状态,v1.1.45.xx 版本新增)
|
||||
* mg_common_game_asr
|
||||
*/
|
||||
default void onGameMGCommonGameASR(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameASR model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 18. 麦克风状态(2022-02-08新增)
|
||||
* mg_common_self_microphone
|
||||
*/
|
||||
default void onGameMGCommonSelfMicrophone(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfMicrophone model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 19. 耳机(听筒,扬声器)状态(2022-02-08新增)
|
||||
* mg_common_self_headphone
|
||||
*/
|
||||
default void onGameMGCommonSelfHeadphone(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfHeadphone model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 20. App通用状态操作结果错误码(2022-05-10新增)
|
||||
* mg_common_app_common_self_x_resp
|
||||
*/
|
||||
default void onGameMGCommonAPPCommonSelfXResp(ISudFSMStateHandle handle, SudMGPMGState.MGCommonAPPCommonSelfXResp model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 21. 游戏通知app层添加陪玩机器人是否成功(2022-05-17新增)
|
||||
* mg_common_game_add_ai_players
|
||||
*/
|
||||
default void onGameMGCommonGameAddAIPlayers(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameAddAIPlayers model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 22. 游戏通知app层添当前网络连接状态(2022-06-21新增)
|
||||
* mg_common_game_network_state
|
||||
*/
|
||||
default void onGameMGCommonGameNetworkState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameNetworkState model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 23. 游戏通知app获取积分
|
||||
* mg_common_game_score
|
||||
*/
|
||||
default void onGameMGCommonGameGetScore(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameGetScore model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 24. 游戏通知app带入积分
|
||||
* mg_common_game_set_score
|
||||
*/
|
||||
default void onGameMGCommonGameSetScore(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSetScore model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 25. 创建订单
|
||||
* mg_common_game_create_order
|
||||
*/
|
||||
default void onGameMGCommonGameCreateOrder(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameCreateOrder model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 26. 游戏通知app玩家角色(仅对狼人杀有效)
|
||||
* mg_common_player_role_id
|
||||
*/
|
||||
default void onGameMGCommonPlayerRoleId(ISudFSMStateHandle handle, SudMGPMGState.MGCommonPlayerRoleId model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 27. 游戏通知app玩家被扔便便(你画我猜,你说我猜,友尽闯关有效)
|
||||
* mg_common_self_click_poop
|
||||
*/
|
||||
default void onGameMGCommonSelfClickPoop(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickPoop model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 28. 游戏通知app玩家被点赞(你画我猜,你说我猜,友尽闯关有效)
|
||||
* mg_common_self_click_good
|
||||
*/
|
||||
default void onGameMGCommonSelfClickGood(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickGood model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 29. 游戏通知app游戏FPS(仅对碰碰,多米诺骨牌,飞镖达人生效)
|
||||
* mg_common_game_fps
|
||||
*/
|
||||
default void onGameMGCommonGameFps(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameFps model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 30. 游戏通知app游戏弹框
|
||||
* mg_common_alert
|
||||
*/
|
||||
default void onGameMGCommonAlert(ISudFSMStateHandle handle, SudMGPMGState.MGCommonAlert model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 31. 游戏通知app最坑队友(只支持友尽闯关)
|
||||
* mg_common_worst_teammate
|
||||
*/
|
||||
default void onGameMGCommonWorstTeammate(ISudFSMStateHandle handle, SudMGPMGState.MGCommonWorstTeammate model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 32. 游戏通知app因玩家逃跑导致游戏结束(只支持友尽闯关)
|
||||
* mg_common_game_over_tip
|
||||
*/
|
||||
default void onGameMGCommonGameOverTip(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameOverTip model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 33. 游戏通知app玩家颜色(只支持友尽闯关)
|
||||
* mg_common_game_player_color
|
||||
*/
|
||||
default void onGameMGCommonGamePlayerColor(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerColor model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 34. 游戏通知app玩家头像的坐标(只支持ludo)
|
||||
* mg_common_game_player_icon_position
|
||||
*/
|
||||
default void onGameMGCommonGamePlayerIconPosition(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerIconPosition model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 35. 游戏通知app退出游戏(只支持teenpattipro 与 德州pro)
|
||||
* mg_common_self_click_exit_game_btn
|
||||
*/
|
||||
default void onGameMGCommonSelfClickExitGameBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickExitGameBtn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 36. 游戏通知app是否要开启带入积分(只支持teenpattipro 与 德州pro)
|
||||
* mg_common_game_is_app_chip
|
||||
*/
|
||||
default void onGameMGCommonGameIsAppChip(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameIsAppChip model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 37. 游戏通知app当前游戏的设置信息(只支持德州pro,teenpatti pro)
|
||||
* mg_common_game_rule
|
||||
*/
|
||||
default void onGameMGCommonGameRule(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameRule model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 38. 游戏通知app进行玩法设置(只支持德州pro,teenpatti pro)
|
||||
* mg_common_game_settings
|
||||
*/
|
||||
default void onGameMGCommonGameSettings(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSettings model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 39. 游戏通知app钱币不足(只支持德州pro,teenpatti pro)
|
||||
* mg_common_game_money_not_enough
|
||||
*/
|
||||
default void onGameMGCommonGameMoneyNotEnough(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameMoneyNotEnough model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 40. 游戏通知app下发定制ui配置表(只支持ludo)
|
||||
* mg_common_game_ui_custom_config
|
||||
*/
|
||||
default void onGameMGCommonGameUiCustomConfig(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameUiCustomConfig model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 41. 设置app提供给游戏可点击区域(赛车)
|
||||
* mg_common_set_click_rect
|
||||
*/
|
||||
default void onGameMGCommonSetClickRect(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSetClickRect model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 42. 通知app提供对应uids列表玩家的数据(赛车)
|
||||
* mg_common_users_info
|
||||
*/
|
||||
default void onGameMGCommonUsersInfo(ISudFSMStateHandle handle, SudMGPMGState.MGCommonUsersInfo model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 43. 通知app游戏前期准备完成(赛车)
|
||||
* mg_common_game_prepare_finish
|
||||
*/
|
||||
default void onGameMGCommonGamePrepareFinish(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePrepareFinish model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 44. 通知app游戏主界面已显示(赛车)
|
||||
* mg_common_show_game_scene
|
||||
*/
|
||||
default void onGameMGCommonShowGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCommonShowGameScene model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 45. 通知app游戏主界面已隐藏(赛车)
|
||||
* mg_common_hide_game_scene
|
||||
*/
|
||||
default void onGameMGCommonHideGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCommonHideGameScene model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
// endregion 游戏回调APP 通用状态
|
||||
|
||||
// region 游戏回调APP 玩家状态
|
||||
|
||||
/**
|
||||
* 1.加入状态(已修改)
|
||||
* mg_common_player_in
|
||||
*/
|
||||
default void onPlayerMGCommonPlayerIn(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerIn model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.准备状态(已修改)
|
||||
* mg_common_player_ready
|
||||
*/
|
||||
default void onPlayerMGCommonPlayerReady(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerReady model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.队长状态(已修改)
|
||||
* mg_common_player_captain
|
||||
*/
|
||||
default void onPlayerMGCommonPlayerCaptain(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerCaptain model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4.游戏状态(已修改)
|
||||
* mg_common_player_playing
|
||||
*/
|
||||
default void onPlayerMGCommonPlayerPlaying(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerPlaying model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 5.玩家在线状态
|
||||
* mg_common_player_online
|
||||
*/
|
||||
default void onPlayerMGCommonPlayerOnline(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerOnline model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 6.玩家换游戏位状态
|
||||
* mg_common_player_change_seat
|
||||
*/
|
||||
default void onPlayerMGCommonPlayerChangeSeat(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerChangeSeat model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 7. 游戏通知app点击玩家头像
|
||||
* mg_common_self_click_game_player_icon
|
||||
*/
|
||||
default void onPlayerMGCommonSelfClickGamePlayerIcon(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfClickGamePlayerIcon model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8. 游戏通知app玩家死亡状态(2022-04-24新增)
|
||||
* mg_common_self_die_status
|
||||
*/
|
||||
default void onPlayerMGCommonSelfDieStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfDieStatus model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 9. 游戏通知app轮到玩家出手状态(2022-04-24新增)
|
||||
* mg_common_self_turn_status
|
||||
*/
|
||||
default void onPlayerMGCommonSelfTurnStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfTurnStatus model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 10. 游戏通知app玩家选择状态(2022-04-24新增)
|
||||
* mg_common_self_select_status
|
||||
*/
|
||||
default void onPlayerMGCommonSelfSelectStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfSelectStatus model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 11. 游戏通知app层当前游戏剩余时间(2022-05-23新增,目前UMO生效)
|
||||
* mg_common_game_countdown_time
|
||||
*/
|
||||
default void onPlayerMGCommonGameCountdownTime(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonGameCountdownTime model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 12. 游戏通知app层当前玩家死亡后变成ob视角(2022-08-23新增,目前狼人杀生效)
|
||||
* mg_common_self_ob_status
|
||||
*/
|
||||
default void onPlayerMGCommonSelfObStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfObStatus model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
// endregion 游戏回调APP 玩家状态
|
||||
|
||||
// region 游戏回调APP 玩家状态 你画我猜
|
||||
// 参考文档:https://github.com/SudTechnology/sud-mgp-doc/blob/main/Client/MG%20FSM/%E4%BD%A0%E7%94%BB%E6%88%91%E7%8C%9C.md
|
||||
|
||||
/**
|
||||
* 1. 选词中状态(已修改)
|
||||
* mg_dg_selecting
|
||||
*/
|
||||
default void onPlayerMGDGSelecting(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGSelecting model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. 作画中状态(已修改)
|
||||
* mg_dg_painting
|
||||
*/
|
||||
default void onPlayerMGDGPainting(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGPainting model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. 显示错误答案状态(已修改)
|
||||
* mg_dg_erroranswer
|
||||
*/
|
||||
default void onPlayerMGDGErroranswer(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGErroranswer model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. 显示总积分状态(已修改)
|
||||
* mg_dg_totalscore
|
||||
*/
|
||||
default void onPlayerMGDGTotalscore(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGTotalscore model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. 本次获得积分状态(已修改)
|
||||
* mg_dg_score
|
||||
*/
|
||||
default void onPlayerMGDGScore(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGScore model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
// endregion 游戏回调APP 玩家状态 你画我猜
|
||||
|
||||
// region 游戏回调APP 通用状态 元宇宙砂砂舞
|
||||
|
||||
/**
|
||||
* 1. 元宇宙砂砂舞指令回调
|
||||
* mg_common_game_disco_action
|
||||
*/
|
||||
default void onGameMGCommonGameDiscoAction(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameDiscoAction model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. 元宇宙砂砂舞指令动作结束通知
|
||||
* mg_common_game_disco_action_end
|
||||
*/
|
||||
default void onGameMGCommonGameDiscoActionEnd(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameDiscoActionEnd model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
// endregion 游戏回调APP 通用状态 元宇宙砂砂舞
|
||||
|
||||
// region 游戏回调APP 通用状态 定制火箭
|
||||
|
||||
/**
|
||||
* 1. 礼物配置文件(火箭)
|
||||
* mg_custom_rocket_config
|
||||
*/
|
||||
default void onGameMGCustomRocketConfig(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketConfig model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. 拥有模型列表(火箭)
|
||||
* mg_custom_rocket_model_list
|
||||
*/
|
||||
default void onGameMGCustomRocketModelList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketModelList model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. 拥有组件列表(火箭)
|
||||
* mg_custom_rocket_component_list
|
||||
*/
|
||||
default void onGameMGCustomRocketComponentList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketComponentList model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. 获取用户信息(火箭)
|
||||
* mg_custom_rocket_user_info
|
||||
*/
|
||||
default void onGameMGCustomRocketUserInfo(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketUserInfo model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. 订单记录列表(火箭)
|
||||
* mg_custom_rocket_order_record_list
|
||||
*/
|
||||
default void onGameMGCustomRocketOrderRecordList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketOrderRecordList model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 6. 展馆内列表(火箭)
|
||||
* mg_custom_rocket_room_record_list
|
||||
*/
|
||||
default void onGameMGCustomRocketRoomRecordList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketRoomRecordList model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 7. 展馆内玩家送出记录(火箭)
|
||||
* mg_custom_rocket_user_record_list
|
||||
*/
|
||||
default void onGameMGCustomRocketUserRecordList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketUserRecordList model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8. 设置默认模型(火箭)
|
||||
* mg_custom_rocket_set_default_model
|
||||
*/
|
||||
default void onGameMGCustomRocketSetDefaultModel(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketSetDefaultModel model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 9. 动态计算一键发送价格(火箭)
|
||||
* mg_custom_rocket_dynamic_fire_price
|
||||
*/
|
||||
default void onGameMGCustomRocketDynamicFirePrice(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketDynamicFirePrice model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 10. 一键发送(火箭)
|
||||
* mg_custom_rocket_fire_model
|
||||
*/
|
||||
default void onGameMGCustomRocketFireModel(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketFireModel model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 11. 新组装模型(火箭)
|
||||
* mg_custom_rocket_create_model
|
||||
*/
|
||||
default void onGameMGCustomRocketCreateModel(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketCreateModel model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 12. 模型更换组件(火箭)
|
||||
* mg_custom_rocket_replace_component
|
||||
*/
|
||||
default void onGameMGCustomRocketReplaceComponent(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketReplaceComponent model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 13. 购买组件(火箭)
|
||||
* mg_custom_rocket_buy_component
|
||||
*/
|
||||
default void onGameMGCustomRocketBuyComponent(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketBuyComponent model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 14. 播放效果开始(火箭)
|
||||
* mg_custom_rocket_play_effect_start
|
||||
*/
|
||||
default void onGameMGCustomRocketPlayEffectStart(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketPlayEffectStart model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 15. 播放效果完成(火箭)
|
||||
* mg_custom_rocket_play_effect_finish
|
||||
*/
|
||||
default void onGameMGCustomRocketPlayEffectFinish(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketPlayEffectFinish model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 16. 验证签名合规(火箭)
|
||||
* mg_custom_rocket_verify_sign
|
||||
*/
|
||||
default void onGameMGCustomRocketVerifySign(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketVerifySign model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 17. 上传icon(火箭)
|
||||
* mg_custom_rocket_upload_model_icon
|
||||
*/
|
||||
default void onGameMGCustomRocketUploadModelIcon(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketUploadModelIcon model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 18. 前期准备完成(火箭)
|
||||
* mg_custom_rocket_prepare_finish
|
||||
*/
|
||||
default void onGameMGCustomRocketPrepareFinish(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketPrepareFinish model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 19. 火箭主界面已显示(火箭)
|
||||
* mg_custom_rocket_show_game_scene
|
||||
*/
|
||||
default void onGameMGCustomRocketShowGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketShowGameScene model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 20. 火箭主界面已隐藏(火箭)
|
||||
* mg_custom_rocket_hide_game_scene
|
||||
*/
|
||||
default void onGameMGCustomRocketHideGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketHideGameScene model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 21. 点击锁住组件(火箭)
|
||||
* mg_custom_rocket_click_lock_component
|
||||
*/
|
||||
default void onGameMGCustomRocketClickLockComponent(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketClickLockComponent model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 22. 火箭效果飞行点击(火箭)
|
||||
* mg_custom_rocket_fly_click
|
||||
*/
|
||||
default void onGameMGCustomRocketFlyClick(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketFlyClick model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 23. 火箭效果飞行结束(火箭)
|
||||
* mg_custom_rocket_fly_end
|
||||
*/
|
||||
default void onGameMGCustomRocketFlyEnd(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketFlyEnd model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 24. 设置点击区域(火箭)
|
||||
* mg_custom_rocket_set_click_rect
|
||||
*/
|
||||
default void onGameMGCustomRocketSetClickRect(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketSetClickRect model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 25. 颜色和签名自定义改到装配间的模式,保存颜色或签名
|
||||
* mg_custom_rocket_save_sign_color
|
||||
*/
|
||||
default void onGameMGCustomRocketSaveSignColor(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketSaveSignColor model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
// endregion 游戏回调APP 通用状态 定制火箭
|
||||
|
||||
// region 游戏回调APP 通用状态 棒球
|
||||
|
||||
/**
|
||||
* 1. 查询排行榜数据(棒球)
|
||||
* mg_baseball_ranking
|
||||
*/
|
||||
default void onGameMGBaseballRanking(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballRanking model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. 查询我的排名(棒球)
|
||||
* mg_baseball_my_ranking
|
||||
*/
|
||||
default void onGameMGBaseballMyRanking(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballMyRanking model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. 查询当前距离我的前后玩家数据(棒球)
|
||||
* mg_baseball_range_info
|
||||
*/
|
||||
default void onGameMGBaseballRangeInfo(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballRangeInfo model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. 设置app提供给游戏可点击区域(棒球)
|
||||
* mg_baseball_set_click_rect
|
||||
*/
|
||||
default void onGameMGBaseballSetClickRect(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballSetClickRect model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. 前期准备完成(棒球)
|
||||
* mg_baseball_prepare_finish
|
||||
*/
|
||||
default void onGameMGBaseballPrepareFinish(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballPrepareFinish model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 6. 主界面已显示(棒球)
|
||||
* mg_baseball_show_game_scene
|
||||
*/
|
||||
default void onGameMGBaseballShowGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballShowGameScene model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 7. 主界面已隐藏(棒球)
|
||||
* mg_baseball_hide_game_scene
|
||||
*/
|
||||
default void onGameMGBaseballHideGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballHideGameScene model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8. 获取文本配置数据(棒球)
|
||||
* mg_baseball_text_config
|
||||
*/
|
||||
default void onGameMGBaseballTextConfig(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballTextConfig model) {
|
||||
ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
}
|
||||
// endregion 游戏回调APP 通用状态 棒球
|
||||
|
||||
/**
|
||||
* 游戏状态变化
|
||||
* 透传游戏向App发送的游戏通用状态消息
|
||||
* **********使用此方法可先看下此方法的使用逻辑*************
|
||||
*
|
||||
* @param handle 回调操作
|
||||
* @param state 状态命令
|
||||
* @param dataJson 状态值
|
||||
* @return 返回true,表示由此方法接管该状态处理,此时需注意调用:ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
*/
|
||||
default boolean onGameStateChange(ISudFSMStateHandle handle, String state, String dataJson) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏玩家状态变化
|
||||
* 透传游戏向App发送的玩家状态变化
|
||||
* **********使用此方法可先看下此方法的使用逻辑*************
|
||||
*
|
||||
* @param handle 回调操作
|
||||
* @param userId 用户Id
|
||||
* @param state 状态命令
|
||||
* @param dataJson 状态值
|
||||
* @return 返回true,表示由此方法接管该状态处理,此时需注意调用:ISudFSMStateHandleUtils.handleSuccess(handle);
|
||||
*/
|
||||
default boolean onPlayerStateChange(ISudFSMStateHandle handle, String userId, String state, String dataJson) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,446 @@
|
||||
/*
|
||||
* Copyright © Sud.Tech
|
||||
* https://sud.tech
|
||||
*/
|
||||
|
||||
package com.yunbao.common.sud.decorator;
|
||||
|
||||
import com.yunbao.common.sud.state.SudMGPAPPState;
|
||||
import com.yunbao.common.utils.SudJsonUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
import tech.sud.mgp.core.ISudFSTAPP;
|
||||
import tech.sud.mgp.core.ISudListenerNotifyStateChange;
|
||||
|
||||
/**
|
||||
* ISudFSTAPP的装饰类,接近于业务
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSTAPP.html
|
||||
* 注意:
|
||||
* 1,向游戏侧发送状态之后,不能立即调用destroyMG()方法,也不能立即finish Activity。例如:{@link SudFSTAPPDecorator#notifyAPPCommonSelfEnd()}
|
||||
*/
|
||||
public class SudFSTAPPDecorator {
|
||||
|
||||
/**
|
||||
* APP调用游戏的接口
|
||||
*/
|
||||
private ISudFSTAPP iSudFSTAPP;
|
||||
|
||||
/**
|
||||
* 设置app调用sdk的对象
|
||||
*
|
||||
* @param iSudFSTAPP
|
||||
*/
|
||||
public void setISudFSTAPP(ISudFSTAPP iSudFSTAPP) {
|
||||
this.iSudFSTAPP = iSudFSTAPP;
|
||||
}
|
||||
|
||||
// region 状态通知,ISudFSTAPP.notifyStateChange
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 1. 加入状态
|
||||
*
|
||||
* @param isIn true 加入游戏,false 退出游戏
|
||||
* @param seatIndex 加入的游戏位(座位号) 默认传seatIndex = -1 随机加入,seatIndex 从0开始,不可大于座位数
|
||||
* @param isSeatRandom 默认为ture, 带有游戏位(座位号)的时候,如果游戏位(座位号)已经被占用,是否随机分配一个空位坐下 isSeatRandom=true 随机分配空位坐下,isSeatRandom=false 不随机分配
|
||||
* @param teamId 不支持分队的游戏:数值填1;支持分队的游戏:数值填1或2(两支队伍);
|
||||
*/
|
||||
public void notifyAPPCommonSelfIn(boolean isIn, int seatIndex, boolean isSeatRandom, int teamId) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfIn state = new SudMGPAPPState.APPCommonSelfIn();
|
||||
state.isIn = isIn;
|
||||
state.seatIndex = seatIndex;
|
||||
state.isSeatRandom = isSeatRandom;
|
||||
state.teamId = teamId;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_IN, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 2. 准备状态
|
||||
* 用户(本人)准备/取消准备
|
||||
*
|
||||
* @param isReady true 准备,false 取消准备
|
||||
*/
|
||||
public void notifyAPPCommonSelfReady(boolean isReady) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfReady state = new SudMGPAPPState.APPCommonSelfReady();
|
||||
state.isReady = isReady;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_READY, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 3. 游戏状态 模型
|
||||
* 用户游戏状态,如果用户在游戏中,建议:
|
||||
* a.空出屏幕中心区:
|
||||
* 关闭全屏礼物特效;
|
||||
* b.部分强操作类小游戏(spaceMax为true),尽量收缩原生UI,给游戏留出尽量大的操作空间:
|
||||
* 收缩公屏;
|
||||
* 收缩麦位;
|
||||
* 如果不在游戏中,则恢复。
|
||||
*
|
||||
* @param isPlaying true 开始游戏,false 结束游戏
|
||||
* @param reportGameInfoExtras string类型,Https服务回调report_game_info参数,最大长度1024字节,超过则截断(2022-01-21)
|
||||
*/
|
||||
public void notifyAPPCommonSelfPlaying(boolean isPlaying, String reportGameInfoExtras, String reportGameInfoKey) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfPlaying state = new SudMGPAPPState.APPCommonSelfPlaying();
|
||||
state.isPlaying = isPlaying;
|
||||
state.reportGameInfoExtras = reportGameInfoExtras;
|
||||
state.reportGameInfoKey = reportGameInfoKey;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_PLAYING, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 4. 队长状态
|
||||
* 用户是否为队长,队长在游戏中会有开始游戏的权利。
|
||||
* 发送此状态后,会把队长身份转移到另一名用户身上。
|
||||
* 注意:必须是队长发送才有效果。可通过{@link SudFSMMGDecorator#getCaptainUserId()}拿到当前队长id
|
||||
*
|
||||
* @param curCaptainUID 必填,指定队长uid
|
||||
*/
|
||||
public void notifyAPPCommonSelfCaptain(String curCaptainUID) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfCaptain state = new SudMGPAPPState.APPCommonSelfCaptain();
|
||||
state.curCaptainUID = curCaptainUID;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_CAPTAIN, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 5. 踢人
|
||||
* 用户(本人,队长)踢其他玩家;
|
||||
* 队长才能踢人;
|
||||
*
|
||||
* @param kickedUID 被踢用户uid
|
||||
*/
|
||||
public void notifyAPPCommonSelfKick(String kickedUID) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfKick state = new SudMGPAPPState.APPCommonSelfKick();
|
||||
state.kickedUID = kickedUID;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_KICK, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 6. 结束游戏
|
||||
* 用户(本人,队长)结束(本局)游戏
|
||||
* 注意:必须是队长发送才有效果。可通过{@link SudFSMMGDecorator#getCaptainUserId()}拿到当前队长id
|
||||
*/
|
||||
public void notifyAPPCommonSelfEnd() {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfEnd state = new SudMGPAPPState.APPCommonSelfEnd();
|
||||
// 使用iSudFSTAPP.notifyStateChange方法向游戏侧发送状态时,因为大部分状态都需要通过网络向后端发送状态指令
|
||||
// 所以如果发送状态后,马上就销毁游戏或者Activity,那么状态指令大概率会不生效
|
||||
// *** 如果要确保指令能到达后端,那么发送指令后不要立即destroyMG()或finish Activity,可在发送后delay一定时间(如300 or 500 ms)再销毁
|
||||
// *** 如果不在乎指令是否能成功到达,可忽略delay
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_END, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 9. 麦克风状态
|
||||
* 用户(本人)麦克风状态,建议:
|
||||
* 进入房间后初始通知一次;
|
||||
* 每次变更(开麦/闭麦/禁麦/解麦)通知一次;
|
||||
*
|
||||
* @param isOn true 开麦,false 闭麦
|
||||
* @param isDisabled true 被禁麦,false 未被禁麦
|
||||
*/
|
||||
public void notifyAPPCommonSelfMicrophone(boolean isOn, boolean isDisabled) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfMicrophone state = new SudMGPAPPState.APPCommonSelfMicrophone();
|
||||
state.isOn = isOn;
|
||||
state.isDisabled = isDisabled;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_MICROPHONE, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 10. 文字命中状态
|
||||
* 用户(本人)聊天信息命中关键词状态,建议:
|
||||
* 精确匹配;
|
||||
* 首次聊天内容命中关键词之后,后续聊天内容不翻转成未命中;
|
||||
* 直至小游戏侧关键词更新,再将状态翻转为未命中;
|
||||
*
|
||||
* @param isHit true 命中,false 未命中
|
||||
* @param keyWord 单个关键词, 兼容老版本
|
||||
* @param text 返回转写文本
|
||||
* @param wordType text:文本包含匹配; number:数字等于匹配
|
||||
* @param keyWordList 命中关键词,可以包含多个关键词
|
||||
* @param numberList 在number模式下才有,返回转写的多个数字
|
||||
*/
|
||||
public void notifyAPPCommonSelfTextHitState(boolean isHit, String keyWord, String text,
|
||||
String wordType, List<String> keyWordList, List<Integer> numberList) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonSelfTextHitState state = new SudMGPAPPState.APPCommonSelfTextHitState();
|
||||
state.isHit = isHit;
|
||||
state.keyWord = keyWord;
|
||||
state.text = text;
|
||||
state.wordType = wordType;
|
||||
state.keyWordList = keyWordList;
|
||||
state.numberList = numberList;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_TEXT_HIT, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 11. 打开或关闭背景音乐(2021-12-27新增)
|
||||
*
|
||||
* @param isOpen true 打开背景音乐,false 关闭背景音乐
|
||||
*/
|
||||
public void notifyAPPCommonOpenBgMusic(boolean isOpen) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonOpenBgMusic state = new SudMGPAPPState.APPCommonOpenBgMusic();
|
||||
state.isOpen = isOpen;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_OPEN_BG_MUSIC, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 12. 打开或关闭音效(2021-12-27新增)
|
||||
*
|
||||
* @param isOpen true 打开音效,false 关闭音效
|
||||
*/
|
||||
public void notifyAPPCommonOpenSound(boolean isOpen) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonOpenSound state = new SudMGPAPPState.APPCommonOpenSound();
|
||||
state.isOpen = isOpen;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_OPEN_SOUND, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 13. 打开或关闭游戏中的振动效果(2021-12-27新增)
|
||||
*
|
||||
* @param isOpen 打开振动效果,false 关闭振动效果
|
||||
*/
|
||||
public void notifyAPPCommonOpenVibrate(boolean isOpen) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonOpenVibrate state = new SudMGPAPPState.APPCommonOpenVibrate();
|
||||
state.isOpen = isOpen;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_OPEN_VIBRATE, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 14. 设置游戏的音量大小(2021-12-31新增)
|
||||
*
|
||||
* @param volume 音量大小 0 到 100
|
||||
*/
|
||||
public void notifyAPPCommonGameSoundVolume(int volume) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonGameSoundVolume state = new SudMGPAPPState.APPCommonGameSoundVolume();
|
||||
state.volume = volume;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_SOUND_VOLUME, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 15. 设置游戏玩法选项(2022-05-10新增)
|
||||
*
|
||||
* @param ludo ludo游戏
|
||||
*/
|
||||
public void notifyAPPCommonGameSettingSelectInfo(SudMGPAPPState.Ludo ludo) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonGameSettingSelectInfo state = new SudMGPAPPState.APPCommonGameSettingSelectInfo();
|
||||
state.ludo = ludo;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_SETTING_SELECT_INFO, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 16. 设置游戏中的AI玩家(2022-05-11新增)
|
||||
*
|
||||
* @param aiPlayers AI玩家
|
||||
* @param isReady 机器人加入后是否自动准备 1:自动准备,0:不自动准备 默认为1
|
||||
*/
|
||||
public void notifyAPPCommonGameAddAIPlayers(List<SudMGPAPPState.AIPlayers> aiPlayers, int isReady) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonGameAddAIPlayers state = new SudMGPAPPState.APPCommonGameAddAIPlayers();
|
||||
state.aiPlayers = aiPlayers;
|
||||
state.isReady = isReady;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_ADD_AI_PLAYERS, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 17. app在收到游戏断开连接通知后,通知游戏重试连接(2022-06-21新增,暂时支持ludo)
|
||||
*/
|
||||
public void notifyAPPCommonGameReconnect() {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonGameReconnect state = new SudMGPAPPState.APPCommonGameReconnect();
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_RECONNECT, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 18. app返回玩家当前积分
|
||||
*/
|
||||
public void notifyAPPCommonGameScore(long score) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.APPCommonGameScore state = new SudMGPAPPState.APPCommonGameScore();
|
||||
state.score = score;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_SCORE, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
// endregion 状态通知,ISudFSTAPP.notifyStateChange
|
||||
|
||||
// region 生命周期
|
||||
public void startMG() {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.startMG();
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseMG() {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.pauseMG();
|
||||
}
|
||||
}
|
||||
|
||||
public void playMG() {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.playMG();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopMG() {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.stopMG();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyMG() {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.destroyMG();
|
||||
}
|
||||
}
|
||||
|
||||
// endregion 生命周期
|
||||
|
||||
/**
|
||||
* 更新code
|
||||
*
|
||||
* @param code
|
||||
* @param listener
|
||||
*/
|
||||
public void updateCode(String code, ISudListenerNotifyStateChange listener) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.updateCode(code, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 音频流数据
|
||||
*/
|
||||
public void pushAudio(ByteBuffer buffer, int bufferLength) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.pushAudio(buffer, bufferLength);
|
||||
}
|
||||
}
|
||||
|
||||
// region 元宇宙砂砂舞
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 1. 元宇宙砂砂舞相关设置
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/APPFST/CommonStateForDisco.html
|
||||
*
|
||||
* @param actionId 必传的参数,用于指定类型的序号,不同序号用于区分游戏内的不同功能,不传则会判断为无效指令,具体序号代表的功能见下表
|
||||
* @param cooldown 持续时间,单位秒,部分功能有持续时间就需要传对应的数值,不传或传错则会按各自功能的默认值处理(见下表)
|
||||
* @param isTop 是否置顶,针对部分功能可排队置顶(false:不置顶;true:置顶;默认为false)
|
||||
* @param field1 额外参数1,针对部分功能有具体的意义
|
||||
* @param field2 额外参数2,针对部分功能有具体的意义
|
||||
*/
|
||||
public void notifyAppCommonGameDiscoAction(int actionId, Integer cooldown, Boolean isTop, String field1, String field2) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
SudMGPAPPState.AppCommonGameDiscoAction state = new SudMGPAPPState.AppCommonGameDiscoAction();
|
||||
state.actionId = actionId;
|
||||
state.cooldown = cooldown;
|
||||
state.isTop = isTop;
|
||||
state.field1 = field1;
|
||||
state.field2 = field2;
|
||||
iSudFSTAPP.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_DISCO_ACTION, SudJsonUtils.toJson(state), null);
|
||||
}
|
||||
}
|
||||
// endregion 元宇宙砂砂舞
|
||||
|
||||
/**
|
||||
* APP状态通知给小游戏
|
||||
*
|
||||
* @param state 状态标识
|
||||
* @param dataJson 数据
|
||||
* @param listener 回调监听
|
||||
*/
|
||||
public void notifyStateChange(String state, String dataJson, ISudListenerNotifyStateChange listener) {
|
||||
ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP;
|
||||
if (iSudFSTAPP != null) {
|
||||
iSudFSTAPP.notifyStateChange(state, dataJson, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* APP状态通知给小游戏
|
||||
*
|
||||
* @param state 状态标识
|
||||
* @param dataJson 数据
|
||||
*/
|
||||
public void notifyStateChange(String state, String dataJson) {
|
||||
notifyStateChange(state, dataJson, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* APP状态通知给小游戏
|
||||
*
|
||||
* @param state 状态标识
|
||||
* @param obj 数据
|
||||
*/
|
||||
public void notifyStateChange(String state, Object obj) {
|
||||
notifyStateChange(state, SudJsonUtils.toJson(obj), null);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright © Sud.Tech
|
||||
* https://sud.tech
|
||||
*/
|
||||
|
||||
package com.yunbao.common.sud.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 游戏配置模型
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG/onGetGameCfg.html
|
||||
*/
|
||||
public class GameConfigModel implements Serializable {
|
||||
|
||||
public int gameMode = 1; // 游戏模式(每个游戏默认模式是1,不填是1)
|
||||
public int gameCPU = 0; // 游戏CPU(值为0和1;0:CPU正常功耗,1:CPU低功耗;默认是0,CPU正常功耗)
|
||||
public int gameSoundControl = 0; // 游戏中声音的播放是否被app层接管(值为0和1;0:游戏播放声音,1:app层播放声音,游戏中不播放任何声音;默认是0)
|
||||
public int gameSoundVolume = 100; // 游戏中音量的大小(值为0到100;默认是100)
|
||||
public GameUi ui = new GameUi(); // 对游戏ui界面的配置,可定制ui界面的显示与不显示
|
||||
|
||||
// 游戏配置中,ui部分
|
||||
public static class GameUi implements Serializable {
|
||||
public GameSettle gameSettle = new GameSettle(); // 结算界面
|
||||
public GamePing ping = new GamePing(); // 界面中的ping值
|
||||
public GameVersion version = new GameVersion(); // 界面中的版本信息值
|
||||
public GameLevel level = new GameLevel(); // 大厅中的段位信息
|
||||
public GameLobbySettingBtn lobby_setting_btn = new GameLobbySettingBtn(); // 大厅的设置按钮
|
||||
public GameLobbyHelpBtn lobby_help_btn = new GameLobbyHelpBtn(); // 大厅的帮助按钮
|
||||
public GameLobbyPlayers lobby_players = new GameLobbyPlayers(); // 大厅玩家展示位
|
||||
public GameLobbyPlayerCaptainIcon lobby_player_captain_icon = new GameLobbyPlayerCaptainIcon(); // 大厅玩家展示位上队长标识
|
||||
public GameLobbyPlayerKickoutIcon lobby_player_kickout_icon = new GameLobbyPlayerKickoutIcon(); // 大厅玩家展示位上踢人标识
|
||||
public GameLobbyRule lobby_rule = new GameLobbyRule(); // 大厅的玩法规则描述文字
|
||||
public GameLobbyGameSetting lobby_game_setting = new GameLobbyGameSetting(); // 玩法设置
|
||||
public GameJoinBtn join_btn = new GameJoinBtn(); // 加入按钮
|
||||
public GameCancelJoinBtn cancel_join_btn = new GameCancelJoinBtn(); // 取消加入按钮
|
||||
public GameReadyBtn ready_btn = new GameReadyBtn(); // 准备按钮
|
||||
public GameCancelReadyBtn cancel_ready_btn = new GameCancelReadyBtn(); // 取消准备按钮
|
||||
public GameStartBtn start_btn = new GameStartBtn(); // 开始按钮
|
||||
public GameShareBtn share_btn = new GameShareBtn(); // 分享
|
||||
public GameSttingBtn game_setting_btn = new GameSttingBtn(); // 游戏场景中的设置按钮
|
||||
public GameHelpBtn game_help_btn = new GameHelpBtn(); // 游戏场景中的帮助按钮
|
||||
public GameSettleCloseBtn game_settle_close_btn = new GameSettleCloseBtn(); // 游戏结算界面中的关闭按钮
|
||||
public GameSettleAgainBtn game_settle_again_btn = new GameSettleAgainBtn(); // 游戏结算界面中的再来一局按钮
|
||||
public GameBg game_bg = new GameBg();// 是否隐藏背景图,包括大厅和战斗
|
||||
public BlockChangeSeat block_change_seat = new BlockChangeSeat(); // 自定义阻止换座位
|
||||
public GameSettingSelectPnl game_setting_select_pnl = new GameSettingSelectPnl(); // 大厅中的玩法选择设置面板
|
||||
public GameManagedImage game_managed_image = new GameManagedImage(); // 游戏中的托管图标
|
||||
public GameTableImage game_table_image = new GameTableImage(); // 游戏中牌桌背景图 (注:只对某些带牌桌类游戏有作用)
|
||||
public GameCountdownTime game_countdown_time = new GameCountdownTime(); // 游戏中游戏倒计时显示 (注:现在只针对umo生效)
|
||||
public GameSelectedTips game_selected_tips = new GameSelectedTips(); // 游戏中所选择的玩法提示文字 (注:现在只针对ludo生效)
|
||||
public NFTAvatar nft_avatar = new NFTAvatar(); // 控制NFT头像的开关
|
||||
public GameOpening game_opening = new GameOpening(); // 控制开场动画的开关
|
||||
public GameMvp game_mvp = new GameMvp(); // 游戏结算前的mvp动画
|
||||
public UmoIcon umo_icon = new UmoIcon(); // 游戏中动画和头像右上角的UMO图标
|
||||
public Logo logo = new Logo(); // 大厅中的logo
|
||||
public GamePlayers game_players = new GamePlayers(); // 游戏中的游戏位
|
||||
}
|
||||
|
||||
// 结算界面
|
||||
public static class GameSettle implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏结算界面(false: 显示; true: 隐藏,默认为 false)
|
||||
}
|
||||
|
||||
// 界面中的ping值
|
||||
public static class GamePing implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏ping值(false: 显示;true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 界面中的版本信息值
|
||||
public static class GameVersion implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏版本信息(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 大厅中的段位信息
|
||||
public static class GameLevel implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏段位信息(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 大厅的设置按钮
|
||||
public static class GameLobbySettingBtn implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏大厅的设置按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 大厅的帮助按钮
|
||||
public static class GameLobbyHelpBtn implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏大厅的帮助按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 大厅玩家展示位
|
||||
public static class GameLobbyPlayers implements Serializable {
|
||||
public boolean custom = false; // 大厅玩家展示位头像点击加入(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false)
|
||||
public boolean hide = false; // 是否隐藏大厅玩家展示位(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 大厅玩家展示位上队长标识
|
||||
public static class GameLobbyPlayerCaptainIcon implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏大厅玩家展示位上队长标识(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 大厅玩家展示位上踢人标识
|
||||
public static class GameLobbyPlayerKickoutIcon implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏大厅玩家展示位上踢人标识(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 大厅的玩法规则描述文字
|
||||
public static class GameLobbyRule implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏大厅的玩法规则描述文字(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 玩法设置
|
||||
public static class GameLobbyGameSetting implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏玩法设置(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 加入按钮
|
||||
public static class GameJoinBtn implements Serializable {
|
||||
public boolean custom = false; // 加入按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false)
|
||||
public boolean hide = false; // 是否隐藏加入按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 取消加入按钮
|
||||
public static class GameCancelJoinBtn implements Serializable {
|
||||
public boolean custom = false; // 取消加入按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false)
|
||||
public boolean hide = false; // 是否隐藏取消加入按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 准备按钮
|
||||
public static class GameReadyBtn implements Serializable {
|
||||
public boolean custom = false; // 准备按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false)
|
||||
public boolean hide = false; // 是否隐藏准备按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 取消准备按钮
|
||||
public static class GameCancelReadyBtn implements Serializable {
|
||||
public boolean custom = false; // 取消准备按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false)
|
||||
public boolean hide = false; // 是否隐藏取消准备按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 开始游戏按钮
|
||||
public static class GameStartBtn implements Serializable {
|
||||
public boolean custom = false; // 开始游戏按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false)
|
||||
public boolean hide = false; // 是否隐藏开始游戏按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 分享按钮
|
||||
public static class GameShareBtn implements Serializable {
|
||||
public boolean custom = false; // 分享按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false)
|
||||
public boolean hide = true; // 是否隐藏分享按钮(false: 显示; true: 隐藏,默认为true)
|
||||
}
|
||||
|
||||
// 游戏场景中的设置按钮
|
||||
public static class GameSttingBtn implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏游戏场景中的设置按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 游戏场景中的帮助按钮
|
||||
public static class GameHelpBtn implements Serializable {
|
||||
public boolean hide = false; // 是否隐藏游戏场景中的帮助按钮(false: 显示; true: 隐藏,默认为false)
|
||||
}
|
||||
|
||||
// 游戏结算界面中的关闭按钮
|
||||
public static class GameSettleCloseBtn implements Serializable {
|
||||
public boolean custom = false; // 游戏结算界面中的关闭按钮(false: 关闭结算界面返回大厅; true: 游戏通知按钮点击事件,并关闭结算界面返回大厅;默认为false)
|
||||
}
|
||||
|
||||
// 游戏结算界面中的再来一局按钮
|
||||
public static class GameSettleAgainBtn implements Serializable {
|
||||
// 游戏结算界面中的再来一局按钮
|
||||
// (false: 关闭结算界面返回大厅并将玩家设置为准备状态; true: 游戏通知按钮点击事件,并关闭结算界面返回大厅(不将玩家设置为准备状态);默认为false)
|
||||
public boolean custom = false;
|
||||
|
||||
// 是否隐藏结算界面中的『再来一局』按钮(false: 显示; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 是否隐藏背景图,包括大厅和战斗
|
||||
// !!!这里只隐藏加载完成后的背景图,加载中背景图如需隐藏则调用:{SudMGP.getCfg().setShowLoadingGameBg(false); }
|
||||
public static class GameBg implements Serializable {
|
||||
//(false: 显示; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 自定义阻止换座位
|
||||
public static class BlockChangeSeat implements Serializable {
|
||||
//(false: 可以换座位; true: 不可以换座位;默认为false)
|
||||
public boolean custom = false;
|
||||
}
|
||||
|
||||
// 大厅中的玩法选择设置面板
|
||||
public static class GameSettingSelectPnl implements Serializable {
|
||||
// 是否隐藏大厅中的玩法选择设置面板(false: 显示; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 游戏中的托管图标
|
||||
public static class GameManagedImage implements Serializable {
|
||||
// 是否隐藏游戏中的托管图标(false: 显示; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 游戏中牌桌背景图 (注:只对某些带牌桌类游戏有作用)
|
||||
public static class GameTableImage implements Serializable {
|
||||
// 是否隐藏游戏牌桌背景图(false: 显示; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 游戏中游戏倒计时显示 (注:现在只针对umo生效)
|
||||
public static class GameCountdownTime implements Serializable {
|
||||
// 是否隐藏游戏中游戏倒计时显示(false: 显示; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 游戏中所选择的玩法提示文字 (注:现在只针对ludo生效)
|
||||
public static class GameSelectedTips implements Serializable {
|
||||
// 是否隐藏游戏中所选择的玩法提示文字显示(false: 显示; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 控制NFT头像的开关
|
||||
public static class NFTAvatar implements Serializable {
|
||||
// true隐藏 false显示
|
||||
public boolean hide = true;
|
||||
}
|
||||
|
||||
// 控制开场动画的开关
|
||||
public static class GameOpening implements Serializable {
|
||||
// true隐藏 false显示
|
||||
public boolean hide = true;
|
||||
}
|
||||
|
||||
// 游戏结算前的mvp动画
|
||||
public static class GameMvp implements Serializable {
|
||||
// true隐藏 false显示
|
||||
public boolean hide = true;
|
||||
}
|
||||
|
||||
// 游戏中动画和头像右上角的UMO图标
|
||||
public static class UmoIcon implements Serializable {
|
||||
// 是否隐藏游戏中动画和头像右上角的UMO图标并改为UNO(false: 不隐藏,依然显示UMO; true: 隐藏,改为显示UNO,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 大厅中的logo
|
||||
public static class Logo implements Serializable {
|
||||
// 是否隐藏大厅中的logo(false: 不隐藏; true: 隐藏,默认为false)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
// 游戏中的游戏位
|
||||
public static class GamePlayers implements Serializable {
|
||||
// 是否隐藏游戏中的游戏位(false: 不隐藏; true: 隐藏,默认为false,暂时只支持你画我猜)
|
||||
public boolean hide = false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright © Sud.Tech
|
||||
* https://sud.tech
|
||||
*/
|
||||
|
||||
package com.yunbao.common.sud.model;
|
||||
|
||||
/**
|
||||
* 游戏视图
|
||||
* 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG/onGetGameViewInfo.html
|
||||
*/
|
||||
public class GameViewInfoModel {
|
||||
// 返回码
|
||||
public int ret_code;
|
||||
|
||||
// 返回消息
|
||||
public String ret_msg;
|
||||
|
||||
// 游戏View的大小
|
||||
public GameViewSizeModel view_size = new GameViewSizeModel();
|
||||
|
||||
// 游戏安全操作区域
|
||||
public GameViewRectModel view_game_rect = new GameViewRectModel();
|
||||
|
||||
public static class GameViewSizeModel {
|
||||
// 游戏View的宽 (单位像素)
|
||||
public int width;
|
||||
|
||||
// 游戏View的高 (单位像素)
|
||||
public int height;
|
||||
}
|
||||
|
||||
public static class GameViewRectModel {
|
||||
// 相对于view_size左边框偏移(单位像素)
|
||||
public int left;
|
||||
// 相对于view_size上边框偏移(单位像素)
|
||||
public int top;
|
||||
// 相对于view_size右边框偏移(单位像素)
|
||||
public int right;
|
||||
// 相对于view_size下边框偏移(单位像素)
|
||||
public int bottom;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright © Sud.Tech
|
||||
* https://sud.tech
|
||||
*/
|
||||
|
||||
package com.yunbao.common.sud.state;
|
||||
|
||||
/**
|
||||
* mg2app,状态响应
|
||||
*/
|
||||
public class MGStateResponse {
|
||||
|
||||
// 返回码,成功
|
||||
public static final int SUCCESS = 0;
|
||||
|
||||
public int ret_code; // 返回码
|
||||
public String ret_msg; // 返回消息
|
||||
}
|
1001
common/src/main/java/com/yunbao/common/sud/state/SudMGPAPPState.java
Normal file
1001
common/src/main/java/com/yunbao/common/sud/state/SudMGPAPPState.java
Normal file
File diff suppressed because it is too large
Load Diff
1509
common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java
Normal file
1509
common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright © Sud.Tech
|
||||
* https://sud.tech
|
||||
*/
|
||||
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import com.yunbao.common.sud.state.MGStateResponse;
|
||||
|
||||
import tech.sud.mgp.core.ISudFSMStateHandle;
|
||||
|
||||
public class ISudFSMStateHandleUtils {
|
||||
|
||||
/**
|
||||
* 回调游戏,成功
|
||||
*
|
||||
* @param handle
|
||||
*/
|
||||
public static void handleSuccess(ISudFSMStateHandle handle) {
|
||||
MGStateResponse response = new MGStateResponse();
|
||||
response.ret_code = MGStateResponse.SUCCESS;
|
||||
response.ret_msg = "success";
|
||||
handle.success(SudJsonUtils.toJson(response));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
/**
|
||||
* json解析工具
|
||||
*/
|
||||
public class SudJsonUtils {
|
||||
|
||||
/**
|
||||
* 解析json
|
||||
*
|
||||
* @return 如果解析出错,则返回空对象
|
||||
*/
|
||||
public static <T> T fromJson(final String json, final Class<T> type) {
|
||||
try {
|
||||
return getGson().fromJson(json, type);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象解析成json
|
||||
*
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
public static String toJson(final Object object) {
|
||||
return getGson().toJson(object);
|
||||
}
|
||||
|
||||
public static Gson getGson() {
|
||||
return InnerClass.gson;
|
||||
}
|
||||
|
||||
public static class InnerClass {
|
||||
public static Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
}
|
||||
|
||||
}
|
@ -9,9 +9,9 @@ ext {
|
||||
]
|
||||
manifestPlaceholders = [
|
||||
//正式、
|
||||
// serverHost : "https://napi.yaoulive.com",
|
||||
serverHost : "https://napi.yaoulive.com",
|
||||
// 测试
|
||||
serverHost : " https://ceshi.yaoulive.com",
|
||||
// serverHost : " https://ceshi.yaoulive.com",
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user