You've already forked Darklings-FightingGame
mirror of
https://github.com/izzy2lost/Darklings-FightingGame.git
synced 2026-03-10 11:35:19 -07:00
61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using Demonics.UI;
|
|
using System;
|
|
using System.Text;
|
|
using TMPro;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
public class OnlineClientMenu : BaseMenu
|
|
{
|
|
[SerializeField] private TMP_InputField _roomIdInputField = default;
|
|
[SerializeField] private TMP_InputField _playerNameInputField = default;
|
|
[SerializeField] private BaseSelector _characterSelector = default;
|
|
[SerializeField] private BaseSelector _assistSelector = default;
|
|
[SerializeField] private BaseSelector _colorSelector = default;
|
|
[SerializeField] private BaseMenu _onlineHostMenu = default;
|
|
private string _cachedRoomIdText = "";
|
|
|
|
|
|
void OnDisable()
|
|
{
|
|
_cachedRoomIdText = "";
|
|
_roomIdInputField.text = "";
|
|
}
|
|
|
|
public void Client()
|
|
{
|
|
string connectionPayload = JsonUtility.ToJson(new ConnectionPayload()
|
|
{
|
|
//RoomId = _roomIdInputField.text,
|
|
RoomId = "abc",
|
|
PlayerName = _playerNameInputField.text,
|
|
Character = _characterSelector.Value,
|
|
Assist = _assistSelector.Value,
|
|
Color = _colorSelector.Value,
|
|
|
|
});
|
|
byte[] payloadBytes = Encoding.UTF8.GetBytes(connectionPayload);
|
|
NetworkManager.Singleton.NetworkConfig.ConnectionData = payloadBytes;
|
|
NetworkManager.Singleton.StartClient();
|
|
OpenMenuHideCurrent(_onlineHostMenu);
|
|
}
|
|
|
|
public void CheckRoomIdInputField(string field)
|
|
{
|
|
if (_cachedRoomIdText.Length < field.Length)
|
|
{
|
|
if (field.Length == 4 || field.Length == 9)
|
|
{
|
|
_roomIdInputField.text += "-";
|
|
_roomIdInputField.MoveToEndOfLine(false, false);
|
|
}
|
|
}
|
|
_cachedRoomIdText = field;
|
|
}
|
|
|
|
public void Paste()
|
|
{
|
|
_roomIdInputField.text = GUIUtility.systemCopyBuffer;
|
|
}
|
|
}
|