精灵夺宝:增加vap特效

This commit is contained in:
huangjian
2023-03-01 14:25:32 +08:00
parent 30c8e77d40
commit 442098c61e
19 changed files with 172 additions and 40 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -13,6 +13,7 @@ import com.mango.core.utils.net.ServerException
import com.mango.core.utils.toast
import com.mango.moshen.base.BaseViewModel
import com.mango.moshen.base.Event
import com.mango.moshen.treasurefairy.view.MyFairyItemView
class FairyViewModel : BaseViewModel() {
@@ -58,6 +59,9 @@ class FairyViewModel : BaseViewModel() {
private val _testResultLiveData = MutableLiveData<Event<FairyInfo>>()
val testResultLiveData: LiveData<Event<FairyInfo>> = _testResultLiveData
private val _testLegendResultLiveData = MutableLiveData<Event<FairyInfo>>()
val testLegendResultLiveData: LiveData<Event<FairyInfo>> = _testLegendResultLiveData
private val _testRecordLiveData = MutableLiveData<ListResult<TestFairyRecordInfo>>()
val testRecordLiveData: LiveData<ListResult<TestFairyRecordInfo>> = _testRecordLiveData
@@ -139,6 +143,10 @@ class FairyViewModel : BaseViewModel() {
)
}
fun cleanDrawForestLiveData() {
_drawForestLiveData.value = null
}
fun getForestInfo() {
safeLaunch(
onError = {
@@ -247,6 +255,8 @@ class FairyViewModel : BaseViewModel() {
fun cleanTestParam() {
_compoundFairyInfosLiveData.value = null
_testLegendResultLiveData.value = null
_testResultLiveData.value = null
val myFairyInfo = _myFairyInfoLiveData.value
myFairyInfo?.lowElves?.forEach {
it.selectedNum = 0
@@ -333,23 +343,38 @@ class FairyViewModel : BaseViewModel() {
}
}
fun testFairy(level: Int) {
fun testFairy(level: Int): Boolean {
val fairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
if (fairyInfos.size() != 3) {
"精灵数量不足".toast()
return
return false
}
safeLaunch {
safeLaunch(
onError = {
if (level == MyFairyItemView.EPIC) {
_testLegendResultLiveData.value = null
} else {
_testResultLiveData.value = null
}
it.message.toast()
},
block = {
val fairyTestParam = FairyTestParam()
fairyInfos.forEach { _, value ->
fairyTestParam.expendList.add(Compound(value.elfId, 1))
}
fairyTestParam.level = level
val result = TreasureFairyModel.testFairy(fairyTestParam)
_testResultLiveData.value = result?.let { Event(it) }
_compoundFairyInfosLiveData.value = null
(if (level == MyFairyItemView.EPIC) {
_testLegendResultLiveData
} else {
_testResultLiveData
}).value = result?.let { Event(it) }
getMyFairyInfo()
}
)
return true
}
fun getTestFairyRecordList(

View File

@@ -20,6 +20,18 @@ class ForestFairyDialog : BaseDialog<TreasureFairyDialogForestBinding>() {
private val viewModel: FairyViewModel by activityViewModels()
private var currentType = 1
private val showResultRunnable = Runnable {
if (canShowResult) {
canShowResult = false
enabledOpenBtn(true)
ForestPrizeDialog.newInstance().show(context)
} else {
resultNotShowed = true
}
}
private var canShowResult = false
private var resultNotShowed = false
companion object {
fun newInstance(): ForestFairyDialog {
val args = Bundle()
@@ -62,18 +74,33 @@ class ForestFairyDialog : BaseDialog<TreasureFairyDialogForestBinding>() {
}
binding.viewBgGrab1.setOnClickListener {
enabledOpenBtn(false)
binding.animView.startPlay(requireContext().assets, "vap/fairy_anim_once.mp4")
binding.animView.postDelayed(showResultRunnable,1900)
viewModel.drawForestFairy(1, currentType)
}
binding.viewBgGrab10.setOnClickListener {
enabledOpenBtn(false)
binding.animView.startPlay(requireContext().assets, "vap/fairy_anim_ten.mp4")
binding.animView.postDelayed(showResultRunnable,1900)
viewModel.drawForestFairy(10, currentType)
}
binding.animView.setOnClickListener {
if (canShowResult) {
binding.animView.removeCallbacks(showResultRunnable)
showResultRunnable.run()
}
}
viewModel.drawForestLiveData.observe(viewLifecycleOwner) {
enabledOpenBtn(true)
it?.getContentIfNotHandled()?.let {
ForestPrizeDialog.newInstance().show(context)
canShowResult = true
if (resultNotShowed) {
showResultRunnable.run()
}
}?:run{
enabledOpenBtn(true)
}
}

View File

@@ -48,10 +48,14 @@ class ForestPrizeDialog : BaseDialog<TreasureFairyDialogForestPrizeBinding>() {
val hasSurprise = prizeInfoList.find { it.propType == 1 } != null
val isFairy =
requireArguments().getBoolean("isFairy", true) || !hasSurprise
if (isFairy) {
viewModel.cleanDrawForestLiveData()
}
binding.tvTitle.text = if (isFairy) "获得精灵" else "意外发现"
if (!isFairy && !isSingle && hasSurprise) {
newInstance(true).show(context)
}
val showPrizeInfoList =
prizeInfoList.filter { if (isFairy) (it.propType != 1) else (it.propType == 1) }
val isShowDateSingle = showPrizeInfoList.size == 1

View File

@@ -49,7 +49,7 @@ class TestFairyResultDialog : BaseDialog<TreasureFairyDialogTestFairyResultBindi
.build()
rvDelegate.setNewData(arrayListOf(prizeInfoList?.peekContent()))
viewModel.cleanTestParam()
}
}

View File

@@ -6,6 +6,7 @@ import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.mango.core.treasurefairy.FairyInfo
import com.mango.moshen.R
import com.mango.moshen.base.BaseViewBindingFragment
import com.mango.moshen.databinding.TreasureFairyFragmentTestFairyBinding
import com.mango.moshen.treasurefairy.FairyViewModel
@@ -33,6 +34,18 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
private lateinit var rvDelegate: RVDelegate<FairyInfo>
private lateinit var testFairyAdapter: TestFairyAdapter
private val showResultRunnable = Runnable {
if (canShowResult) {
canShowResult = false
binding.ivBegin.isEnabled = true
TestFairyResultDialog.newInstance().show(context)
} else {
resultNotShowed = true
}
}
private var canShowResult = false
private var resultNotShowed = false
@SuppressLint("CheckResult")
override fun init() {
val fairyViews = listOf(binding.ivFairy0, binding.ivFairy1, binding.ivFairy2)
@@ -57,7 +70,7 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
rvDelegate.setNewData(fairyInfos)
}
if (fairyType == MyFairyItemView.EPIC){
if (fairyType == MyFairyItemView.EPIC) {
binding.tvTips.text = "点击投入试炼传说精灵"
}
@@ -79,12 +92,45 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
viewModel.oneKeyAdd(testFairyAdapter.data)
}
binding.ivBegin.setOnClickListener {
viewModel.testFairy(fairyType)
if (fairyType == MyFairyItemView.EPIC) {
binding.viewBgAnim.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_anim_legend)
}
viewModel.testResultLiveData.observe(viewLifecycleOwner) {
binding.ivBegin.setOnClickListener {
if (viewModel.testFairy(fairyType)) {
binding.animView.startPlay(
requireContext().assets,
if (fairyType == MyFairyItemView.BASE) {
"vap/test_fairy_anim_epic.mp4"
} else {
"vap/test_fairy_anim_legend.mp4"
}
)
binding.ivBegin.isEnabled = false
canShowResult = false
binding.ivBegin.postDelayed(showResultRunnable, 1800)
}
}
binding.animView.setOnClickListener {
if (canShowResult) {
binding.ivBegin.removeCallbacks(showResultRunnable)
showResultRunnable.run()
}
}
(if (fairyType == MyFairyItemView.BASE) {
viewModel.testResultLiveData
} else {
viewModel.testLegendResultLiveData
}).observe(
viewLifecycleOwner
) {
it?.getContentIfNotHandled()?.let {
TestFairyResultDialog.newInstance().show(context)
canShowResult = true
if (resultNotShowed) {
showResultRunnable.run()
}
} ?: run {
binding.ivBegin.isEnabled = true
}
}
viewModel.compoundFairyInfosLiveData.observe(viewLifecycleOwner) {

View File

@@ -28,7 +28,7 @@ class ExchangeItemView @JvmOverloads constructor(
fairyInfo?.let {
binding.ivFairyIcon.load(it.elfPicUrl)
binding.tvFairyName.text = it.elfName
binding.tvFairyNum.text = "x${it.elfNum}"
binding.tvFairyNum.text = "${it.elfNum}"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -101,6 +101,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_record" />
<com.tencent.qgame.animplayer.AnimView
android:id="@+id/anim_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@id/view_bg_forest"
app:layout_constraintEnd_toEndOf="@id/view_bg_forest"
app:layout_constraintStart_toStartOf="@id/view_bg_forest"
app:layout_constraintTop_toTopOf="@id/view_bg_forest" />
<ImageView
android:id="@+id/iv_previous"
android:layout_width="50dp"

View File

@@ -36,12 +36,12 @@
android:gravity="center"
android:paddingStart="8dp"
android:paddingTop="2dp"
android:text="0"
android:textColor="@color/white"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="@id/iv_more"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/iv_more"
tools:text="12.2W" />
app:layout_constraintTop_toTopOf="@id/iv_more" />
<ImageView
android:id="@+id/iv_fairy_treasure"

View File

@@ -20,39 +20,54 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="25dp"
android:background="@drawable/treasure_fairy_bg_test_fairy_anim"
android:background="@drawable/treasure_fairy_bg_test_fairy_anim_epic"
app:layout_constraintDimensionRatio="684:490"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/view_bg_top"
app:layout_constraintWidth_percent="0.91" />
<com.tencent.qgame.animplayer.AnimView
android:id="@+id/anim_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@id/view_bg_anim"
app:layout_constraintEnd_toEndOf="@id/view_bg_anim"
app:layout_constraintStart_toStartOf="@id/view_bg_anim"
app:layout_constraintTop_toTopOf="@id/view_bg_anim" />
<ImageView
android:id="@+id/iv_fairy_0"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="30dp"
android:layout_marginBottom="46dp"
app:layout_constraintBottom_toBottomOf="@id/view_bg_anim"
app:layout_constraintStart_toStartOf="@id/view_bg_anim" />
app:layout_constraintEnd_toEndOf="@id/view_bg_anim"
app:layout_constraintHorizontal_bias="0.105"
app:layout_constraintStart_toStartOf="@id/view_bg_anim"
app:layout_constraintTop_toTopOf="@id/view_bg_anim"
app:layout_constraintVertical_bias="0.74" />
<ImageView
android:id="@+id/iv_fairy_1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="26dp"
app:layout_constraintBottom_toBottomOf="@id/view_bg_anim"
app:layout_constraintEnd_toEndOf="@id/view_bg_anim"
app:layout_constraintStart_toStartOf="@id/view_bg_anim" />
app:layout_constraintStart_toStartOf="@id/view_bg_anim"
app:layout_constraintTop_toTopOf="@id/view_bg_anim"
app:layout_constraintVertical_bias="0.85" />
<ImageView
android:id="@+id/iv_fairy_2"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="46dp"
android:src="@drawable/default_avatar"
app:layout_constraintBottom_toBottomOf="@id/view_bg_anim"
app:layout_constraintEnd_toEndOf="@id/view_bg_anim" />
app:layout_constraintEnd_toEndOf="@id/view_bg_anim"
app:layout_constraintHorizontal_bias="0.892"
app:layout_constraintStart_toStartOf="@id/view_bg_anim"
app:layout_constraintTop_toTopOf="@id/view_bg_anim"
app:layout_constraintVertical_bias="0.745" />
<ImageView
android:id="@+id/iv_begin"

View File

@@ -55,10 +55,12 @@
android:layout_width="20dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="x5"
android:textColor="#1f5764"
android:textSize="10sp"
app:layout_constraintBaseline_toTopOf="@id/tv_fairy_name"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.83"
tools:text="5" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -15,6 +15,8 @@ public class PathFilter {
List<String> list = new ArrayList<>();
list.add("/dynamic/square/publish");
list.add("dynamic/square/publish");
list.add("act/seize-treasure/elf/compound");
list.add("/act/seize-treasure/elf/compound");
return list;
}

View File

@@ -26,7 +26,7 @@ data class ExchangeGiftInfo(
fun getPrizeUnit(): String {
return if (rewardType == "gift") {
"${rewardShowValue})"
"${rewardShowValue}"
} else {
"${rewardNum}${rewardUnit}"
}

View File

@@ -82,20 +82,19 @@ object TreasureFairyModel {
}
suspend fun exchangeGift(itemId: Long): ExchangeGiftInfo? = launchRequest {
api.exchangeGift(itemId)
api.exchangeGift(itemId, AvRoomDataManager.get().roomUid)
}
suspend fun getDebrisExchangeList(): List<ExchangeGiftInfo>? = launchRequest {
api.getDebrisExchangeList()
}
suspend fun getExchangeRecord(
convertType: Int,
page: Int,
pageSize: Int
): List<ExchangeGiftInfo>? = launchRequest {
api.getExchangeRecord(convertType,page, pageSize)
api.getExchangeRecord(convertType, page, pageSize)
}
@@ -238,7 +237,10 @@ object TreasureFairyModel {
*/
@FormUrlEncoded
@POST("act/seize-treasure/convert")
suspend fun exchangeGift(@Field("itemId") itemId: Long): ServiceResult<ExchangeGiftInfo>
suspend fun exchangeGift(
@Field("itemId") itemId: Long,
@Field("roomUid") roomUid: Long
): ServiceResult<ExchangeGiftInfo>
/**