Skip to content

Commit cee1941

Browse files
committed
Refactor main menu UI and add user system
Reorganized the main menu system by moving MainMenu.cs to a new MainMenuSystem namespace and directory, and replaced the old MainMenu UI implementation with a modular, template-based UI using UXML and USS. Introduced MainMenuHUDController for UI logic, added new user management scripts (User, UserManager), and updated scene and material references accordingly. Also improved settings handling and camera naming for clarity.
1 parent 775a268 commit cee1941

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+851
-618
lines changed

Red Strike/Assets/GameSettings/Settings.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ MonoBehaviour:
1212
m_Script: {fileID: 11500000, guid: a239fa25edb29264caefa31c21e79db7, type: 3}
1313
m_Name: Settings
1414
m_EditorClassIdentifier:
15-
masterVolume: 1
15+
masterVolume: 0.865
1616
musicVolume: 0.8
17-
fullscreen: 1
17+
isFullscreen: 1

Red Strike/Assets/GameSettings/Settings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace GameSettings
66
public class Settings : ScriptableObject
77
{
88
[Header("Audio Settings")]
9-
public float masterVolume = 1.0f;
10-
public float musicVolume = 0.8f;
9+
[Range(0f, 1f)] public float masterVolume = 1.0f;
10+
[Range(0f, 1f)] public float musicVolume = 0.8f;
1111

1212
[Header("Graphics Settings")]
1313
public bool isFullscreen = true;
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using System.Collections;
2+
using Unity.Cinemachine;
3+
using UnityEngine;
4+
using GameSettings;
5+
using NetworkingSystem;
6+
7+
namespace MainMenuSystem
8+
{
9+
public class MainMenu : MonoBehaviour
10+
{
11+
[Header("Scene Elements")]
12+
public Transform sunTransform;
13+
public float rotationSpeed = 70f;
14+
15+
public Transform planetTransform;
16+
public float planetRotationSpeed = 30f;
17+
18+
[Header("Cinemachine Cameras")]
19+
public CinemachineCamera cinemachineCamera_Main;
20+
public CinemachineCamera cinemachineCamera_Options;
21+
public CinemachineCamera cinemachineCamera_Credits;
22+
23+
[Header("Spaceship Animation")]
24+
public GameObject spaceShip;
25+
public float shipDuration = 5f;
26+
public Vector3 shipStartPosition;
27+
public Vector3 targetPosition;
28+
29+
[Header("System References")]
30+
public Settings settings;
31+
private GameBootstrap gameBootstrap;
32+
33+
private void Awake()
34+
{
35+
gameBootstrap = GetComponent<GameBootstrap>();
36+
}
37+
38+
private void Start()
39+
{
40+
if (spaceShip != null)
41+
{
42+
spaceShip.transform.position = shipStartPosition;
43+
}
44+
45+
SwitchToCamera(CameraState.Main);
46+
}
47+
48+
private void Update()
49+
{
50+
if (sunTransform != null)
51+
{
52+
sunTransform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime);
53+
}
54+
55+
if (planetTransform != null)
56+
{
57+
planetTransform.Rotate(Vector3.up, planetRotationSpeed * Time.deltaTime);
58+
}
59+
}
60+
61+
public enum CameraState { Main, Options, Credits }
62+
63+
public void SwitchToCamera(CameraState state)
64+
{
65+
cinemachineCamera_Main.Priority = 0;
66+
cinemachineCamera_Options.Priority = 0;
67+
cinemachineCamera_Credits.Priority = 0;
68+
69+
switch (state)
70+
{
71+
case CameraState.Main:
72+
cinemachineCamera_Main.Priority = 10;
73+
break;
74+
case CameraState.Options:
75+
cinemachineCamera_Options.Priority = 10;
76+
break;
77+
case CameraState.Credits:
78+
cinemachineCamera_Credits.Priority = 10;
79+
break;
80+
}
81+
}
82+
83+
public void StartGameAsHost()
84+
{
85+
StartCoroutine(LaunchSequence(() => gameBootstrap.StartHost()));
86+
}
87+
88+
public void StartGameAsClient()
89+
{
90+
StartCoroutine(LaunchSequence(() => gameBootstrap.StartClient()));
91+
}
92+
93+
private IEnumerator LaunchSequence(System.Action onComplete)
94+
{
95+
if (cinemachineCamera_Main != null && spaceShip != null)
96+
{
97+
cinemachineCamera_Main.Target.TrackingTarget = spaceShip.transform;
98+
}
99+
100+
Vector3 initialPosition = spaceShip.transform.position;
101+
float elapsed = 0f;
102+
103+
while (elapsed < shipDuration)
104+
{
105+
if (spaceShip != null)
106+
{
107+
spaceShip.transform.position = Vector3.Lerp(initialPosition, targetPosition, elapsed / shipDuration);
108+
}
109+
elapsed += Time.deltaTime;
110+
yield return null;
111+
}
112+
113+
if (spaceShip != null)
114+
{
115+
spaceShip.transform.position = targetPosition;
116+
}
117+
118+
onComplete?.Invoke();
119+
}
120+
121+
public void ApplyAudioSettings(float masterVol, float musicVol)
122+
{
123+
AudioListener.volume = masterVol / 100f;
124+
125+
if (settings != null)
126+
{
127+
settings.masterVolume = masterVol;
128+
settings.musicVolume = musicVol;
129+
}
130+
}
131+
132+
public void ApplyVideoSettings(bool isFullscreen)
133+
{
134+
Screen.fullScreen = isFullscreen;
135+
136+
if (settings != null)
137+
{
138+
settings.isFullscreen = isFullscreen;
139+
}
140+
}
141+
}
142+
}
File renamed without changes.

Red Strike/Assets/PlanetAtmosphereSystem/AtmosphereMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Material:
4747
- _GunesYonu: {r: -0.91, g: 0.4, b: 3.24, a: 0}
4848
- _RenkUzak: {r: 0, g: 0.10166844, b: 2.152374, a: 1}
4949
- _RenkYakin: {r: 0, g: 5.670685, b: 8, a: 1}
50-
- _SunDirection: {r: 0.053725094, g: 0.9509352, b: -0.30468985, a: 0}
50+
- _SunDirection: {r: -0.05539332, g: -0.9330967, b: 0.35533378, a: 0}
5151
m_BuildTextureStacks: []
5252
m_AllowLocking: 1
5353
--- !u!114 &1522106816477559216

Red Strike/Assets/PlanetAtmosphereSystem/CloudMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Material:
4343
m_Colors:
4444
- _Color: {r: 0, g: 3.8274493, b: 5.992155, a: 1}
4545
- _GunesYonu: {r: -1, g: 0, b: 0, a: 0}
46-
- _SunDirection: {r: 0.053725094, g: 0.9509352, b: -0.30468985, a: 0}
46+
- _SunDirection: {r: -0.05539332, g: -0.9330967, b: 0.35533378, a: 0}
4747
m_BuildTextureStacks: []
4848
m_AllowLocking: 1
4949
--- !u!114 &8499732345945835446

Red Strike/Assets/PlanetAtmosphereSystem/FogMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ Material:
5454
- _QueueControl: 0
5555
- _QueueOffset: 0
5656
m_Colors:
57-
- _SunDirection: {r: 0.053725094, g: 0.9509352, b: -0.30468985, a: 0}
57+
- _SunDirection: {r: -0.05539332, g: -0.9330967, b: 0.35533378, a: 0}
5858
m_BuildTextureStacks: []
5959
m_AllowLocking: 1

Red Strike/Assets/Scenes/Menu.unity

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ GameObject:
218218
- component: {fileID: 312053530}
219219
- component: {fileID: 312053529}
220220
m_Layer: 0
221-
m_Name: CinemachineCamera_C
221+
m_Name: CinemachineCamera_Credits
222222
m_TagString: Untagged
223223
m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0}
224224
m_NavMeshLayer: 0
@@ -324,7 +324,7 @@ GameObject:
324324
- component: {fileID: 656923634}
325325
- component: {fileID: 656923636}
326326
m_Layer: 0
327-
m_Name: CinemachineCamera_A
327+
m_Name: CinemachineCamera_Main
328328
m_TagString: Untagged
329329
m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0}
330330
m_NavMeshLayer: 0
@@ -721,6 +721,8 @@ GameObject:
721721
- component: {fileID: 1693417821}
722722
- component: {fileID: 1693417824}
723723
- component: {fileID: 1693417825}
724+
- component: {fileID: 1693417826}
725+
- component: {fileID: 1693417827}
724726
m_Layer: 0
725727
m_Name: GameManager
726728
m_TagString: Untagged
@@ -744,11 +746,11 @@ MonoBehaviour:
744746
rotationSpeed: 50
745747
planetTransform: {fileID: 548609336}
746748
planetRotationSpeed: 5
747-
cinemachineCamera_A: {fileID: 656923634}
748-
cinemachineCamera_B: {fileID: 2037435840}
749-
cinemachineCamera_C: {fileID: 312053529}
749+
cinemachineCamera_Main: {fileID: 656923634}
750+
cinemachineCamera_Options: {fileID: 2037435840}
751+
cinemachineCamera_Credits: {fileID: 312053529}
750752
spaceShip: {fileID: 2738940240077496202}
751-
shipDuraction: 8
753+
shipDuration: 5
752754
shipStartPosition: {x: 2.24, y: -0.6, z: -19}
753755
targetPosition: {x: 2.24, y: -0.6, z: -9.72}
754756
settings: {fileID: 11400000, guid: e041f970da61a87429a66823e0614072, type: 2}
@@ -817,6 +819,31 @@ MonoBehaviour:
817819
blendDistance: 0
818820
weight: 1
819821
sharedProfile: {fileID: 11400000, guid: 10fc4df2da32a41aaa32d77bc913491c, type: 2}
822+
--- !u!114 &1693417826
823+
MonoBehaviour:
824+
m_ObjectHideFlags: 0
825+
m_CorrespondingSourceObject: {fileID: 0}
826+
m_PrefabInstance: {fileID: 0}
827+
m_PrefabAsset: {fileID: 0}
828+
m_GameObject: {fileID: 1693417820}
829+
m_Enabled: 1
830+
m_EditorHideFlags: 0
831+
m_Script: {fileID: 11500000, guid: 070f9b94623cc914aa10c7ad1890f720, type: 3}
832+
m_Name:
833+
m_EditorClassIdentifier:
834+
currentUser: {fileID: 11400000, guid: 2b46c82990ed440479c1d114012f1ce9, type: 2}
835+
--- !u!114 &1693417827
836+
MonoBehaviour:
837+
m_ObjectHideFlags: 0
838+
m_CorrespondingSourceObject: {fileID: 0}
839+
m_PrefabInstance: {fileID: 0}
840+
m_PrefabAsset: {fileID: 0}
841+
m_GameObject: {fileID: 1693417820}
842+
m_Enabled: 1
843+
m_EditorHideFlags: 0
844+
m_Script: {fileID: 11500000, guid: 5683203e1a8eca74da158ac5b1208cae, type: 3}
845+
m_Name:
846+
m_EditorClassIdentifier:
820847
--- !u!1 &1877737717
821848
GameObject:
822849
m_ObjectHideFlags: 0
@@ -986,7 +1013,7 @@ GameObject:
9861013
- component: {fileID: 2037435841}
9871014
- component: {fileID: 2037435840}
9881015
m_Layer: 0
989-
m_Name: CinemachineCamera_B
1016+
m_Name: CinemachineCamera_Options
9901017
m_TagString: Untagged
9911018
m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0}
9921019
m_NavMeshLayer: 0

0 commit comments

Comments
 (0)