|
|
@@ -120,56 +120,9 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
*/
|
|
|
private fun saveData(gameDataBean: GameDataBean, isPass: String) {
|
|
|
viewModel.saveGameRecord(gameCode, playClass, gameDataBean, fail = {
|
|
|
- it.toast()
|
|
|
+ parsingData(gameDataBean, isPass)
|
|
|
}, success = {
|
|
|
- runOnUiThread {
|
|
|
- if (TextUtils.equals("2", isPass)) {
|
|
|
- RxBus.get().send(RxBusCodes.QUITGAME)
|
|
|
- finish()
|
|
|
- } else if (TextUtils.equals("3", isPass)) {
|
|
|
- //游戏通关
|
|
|
- ARouter.getInstance().build(RouterUrlCommon.gameSettlement)
|
|
|
- .withString("gameCode", gameCode)
|
|
|
- .withString("playClass", playClass)
|
|
|
- .withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
- .navigation(mContext)
|
|
|
- } else {
|
|
|
- val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
|
|
|
- gameTotalScore = score.toString()
|
|
|
- if (TextUtils.equals("A", playClass)) {
|
|
|
- val completionTrainingDialog = CompletionTrainingDialog()
|
|
|
- completionTrainingDialog.setData(
|
|
|
- gameTotalScore,
|
|
|
- gameDataBean.curLevelScore
|
|
|
- )
|
|
|
- completionTrainingDialog.onDialogClickListener = {
|
|
|
- finish()
|
|
|
- LiveEventBusUtil.send(RxBusCodes.GAMEOVERTIME, "")
|
|
|
- }
|
|
|
- completionTrainingDialog.show(
|
|
|
- supportFragmentManager,
|
|
|
- "completionTrainingDialog"
|
|
|
- )
|
|
|
- } else {
|
|
|
- //游戏成功/失败
|
|
|
- gameResultDialog = GameResultDialog()
|
|
|
- gameResultDialog?.setData(
|
|
|
- gameDataBean.curLevel,
|
|
|
- gameTotalScore,
|
|
|
- gameDataBean.curLevelScore,
|
|
|
- gameDataBean.isPass
|
|
|
- )
|
|
|
- gameResultDialog?.onBackHomeDialogClickListener = {
|
|
|
- finish()
|
|
|
- LiveEventBusUtil.send(RxBusCodes.GAMEOVERTIME, "")
|
|
|
- }
|
|
|
- gameResultDialog?.onGameDialogClickListener = {
|
|
|
- loadJs(it)
|
|
|
- }
|
|
|
- gameResultDialog?.show(supportFragmentManager, "gameResultDialog")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ parsingData(gameDataBean, isPass)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -380,7 +333,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
LiveEventBusUtil.observer<String>(this, RxBusCodes.SAVEDATA) {
|
|
|
binding.tvScore.post {
|
|
|
if (TextUtils.isEmpty(it).not()) {
|
|
|
- Log.e("wpp", "-----------"+it)
|
|
|
+ Log.e("wpp", "-----------" + it)
|
|
|
val gameDataBean = GsonUtil.GsonToBean(it, GameDataBean::class.java)
|
|
|
if (gameDataBean != null) {
|
|
|
val isPass = gameDataBean.isPass
|
|
|
@@ -483,4 +436,60 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 游戏保存接口
|
|
|
+ */
|
|
|
+ private fun parsingData(gameDataBean: GameDataBean, isPass: String) {
|
|
|
+ runOnUiThread {
|
|
|
+ runOnUiThread {
|
|
|
+ if (TextUtils.equals("2", isPass)) {
|
|
|
+ RxBus.get().send(RxBusCodes.QUITGAME)
|
|
|
+ finish()
|
|
|
+ } else if (TextUtils.equals("3", isPass)) {
|
|
|
+ //游戏通关
|
|
|
+ ARouter.getInstance().build(RouterUrlCommon.gameSettlement)
|
|
|
+ .withString("gameCode", gameCode)
|
|
|
+ .withString("playClass", playClass)
|
|
|
+ .withTransition(R.anim.leftin, R.anim.leftout)
|
|
|
+ .navigation(mContext)
|
|
|
+ } else {
|
|
|
+ val score: Int = gameTotalScore.toInt() + gameDataBean.curLevelScore.toInt()
|
|
|
+ gameTotalScore = score.toString()
|
|
|
+ if (TextUtils.equals("A", playClass)) {
|
|
|
+ val completionTrainingDialog = CompletionTrainingDialog()
|
|
|
+ completionTrainingDialog.setData(
|
|
|
+ gameTotalScore,
|
|
|
+ gameDataBean.curLevelScore
|
|
|
+ )
|
|
|
+ completionTrainingDialog.onDialogClickListener = {
|
|
|
+ finish()
|
|
|
+ LiveEventBusUtil.send(RxBusCodes.GAMEOVERTIME, "")
|
|
|
+ }
|
|
|
+ completionTrainingDialog.show(
|
|
|
+ supportFragmentManager,
|
|
|
+ "completionTrainingDialog"
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ //游戏成功/失败
|
|
|
+ gameResultDialog = GameResultDialog()
|
|
|
+ gameResultDialog?.setData(
|
|
|
+ gameDataBean.curLevel,
|
|
|
+ gameTotalScore,
|
|
|
+ gameDataBean.curLevelScore,
|
|
|
+ gameDataBean.isPass
|
|
|
+ )
|
|
|
+ gameResultDialog?.onBackHomeDialogClickListener = {
|
|
|
+ finish()
|
|
|
+ LiveEventBusUtil.send(RxBusCodes.GAMEOVERTIME, "")
|
|
|
+ }
|
|
|
+ gameResultDialog?.onGameDialogClickListener = {
|
|
|
+ loadJs(it)
|
|
|
+ }
|
|
|
+ gameResultDialog?.show(supportFragmentManager, "gameResultDialog")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|