|
|
@@ -86,6 +86,14 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //游戏关卡
|
|
|
+ LiveEventBusUtil.observer<String>(this, RxBusCodes.SETLEVEL) {
|
|
|
+ binding.tvGameLevel.post {
|
|
|
+ if (TextUtils.isEmpty(it).not()) {
|
|
|
+ binding.tvGameLevel.text = it
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//游戏进度
|
|
|
LiveEventBusUtil.observer<String>(this, RxBusCodes.SAVEDATA) {
|
|
|
binding.tvScore.post {
|
|
|
@@ -119,11 +127,7 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
finish()
|
|
|
}
|
|
|
gameResultDialog?.onGameDialogClickListener = {
|
|
|
- if (TextUtils.equals("0", it)) {
|
|
|
- it.toast()
|
|
|
- } else {
|
|
|
- it.toast()
|
|
|
- }
|
|
|
+ loadJs(it)
|
|
|
}
|
|
|
gameResultDialog?.show(supportFragmentManager, "gameResultDialog")
|
|
|
}
|
|
|
@@ -227,4 +231,23 @@ class PlayGameActivity : BaseMVVMActivity<ActivityPlayGameBinding, PlayGameViewM
|
|
|
binding.webView.removeAllViews() // 移除webview上子view
|
|
|
binding.webView.destroy() // 销毁WebView自身。
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * webview调用游戏中方法
|
|
|
+ */
|
|
|
+ private fun loadJs(it: String) {
|
|
|
+ if (TextUtils.equals("0", it)) {
|
|
|
+ binding.webView.evaluateJavascript(
|
|
|
+ "javascript:NextLevel()"
|
|
|
+ ) {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ binding.webView.evaluateJavascript(
|
|
|
+ "javascript:RestartGame()"
|
|
|
+ ) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|