Добавить оплату повторов в PvE и PvP

This commit is contained in:
Сергей Бондарь 2026-08-27 12:55:29 +03:00
parent ebc47a80dd
commit 16ab9e47f9
3 changed files with 32 additions and 28 deletions

View File

@ -63,11 +63,14 @@ public class PveLossPanel : MonoBehaviour, IControlable
public void Close()
{
int selectedButtonIndex = buttonIndex;
if (selectedButtonIndex == 0 && revengeButton is RevengeButton paidRestartButton &&
!paidRestartButton.TryPay(GameMode.pve))
return;
ControlsEnabled = false;
ControlsPerformer.Instance.SetControlable(null);
int selectedButtonIndex = buttonIndex;
if (_animation != null)
{

View File

@ -67,10 +67,13 @@ public class PvpWinPanel : MonoBehaviour, IControlable
public void Close()
{
int selectedButtonIndex = _buttonIndex;
if (selectedButtonIndex == 0 && !_restartButton.TryPay(GameMode.pvp))
return;
ControlsEnabled = false;
ControlsPerformer.Instance.SetControlable(null);
int selectedButtonIndex = _buttonIndex;
_animation?.Kill();
_animation = GetCloseSequence();
_animation.OnComplete(() => CompleteClose(selectedButtonIndex));
@ -88,7 +91,7 @@ public class PvpWinPanel : MonoBehaviour, IControlable
_description.localRotation = Quaternion.identity;
_description.GetComponent<TextMeshProUGUI>().text = GetDescription(winner, isMatchWin, player1Score, player2Score);
_restartButton.InitializeForFreeRestart();
_restartButton.Initialize(GameMode.pvp);
_restartButton.transform.localScale = Vector3.zero;
_menuButton.transform.localScale = Vector3.zero;
_background.color = _backgroundDisabledColor;

View File

@ -1,50 +1,48 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
public class RevengeButton : PveLossButton
{
[Header("Layout ссылки")]
[SerializeField] private TextMeshProUGUI oldPrice;
[SerializeField] private TextMeshProUGUI actualPrice;
[SerializeField] private Image saleImage;
[SerializeField, FormerlySerializedAs("oldPrice")] private TextMeshProUGUI _oldPrice;
[SerializeField, FormerlySerializedAs("actualPrice")] private TextMeshProUGUI _actualPrice;
[SerializeField, FormerlySerializedAs("saleImage")] private Image _saleImage;
public override void Initialize()
=> Initialize(GameMode.pve);
public void Initialize(GameMode gameMode)
{
if (PaymentSystem.Freeplay)
{
oldPrice.gameObject.SetActive(false);
actualPrice.gameObject.SetActive(false);
saleImage.gameObject.SetActive(false);
_oldPrice.gameObject.SetActive(false);
_actualPrice.gameObject.SetActive(false);
_saleImage.gameObject.SetActive(false);
return;
}
int revengePrice = PaymentSystem.PriceRevengePve;
int normalPrice = PaymentSystem.PricePve;
int revengePrice = PaymentSystem.GetRevengePrice(gameMode);
int normalPrice = PaymentSystem.GetModePrice(gameMode);
actualPrice.gameObject.SetActive(true);
actualPrice.text = $"{revengePrice} {PaymentSystem.ValutaName}";
_actualPrice.gameObject.SetActive(true);
_actualPrice.text = PaymentSystem.GetPluralizedMoney(revengePrice);
bool revengeCheaper = revengePrice < normalPrice;
oldPrice.gameObject.SetActive(revengeCheaper);
oldPrice.text = $"{normalPrice} {PaymentSystem.ValutaName}";
saleImage.gameObject.SetActive(revengeCheaper);
_oldPrice.gameObject.SetActive(revengeCheaper);
_oldPrice.text = PaymentSystem.GetPluralizedMoney(normalPrice);
_saleImage.gameObject.SetActive(revengeCheaper);
}
public void InitializeForFreeRestart()
{
oldPrice.gameObject.SetActive(false);
actualPrice.gameObject.SetActive(false);
saleImage.gameObject.SetActive(false);
}
public bool TryPay(GameMode gameMode)
=> PaymentSystem.TryPay(PaymentSystem.GetRevengePrice(gameMode));
public override void Interact()
{
if (!interactable) return;
if (!interactable)
return;
base.Interact();
}
}