Compare commits
No commits in common. 'd5d654fa7917fae38d5fdb66ee73c05b6890f1e5' and '741bb7fbc043c2172e7f9a92e5085bcff3ec9dfb' have entirely different histories.
d5d654fa79
...
741bb7fbc0
42 changed files with 248 additions and 405 deletions
@ -0,0 +1,105 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using UnityEngine.Serialization; |
||||||
|
|
||||||
|
[ExecuteInEditMode] |
||||||
|
public class Dimensions : MonoBehaviour { |
||||||
|
|
||||||
|
public static Dimensions Singleton; |
||||||
|
|
||||||
|
public bool isUpdating; |
||||||
|
|
||||||
|
[FormerlySerializedAs("panelHeightPixels")] |
||||||
|
[Tooltip("Player panels height")] |
||||||
|
public float panelHeightPixelsMinimum; |
||||||
|
|
||||||
|
[Tooltip("Size in Unity units")] |
||||||
|
public Vector2 playGroundSize; |
||||||
|
|
||||||
|
[Tooltip("Height of the empty space between board and death zone")] |
||||||
|
public float emptySpaceHeight; |
||||||
|
|
||||||
|
|
||||||
|
public Camera mainCamera; |
||||||
|
public EdgeCollider2D topC, bottomC, leftC, rightC; |
||||||
|
public SpriteRenderer playGround; |
||||||
|
public SpriteRenderer playerPanelTop; |
||||||
|
public SpriteRenderer playerPanelBottom; |
||||||
|
public SpriteRenderer background; |
||||||
|
|
||||||
|
private LineRenderer topL, bottomL; |
||||||
|
|
||||||
|
public Vector2 PlaySize { get; private set; } |
||||||
|
|
||||||
|
public Vector2 PlaySizeBoards { get; private set; } |
||||||
|
|
||||||
|
public float PanelHeightPixels { get; private set; } |
||||||
|
|
||||||
|
private void Awake() { |
||||||
|
Singleton = this; |
||||||
|
GetComponents(); |
||||||
|
SetDimensions(); |
||||||
|
if (Application.isPlaying) |
||||||
|
isUpdating = false; |
||||||
|
} |
||||||
|
|
||||||
|
private void Update() { |
||||||
|
if (!isUpdating) |
||||||
|
return; |
||||||
|
SetDimensions(); |
||||||
|
} |
||||||
|
|
||||||
|
private void GetComponents() { |
||||||
|
topL = topC.GetComponent<LineRenderer>(); |
||||||
|
bottomL = bottomC.GetComponent<LineRenderer>(); |
||||||
|
} |
||||||
|
|
||||||
|
private void SetDimensions() { |
||||||
|
var heightByPanels = 1 / (1 - 2 * panelHeightPixelsMinimum / mainCamera.pixelHeight) * playGroundSize.y; |
||||||
|
var heightByPlayground = playGroundSize.x / mainCamera.aspect; |
||||||
|
var height = Mathf.Max(heightByPanels, heightByPlayground); |
||||||
|
var width = mainCamera.aspect * height; |
||||||
|
var panelHeight = (height - playGroundSize.y) / 2; |
||||||
|
|
||||||
|
mainCamera.orthographicSize = height / 2; |
||||||
|
|
||||||
|
var top = playGroundSize.y / 2; |
||||||
|
var right = playGroundSize.x / 2; |
||||||
|
|
||||||
|
PanelHeightPixels = panelHeight / height * mainCamera.pixelHeight; |
||||||
|
PlaySize = playGroundSize; |
||||||
|
PlaySizeBoards = playGroundSize - new Vector2(0, emptySpaceHeight * 2); |
||||||
|
|
||||||
|
Vector2 v1 = new Vector3(-right, 0); |
||||||
|
Vector2 v2 = new Vector3(right, 0); |
||||||
|
Vector2 v3 = new Vector3(0, top); |
||||||
|
Vector2 v4 = new Vector3(0, -top); |
||||||
|
|
||||||
|
topC.transform.position = new Vector2(0, top); |
||||||
|
bottomC.transform.position = new Vector2(0, -top); |
||||||
|
leftC.transform.position = new Vector2(-right, 0); |
||||||
|
rightC.transform.position = new Vector2(right, 0); |
||||||
|
topC.points = new[] {v1, v2}; |
||||||
|
bottomC.points = new[] {v1, v2}; |
||||||
|
leftC.points = new[] {v3, v4}; |
||||||
|
rightC.points = new[] {v3, v4}; |
||||||
|
|
||||||
|
playGround.transform.rotation = Quaternion.Euler(0, 0, 90); |
||||||
|
playGround.size = new Vector2(playGroundSize.y, playGroundSize.x); |
||||||
|
|
||||||
|
const float lineWidth = 0.5f; |
||||||
|
var offset = Vector3.up * lineWidth / 2; |
||||||
|
|
||||||
|
topL.positionCount = bottomL.positionCount = 2; |
||||||
|
var v12 = new[] {(Vector3) v1 - offset, (Vector3) v2 - offset}; |
||||||
|
topL.SetPositions(v12); |
||||||
|
v12 = new[] {(Vector3) v1 + offset, (Vector3) v2 + offset}; |
||||||
|
bottomL.SetPositions(v12); |
||||||
|
|
||||||
|
playerPanelTop.transform.position = new Vector2(0, (height + PlaySize.y) / 4); |
||||||
|
playerPanelBottom.transform.position = new Vector2(0, -(height + PlaySize.y) / 4); |
||||||
|
|
||||||
|
playerPanelTop.size = playerPanelBottom.size = new Vector2(width, panelHeight); |
||||||
|
|
||||||
|
background.size = new Vector2(width, playGroundSize.y); |
||||||
|
} |
||||||
|
} |
@ -1,107 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
using UnityEngine.Serialization; |
|
||||||
|
|
||||||
namespace Game { |
|
||||||
[ExecuteInEditMode] |
|
||||||
public class Dimensions : MonoBehaviour { |
|
||||||
|
|
||||||
public static Dimensions Singleton; |
|
||||||
|
|
||||||
public bool isUpdating; |
|
||||||
|
|
||||||
[FormerlySerializedAs("panelHeightPixels")] |
|
||||||
[Tooltip("Player panels height")] |
|
||||||
public float panelHeightPixelsMinimum; |
|
||||||
|
|
||||||
[Tooltip("Size in Unity units")] |
|
||||||
public Vector2 playGroundSize; |
|
||||||
|
|
||||||
[Tooltip("Height of the empty space between board and death zone")] |
|
||||||
public float emptySpaceHeight; |
|
||||||
|
|
||||||
|
|
||||||
public Camera mainCamera; |
|
||||||
public EdgeCollider2D topC, bottomC, leftC, rightC; |
|
||||||
public SpriteRenderer playGround; |
|
||||||
public SpriteRenderer playerPanelTop; |
|
||||||
public SpriteRenderer playerPanelBottom; |
|
||||||
public SpriteRenderer background; |
|
||||||
|
|
||||||
private LineRenderer topL, bottomL; |
|
||||||
|
|
||||||
public Vector2 PlaySize { get; private set; } |
|
||||||
|
|
||||||
public Vector2 PlaySizeBoards { get; private set; } |
|
||||||
|
|
||||||
public float PanelHeightPixels { get; private set; } |
|
||||||
|
|
||||||
private void Awake() { |
|
||||||
Singleton = this; |
|
||||||
GetComponents(); |
|
||||||
SetDimensions(); |
|
||||||
if (Application.isPlaying) |
|
||||||
isUpdating = false; |
|
||||||
} |
|
||||||
|
|
||||||
private void Update() { |
|
||||||
if (!isUpdating) |
|
||||||
return; |
|
||||||
SetDimensions(); |
|
||||||
} |
|
||||||
|
|
||||||
private void GetComponents() { |
|
||||||
topL = topC.GetComponent<LineRenderer>(); |
|
||||||
bottomL = bottomC.GetComponent<LineRenderer>(); |
|
||||||
} |
|
||||||
|
|
||||||
private void SetDimensions() { |
|
||||||
var heightByPanels = 1 / (1 - 2 * panelHeightPixelsMinimum / mainCamera.pixelHeight) * playGroundSize.y; |
|
||||||
var heightByPlayground = playGroundSize.x / mainCamera.aspect; |
|
||||||
var height = Mathf.Max(heightByPanels, heightByPlayground); |
|
||||||
var width = mainCamera.aspect * height; |
|
||||||
var panelHeight = (height - playGroundSize.y) / 2; |
|
||||||
|
|
||||||
mainCamera.orthographicSize = height / 2; |
|
||||||
|
|
||||||
var top = playGroundSize.y / 2; |
|
||||||
var right = playGroundSize.x / 2; |
|
||||||
|
|
||||||
PanelHeightPixels = panelHeight / height * mainCamera.pixelHeight; |
|
||||||
PlaySize = playGroundSize; |
|
||||||
PlaySizeBoards = playGroundSize - new Vector2(0, emptySpaceHeight * 2); |
|
||||||
|
|
||||||
Vector2 v1 = new Vector3(-right, 0); |
|
||||||
Vector2 v2 = new Vector3(right, 0); |
|
||||||
Vector2 v3 = new Vector3(0, top); |
|
||||||
Vector2 v4 = new Vector3(0, -top); |
|
||||||
|
|
||||||
topC.transform.position = new Vector2(0, top); |
|
||||||
bottomC.transform.position = new Vector2(0, -top); |
|
||||||
leftC.transform.position = new Vector2(-right, 0); |
|
||||||
rightC.transform.position = new Vector2(right, 0); |
|
||||||
topC.points = new[] {v1, v2}; |
|
||||||
bottomC.points = new[] {v1, v2}; |
|
||||||
leftC.points = new[] {v3, v4}; |
|
||||||
rightC.points = new[] {v3, v4}; |
|
||||||
|
|
||||||
playGround.transform.rotation = Quaternion.Euler(0, 0, 90); |
|
||||||
playGround.size = new Vector2(playGroundSize.y, playGroundSize.x); |
|
||||||
|
|
||||||
const float lineWidth = 0.5f; |
|
||||||
var offset = Vector3.up * lineWidth / 2; |
|
||||||
|
|
||||||
topL.positionCount = bottomL.positionCount = 2; |
|
||||||
var v12 = new[] {(Vector3) v1 - offset, (Vector3) v2 - offset}; |
|
||||||
topL.SetPositions(v12); |
|
||||||
v12 = new[] {(Vector3) v1 + offset, (Vector3) v2 + offset}; |
|
||||||
bottomL.SetPositions(v12); |
|
||||||
|
|
||||||
playerPanelTop.transform.position = new Vector2(0, (height + PlaySize.y) / 4); |
|
||||||
playerPanelBottom.transform.position = new Vector2(0, -(height + PlaySize.y) / 4); |
|
||||||
|
|
||||||
playerPanelTop.size = playerPanelBottom.size = new Vector2(width, panelHeight); |
|
||||||
|
|
||||||
background.size = new Vector2(width, playGroundSize.y); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,76 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
using UnityEngine; |
|
||||||
using UnityEngine.UIElements; |
|
||||||
|
|
||||||
namespace Game { |
|
||||||
public class GameUI : MonoBehaviour { |
|
||||||
|
|
||||||
public delegate void ButtonDown(Side verticalSide, string horizontalSide); |
|
||||||
public delegate void ButtonUp(Side side, string direction); |
|
||||||
public static GameUI Singleton; |
|
||||||
public ButtonDown buttonDown; |
|
||||||
public ButtonUp buttonUp; |
|
||||||
|
|
||||||
private UIDocument document; |
|
||||||
|
|
||||||
private List<VisualElement> PlayerPanels => document.rootVisualElement.Children().Where(e => e.ClassListContains("player_panel")).ToList(); |
|
||||||
|
|
||||||
private void Awake() { |
|
||||||
Singleton = this; |
|
||||||
document = GetComponent<UIDocument>(); |
|
||||||
PreparePlayerPanels(); |
|
||||||
} |
|
||||||
|
|
||||||
public VisualElement PlayerPanel(Side side) { |
|
||||||
return side switch { |
|
||||||
Side.Top => PlayerPanels[0], |
|
||||||
Side.Bottom => PlayerPanels[1], |
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(side), side, null) |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
public static VisualElement AddModification(VisualElement playerPanel, ModificationProperties properties) { |
|
||||||
var listElement = ModsList(playerPanel, properties.type); |
|
||||||
|
|
||||||
VisualElement newElement = new() { |
|
||||||
style = { |
|
||||||
backgroundImage = Background.FromSprite(properties.image) |
|
||||||
} |
|
||||||
}; |
|
||||||
listElement.Add(newElement); |
|
||||||
|
|
||||||
return newElement; |
|
||||||
} |
|
||||||
|
|
||||||
private static VisualElement ModsList(VisualElement player, ModType type) { |
|
||||||
return type switch { |
|
||||||
ModType.Buff => player.Children().First(e => e.ClassListContains("mods_list")), |
|
||||||
ModType.Nerf => player.Children().Last(e => e.ClassListContains("mods_list")), |
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null) |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
private void PreparePlayerPanels() { |
|
||||||
var pixelHeight = Dimensions.Singleton.PanelHeightPixels; |
|
||||||
PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = new Length(pixelHeight, LengthUnit.Pixel); |
|
||||||
|
|
||||||
SetupGoButton(Side.Top, "left"); |
|
||||||
SetupGoButton(Side.Top, "right"); |
|
||||||
SetupGoButton(Side.Bottom, "left"); |
|
||||||
SetupGoButton(Side.Bottom, "right"); |
|
||||||
} |
|
||||||
|
|
||||||
public Label GetGoButton(Side sideVertical, string sideHorizontal) { |
|
||||||
return PlayerPanel(sideVertical).Q<Label>("go_" + sideHorizontal); |
|
||||||
} |
|
||||||
|
|
||||||
private void SetupGoButton(Side sideVertical, string sideHorizontal) { |
|
||||||
var element = GetGoButton(sideVertical, sideHorizontal); |
|
||||||
element.RegisterCallback<PointerDownEvent>(_ => buttonDown(sideVertical, sideHorizontal)); |
|
||||||
element.RegisterCallback<PointerUpEvent>(_ => buttonUp(sideVertical, sideHorizontal)); |
|
||||||
element.RegisterCallback<PointerLeaveEvent>(_ => buttonUp(sideVertical, sideHorizontal)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,7 +1,7 @@ |
|||||||
using System; |
using System; |
||||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||||
|
|
||||||
namespace Global { |
namespace Game { |
||||||
public enum Type { RealOnline, RealOffline, Hybrid, AI, RealOnlineRanked } |
public enum Type { RealOnline, RealOffline, Hybrid, AI, RealOnlineRanked } |
||||||
public enum Difficulty { VeryEasy, Easy, Medium, Hard, VeryHard } |
public enum Difficulty { VeryEasy, Easy, Medium, Hard, VeryHard } |
||||||
[Serializable] |
[Serializable] |
@ -0,0 +1,75 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using Game; |
||||||
|
using UnityEngine; |
||||||
|
using UnityEngine.UIElements; |
||||||
|
|
||||||
|
public class GameUI : MonoBehaviour { |
||||||
|
|
||||||
|
public delegate void ButtonDown(Side verticalSide, string horizontalSide); |
||||||
|
public delegate void ButtonUp(Side side, string direction); |
||||||
|
public static GameUI Singleton; |
||||||
|
public ButtonDown buttonDown; |
||||||
|
public ButtonUp buttonUp; |
||||||
|
|
||||||
|
private UIDocument document; |
||||||
|
|
||||||
|
private List<VisualElement> PlayerPanels => document.rootVisualElement.Children().Where(e => e.ClassListContains("player_panel")).ToList(); |
||||||
|
|
||||||
|
private void Awake() { |
||||||
|
Singleton = this; |
||||||
|
document = GetComponent<UIDocument>(); |
||||||
|
PreparePlayerPanels(); |
||||||
|
} |
||||||
|
|
||||||
|
public VisualElement PlayerPanel(Side side) { |
||||||
|
return side switch { |
||||||
|
Side.Top => PlayerPanels[0], |
||||||
|
Side.Bottom => PlayerPanels[1], |
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(side), side, null) |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
public static VisualElement AddModification(VisualElement playerPanel, ModificationProperties properties) { |
||||||
|
var listElement = ModsList(playerPanel, properties.type); |
||||||
|
|
||||||
|
VisualElement newElement = new() { |
||||||
|
style = { |
||||||
|
backgroundImage = Background.FromSprite(properties.image) |
||||||
|
} |
||||||
|
}; |
||||||
|
listElement.Add(newElement); |
||||||
|
|
||||||
|
return newElement; |
||||||
|
} |
||||||
|
|
||||||
|
private static VisualElement ModsList(VisualElement player, ModType type) { |
||||||
|
return type switch { |
||||||
|
ModType.Buff => player.Children().First(e => e.ClassListContains("mods_list")), |
||||||
|
ModType.Nerf => player.Children().Last(e => e.ClassListContains("mods_list")), |
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null) |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
private void PreparePlayerPanels() { |
||||||
|
var pixelHeight = Dimensions.Singleton.PanelHeightPixels; |
||||||
|
PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = new Length(pixelHeight, LengthUnit.Pixel); |
||||||
|
|
||||||
|
SetupGoButton(Side.Top, "left"); |
||||||
|
SetupGoButton(Side.Top, "right"); |
||||||
|
SetupGoButton(Side.Bottom, "left"); |
||||||
|
SetupGoButton(Side.Bottom, "right"); |
||||||
|
} |
||||||
|
|
||||||
|
public Label GetGoButton(Side sideVertical, string sideHorizontal) { |
||||||
|
return PlayerPanel(sideVertical).Q<Label>("go_" + sideHorizontal); |
||||||
|
} |
||||||
|
|
||||||
|
private void SetupGoButton(Side sideVertical, string sideHorizontal) { |
||||||
|
var element = GetGoButton(sideVertical, sideHorizontal); |
||||||
|
element.RegisterCallback<PointerDownEvent>(_ => buttonDown(sideVertical, sideHorizontal)); |
||||||
|
element.RegisterCallback<PointerUpEvent>(_ => buttonUp(sideVertical, sideHorizontal)); |
||||||
|
element.RegisterCallback<PointerLeaveEvent>(_ => buttonUp(sideVertical, sideHorizontal)); |
||||||
|
} |
||||||
|
} |
@ -1,3 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 93c5f73e1f8b4c8e8bf3fd5441f57118 |
|
||||||
timeCreated: 1682433867 |
|
@ -1,3 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: c8417b25b37d4910b8ba034e65d026fc |
|
||||||
timeCreated: 1682433665 |
|
@ -1,77 +0,0 @@ |
|||||||
using Global; |
|
||||||
using UnityEngine.UIElements; |
|
||||||
|
|
||||||
namespace Menu { |
|
||||||
public class MainMenuUI { |
|
||||||
|
|
||||||
private VisualElement mainMenu, playMenu, settingsMenu; |
|
||||||
public VisualElement Root { get; set; } |
|
||||||
|
|
||||||
public void Show() { |
|
||||||
Root.style.display = DisplayStyle.Flex; |
|
||||||
} |
|
||||||
|
|
||||||
private void Hide() { |
|
||||||
Root.style.display = DisplayStyle.None; |
|
||||||
} |
|
||||||
|
|
||||||
public void ResetAndShow() { |
|
||||||
mainMenu = Root.Q("main_menu"); |
|
||||||
playMenu = Root.Q("play_menu"); |
|
||||||
settingsMenu = Root.Q("settings_menu"); |
|
||||||
|
|
||||||
mainMenu.Q("btn_play").RegisterCallback<ClickEvent>(PlayPressed); |
|
||||||
mainMenu.Q("btn_settings").RegisterCallback<ClickEvent>(SettingsPressed); |
|
||||||
|
|
||||||
playMenu.Q("btn_find").RegisterCallback<ClickEvent>(FindPressed); |
|
||||||
playMenu.Q("btn_host").RegisterCallback<ClickEvent>(HostPressed); |
|
||||||
playMenu.Q("btn_join").RegisterCallback<ClickEvent>(JoinPressed); |
|
||||||
playMenu.Q("btn_bot").RegisterCallback<ClickEvent>(BotPressed); |
|
||||||
playMenu.Q("btn_bots").RegisterCallback<ClickEvent>(BotsPressed); |
|
||||||
|
|
||||||
mainMenu.style.display = DisplayStyle.Flex; |
|
||||||
playMenu.style.display = DisplayStyle.None; |
|
||||||
settingsMenu.style.display = DisplayStyle.None; |
|
||||||
|
|
||||||
Show(); |
|
||||||
} |
|
||||||
|
|
||||||
private void PlayPressed(ClickEvent evt) { |
|
||||||
mainMenu.style.display = DisplayStyle.None; |
|
||||||
playMenu.style.display = DisplayStyle.Flex; |
|
||||||
|
|
||||||
RoomSettings.SpawnRates[Spawnable.Modification] = SpawnRate.Many; |
|
||||||
RoomSettings.SpawnRates[Spawnable.NewBallPermanent] = SpawnRate.Many; |
|
||||||
RoomSettings.SpawnRates[Spawnable.NewBallTemporary] = SpawnRate.Few; |
|
||||||
RoomSettings.SpawnRates[Spawnable.Wormhole] = SpawnRate.Many; |
|
||||||
} |
|
||||||
|
|
||||||
private void SettingsPressed(ClickEvent evt) { |
|
||||||
mainMenu.style.display = DisplayStyle.None; |
|
||||||
settingsMenu.style.display = DisplayStyle.Flex; |
|
||||||
} |
|
||||||
|
|
||||||
private void FindPressed(ClickEvent evt) { } |
|
||||||
|
|
||||||
private void HostPressed(ClickEvent evt) { } |
|
||||||
|
|
||||||
private void JoinPressed(ClickEvent evt) { } |
|
||||||
|
|
||||||
private void BotPressed(ClickEvent evt) { |
|
||||||
RoomSettings.Type = Type.Hybrid; |
|
||||||
|
|
||||||
GoToRoom(); |
|
||||||
} |
|
||||||
|
|
||||||
private void BotsPressed(ClickEvent evt) { |
|
||||||
RoomSettings.Type = Type.AI; |
|
||||||
|
|
||||||
GoToRoom(); |
|
||||||
} |
|
||||||
|
|
||||||
private void GoToRoom() { |
|
||||||
Hide(); |
|
||||||
MainUI.Instance.roomUI.Show(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,3 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 06da811c70ca4fd398fc8155d2783017 |
|
||||||
timeCreated: 1682506834 |
|
@ -1,27 +0,0 @@ |
|||||||
using Game; |
|
||||||
using Global; |
|
||||||
using UnityEngine; |
|
||||||
using UnityEngine.SceneManagement; |
|
||||||
using UnityEngine.UIElements; |
|
||||||
|
|
||||||
namespace Menu { |
|
||||||
public class MainUI : MonoBehaviour { |
|
||||||
|
|
||||||
private VisualElement root; |
|
||||||
public RoomUI roomUI; |
|
||||||
public MainMenuUI mainMenuUI; |
|
||||||
|
|
||||||
public static MainUI Instance { get; private set; } |
|
||||||
|
|
||||||
private void Awake() { |
|
||||||
Instance = this; |
|
||||||
|
|
||||||
root = GetComponent<UIDocument>().rootVisualElement; |
|
||||||
mainMenuUI = new MainMenuUI{Root = root.Q<TemplateContainer>("MainMenu").contentContainer}; |
|
||||||
roomUI = new RoomUI{Root = root.Q("Room")}; |
|
||||||
|
|
||||||
mainMenuUI.ResetAndShow(); |
|
||||||
roomUI.Hide(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,24 +0,0 @@ |
|||||||
using System; |
|
||||||
using UnityEngine; |
|
||||||
using UnityEngine.Serialization; |
|
||||||
using UnityEngine.UIElements; |
|
||||||
|
|
||||||
namespace Menu { |
|
||||||
public class RoomUI { |
|
||||||
public VisualElement Root { get; set; } |
|
||||||
|
|
||||||
public void Show() { |
|
||||||
|
|
||||||
Root.style.display = DisplayStyle.Flex; |
|
||||||
} |
|
||||||
|
|
||||||
public void Hide() { |
|
||||||
Root.style.display = DisplayStyle.None; |
|
||||||
} |
|
||||||
|
|
||||||
private void BackToMainMenu() { |
|
||||||
Hide(); |
|
||||||
MainUI.Instance.mainMenuUI.ResetAndShow(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,3 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 1019f607711d4756a89c2d56e4edfc9b |
|
||||||
timeCreated: 1682433830 |
|
@ -0,0 +1,66 @@ |
|||||||
|
using Game; |
||||||
|
using UnityEngine; |
||||||
|
using UnityEngine.SceneManagement; |
||||||
|
using UnityEngine.UIElements; |
||||||
|
|
||||||
|
public class MenuUI : MonoBehaviour { |
||||||
|
|
||||||
|
private VisualElement mainMenu, playMenu, settingsMenu; |
||||||
|
|
||||||
|
private VisualElement root; |
||||||
|
|
||||||
|
private void OnEnable() { |
||||||
|
root = GetComponent<UIDocument>().rootVisualElement; |
||||||
|
|
||||||
|
mainMenu = root.Q("main_menu"); |
||||||
|
playMenu = root.Q("play_menu"); |
||||||
|
settingsMenu = root.Q("settings_menu"); |
||||||
|
|
||||||
|
mainMenu.Q("btn_play").RegisterCallback<ClickEvent>(PlayPressed); |
||||||
|
mainMenu.Q("btn_settings").RegisterCallback<ClickEvent>(SettingsPressed); |
||||||
|
|
||||||
|
playMenu.Q("btn_find").RegisterCallback<ClickEvent>(FindPressed); |
||||||
|
playMenu.Q("btn_host").RegisterCallback<ClickEvent>(HostPressed); |
||||||
|
playMenu.Q("btn_join").RegisterCallback<ClickEvent>(JoinPressed); |
||||||
|
playMenu.Q("btn_bot").RegisterCallback<ClickEvent>(BotPressed); |
||||||
|
playMenu.Q("btn_bots").RegisterCallback<ClickEvent>(BotsPressed); |
||||||
|
|
||||||
|
// PlayPressed(null); |
||||||
|
// BotPressed(null); |
||||||
|
} |
||||||
|
|
||||||
|
private void PlayPressed(ClickEvent evt) { |
||||||
|
mainMenu.style.display = DisplayStyle.None; |
||||||
|
playMenu.style.display = DisplayStyle.Flex; |
||||||
|
|
||||||
|
RoomSettings.SpawnRates[Spawnable.Modification] = SpawnRate.Many; |
||||||
|
RoomSettings.SpawnRates[Spawnable.NewBallPermanent] = SpawnRate.Many; |
||||||
|
RoomSettings.SpawnRates[Spawnable.NewBallTemporary] = SpawnRate.Few; |
||||||
|
RoomSettings.SpawnRates[Spawnable.Wormhole] = SpawnRate.Many; |
||||||
|
} |
||||||
|
|
||||||
|
private void SettingsPressed(ClickEvent evt) { |
||||||
|
mainMenu.style.display = DisplayStyle.None; |
||||||
|
settingsMenu.style.display = DisplayStyle.Flex; |
||||||
|
} |
||||||
|
|
||||||
|
private void FindPressed(ClickEvent evt) { } |
||||||
|
|
||||||
|
private void HostPressed(ClickEvent evt) { } |
||||||
|
|
||||||
|
private void JoinPressed(ClickEvent evt) { } |
||||||
|
|
||||||
|
private void BotPressed(ClickEvent evt) { |
||||||
|
RoomSettings.Type = Type.Hybrid; |
||||||
|
RoomSettings.AIDifficulty = Difficulty.VeryHard; |
||||||
|
|
||||||
|
SceneManager.LoadScene("Game"); |
||||||
|
} |
||||||
|
|
||||||
|
private void BotsPressed(ClickEvent evt) { |
||||||
|
RoomSettings.Type = Type.AI; |
||||||
|
RoomSettings.AIDifficulty = Difficulty.VeryHard; |
||||||
|
|
||||||
|
SceneManager.LoadScene("Game"); |
||||||
|
} |
||||||
|
} |
@ -1,7 +0,0 @@ |
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> |
|
||||||
<ui:Template name="MainMenu" src="project://database/Assets/UI/MainMenu.uxml?fileID=9197481963319205126&guid=8c18fadf28797192cb95360376cdf508&type=3#MainMenu" /> |
|
||||||
<ui:Template name="Room" src="project://database/Assets/UI/Room.uxml?fileID=9197481963319205126&guid=413eb0fe30f77d6f6a3f14b36a8c5b49&type=3#Room" /> |
|
||||||
<Style src="project://database/Assets/UI/Styles/Main/main.uss?fileID=7433441132597879392&guid=bf06c821ac0da0c7ea35aebdb8b6f154&type=3#main" /> |
|
||||||
<ui:Instance template="MainMenu" name="MainMenu" class="entry" /> |
|
||||||
<ui:Instance template="Room" name="Room" class="entry" style="display: none;" /> |
|
||||||
</ui:UXML> |
|
@ -1,10 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 59c75f243b2251b6aa02eec69db9c6ed |
|
||||||
ScriptedImporter: |
|
||||||
internalIDToNameTable: [] |
|
||||||
externalObjects: {} |
|
||||||
serializedVersion: 2 |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
|
@ -1,6 +0,0 @@ |
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> |
|
||||||
<Style src="project://database/Assets/UI/Styles/global.uss?fileID=7433441132597879392&guid=f6d2ff1ab9bcd826f88710e642615fa6&type=3#global" /> |
|
||||||
<Style src="project://database/Assets/UI/Styles/Main/room.uss?fileID=7433441132597879392&guid=c15d8498d3bc788d5b018c73af37f733&type=3#room" /> |
|
||||||
<Style src="project://database/Assets/UI/Styles/Main/menu.uss?fileID=7433441132597879392&guid=a6abab2f6d20ba823bad41d2081810e9&type=3#menu" /> |
|
||||||
<ui:Button text="Button" display-tooltip-when-elided="true" /> |
|
||||||
</ui:UXML> |
|
@ -1,10 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 413eb0fe30f77d6f6a3f14b36a8c5b49 |
|
||||||
ScriptedImporter: |
|
||||||
internalIDToNameTable: [] |
|
||||||
externalObjects: {} |
|
||||||
serializedVersion: 2 |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
|
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 5f387b1fd1334ee889aa311741a7e062 |
|
||||||
folderAsset: yes |
|
||||||
DefaultImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 2c2eeee4a0183fc06b7b877afcef840d |
|
||||||
folderAsset: yes |
|
||||||
DefaultImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
@ -1,4 +0,0 @@ |
|||||||
.entry { |
|
||||||
width: 100%; |
|
||||||
height: 100%; |
|
||||||
} |
|
@ -1,11 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: bf06c821ac0da0c7ea35aebdb8b6f154 |
|
||||||
ScriptedImporter: |
|
||||||
internalIDToNameTable: [] |
|
||||||
externalObjects: {} |
|
||||||
serializedVersion: 2 |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} |
|
||||||
disableValidation: 0 |
|
@ -1,11 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: c15d8498d3bc788d5b018c73af37f733 |
|
||||||
ScriptedImporter: |
|
||||||
internalIDToNameTable: [] |
|
||||||
externalObjects: {} |
|
||||||
serializedVersion: 2 |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} |
|
||||||
disableValidation: 0 |
|
Loading…
Reference in new issue