Adding a ton of materials and textures, and adding terrain!
This commit is contained in:
parent
3568936359
commit
a911d0f13e
784 changed files with 32877 additions and 707 deletions
|
|
@ -48,6 +48,10 @@ namespace TD.UI
|
|||
private Button joinButton;
|
||||
private Button quitButton;
|
||||
private Button quickStartButton;
|
||||
private VisualElement hostPanel;
|
||||
private TextField hostPortField;
|
||||
private Button hostConfirmButton;
|
||||
private Button hostCancelButton;
|
||||
private VisualElement joinPanel;
|
||||
private TextField joinAddressField;
|
||||
private TextField joinPortField;
|
||||
|
|
@ -109,6 +113,42 @@ namespace TD.UI
|
|||
buttonColumn.Add(quitButton);
|
||||
buttonColumn.Add(quickStartButton);
|
||||
|
||||
// Host sub-panel — hidden until Host is clicked. Holds the port field
|
||||
// and the Start Host / Cancel buttons.
|
||||
hostPanel = new VisualElement();
|
||||
hostPanel.style.flexDirection = FlexDirection.Column;
|
||||
hostPanel.style.alignItems = Align.Center;
|
||||
hostPanel.style.marginTop = 24;
|
||||
hostPanel.style.paddingTop = 16;
|
||||
hostPanel.style.paddingBottom = 16;
|
||||
hostPanel.style.paddingLeft = 24;
|
||||
hostPanel.style.paddingRight = 24;
|
||||
hostPanel.style.backgroundColor = new Color(0f, 0f, 0f, 0.4f);
|
||||
hostPanel.style.display = DisplayStyle.None;
|
||||
root.Add(hostPanel);
|
||||
|
||||
hostPortField = new TextField("Port");
|
||||
hostPortField.value = defaultPort.ToString();
|
||||
hostPortField.style.width = 280;
|
||||
StyleJoinFieldText(hostPortField);
|
||||
hostPanel.Add(hostPortField);
|
||||
|
||||
var hostButtons = new VisualElement();
|
||||
hostButtons.style.flexDirection = FlexDirection.Row;
|
||||
hostButtons.style.marginTop = 12;
|
||||
hostPanel.Add(hostButtons);
|
||||
|
||||
hostConfirmButton = new Button(OnHostConfirmClicked) { text = "Start Host" };
|
||||
hostConfirmButton.style.minWidth = 120;
|
||||
hostConfirmButton.style.height = 32;
|
||||
hostConfirmButton.style.marginRight = 8;
|
||||
hostButtons.Add(hostConfirmButton);
|
||||
|
||||
hostCancelButton = new Button(OnHostCancelClicked) { text = "Cancel" };
|
||||
hostCancelButton.style.minWidth = 120;
|
||||
hostCancelButton.style.height = 32;
|
||||
hostButtons.Add(hostCancelButton);
|
||||
|
||||
// Join sub-panel — hidden until Join is clicked. Holds the IP+port
|
||||
// fields and the Connect / Cancel buttons.
|
||||
joinPanel = new VisualElement();
|
||||
|
|
@ -187,19 +227,37 @@ namespace TD.UI
|
|||
|
||||
private void OnHostClicked()
|
||||
{
|
||||
statusLabel.text = "Starting host…";
|
||||
if (!NetworkBootstrap.StartHost(defaultPort))
|
||||
hostPanel.style.display = hostPanel.style.display == DisplayStyle.None
|
||||
? DisplayStyle.Flex
|
||||
: DisplayStyle.None;
|
||||
}
|
||||
|
||||
private void OnHostConfirmClicked()
|
||||
{
|
||||
ushort port = defaultPort;
|
||||
if (!string.IsNullOrWhiteSpace(hostPortField.value)
|
||||
&& ushort.TryParse(hostPortField.value.Trim(), out var parsed))
|
||||
{
|
||||
port = parsed;
|
||||
}
|
||||
|
||||
statusLabel.text = $"Starting host on port {port}…";
|
||||
if (!NetworkBootstrap.StartHost(port))
|
||||
{
|
||||
statusLabel.text = "Failed to start host. Check the console.";
|
||||
return;
|
||||
}
|
||||
|
||||
// After StartHost the local peer is the server + client. Trigger
|
||||
// the networked scene load to take everyone to the Lobby. NGO
|
||||
// replicates this to any future-joining clients automatically.
|
||||
hostPanel.style.display = DisplayStyle.None;
|
||||
NetworkBootstrap.LoadSceneAsHost(SceneNames.Lobby);
|
||||
}
|
||||
|
||||
private void OnHostCancelClicked()
|
||||
{
|
||||
hostPanel.style.display = DisplayStyle.None;
|
||||
statusLabel.text = string.Empty;
|
||||
}
|
||||
|
||||
private void OnJoinClicked()
|
||||
{
|
||||
// Toggle the join sub-panel.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue