using System.Collections; using UnityEngine; public class UiManager : MonoBehaviour { public RectTransform UpperMenuGroup; public RectTransform PveOption; public RectTransform PvpOption; public RectTransform DownMenuGroup; [field: SerializeField] public bool AnimationInProcess { get; private set; } = false; private GameManager gm => GameManager.instance; private bool menuOpened = true; #region начальные и конечные позиции для элементов меню //s - startPosition, e - endPosition Vector2 //надпись "ФИШКА" sLabel = new Vector2(0, 320), eLabel = new Vector2(0, 1000), //Иконки режимов sButton = new Vector2(400, -15), eButton = new Vector2(2000, -15), //подсказка + лого + техподдержка sLabel2 = new Vector2(0, -380), eLabel2 = new Vector2(0, -1000), //ИГРОВОЕ ПОЛЕ sBoard = new Vector2(-40, -0.5f), eBoard = new Vector2(0, -0.5f), sNoPrize = new Vector2(-0, -70f), eNoPrize = new Vector2(15, -409); Vector3 sCoin = new Vector3(0, -201.538483f, 0), eCoin = new Vector3(-732.999939f, 372, 0); Vector2 sSmallPrizesOutSize = new Vector2(560, 100); Vector2 eSmallPrizesOutSize = new Vector2(660, 100); #endregion public void CloseMenu() { if (!menuOpened) return; menuOpened = false; AnimationInProcess = true; StopAllCoroutines(); StartCoroutine(CloseMenuCoroutine()); } private IEnumerator CloseMenuCoroutine() { float parametr; //Мув кнопок, надписей, монетника parametr = 0; while (parametr < 1) { parametr += Time.deltaTime * 2; UpperMenuGroup.localPosition = Vector3.Lerp(sLabel, eLabel, parametr); PveOption.localPosition = Vector3.Lerp(new Vector3(-sButton.x, sButton.y, 0), new Vector3(-eButton.x, eButton.y, 0), parametr); PvpOption.localPosition = Vector3.Lerp(sButton, eButton, parametr); DownMenuGroup.localPosition = Vector3.Lerp(sLabel2, eLabel2, parametr); gm.noPrizeLabel.localPosition = Vector3.Lerp(sNoPrize, eNoPrize + Vector2.left * 3500, parametr); gm.coinPanel.localPosition = Vector3.Lerp(sCoin, eCoin, parametr); gm.smallPrizesOut.sizeDelta = Vector2.Lerp(sSmallPrizesOutSize, eSmallPrizesOutSize, parametr); yield return null; } PveOption.localPosition = -eButton; PvpOption.localPosition = eButton; //мув доски parametr = 0; while (parametr < 1) { parametr += Time.deltaTime * 2; gm.boardTransform.localPosition = Vector3.Lerp(sBoard, eBoard, parametr); gm.noPrizeLabel.localPosition = Vector3.Lerp(sNoPrize + Vector2.left * 3500, eNoPrize, parametr); yield return null; } AnimationInProcess = false; } public void OpenMenu() { if(menuOpened) return; menuOpened = true; AnimationInProcess = true; StopAllCoroutines(); StartCoroutine(OpenMenuCoroutine()); } private IEnumerator OpenMenuCoroutine() { float parametr = 1; while (parametr >= 0) { gm.boardTransform.localPosition = Vector3.Lerp(sBoard, eBoard, parametr); gm.noPrizeLabel.localPosition = Vector3.Lerp(eNoPrize + Vector2.left * 3500, eNoPrize, parametr); parametr -= Time.deltaTime * 2; yield return null; } parametr = 1; while (parametr >= 0) { parametr -= Time.deltaTime * 2; UpperMenuGroup.localPosition = Vector3.Lerp(sLabel, eLabel, parametr); PveOption.localPosition = Vector3.Lerp(-sButton + Vector2.up * sButton.y * 2, -eButton, parametr); PvpOption.localPosition = Vector3.Lerp(sButton, eButton, parametr); gm.noPrizeLabel.localPosition = Vector3.Lerp(sNoPrize, eNoPrize + Vector2.left * 3500, parametr); gm.coinPanel.localPosition = Vector3.Lerp(sCoin, eCoin, parametr); DownMenuGroup.localPosition = Vector3.Lerp(sLabel2, eLabel2, parametr); gm.smallPrizesOut.sizeDelta = Vector2.Lerp(sSmallPrizesOutSize, eSmallPrizesOutSize, parametr); yield return null; } AnimationInProcess = false; } }