Меню красивое
This commit is contained in:
1 parent
855108d88b
commit
efad72b4d9
31 files changed
+30008
-1282
No files matched your search
@@ -27,43 +27,65 @@ namespace Code.App.AppStates
|
||||
Context.UIService.LoadingScreen.Show();
|
||||
|
||||
Context.CameraStateMachine.SwitchState(CameraMode.UltraStatic);
|
||||
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
WaitForSceneToLoad();
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
}
|
||||
|
||||
private CinematicDoorOpening _damnDoor = new();
|
||||
private async UniTaskVoid WaitForSceneToLoad()
|
||||
{
|
||||
await UniTask.WhenAll(
|
||||
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.MainMenu),
|
||||
Context.UIService.AsyncSwitchPanelTo(UIPanel.MainMenu),
|
||||
Context.AudioFactory.WarmMenuMusic()
|
||||
);
|
||||
|
||||
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Menu);
|
||||
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Menu);
|
||||
);
|
||||
|
||||
var hui = ((MainMenuEnvironment)SceneManager.GetActiveScene()
|
||||
InitializeAudio();
|
||||
|
||||
var mainMenuEnvironment = ((MainMenuEnvironment)SceneManager.GetActiveScene()
|
||||
.GetSceneContainer().Resolve<CurrentSceneEnvironment>());
|
||||
_damnDoor.DamnDoor = hui.damnDoor;
|
||||
_damnDoor.DamnDoor.SetPhysics(false);
|
||||
_damnDoor.DoorLight = hui.doorLight;
|
||||
|
||||
var menuPanel = (MainMenuPanel)Context.UIService.CurrentPanel;
|
||||
|
||||
menuPanel.startButton.button.onClick.AddListener(StartGame);
|
||||
menuPanel.exitButton.button.onClick.AddListener(ExitGame);
|
||||
menuPanel.CinematicDoorOpening = _damnDoor;
|
||||
|
||||
((UltraStaticState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(hui.cameraPosition);
|
||||
InitializeUI(mainMenuEnvironment);
|
||||
|
||||
InitializeCamera(mainMenuEnvironment);
|
||||
|
||||
InitializeInput();
|
||||
|
||||
Context.UIService.LoadingScreen.Hide();
|
||||
|
||||
}
|
||||
|
||||
private void InitializeCamera(MainMenuEnvironment mainMenuEnvironment)
|
||||
{
|
||||
((UltraStaticState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(mainMenuEnvironment
|
||||
.cameraPosition);
|
||||
}
|
||||
|
||||
private void InitializeInput()
|
||||
{
|
||||
Context.InputService.EnableMap(ActionMappings.MainMenu);
|
||||
}
|
||||
|
||||
private void InitializeAudio()
|
||||
{
|
||||
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Menu);
|
||||
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Menu);
|
||||
}
|
||||
|
||||
private void InitializeUI(MainMenuEnvironment mainMenuEnvironment)
|
||||
{
|
||||
var menuPanel = (MainMenuPanel)Context.UIService.CurrentPanel;
|
||||
menuPanel.Initialize(mainMenuEnvironment.uiVariables,
|
||||
mainMenuEnvironment.startButton,
|
||||
mainMenuEnvironment.settingButton,
|
||||
mainMenuEnvironment.exitButton);
|
||||
|
||||
menuPanel.startButton.button.onClick.AddListener(StartGame);
|
||||
menuPanel.exitButton.button.onClick.AddListener(ExitGame);
|
||||
|
||||
mainMenuEnvironment.menuButtonsCanvas.worldCamera = Context.CameraStateMachine.Camera;
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
}
|
||||
@@ -82,8 +104,8 @@ namespace Code.App.AppStates
|
||||
public override void ExitState()
|
||||
{
|
||||
Context.InputService.DisableMap(ActionMappings.MainMenu);
|
||||
Context.AudioService.GladlyAskToStopMusic(MusicType.Menu, callback: Context.AudioFactory.ReleaseMenuMusic);
|
||||
|
||||
Context.AudioService.GladlyAskToStopMusic(MusicType.Menu, callback: Context.AudioFactory.ReleaseMenuMusic);
|
||||
|
||||
base.ExitState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,44 @@ namespace Code.Gameplay.Door
|
||||
{
|
||||
public class CinematicDoorOpening
|
||||
{
|
||||
public DamnDoor DamnDoor;
|
||||
public Light DoorLight;
|
||||
private MainMenuDoor _mainMenuDoor;
|
||||
private Light _doorLight;
|
||||
|
||||
public void PreOpen(bool start)
|
||||
public CinematicDoorOpening(MainMenuDoor mainMenuDoor, Light doorLight)
|
||||
{
|
||||
DoorLight.DOColor(start ? Color.yellow : Color.red, 0.2f);
|
||||
_mainMenuDoor = mainMenuDoor;
|
||||
_doorLight = doorLight;
|
||||
}
|
||||
public void PreOpen(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
_doorLight.DOColor(Color.green, 0.2f);
|
||||
break;
|
||||
case 1:
|
||||
_doorLight.DOColor(Color.yellow, 0.2f);
|
||||
break;
|
||||
case 2:
|
||||
_doorLight.DOColor(Color.red, 0.2f);
|
||||
break;
|
||||
}
|
||||
|
||||
DamnDoor.Petlya.DORotate(new Vector3(0, -40, 0), 1f);
|
||||
_mainMenuDoor.Petlya.DORotate(new Vector3(0, -10, 0), 1f);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
DamnDoor.Petlya.DORotate(new Vector3(0, 0, 0), 1f);
|
||||
_mainMenuDoor.Petlya.DORotate(new Vector3(0, 0, 0), 1f);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MainMenuUIVariables
|
||||
{
|
||||
public MainMenuDoor MainMenuDoor;
|
||||
public Light DoorLight;
|
||||
public Color ButtonDefaultColor;
|
||||
public Color ButtonHoverColor;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ using UnityEngine;
|
||||
|
||||
namespace Code.Gameplay.Door
|
||||
{
|
||||
public class DamnDoor : MonoBehaviour
|
||||
public class MainMenuDoor : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Rigidbody rigidbody;
|
||||
[SerializeField] private Transform petlya;
|
||||
File renamed without changes.
@@ -1,6 +1,8 @@
|
||||
using Code.Gameplay.Door;
|
||||
using Code.UI.Panels.Etc;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.GlobalIllumination;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Code.Scenes.SceneEnvironments
|
||||
{
|
||||
@@ -8,14 +10,20 @@ namespace Code.Scenes.SceneEnvironments
|
||||
public class MainMenuEnvironment : CurrentSceneEnvironment
|
||||
{
|
||||
public Transform cameraPosition;
|
||||
public DamnDoor damnDoor;
|
||||
public Light doorLight;
|
||||
public MainMenuUIVariables uiVariables;
|
||||
public MainMenuButton startButton;
|
||||
public MainMenuButton settingButton;
|
||||
public MainMenuButton exitButton;
|
||||
public Canvas menuButtonsCanvas;
|
||||
|
||||
public void TransitVariables(MainMenuEnvironment env)
|
||||
{
|
||||
cameraPosition = env.cameraPosition;
|
||||
damnDoor = env.damnDoor;
|
||||
doorLight = env.doorLight;
|
||||
uiVariables = env.uiVariables;
|
||||
startButton = env.startButton;
|
||||
settingButton = env.settingButton;
|
||||
exitButton = env.exitButton;
|
||||
menuButtonsCanvas = env.menuButtonsCanvas;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ namespace Code.UI.Panels.Etc
|
||||
{
|
||||
public Button button;
|
||||
public Action OnPointerEnterEvent, OnPointerExitEvent;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData) => OnPointerEnterEvent?.Invoke();
|
||||
public void OnPointerExit(PointerEventData eventData) => OnPointerExitEvent?.Invoke();
|
||||
|
||||
public virtual void OnPointerEnter(PointerEventData eventData) => OnPointerEnterEvent?.Invoke();
|
||||
public virtual void OnPointerExit(PointerEventData eventData) => OnPointerExitEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Code.UI.Panels.Etc
|
||||
{
|
||||
public class MainMenuButton : HoverButton
|
||||
{
|
||||
public TMP_Text text;
|
||||
|
||||
public Color defaultColor;
|
||||
public Color hoverColor;
|
||||
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
text.DOColor(hoverColor, 0.2f);
|
||||
OnPointerEnterEvent?.Invoke();
|
||||
}
|
||||
public override void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
text.DOColor(defaultColor, 0.2f);
|
||||
OnPointerExitEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0e3f905e0af4d1ab624b1dfe8eaa1df
|
||||
timeCreated: 1763762376
|
||||
@@ -8,15 +8,18 @@ namespace Code.UI.Panels
|
||||
{
|
||||
[SerializeField] private Image background;
|
||||
[SerializeField] private TMP_Text loadingTitle;
|
||||
[SerializeField] private TMP_Text vyapWatermark;
|
||||
public override void Hide()
|
||||
{
|
||||
background.enabled = false;
|
||||
loadingTitle.enabled = false;
|
||||
vyapWatermark.enabled = false;
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
background.enabled = true;
|
||||
loadingTitle.enabled = true;
|
||||
vyapWatermark.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,38 @@ namespace Code.UI.Panels
|
||||
{
|
||||
public class MainMenuPanel : UIElement
|
||||
{
|
||||
public HoverButton startButton;
|
||||
public HoverButton exitButton;
|
||||
public CinematicDoorOpening CinematicDoorOpening;
|
||||
public MainMenuButton startButton;
|
||||
public MainMenuButton settingButton;
|
||||
public MainMenuButton exitButton;
|
||||
|
||||
public void Start()
|
||||
private CinematicDoorOpening _cinematicDoorOpening;
|
||||
|
||||
public void Initialize(MainMenuUIVariables mainMenuUIVariables,
|
||||
MainMenuButton startButton,
|
||||
MainMenuButton settingButton,
|
||||
MainMenuButton exitButton)
|
||||
{
|
||||
this.startButton = startButton;
|
||||
this.settingButton = settingButton;
|
||||
this.exitButton = exitButton;
|
||||
|
||||
startButton.defaultColor = mainMenuUIVariables.ButtonDefaultColor;
|
||||
settingButton.defaultColor = mainMenuUIVariables.ButtonDefaultColor;
|
||||
exitButton.defaultColor = mainMenuUIVariables.ButtonDefaultColor;
|
||||
|
||||
startButton.hoverColor = mainMenuUIVariables.ButtonHoverColor;
|
||||
settingButton.hoverColor = mainMenuUIVariables.ButtonHoverColor;
|
||||
exitButton.hoverColor = mainMenuUIVariables.ButtonHoverColor;
|
||||
|
||||
startButton.OnPointerEnterEvent = OpenStart;
|
||||
settingButton.OnPointerEnterEvent = OpenSettings;
|
||||
exitButton.OnPointerEnterEvent = OpenExit;
|
||||
|
||||
startButton.OnPointerExitEvent = CloseDoor;
|
||||
settingButton.OnPointerExitEvent = CloseDoor;
|
||||
exitButton.OnPointerExitEvent = CloseDoor;
|
||||
|
||||
_cinematicDoorOpening = new(mainMenuUIVariables.MainMenuDoor, mainMenuUIVariables.DoorLight);
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
@@ -25,17 +47,12 @@ namespace Code.UI.Panels
|
||||
{
|
||||
}
|
||||
|
||||
private void OpenExit()
|
||||
{
|
||||
CinematicDoorOpening.PreOpen(false);
|
||||
}
|
||||
private void OpenStart()
|
||||
{
|
||||
CinematicDoorOpening.PreOpen(true);
|
||||
}
|
||||
private void CloseDoor()
|
||||
{
|
||||
CinematicDoorOpening.Close();
|
||||
}
|
||||
private void OpenStart() => _cinematicDoorOpening.PreOpen(0);
|
||||
|
||||
private void OpenSettings() => _cinematicDoorOpening.PreOpen(1);
|
||||
|
||||
private void OpenExit() => _cinematicDoorOpening.PreOpen(2);
|
||||
|
||||
private void CloseDoor() => _cinematicDoorOpening.Close();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user