Реализация кнопки "Реванш"

This commit is contained in:
Сергей Бондарь 2026-08-05 14:40:54 +03:00
parent 67f9167523
commit 6a2c464474
9 changed files with 213 additions and 6 deletions

View File

@ -92,7 +92,7 @@ RectTransform:
m_GameObject: {fileID: 324693485723832659}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 1.0919, y: 1.0919, z: 1.0919}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2249570968408950659}
@ -241,7 +241,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -3.4, y: 195.34}
m_AnchoredPosition: {x: 0, y: 195.34}
m_SizeDelta: {x: 983.45, y: 348.78}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2566056016197653151
@ -429,6 +429,7 @@ GameObject:
m_Component:
- component: {fileID: 9178296791575972612}
- component: {fileID: 8426122535526181580}
- component: {fileID: 8505923519972849031}
m_Layer: 5
m_Name: Loss
m_TagString: Untagged
@ -465,6 +466,22 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 692335900938401466}
m_CullTransparentMesh: 1
--- !u!114 &8505923519972849031
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 692335900938401466}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cbcfdbb18f10e58428fb67dca6b35cfc, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PveLossPanel
panel: {fileID: 7844923938917649029}
startPanelX: -1500
shownPanelX: 0
hiddenPanelX: 1500
--- !u!1 &1203473188556384456
GameObject:
m_ObjectHideFlags: 0
@ -826,7 +843,7 @@ GameObject:
- component: {fileID: 927060223010217821}
- component: {fileID: 3602403371296692407}
m_Layer: 5
m_Name: new price
m_Name: actual price
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -841,7 +858,7 @@ RectTransform:
m_GameObject: {fileID: 2836474543009031495}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 1.0919, y: 1.0919, z: 1.0919}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 869825121192353493}
@ -1204,7 +1221,7 @@ RectTransform:
m_GameObject: {fileID: 5514029907908979855}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 1.0919, y: 1.0919, z: 1.0919}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 869825121192353493}
@ -1276,7 +1293,7 @@ MonoBehaviour:
m_fontSizeMin: 0
m_fontSizeMax: 64
m_fontStyle: 0
m_HorizontalAlignment: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
@ -1325,6 +1342,7 @@ GameObject:
- component: {fileID: 7937983908272865224}
- component: {fileID: 7744780582088711646}
- component: {fileID: 5162155233318121302}
- component: {fileID: 4473216201978052634}
m_Layer: 5
m_Name: revenge button
m_TagString: Untagged
@ -1391,3 +1409,27 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &4473216201978052634
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5566858640492429940}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 037529eb445df784099968d77894e992, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::RevengeButton
oldPrice: {fileID: 4678695876483313210}
actualPrice: {fileID: 3602403371296692407}
saleImage: {fileID: 7404512200329150473}
background: {fileID: 5162155233318121302}
texts:
- {fileID: 7100246456324829929}
- {fileID: 4678695876483313210}
- {fileID: 3602403371296692407}
switchDuration: 0.2
enabledScale: 1.1
disabledScale: 0.9
ease: 1

View File

@ -154,6 +154,10 @@ public class GameManager : MonoBehaviour
public void SetMode(GameMode mode) => gameMode = mode;
public void PerformRevenge()
{//todo: реализовать переход на реванш
}
public void IncreaseScore(Team player)
{

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 18d8b7710fdc05b4fa15fde9f50c067c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,59 @@
using UnityEngine;
using DG.Tweening;
using System;
public class PveLossPanel : MonoBehaviour, IControlable
{
[SerializeField] private RectTransform panel;
[SerializeField] private float startPanelX, shownPanelX, hiddenPanelX;
public bool ControlsEnabled { get; set; }
public void Open()
{
Initialize();
Sequence open = GetOpenSequence();
open.onComplete += () => ControlsEnabled = true;
open.PlayForward();
}
private void Initialize()
{
panel.anchoredPosition = new Vector2(startPanelX, panel.anchoredPosition.y);
//todo: установить цену, сконфигурировать кнопку.
}
private void Revenge()
{
print("Рестарт");
}
private void Menu()
{
print("Переход в меню");
}
private Sequence GetOpenSequence()
{
Sequence seq = DOTween.Sequence();
seq.Append(panel.DOAnchorPosX(shownPanelX, 1f).SetEase(Ease.OutBack));
return seq;
}
private Sequence GetCloseSequence(Action callback)
{
Sequence seq = DOTween.Sequence();
seq.Append(panel.DOAnchorPosX(hiddenPanelX, 1f).SetEase(Ease.InBack));
return seq;
}
public void UpdateControls()
{
throw new System.NotImplementedException();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cbcfdbb18f10e58428fb67dca6b35cfc

View File

@ -0,0 +1,77 @@
using DG.Tweening;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class RevengeButton : MButton
{
[Header("Layout ссылки")]
[SerializeField] private TextMeshProUGUI oldPrice;
[SerializeField] private TextMeshProUGUI actualPrice;
[SerializeField] private Image saleImage;
[SerializeField] private Image background;
[SerializeField] private List<TextMeshProUGUI> texts;
[Header("Анимация")]
[SerializeField] private float switchDuration;
[SerializeField] private float enabledScale = 1.1f, disabledScale = 0.9f;
[SerializeField] private Ease ease = Ease.Linear;
private Sequence animSequence;
private bool interactable;
public override void Initialize()
{
if (PaymentSystem.Freeplay)
{
oldPrice.gameObject.SetActive(false);
actualPrice.gameObject.SetActive(false);
saleImage.gameObject.SetActive(false);
return;
}
int revengePrice = PaymentSystem.PriceRevenge;
int normalPrice = PaymentSystem.PricePve;
actualPrice.gameObject.SetActive(true);
actualPrice.text = $"{revengePrice} {PaymentSystem.ValutaName}";
bool revengeCheaper = revengePrice < normalPrice;
oldPrice.gameObject.SetActive(revengeCheaper);
oldPrice.text = $"{normalPrice} {PaymentSystem.ValutaName}";
saleImage.gameObject.SetActive(revengeCheaper);
}
public override void Select() => SetSelected(true);
public override void Deselect() => SetSelected(false);
public override void Interact()
{
if (!interactable) return;
GameManager.instance.PerformRevenge();
}
private void SetSelected(bool selected)
{
interactable = false;
if (animSequence != null)
animSequence.Kill();
Color bgColor = selected ? Color.white : Color.black;
Color textColor = selected ? Color.black : Color.white;
float scale = selected ? enabledScale : disabledScale;
animSequence.Join(background.DOColor(bgColor, switchDuration).SetEase(ease));
animSequence.Join(transform.DOScale(scale, switchDuration).SetEase(ease));
foreach (var text in texts)
animSequence.Join(text.DOColor(textColor, switchDuration).SetEase(ease));
animSequence.onComplete += () => interactable = selected;
animSequence.PlayForward();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 037529eb445df784099968d77894e992

11
Assets/Scripts/MButton.cs Normal file
View File

@ -0,0 +1,11 @@
using UnityEngine;
public abstract class MButton : MonoBehaviour
{
public abstract void Initialize();
public abstract void Select();
public abstract void Deselect();
public abstract void Interact();
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 771a5b340476e5b47b4768bbc3903436