Панель проигрыша реализована

This commit is contained in:
Сергей Бондарь 2026-08-05 16:41:14 +03:00
parent 0d2a142688
commit 4171fc6f3c
6 changed files with 296 additions and 55 deletions

View File

@ -279,6 +279,57 @@ MonoBehaviour:
startPanelX: -1500
shownPanelX: 0
hiddenPanelX: 1500
description: {fileID: 4548603131953907052}
revengeButton: {fileID: 4473216201978052634}
menuButton: {fileID: 3149010045339756087}
background: {fileID: 5911409891330945285}
backgroundEnabledColor: {r: 0, g: 0, b: 0, a: 0.78431374}
backgroundDisabledColor: {r: 0, g: 0, b: 0, a: 0}
elasticCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 3.3265033
outSlope: 3.3265033
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0.09685003
- serializedVersion: 3
time: 0.5913489
value: 1.0537547
inSlope: -0.08538857
outSlope: -0.08538857
tangentMode: 0
weightedMode: 0
inWeight: 0.40856364
outWeight: 0.6827316
- serializedVersion: 3
time: 0.7950607
value: 0.85623163
inSlope: -0.026630348
outSlope: -0.026630348
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 1
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
buttons:
- {fileID: 4473216201978052634}
- {fileID: 3149010045339756087}
--- !u!1 &2351381157185884270
GameObject:
m_ObjectHideFlags: 0
@ -503,6 +554,54 @@ PrefabInstance:
propertyPath: m_Name
value: revenge button
objectReference: {fileID: 0}
- target: {fileID: 2146687310847847456, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2146687310847847456, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2146687310847847456, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2146687310847847456, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2146687310847847456, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2146687310847847456, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3305016882671206316, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3305016882671206316, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3305016882671206316, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3305016882671206316, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3305016882671206316, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3305016882671206316, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4544308652318507848, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_Pivot.x
value: 0.5
@ -583,11 +682,50 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4561252498154564428, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4561252498154564428, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4561252498154564428, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4561252498154564428, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4561252498154564428, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4561252498154564428, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5621009149773953795, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
propertyPath: m_AnchoredPosition.x
value: 2.069992
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
--- !u!114 &4473216201978052634 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8011284185176063130, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
m_PrefabInstance: {fileID: 5852923504620682368}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 037529eb445df784099968d77894e992, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::RevengeButton
--- !u!224 &7937983908272865224 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 4544308652318507848, guid: 557c00588450b594a927dd0a02259ccd, type: 3}
@ -690,6 +828,17 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7be014d367dc2e1408a34e643b46efd1, type: 3}
--- !u!114 &3149010045339756087 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8229287748664866622, guid: 7be014d367dc2e1408a34e643b46efd1, type: 3}
m_PrefabInstance: {fileID: 6451347543270379785}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f1517e2526bda7745a3a372ae8b81849, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::GotoMenuButton
--- !u!224 &3872842078604932601 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 7798214962221343984, guid: 7be014d367dc2e1408a34e643b46efd1, type: 3}

View File

@ -89,8 +89,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f1517e2526bda7745a3a372ae8b81849, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::GotoMenuButton
switchDuration: 0.2
enabledScale: 1.1
switchDuration: 0.1
enabledScale: 1.05
disabledScale: 0.9
ease: 1
background: {fileID: 7498881263536980240}

View File

@ -165,8 +165,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 037529eb445df784099968d77894e992, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::RevengeButton
switchDuration: 0.2
enabledScale: 1.1
switchDuration: 0.1
enabledScale: 1.05
disabledScale: 0.9
ease: 1
background: {fileID: 1628731035324421078}

View File

@ -38606,85 +38606,77 @@ PrefabInstance:
propertyPath: m_Name
value: Loss
objectReference: {fileID: 0}
- target: {fileID: 692335900938401466, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_IsActive
- target: {fileID: 5544866098104471712, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2249570968408950659, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchoredPosition.x
value: 2.069992
objectReference: {fileID: 0}
- target: {fileID: 5544866098104471712, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5544866098104471712, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5544866098104471712, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_SizeDelta.x
value: 110.65478
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5544866098104471712, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_SizeDelta.y
value: 31.14
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5544866098104471712, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchoredPosition.x
value: 55.327393
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5544866098104471712, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchoredPosition.y
value: -16.715
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7959285585224308684, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7959285585224308684, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7959285585224308684, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_SizeDelta.x
value: 66.4026
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7959285585224308684, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_SizeDelta.y
value: 31.14
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7959285585224308684, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchoredPosition.x
value: 163.85608
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7959285585224308684, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchoredPosition.y
value: -16.715
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999324220713993004, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999324220713993004, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999324220713993004, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_SizeDelta.x
value: 66.4026
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999324220713993004, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_SizeDelta.y
value: 31.14
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999324220713993004, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchoredPosition.x
value: 250.2587
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999324220713993004, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_AnchoredPosition.y
value: -16.715
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9178296791575972612, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
propertyPath: m_Pivot.x

View File

@ -30,6 +30,7 @@ public abstract class PveLossButton : MButton
Color textColor = selected ? Color.black : Color.white;
float scale = selected ? enabledScale : disabledScale;
animSequence = DOTween.Sequence();
animSequence.Join(background.DOColor(bgColor, switchDuration).SetEase(ease));
animSequence.Join(transform.DOScale(scale, switchDuration).SetEase(ease));

View File

@ -1,59 +1,158 @@
using UnityEngine;
using DG.Tweening;
using System;
using System.Collections.Generic;
using UnityEngine.UI;
public class PveLossPanel : MonoBehaviour, IControlable
{
[SerializeField] private RectTransform panel;
[SerializeField] private float startPanelX, shownPanelX, hiddenPanelX;
[SerializeField] private Transform description;
[SerializeField] private RevengeButton revengeButton;
[SerializeField] private GotoMenuButton menuButton;
[SerializeField] private Image background;
[SerializeField] private Color backgroundEnabledColor, backgroundDisabledColor;
[SerializeField] private AnimationCurve elasticCurve;
private Sequence _animation;
[Header("Работа с кнопками")]
[SerializeField] private List<PveLossButton> buttons;
private int buttonIndex;
public bool ControlsEnabled { get; set; }
private void Start()
{
ControlsPerformer.Instance.SetControlable(this);
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha1)) Open();
if (Input.GetKeyDown(KeyCode.Alpha2)) Close();
}
public void UpdateControls()
{
int direction = 0;
if (In.GetButtonDownAnyPlayer(PlayerAction.left)) direction -= 1;
if (In.GetButtonDownAnyPlayer(PlayerAction.right)) direction += 1;
int newButtonIndex = Mathf.Clamp(buttonIndex + direction, 0, buttons.Count);
bool indexChanged = newButtonIndex != buttonIndex;
if (indexChanged)
{
buttonIndex = newButtonIndex;
RefreshButtons();
}
//interact
if(In.GetButtonDownAnyPlayer(PlayerAction.action))
{
var selectedButton = buttons[buttonIndex];
selectedButton.Interact();
}
}
public void Open()
{
if (_animation != null)
{
_animation.Kill();
}
Initialize();
Sequence open = GetOpenSequence();
open.onComplete += () => ControlsEnabled = true;
open.PlayForward();
_animation = GetOpenSequence();
_animation.onComplete += () =>
{
ControlsEnabled = true;
RefreshButtons();
};
_animation.PlayForward();
}
public void Close()
{
if (_animation != null)
{
_animation.Kill();
}
_animation = GetCloseSequence();
_animation.onComplete += () =>
{
ControlsEnabled = false;
revengeButton.Select();
menuButton.Deselect();
};
_animation.PlayForward();
}
private Sequence GetCloseSequence()
{
Sequence seq = DOTween.Sequence();
seq.Append(panel.DOAnchorPosX(hiddenPanelX, 1f).SetEase(Ease.InBack));
seq.Join(background.DOColor(backgroundDisabledColor, 2).SetEase(Ease.InCubic));
return seq;
}
private void Initialize()
{
panel.anchoredPosition = new Vector2(startPanelX, panel.anchoredPosition.y);
description.localScale = Vector3.zero;
//todo: установить цену, сконфигурировать кнопку.
revengeButton.Initialize();
revengeButton.transform.localScale = Vector3.zero;
menuButton.transform.localScale = Vector3.zero;
background.color = backgroundDisabledColor;
buttonIndex = 0;
}
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));
//фон
seq.Join(background.DOColor(backgroundEnabledColor, 2).SetEase(Ease.OutCubic));
//текст описания
seq.Append(description.DOScale(1, 0.5f).SetEase(elasticCurve));
seq.AppendInterval(0.2f);
//вращение описания
float rotationDuration = 0.2f;
seq.Append(description.DOLocalRotate(new Vector3(0, 0, 2), rotationDuration));
seq.Append(description.DOLocalRotate(new Vector3(0, 0, -2), rotationDuration));
seq.Append(description.DOLocalRotate(new Vector3(0, 0, 0), rotationDuration / 2));
//появление кнопок
seq.Join(revengeButton.transform.DOScale(1.05f, 0.5f).SetEase(Ease.OutBack));
seq.Append(menuButton.transform.DOScale(0.9f, 0.5f).SetEase(Ease.OutBack));
return seq;
}
public void UpdateControls()
private void RefreshButtons()
{
throw new System.NotImplementedException();
if (buttonIndex == 0)
{
buttons[0].Select();
buttons[1].Deselect();
}
else if (buttonIndex == 1)
{
buttons[1].Select();
buttons[0].Deselect();
}
}
}