Skip to content

Commit a5cda2d

Browse files
committed
Add faction selection UI and logic to user system
Implemented faction selection in the user profile, including new UI elements and navigation for selecting factions. Added faction images and metadata, updated user data structure to support selected and available factions, and enhanced the main menu controller and user manager to handle faction changes. Also adjusted UI Toolkit settings and improved default panel scaling and resolution.
1 parent 0262d62 commit a5cda2d

20 files changed

+718
-40
lines changed

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.030348197, g: 0.9846097, b: -0.17211302, a: 0}
50+
- _SunDirection: {r: -0.16355523, g: -0.0064900084, b: 0.98651296, 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.030348197, g: 0.9846097, b: -0.17211302, a: 0}
46+
- _SunDirection: {r: -0.16355523, g: -0.0064900084, b: 0.98651296, 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.030348197, g: 0.9846097, b: -0.17211302, a: 0}
57+
- _SunDirection: {r: -0.16355523, g: -0.0064900084, b: 0.98651296, a: 0}
5858
m_BuildTextureStacks: []
5959
m_AllowLocking: 1

Red Strike/Assets/UI Toolkit/PanelSettings.asset

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ MonoBehaviour:
1717
m_TargetTexture: {fileID: 0}
1818
m_RenderMode: 0
1919
m_WorldSpaceLayer: 0
20-
m_ScaleMode: 1
20+
m_ScaleMode: 2
2121
m_ReferenceSpritePixelsPerUnit: 100
2222
m_PixelsPerUnit: 100
2323
m_Scale: 1
2424
m_ReferenceDpi: 96
2525
m_FallbackDpi: 96
26-
m_ReferenceResolution: {x: 1200, y: 800}
26+
m_ReferenceResolution: {x: 1920, y: 1080}
2727
m_ScreenMatchMode: 0
28-
m_Match: 0
28+
m_Match: 0.5
2929
m_SortingOrder: 0
3030
m_TargetDisplay: 0
3131
m_BindingLogLevel: 0
@@ -46,4 +46,4 @@ MonoBehaviour:
4646
m_SpriteShader: {fileID: 19012, guid: 0000000000000000f000000000000000, type: 0}
4747
m_ICUDataAsset: {fileID: 0}
4848
forceGammaRendering: 0
49-
textSettings: {fileID: 0}
49+
textSettings: {fileID: 11400000, guid: 073cf6e744fa0fb46b667f1e735cef71, type: 2}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 19103, guid: 0000000000000000e000000000000000, type: 0}
13+
m_Name: UITK Text Settings
14+
m_EditorClassIdentifier:
15+
m_Version:
16+
m_DefaultFontAsset: {fileID: 0}
17+
m_DefaultFontAssetPath: Fonts & Materials/
18+
m_FallbackFontAssets: []
19+
m_MatchMaterialPreset: 0
20+
m_MissingCharacterUnicode: 0
21+
m_ClearDynamicDataOnBuild: 1
22+
m_EnableEmojiSupport: 0
23+
m_EmojiFallbackTextAssets: []
24+
m_DefaultSpriteAsset: {fileID: 0}
25+
m_DefaultSpriteAssetPath: Sprite Assets/
26+
m_FallbackSpriteAssets: []
27+
m_MissingSpriteCharacterUnicode: 0
28+
m_DefaultStyleSheet: {fileID: 0}
29+
m_StyleSheetsResourcePath: Text Style Sheets/
30+
m_DefaultColorGradientPresetsPath: Text Color Gradients/
31+
m_UnicodeLineBreakingRules:
32+
m_UnicodeLineBreakingRules: {fileID: 0}
33+
m_LeadingCharacters: {fileID: 4900000, guid: d82c1b31c7e74239bff1220585707d2b, type: 3}
34+
m_FollowingCharacters: {fileID: 4900000, guid: fade42e8bc714b018fac513c043d323b, type: 3}
35+
m_UseModernHangulLineBreakingRules: 0
36+
m_DisplayWarnings: 0

Red Strike/Assets/UI Toolkit/UITK Text Settings.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/UISystem/MainMenuHUDController.cs

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class MainMenuHUDController : MonoBehaviour
3535
private TextField inputSessionName;
3636
private Label lobbyStatusLabel;
3737
private Image avatarImage;
38+
private Image factionIcon;
39+
private Label factionNameLabel;
40+
private Label factionDescLabel;
3841

3942
// Buton Referansları
4043
private Button btnPlay, btnOptions, btnQuit;
@@ -44,6 +47,7 @@ public class MainMenuHUDController : MonoBehaviour
4447
private Button btnConfirmQuit, btnCancelQuit;
4548
private Button btnLogin;
4649
private Button btnAvatarNext, btnAvatarPrev;
50+
private Button btnFactionNext, btnFactionPrev;
4751

4852
private void Awake()
4953
{
@@ -121,6 +125,9 @@ private void BindUIElements()
121125
inputSessionName = root.Q<TextField>("input-session-name");
122126
lobbyStatusLabel = root.Q<Label>("lobby-status-label");
123127
avatarImage = root.Q<Image>("current-avatar-image");
128+
factionIcon = root.Q<Image>("faction-icon");
129+
factionNameLabel = root.Q<Label>("faction-name-label");
130+
factionDescLabel = root.Q<Label>("faction-desc-label");
124131

125132
// Butonlar
126133
btnPlay = root.Q<Button>("btn-play");
@@ -145,6 +152,9 @@ private void BindUIElements()
145152

146153
btnAvatarNext = root.Q<Button>("btn-avatar-next");
147154
btnAvatarPrev = root.Q<Button>("btn-avatar-prev");
155+
156+
btnFactionNext = root.Q<Button>("btn-faction-next");
157+
btnFactionPrev = root.Q<Button>("btn-faction-prev");
148158
}
149159

150160
private void RegisterEvents()
@@ -171,6 +181,9 @@ private void RegisterEvents()
171181

172182
if (btnAvatarNext != null) btnAvatarNext.clicked += OnAvatarNext;
173183
if (btnAvatarPrev != null) btnAvatarPrev.clicked += OnAvatarPrev;
184+
185+
if (btnFactionNext != null) btnFactionNext.clicked += OnFactionNext;
186+
if (btnFactionPrev != null) btnFactionPrev.clicked += OnFactionPrev;
174187
}
175188

176189
private void UnregisterEvents()
@@ -194,12 +207,21 @@ private void UnregisterEvents()
194207

195208
if (btnAvatarNext != null) btnAvatarNext.clicked -= OnAvatarNext;
196209
if (btnAvatarPrev != null) btnAvatarPrev.clicked -= OnAvatarPrev;
210+
211+
if (btnFactionNext != null) btnFactionNext.clicked -= OnFactionNext;
212+
if (btnFactionPrev != null) btnFactionPrev.clicked -= OnFactionPrev;
197213
}
198214

199215
private void SetDefaultValues()
200216
{
201-
if (userManager == null || userManager.currentUser == null || avatarImage == null) return;
202-
avatarImage.sprite = userManager.currentUser.avatar;
217+
if (userManager == null || userManager.currentUser == null) return;
218+
219+
if (avatarImage != null && userManager.currentUser.avatar != null)
220+
{
221+
avatarImage.sprite = userManager.currentUser.avatar;
222+
}
223+
224+
UpdateFactionUI();
203225
}
204226

205227
#endregion
@@ -210,7 +232,7 @@ private void ShowPanel(VisualElement panel)
210232
{
211233
if (panel != null)
212234
panel.style.display = DisplayStyle.Flex;
213-
235+
214236
mainMenu?.PlaySound(MainMenu.AudioClipType.ButtonClick1);
215237
}
216238

@@ -225,6 +247,9 @@ private void HidePanel(VisualElement panel)
225247
private void OnAvatarNext() => OnAvatarChanged(AvatarChangeDirection.Next);
226248
private void OnAvatarPrev() => OnAvatarChanged(AvatarChangeDirection.Previous);
227249

250+
private void OnFactionNext() => OnFactionChanged(FactionSelectionDirection.Next);
251+
private void OnFactionPrev() => OnFactionChanged(FactionSelectionDirection.Previous);
252+
228253
#endregion
229254

230255
#region LOGIC METHODS
@@ -425,6 +450,47 @@ private void OnAvatarChanged(AvatarChangeDirection direction)
425450
avatarImage.MarkDirtyRepaint();
426451
}
427452

453+
public enum FactionSelectionDirection { Previous, Next }
454+
455+
private void OnFactionChanged(FactionSelectionDirection direction)
456+
{
457+
mainMenu?.PlaySound(MainMenu.AudioClipType.ButtonClick2);
458+
459+
if (userManager == null || userManager.currentUser == null) return;
460+
if (userManager.currentUser.factionSelections == null || userManager.currentUser.factionSelections.Count == 0) return;
461+
462+
int currentIndex = userManager.GetCurrentFactionIndex();
463+
int count = userManager.currentUser.factionSelections.Count;
464+
465+
int newIndex = currentIndex;
466+
if (direction == FactionSelectionDirection.Next)
467+
newIndex = (currentIndex + 1) % count;
468+
else
469+
newIndex = (currentIndex - 1 + count) % count;
470+
471+
userManager.UpdateFactionSelection(newIndex);
472+
UpdateFactionUI();
473+
}
474+
475+
private void UpdateFactionUI()
476+
{
477+
if (userManager == null || userManager.currentUser == null) return;
478+
if (userManager.currentUser.selectedFaction == null)
479+
{
480+
if (userManager.currentUser.factionSelections != null && userManager.currentUser.factionSelections.Count > 0)
481+
{
482+
userManager.UpdateFactionSelection(0);
483+
}
484+
else return;
485+
}
486+
487+
var info = userManager.currentUser.selectedFaction.GetFactionInfo();
488+
489+
if (factionIcon != null) factionIcon.sprite = info.factionLogo;
490+
if (factionNameLabel != null) factionNameLabel.text = info.factionName;
491+
if (factionDescLabel != null) factionDescLabel.text = info.factionDescription;
492+
}
493+
428494
private void QuitGame()
429495
{
430496
Application.Quit();

Red Strike/Assets/UISystem/Templates/SettingsPanel.uxml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ui:UXML xmlns:ui="UnityEngine.UIElements">
2-
<ui:VisualElement name="settings-overlay" class="overlay-container" style="display: flex;">
2+
<ui:VisualElement name="settings-overlay" class="overlay-container" style="display: none;">
33

44
<ui:VisualElement class="settings-box">
55

@@ -15,8 +15,8 @@
1515
<!-- CONTENT AREA -->
1616
<ui:VisualElement class="settings-content-area">
1717

18-
<!-- TAB 1: GAMEPLAY (Dokunulmadı) -->
19-
<ui:VisualElement name="content-gameplay" style="display: none;">
18+
<!-- TAB 1: GAMEPLAY -->
19+
<ui:VisualElement name="content-gameplay" style="display: flex;">
2020
<ui:Label text="AUDIO &amp; VIDEO" style="color: #888; margin-bottom: 20px;" />
2121
<ui:VisualElement class="row">
2222
<ui:Label text="MASTER VOLUME" class="setting-label" />
@@ -32,8 +32,8 @@
3232
</ui:VisualElement>
3333
</ui:VisualElement>
3434

35-
<!-- TAB 2: USER PROFILE (DÜZELTİLDİ) -->
36-
<ui:VisualElement name="content-user" style="display: flex;">
35+
<!-- TAB 2: USER PROFILE -->
36+
<ui:VisualElement name="content-user" style="display: none;">
3737
<ui:Label text="ACCOUNT SETTINGS" style="color: #888; margin-bottom: 20px;" />
3838

3939
<!-- Satır 1: Username -->
@@ -46,37 +46,25 @@
4646
<ui:VisualElement class="row">
4747
<ui:Label text="AVATAR" class="setting-label" />
4848
<ui:VisualElement class="avatar-selector" style="flex-direction: row; align-items: center;">
49-
<ui:Button name="btn-avatar-prev" class="arrow-btn" text="&lt;" style="font-size: 24px; width: 40px; height: 40px;" />
49+
<ui:Button name="btn-avatar-prev" class="arrow-btn" text="" style="font-size: 24px; width: 40px; height: 40px;" />
5050
<ui:VisualElement name="current-avatar-container" style="margin-left: 10px; margin-right: 10px; flex-direction: column; align-items: center;">
5151
<ui:Image name="current-avatar-image" style="width: 64px; height: 64px; border-width: 2px; border-color: cyan;" />
5252
</ui:VisualElement>
53-
<ui:Button name="btn-avatar-next" class="arrow-btn" text="&gt;" style="font-size: 24px; width: 40px; height: 40px;" />
53+
<ui:Button name="btn-avatar-next" class="arrow-btn" text="" style="font-size: 24px; width: 40px; height: 40px;" />
5454
</ui:VisualElement>
5555
</ui:VisualElement>
5656

57-
<!-- Satır 3: FACTION SELECTOR (YENİ VE DÜZGÜN YAPI) -->
58-
<!-- Artık .row yerine .faction-row kullanıyoruz -->
57+
<!-- Satır 3: Faction Selector -->
5958
<ui:VisualElement class="faction-row">
60-
61-
<!-- Sol Taraf: Etiket -->
6259
<ui:Label text="SELECT FACTION" class="setting-label" style="width: 150px; white-space: normal;" />
63-
64-
<!-- Sağ Taraf: Seçim Mekanizması -->
6560
<ui:VisualElement class="faction-selector-container">
66-
67-
<!-- Sol Büyük Ok -->
68-
<ui:Button name="btn-faction-prev" text="&lt;" class="faction-nav-btn" />
69-
70-
<!-- Orta Kart -->
61+
<ui:Button name="btn-faction-prev" text="◀" class="faction-nav-btn" />
7162
<ui:VisualElement name="current-faction-container" class="faction-card">
7263
<ui:Image name="faction-icon" class="faction-card-icon" />
7364
<ui:Label name="faction-name-label" text="THE IRON LEGION" class="faction-card-title" />
7465
<ui:Label name="faction-desc-label" text="Heavy armor and defensive tactics dominate the battlefield." class="faction-card-desc" />
7566
</ui:VisualElement>
76-
77-
<!-- Sağ Büyük Ok -->
78-
<ui:Button name="btn-faction-next" text="&gt;" class="faction-nav-btn" />
79-
67+
<ui:Button name="btn-faction-next" text="▶" class="faction-nav-btn" />
8068
</ui:VisualElement>
8169
</ui:VisualElement>
8270

Red Strike/Assets/UserSystem/FactionImages.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.38 MB
Loading

0 commit comments

Comments
 (0)