create main menu

This commit is contained in:
2022-11-12 15:15:01 +05:00
parent b9e9cb72fe
commit a488ab8f99
82 changed files with 7068 additions and 989 deletions
+25 -7
View File
@@ -8,6 +8,16 @@ using DG.Tweening;
using UnityEngine;
using UnityEngine.SceneManagement;
public enum Location
{
Pechatniki,
Sherbinka,
BulevardSlavyanski,
Solnechaya,
Shukenskaya,
AprelevkaDepo
}
public class GameSystem : MonoBehaviour
{
public static GameSystem Instance { get; private set; }
@@ -18,6 +28,15 @@ public class GameSystem : MonoBehaviour
public event Action OnSceneLoaded;
public Dictionary<string, string> locationsName { get; private set; } = new()
{
{"StationPechatnici", "Станция Печатники"},
{"", "Станция Щербинка"},
{"", "Станция Славянский бульвар"},
{"StationSolnechnaya", "Станция Солнечная"},
{"StationShchukinskaya", "Станция Щукенская"},
{"", "Депо Апрелевка"}
};
public void LoadScene(string sceneName)
{
@@ -37,7 +56,6 @@ public class GameSystem : MonoBehaviour
});
}
public void AddGameComponent(IGameComponent component)
{
if(!gameComponents.Contains(component))
@@ -67,20 +85,20 @@ public class GameSystem : MonoBehaviour
void Update()
{
Parallel.ForEach(gameComponents,
component => component.OnUpdate());
for(int i = 0; i < gameComponents.Count; i++)
gameComponents[i].OnUpdate();
}
void FixedUpdate()
{
Parallel.ForEach(gameComponents,
component => component.OnFixedUpdate());
for(int i = 0; i < gameComponents.Count; i++)
gameComponents[i].OnFixedUpdate();
}
void LateUpdate()
{
Parallel.ForEach(gameComponents,
component => component.OnLateUpdate());
for(int i = 0; i < gameComponents.Count; i++)
gameComponents[i].OnLateUpdate();
}
public void RemoveGameComponent(IGameComponent component)
-30
View File
@@ -6,38 +6,8 @@ using UnityEngine;
public class InputHandler : MonoBehaviour, IGameComponent
{
enum Axis
{
x,
y,
z,
w
}
private Transform cameraTransform;
private float X0;
private float P0;
private readonly float F = 1;
private readonly float Q = 6;
private readonly float H = 1;
private readonly float R = 15;
private float Covariance = .1f;
private float[] state = new float[4];
float GetValueAfterFilter(float value, Axis axis)
{
X0 = F * state[(int)axis];
P0 = F * Covariance * F + Q;
var K = H *P0 / (H * P0 * H + R);
state[(int)axis] = X0 + K * (value - H * X0);
Covariance = (1 - K * H) * P0;
return state[(int)axis];
}
void Awake()
{
cameraTransform = transform;
+7
View File
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
public class SceneHandler : MonoBehaviour
{
@@ -62,4 +63,10 @@ public class SceneHandler : MonoBehaviour
OnSceneLoaded?.Invoke();
}
public void LeaveScene()
{
var sceneLoadingOperation = SceneManager.LoadSceneAsync("MainMenu",
LoadSceneMode.Single);
}
}
+10 -2
View File
@@ -16,11 +16,19 @@ public class UICanvas : MonoBehaviour
public void Show()
{
canvasGroup.DOFade(1, .2f);
canvasGroup.DOFade(1, .4f);
}
public void Hide()
{
canvasGroup.DOFade(0, .2f);
canvasGroup.DOFade(0, .4f);
}
void OnEnable()
{
if(canvasGroup == null)
canvasGroup = GetComponent<CanvasGroup>();
canvasGroup.alpha = 0;
Show();
}
}
+5 -1
View File
@@ -11,6 +11,7 @@ public class UITrainButton : MonoBehaviour, IPointerClickHandler
{
public TrainType trainType;
[SerializeField] private Color selectedColor;
private Color unselectedColor;
private Image buttonBase;
public bool isSelected { get; private set; }
@@ -19,13 +20,16 @@ public class UITrainButton : MonoBehaviour, IPointerClickHandler
void Start()
{
buttonBase = GetComponent<Image>();
locomotionHandler = FindObjectOfType<LocomotionHandler>();
unselectedColor = buttonBase.color;
}
public void Select()
{
if(isSelected) return;
if(locomotionHandler == null)
locomotionHandler = FindObjectOfType<LocomotionHandler>();
var buttons = FindObjectsOfType<UITrainButton>();
foreach(var item in buttons)
{