同步游戏状态与麦位状态

This commit is contained in:
huangjian
2021-12-07 18:40:38 +08:00
parent 8d1125cc14
commit 83e961b4ec
17 changed files with 479 additions and 99 deletions

View File

@@ -5,11 +5,14 @@ import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.yizhuan.erban.R import com.yizhuan.erban.R
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo import com.yizhuan.xchat_android_core.bean.RoomQueueInfo
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
/** /**
@@ -35,16 +38,40 @@ class GameMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) {
) )
} }
override fun microType() = MICRO_TYPE_DATING override fun microType() = MICRO_TYPE_DATING
inner class GameMicroViewHolder constructor(itemView: View) : inner class GameMicroViewHolder constructor(itemView: View) :
GiftValueViewHolder(itemView) { GiftValueViewHolder(itemView) {
private val tvGameStatus: TextView = itemView.findViewById(R.id.tv_game_status)
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
public override fun bind(info: RoomQueueInfo, position: Int) { public override fun bind(info: RoomQueueInfo, position: Int) {
super.bind(info, position) super.bind(info, position)
info.mChatRoomMember?.let {
if (it.gameStatus == 0 && !AvRoomDataManager.get().isRoomOwner) {
tvGameStatus.isVisible = false
} else {
tvGameStatus.isVisible = true
val bgRes = when {
AvRoomDataManager.get().isRoomOwner -> {
tvGameStatus.text = "房主"
R.drawable.bg_game_status_owner
}
it.gameStatus == 2 -> {
tvGameStatus.text = "已准备"
R.drawable.bg_game_status_ready
}
else -> {
tvGameStatus.text = "未准备"
R.drawable.bg_game_status_not_ready
}
}
tvGameStatus.setBackgroundResource(bgRes)
}
} ?: run {
tvGameStatus.isVisible = false
}
} }
@@ -54,6 +81,4 @@ class GameMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) {
return 6 return 6
} }
} }

View File

@@ -44,6 +44,7 @@ import com.yizhuan.erban.avroom.dialog.DatingVipRuleDialog
import com.yizhuan.erban.avroom.dialog.RoomOperationDialog import com.yizhuan.erban.avroom.dialog.RoomOperationDialog
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
import com.yizhuan.erban.avroom.game.GameDelegate import com.yizhuan.erban.avroom.game.GameDelegate
import com.yizhuan.erban.avroom.game.OnGameStatusChangeListener
import com.yizhuan.erban.avroom.presenter.GameRoomPresenter import com.yizhuan.erban.avroom.presenter.GameRoomPresenter
import com.yizhuan.erban.avroom.redpackage.RedPackageSendDialog import com.yizhuan.erban.avroom.redpackage.RedPackageSendDialog
import com.yizhuan.erban.avroom.view.IGameRoomView import com.yizhuan.erban.avroom.view.IGameRoomView
@@ -129,7 +130,8 @@ import java.util.*
*/ */
@CreatePresenter(GameRoomPresenter::class) @CreatePresenter(GameRoomPresenter::class)
class GameRoomFragment() : BaseMvpFragment<IGameRoomView?, GameRoomPresenter?>(), class GameRoomFragment() : BaseMvpFragment<IGameRoomView?, GameRoomPresenter?>(),
View.OnClickListener, OnGiftDialogBtnClickListener, IGameRoomView, OnMicroItemClickListener { View.OnClickListener, OnGiftDialogBtnClickListener, IGameRoomView, OnMicroItemClickListener,
OnGameStatusChangeListener {
private var myUid: Long = 0 private var myUid: Long = 0
private lateinit var messageView: MessageView private lateinit var messageView: MessageView
private lateinit var bottomView: BottomView private lateinit var bottomView: BottomView
@@ -201,6 +203,7 @@ class GameRoomFragment() : BaseMvpFragment<IGameRoomView?, GameRoomPresenter?>()
} }
gameDelegate = GameDelegate(requireActivity(), gameBinding.flGameContainer) gameDelegate = GameDelegate(requireActivity(), gameBinding.flGameContainer)
gameDelegate.setOnGameStatusChangeListener(this)
} }
override fun onSetListener() { override fun onSetListener() {
@@ -370,11 +373,13 @@ class GameRoomFragment() : BaseMvpFragment<IGameRoomView?, GameRoomPresenter?>()
) )
} }
RoomEvent.DOWN_MIC -> { RoomEvent.DOWN_MIC -> {
addOrRemoveMatchPool() if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
//自己的消息
gameDelegate.notifySelfInState(false)
}
onDownMicro(roomEvent.micPosition) onDownMicro(roomEvent.micPosition)
} }
RoomEvent.UP_MIC -> { RoomEvent.UP_MIC -> {
addOrRemoveMatchPool()
onUpMicro(roomEvent.micPosition) onUpMicro(roomEvent.micPosition)
} }
RoomEvent.INVITE_UP_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) { RoomEvent.INVITE_UP_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
@@ -814,7 +819,7 @@ class GameRoomFragment() : BaseMvpFragment<IGameRoomView?, GameRoomPresenter?>()
} }
} }
fun onDownMicro(micPosition: Int) { private fun onDownMicro(micPosition: Int) {
showBottomViewForDifRole() showBottomViewForDifRole()
updateMicBtn() updateMicBtn()
gameBinding.microView.removeDragonBar(micPosition) gameBinding.microView.removeDragonBar(micPosition)
@@ -823,23 +828,11 @@ class GameRoomFragment() : BaseMvpFragment<IGameRoomView?, GameRoomPresenter?>()
GiftValueMrg.get().updateRoomGiftValue(false) GiftValueMrg.get().updateRoomGiftValue(false)
} }
fun onQueueMicStateChange(micPosition: Int, micPosState: Int) { private fun onQueueMicStateChange(micPosition: Int, micPosState: Int) {
microView.adapter.notifyDataSetChanged() microView.adapter.notifyDataSetChanged()
onMicStateChanged() onMicStateChanged()
} }
private fun addOrRemoveMatchPool() {
if (AvRoomDataManager.get().isCpRoom && AvRoomDataManager.get().isRoomOwner) {
if (AvRoomDataManager.get().findFreePosition() > 0) {
AvRoomModel.get().removeIsomerism().subscribe()
} else if ((TextUtils.isEmpty(AvRoomDataManager.get().mCurrentRoomInfo?.limitType)
&& TextUtils.isEmpty(AvRoomDataManager.get().mCurrentRoomInfo?.getRoomPwd()))
) {
AvRoomModel.get().addIsomerism().subscribe()
}
}
}
override fun kickDownMicroPhoneSuccess() { override fun kickDownMicroPhoneSuccess() {
updateMicBtn() updateMicBtn()
toast(R.string.kick_mic) toast(R.string.kick_mic)
@@ -1338,4 +1331,12 @@ class GameRoomFragment() : BaseMvpFragment<IGameRoomView?, GameRoomPresenter?>()
return roomFragment return roomFragment
} }
} }
override fun onGameStart() {
gameBinding.tvShowMiniMic.callOnClick()
}
override fun onGameEnd() {
gameBinding.ivShowMic.callOnClick()
}
} }

View File

@@ -0,0 +1,114 @@
package com.yizhuan.erban.avroom.game
/***
*
*
*/
data class GameCfg(
val gameMode: Int = 0,
val ui: Ui = Ui()
) {
data class Ui(
val cancel_join_btn: CancelJoinBtn = CancelJoinBtn(),
val cancel_ready_btn: CancelReadyBtn = CancelReadyBtn(),
val gameSettle: GameSettle = GameSettle(),
val game_help_btn: GameHelpBtn = GameHelpBtn(),
val game_setting_btn: GameSettingBtn = GameSettingBtn(),
val join_btn: JoinBtn = JoinBtn(),
val level: Level = Level(),
val lobby_game_setting: LobbyGameSetting = LobbyGameSetting(),
val lobby_help_btn: LobbyHelpBtn = LobbyHelpBtn(),
val lobby_player_captain_icon: LobbyPlayerCaptainIcon = LobbyPlayerCaptainIcon(),
val lobby_player_kickout_icon: LobbyPlayerKickoutIcon = LobbyPlayerKickoutIcon(),
val lobby_players: LobbyPlayers = LobbyPlayers(),
val lobby_rule: LobbyRule = LobbyRule(),
val lobby_setting_btn: LobbySettingBtn = LobbySettingBtn(),
val ping: Ping = Ping(),
val ready_btn: ReadyBtn = ReadyBtn(),
val share_btn: ShareBtn = ShareBtn(),
val start_btn: StartBtn = StartBtn(),
val version: Version = Version()
) {
data class CancelJoinBtn(
val custom: Boolean = false,
val hide: Boolean = false
)
data class CancelReadyBtn(
val custom: Boolean = false,
val hide: Boolean = false
)
data class GameSettle(
val hide: Boolean = false
)
data class GameHelpBtn(
val hide: Boolean = false
)
data class GameSettingBtn(
val hide: Boolean = false
)
data class JoinBtn(
val custom: Boolean = true,
val hide: Boolean = false
)
data class Level(
val hide: Boolean = true
)
data class LobbyGameSetting(
val hide: Boolean = false
)
data class LobbyHelpBtn(
val hide: Boolean = false
)
data class LobbyPlayerCaptainIcon(
val hide: Boolean = true
)
data class LobbyPlayerKickoutIcon(
val hide: Boolean = true
)
data class LobbyPlayers(
val hide: Boolean = false
)
data class LobbyRule(
val hide: Boolean = false
)
data class LobbySettingBtn(
val hide: Boolean = false
)
data class Ping(
val hide: Boolean = false
)
data class ReadyBtn(
val custom: Boolean = false,
val hide: Boolean = false
)
data class ShareBtn(
val custom: Boolean = false,
val hide: Boolean = true
)
data class StartBtn(
val custom: Boolean = false,
val hide: Boolean = false
)
data class Version(
val hide: Boolean = false
)
}
}

View File

@@ -10,16 +10,20 @@ import android.util.Log
import android.view.View import android.view.View
import android.view.ViewTreeObserver.OnGlobalLayoutListener import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.widget.FrameLayout import android.widget.FrameLayout
import com.google.gson.Gson
import com.yizhuan.xchat_android_core.auth.AuthModel import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.room.game.GameModel import com.yizhuan.xchat_android_core.room.game.GameModel
import com.yizhuan.xchat_android_core.room.model.HomePartyModel
import com.yizhuan.xchat_android_core.user.UserModel
import com.yizhuan.xchat_android_core.utils.LogUtils import com.yizhuan.xchat_android_core.utils.LogUtils
import com.yizhuan.xchat_android_core.utils.net.RxHelper import com.yizhuan.xchat_android_core.utils.net.RxHelper
import com.yizhuan.xchat_android_library.net.rxnet.callback.CallBack
import com.yizhuan.xchat_android_library.utils.SingleToastUtil import com.yizhuan.xchat_android_library.utils.SingleToastUtil
import okhttp3.* import okhttp3.*
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import tech.sud.mgp.core.* import tech.sud.mgp.core.*
import java.io.IOException
import java.util.* import java.util.*
class GameDelegate(val activity: Activity, val container: FrameLayout) { class GameDelegate(val activity: Activity, val container: FrameLayout) {
@@ -33,22 +37,24 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
const val MG_ID_GO_BANG = 1461297734886621238L //游戏ID:五子棋 const val MG_ID_GO_BANG = 1461297734886621238L //游戏ID:五子棋
const val STATUS_NOT_JOIN = 0
const val STATUS_NOT_READY = 1
const val STATUS_READY = 2
} }
private val TAG = "GameActivity" private val TAG = "GameActivity"
private var APP_CODE = "" private var APP_CODE = ""
private val mRoomID = "9009" //房间ID同一个房间ID可对战 private val mRoomID = AvRoomDataManager.get().roomUid.toString()
private val mLanguage = "zh-CN" //语言 private val mLanguage = "zh-CN" //语言
private val mCurrentSeat = 1 //当前用户需要上几号麦位
//调用游戏SDK的接口,成功加载游戏后可用: //调用游戏SDK的接口,成功加载游戏后可用:
private var iSudFSTAPP: ISudFSTAPP? = null private var iSudFSTAPP: ISudFSTAPP? = null
private val gson = Gson()
//小游戏ID //小游戏ID
private var mMGID = MG_ID_BUMPER_CAR private var mMGID = MG_ID_BUMPER_CAR
@@ -57,6 +63,14 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
private var mKeyWord: String? = null private var mKeyWord: String? = null
private val mUid = AuthModel.get().currentUid.toString() private val mUid = AuthModel.get().currentUid.toString()
private val homePartyModel = HomePartyModel()
private var onGameStatusChangeListener: OnGameStatusChangeListener? = null
fun setOnGameStatusChangeListener(onGameStatusChangeListener: OnGameStatusChangeListener) {
this.onGameStatusChangeListener = onGameStatusChangeListener
}
private val loginCallback: AppLoginListener = private val loginCallback: AppLoginListener =
object : AppLoginListener { object : AppLoginListener {
override fun onLoginFailure(err: String?) { override fun onLoginFailure(err: String?) {
@@ -152,7 +166,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
container.addView(gameView) container.addView(gameView)
} }
private fun showToast(content: String) { private fun showToast(content: String?) {
SingleToastUtil.showToast(content) SingleToastUtil.showToast(content)
} }
@@ -271,8 +285,8 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
}) })
} }
override fun onGetGameCfg(p0: ISudFSMStateHandle?, p1: String?) { override fun onGetGameCfg(handle: ISudFSMStateHandle?, p1: String?) {
handle?.success(gson.toJson(GameCfg()))
} }
/** /**
@@ -300,9 +314,9 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
//游戏安全操作区域 //游戏安全操作区域
val viewGameRect = JSONObject() val viewGameRect = JSONObject()
viewGameRect.put("left", 0) viewGameRect.put("left", 0)
viewGameRect.put("top", 600) viewGameRect.put("top", 500)
viewGameRect.put("right", 0) viewGameRect.put("right", 0)
viewGameRect.put("bottom", 600) viewGameRect.put("bottom", 400)
jsonObject.put("view_game_rect", viewGameRect) jsonObject.put("view_game_rect", viewGameRect)
//通知游戏 //通知游戏
@@ -346,6 +360,12 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
} }
} }
} }
SudMGPMGState.APP_COMMON_SELF_CLICK_JOIN_BTN -> {
updateMyMicQueue(STATUS_NOT_READY, true)
}
SudMGPMGState.APP_COMMON_SELF_CLICK_START_BTN -> {
notifySelfPlayingState(true)
}
} }
} }
@@ -373,6 +393,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
} }
private fun handlePlayerIn(userId: String, dataJson: String) { private fun handlePlayerIn(userId: String, dataJson: String) {
if (userId != mUid) return
try { try {
val jsonObject = JSONObject(dataJson) val jsonObject = JSONObject(dataJson)
val retCode = jsonObject.getInt("retCode") val retCode = jsonObject.getInt("retCode")
@@ -390,17 +411,17 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
if (jsonObject.has("teamId")) { if (jsonObject.has("teamId")) {
teamId = jsonObject.getInt("teamId") teamId = jsonObject.getInt("teamId")
} }
showToast("加入游戏分组:$teamId") //showToast("加入游戏分组:$teamId")
} else { // 未加入 } else { // 未加入
var reason = 0 var reason = 0
if (jsonObject.has("reason")) { if (jsonObject.has("reason")) {
reason = jsonObject.getInt("reason") reason = jsonObject.getInt("reason")
} }
if (reason == 0) { if (reason == 0) {
showToast("主动退出游戏") updateMyMicQueue(STATUS_NOT_JOIN)
} else if (reason == 1) { } else if (reason == 1) {
val userid = jsonObject.getString("kickUID") updateMyMicQueue(STATUS_NOT_JOIN)
showToast(userid + "将我踢出游戏") showToast("踢出游戏")
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
@@ -408,7 +429,41 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
} }
} }
private fun updateMyMicQueue(gameStatus: Int, isJoin: Boolean = false) {
UserModel.get().cacheLoginUserInfo?.gameStatus = gameStatus
val position = AvRoomDataManager.get().getMicPosition(mUid)
if (position != AvRoomDataManager.POSITON_NOT_ON_MIC) {
if (isJoin) notifySelfInState(true)
homePartyModel.updateMyMicQueue(
position,
AvRoomDataManager.get().roomId.toString(),
UserModel.get().cacheLoginUserInfo
).subscribe()
} else if (isJoin) {
val upPosition = AvRoomDataManager.get().findFreePosition()
if (upPosition == Int.MIN_VALUE) {
showToast("当前游戏人数已满!")
} else {
UserModel.get().cacheLoginUserInfo?.gameStatus = 1
homePartyModel.upMicroPhone(upPosition,
mUid,
AvRoomDataManager.get().roomId.toString(),
false, object : CallBack<String> {
override fun onSuccess(data: String?) {
notifySelfInState(true)
}
override fun onFail(code: Int, error: String?) {
showToast(error)
}
})
}
}
}
private fun handlePlayerReady(userId: String, dataJson: String) { private fun handlePlayerReady(userId: String, dataJson: String) {
if (userId != mUid) return
try { try {
val jsonObject = JSONObject(dataJson) val jsonObject = JSONObject(dataJson)
val retCode = jsonObject.getInt("retCode") val retCode = jsonObject.getInt("retCode")
@@ -417,11 +472,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
showToast("mg_common_player_ready操作失败 错误码:$retCode") showToast("mg_common_player_ready操作失败 错误码:$retCode")
return return
} }
if (isReady) { // 已准备 updateMyMicQueue(if (isReady) STATUS_READY else STATUS_NOT_READY)
} else { // 未准备
}
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
@@ -443,38 +494,156 @@ class GameDelegate(val activity: Activity, val container: FrameLayout) {
} }
private fun handlePlayerPlaying(userId: String, dataJson: String) { private fun handlePlayerPlaying(userId: String, dataJson: String) {
if (userId != mUid) return
try { try {
val jsonObject = JSONObject(dataJson) val jsonObject = JSONObject(dataJson)
val retCode = jsonObject.getInt("retCode") val retCode = jsonObject.getInt("retCode")
if (retCode != 0) { if (retCode != 0) {
if (retCode == 100503) { when (retCode) {
100503 -> {
showToast("100503: 有人未准备") showToast("100503: 有人未准备")
} else if (retCode == 100504) { }
100504 -> {
showToast("100504: 开始游戏的人数不足") showToast("100504: 开始游戏的人数不足")
} else { }
else -> {
showToast("mg_common_player_playing 操作失败, 错误码:$retCode") showToast("mg_common_player_playing 操作失败, 错误码:$retCode")
} }
}
return return
} }
val isPlaying = jsonObject.getBoolean("isPlaying") val isPlaying = jsonObject.getBoolean("isPlaying")
if (!isPlaying) { // 未在游戏中 AvRoomDataManager.get().isGamePlaying = isPlaying
if (isPlaying) {
onGameStatusChangeListener?.onGameStart()
} else {
onGameStatusChangeListener?.onGameEnd()
var reason = 0 var reason = 0
if (jsonObject.has("reason")) { if (jsonObject.has("reason")) {
reason = jsonObject.getInt("reason") reason = jsonObject.getInt("reason")
} }
when (reason) {
if (reason == 0) { 0 -> {
showToast("正常结束") showToast("正常结束")
} else if (reason == 1) { }
1 -> {
showToast("提前结束(自己不玩了)") showToast("提前结束(自己不玩了)")
} else if (reason == 2) { }
2 -> {
showToast("无真人可以提前结束(无真人,只有机器人)") showToast("无真人可以提前结束(无真人,只有机器人)")
} else if (reason == 3) { }
3 -> {
showToast("所有人都提前结束") showToast("所有人都提前结束")
} else { }
else -> {
showToast("未在游戏中, reason = $reason") showToast("未在游戏中, reason = $reason")
} }
} }
}
} catch (e: Exception) {
e.printStackTrace()
}
}
fun notifySelfInState(isIn: Boolean) {
try {
if (!isIn) {
notifySelfReadyState(false)
}
//状态名称
val state = SudMGPAPPState.APP_COMMON_SELF_IN
//状态数据
val jsonObject = JSONObject()
jsonObject.put("isIn", isIn) // true 加入游戏false 退出游戏
jsonObject.put("teamId", 1) //哪一队伍(2v2,4v4)
val dataJson = jsonObject.toString()
//调用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfReadyState(isReady: Boolean) {
try {
//状态名称
val state = SudMGPAPPState.APP_COMMON_SELF_READY
//状态数据
val jsonObject = JSONObject()
jsonObject.put("isReady", isReady) // true 准备false 取消准备
val dataJson = jsonObject.toString()
//调用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfPlayingState(isPlaying: Boolean) {
try {
//状态名称
val state = SudMGPAPPState.APP_COMMON_SELF_PLAYING
//状态数据
val jsonObject = JSONObject()
jsonObject.put("isPlaying", isPlaying) // true 开始游戏false 结束游戏
val dataJson = jsonObject.toString()
//调用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfCaptainState(uid: String) {
try {
//状态名称
val state = SudMGPAPPState.APP_COMMON_SELF_CAPTAIN
//状态数据
val jsonObject = JSONObject()
jsonObject.put("curCaptainUID", uid) // 必填指定队长uid
val dataJson = jsonObject.toString()
//调用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfKickState(uid: String) {
try {
//状态名称
val state = SudMGPAPPState.APP_COMMON_SELF_KICK
//状态数据
val jsonObject = JSONObject()
jsonObject.put("kickedUID", uid) // 被踢用户uid
val dataJson = jsonObject.toString()
//调用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfEndState() {
try {
//状态名称
val state = SudMGPAPPState.APP_COMMON_SELF_END
//状态数据
val jsonObject = JSONObject()
val dataJson = jsonObject.toString()
//调用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }

View File

@@ -0,0 +1,13 @@
package com.yizhuan.erban.avroom.game
interface OnGameStatusChangeListener {
/**
* 游戏开始
*/
fun onGameStart()
/**
* 游戏结束
*/
fun onGameEnd()
}

View File

@@ -48,16 +48,6 @@ public class SudMGPAPPState {
*/ */
public static final String APP_COMMON_SELF_END = "app_common_self_end"; public static final String APP_COMMON_SELF_END = "app_common_self_end";
/**
* 房间状态, (depreated 已废弃v1.1.30.xx)
*/
public static final String APP_COMMON_SELF_ROOM = "app_common_self_room";
/**
* 麦位状态, (depreated 已废弃v1.1.30.xx)
*/
public static final String APP_COMMON_SELF_SEAT = "app_common_self_seat";
/** /**
* 麦克风状态 * 麦克风状态
*/ */
@@ -68,15 +58,4 @@ public class SudMGPAPPState {
*/ */
public static final String APP_COMMON_SELF_TEXT_HIT = "app_common_self_text_hit"; public static final String APP_COMMON_SELF_TEXT_HIT = "app_common_self_text_hit";
// endregion 通用状态
// region 碰碰我最强
// endregion 碰碰我最强
// region 飞刀达人
// endregion 飞刀达人
// region 你画我猜
// endregion 你画我猜
} }

View File

@@ -90,4 +90,30 @@ public class SudMGPMGState {
// endregion 你画我猜 // endregion 你画我猜
/**
* 加入游戏按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_JOIN_BTN = "mg_common_self_click_join_btn";
/**
* 取消加入游戏按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_CANCEL_JOIN_BTN = "mg_common_self_click_cancel_join_btn";
/**
* 准备按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_READY_BTN = "mg_common_self_click_ready_btn";
/**
* 取消准备按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_CANCEL_READY_BTN = "mg_common_self_click_cancel_ready_btn";
/**
* 开始游戏按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_START_BTN = "mg_common_self_click_start_btn";
/**
* 分享按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_SHARE_BTN = "mg_common_self_click_share_btn";
} }

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="#ffffffff" />
<solid android:color="#ffffa936" />
<corners android:radius="100dp" />
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="#ffffffff" />
<solid android:color="#ff20aaf5" />
<corners android:radius="100dp" />
</shape>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="#ffffffff" />
<solid android:color="#ff56d41a" />
<corners android:radius="100dp" />
</shape>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#ffffffff" />
<solid android:color="#ffffa936" />
<corners android:radius="8dp" />
</shape>
</item>
<item android:width="40dp" android:height="16dp">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#ffffffff" />
<solid android:color="#ff56d41a" />
<corners android:radius="8dp" />
</shape>
</item>
</selector>

View File

@@ -42,14 +42,6 @@
android:visibility="invisible" android:visibility="invisible"
tools:visibility="gone" /> tools:visibility="gone" />
<View
android:id="@+id/view_gender_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="@dimen/dp_10"
android:background="@drawable/shape_circle_micro_man_bg" />
<com.yizhuan.erban.common.widget.CircleImageView <com.yizhuan.erban.common.widget.CircleImageView
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -85,17 +77,17 @@
tools:visibility="gone" /> tools:visibility="gone" />
<TextView <TextView
android:id="@+id/tv_selected_status" android:id="@+id/tv_game_status"
android:layout_width="37dp" android:layout_width="40dp"
android:layout_height="14dp" android:layout_height="16dp"
android:layout_gravity="bottom|center_horizontal" android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:background="@drawable/selector_dating_select_man_bg" android:background="@drawable/bg_game_status_not_ready"
android:gravity="center" android:gravity="center"
android:includeFontPadding="false" android:includeFontPadding="false"
android:text="未选择" android:text="未准备"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="9sp" android:textSize="10dp"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />
@@ -178,10 +170,10 @@
android:id="@+id/ll_charm_click" android:id="@+id/ll_charm_click"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="@dimen/dp_5" android:paddingTop="@dimen/dp_5"
android:paddingBottom="@dimen/dp_5" android:paddingBottom="@dimen/dp_5"
android:layout_marginEnd="5dp"
app:layout_constraintBottom_toBottomOf="@id/view_center_of_charm" app:layout_constraintBottom_toBottomOf="@id/view_center_of_charm"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/view_center_of_charm"> app:layout_constraintTop_toTopOf="@id/view_center_of_charm">

View File

@@ -182,6 +182,8 @@ public final class AvRoomDataManager {
public final MutableLiveData<RoomPkBean> roomPkLiveData = new MutableLiveData<>(); public final MutableLiveData<RoomPkBean> roomPkLiveData = new MutableLiveData<>();
public boolean isGamePlaying;
private static final class Helper { private static final class Helper {
private static final AvRoomDataManager INSTANCE = new AvRoomDataManager(); private static final AvRoomDataManager INSTANCE = new AvRoomDataManager();

View File

@@ -18,7 +18,7 @@ object GameModel : BaseModel() {
fun getGameCode(): Single<GameCodeInfo> { fun getGameCode(): Single<GameCodeInfo> {
return api.getGameCode(AuthModel.get().currentUid) return api.getGameCode(AuthModel.get().currentUid)
//.compose(RxHelper.handleBeanData()) .compose(RxHelper.handleBeanData())
.compose(RxHelper.handleSchAndExce()) .compose(RxHelper.handleSchAndExce())
} }
@@ -45,7 +45,7 @@ object GameModel : BaseModel() {
@POST("/miniGame/getCode") @POST("/miniGame/getCode")
fun getGameCode( fun getGameCode(
@Field("uid") uid: Long @Field("uid") uid: Long
): Single<GameCodeInfo> ): Single<ServiceResult<GameCodeInfo>>
/** /**
* 首页Banner * 首页Banner

View File

@@ -604,6 +604,7 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
contentJsonObj.put("avatar", userInfo.getAvatar()); contentJsonObj.put("avatar", userInfo.getAvatar());
contentJsonObj.put("gender", userInfo.getGender()); contentJsonObj.put("gender", userInfo.getGender());
contentJsonObj.put("groupType", userInfo.getGroupType()); contentJsonObj.put("groupType", userInfo.getGroupType());
contentJsonObj.put("gameStatus", userInfo.getGameStatus());
HeadWearInfo headWearInfo = userInfo.getUserHeadwear(); HeadWearInfo headWearInfo = userInfo.getUserHeadwear();
if (headWearInfo != null) { if (headWearInfo != null) {
String headWearUrl = headWearInfo.getEffect() != null ? headWearInfo.getEffect() : headWearInfo.getPic(); String headWearUrl = headWearInfo.getEffect() != null ? headWearInfo.getEffect() : headWearInfo.getPic();
@@ -614,6 +615,7 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
if (AvRoomDataManager.get().isDatingVip(userInfo.getUid())) { if (AvRoomDataManager.get().isDatingVip(userInfo.getUid())) {
contentJsonObj.put("vipMic", true); contentJsonObj.put("vipMic", true);
} }
NIMChatRoomSDK.getChatRoomService() NIMChatRoomSDK.getChatRoomService()
.updateQueueEx(roomId, String.valueOf(micPosition), contentJsonObj.toJSONString(), true) .updateQueueEx(roomId, String.valueOf(micPosition), contentJsonObj.toJSONString(), true)
.setCallback(new RequestCallback<Void>() { .setCallback(new RequestCallback<Void>() {

View File

@@ -46,6 +46,13 @@ public class MicMemberInfo {
*/ */
private int groupType; private int groupType;
/**
* 游戏模式使用
* 0 未加入游戏
* 1 加入游戏未准备
* 2 加入游戏已准备
*/
private int gameStatus;
public MicMemberInfo() { public MicMemberInfo() {

View File

@@ -199,6 +199,10 @@ public class UserInfo implements Serializable {
@Setter @Setter
private boolean isFirstCharge; private boolean isFirstCharge;
@Getter
@Setter
private int gameStatus;
public Location getUserExpand() { public Location getUserExpand() {
return userExpand; return userExpand;
} }