This commit is contained in:
2026-04-09 09:34:46 +07:00
parent 8ef5ecbe0f
commit 943cb48056
6 changed files with 2063 additions and 13 deletions

View File

@@ -19,6 +19,7 @@ public struct PlayerInputData : INetworkInput
public class BasicSpawner : MonoBehaviour, INetworkRunnerCallbacks
{
private NetworkRunner _runner;
private string _roomName = "Room1";
public LobbyManager LobbyManager;
[SerializeField] private NetworkPrefabRef _playerPrefab;
@@ -75,11 +76,36 @@ public class BasicSpawner : MonoBehaviour, INetworkRunnerCallbacks
{
if (_runner == null || !_runner.IsRunning)
{
if (GUI.Button(new Rect(10, 10, 250, 40), "Bắt đầu (Auto Host/Client)"))
float width = 400;
float height = 300;
float x = (Screen.width - width) / 2f;
float y = (Screen.height - height) / 2f;
GUI.Box(new Rect(x, y, width, height), "FUSION MULTIPLAYER");
float innerX = x + 20;
float innerY = y + 40;
float contentWidth = width - 40;
GUI.Label(new Rect(innerX, innerY, 100, 30), "Tên phòng:");
_roomName = GUI.TextField(new Rect(innerX + 100, innerY, contentWidth - 100, 30), _roomName);
if (GUI.Button(new Rect(innerX, innerY + 50, contentWidth, 60), "VÀO PHÒNG\n(Tự động Host/Client)"))
{
_ = StartGame(GameMode.AutoHostOrClient);
_ = StartGame(GameMode.AutoHostOrClient, _roomName);
}
GUI.Label(new Rect(10, 60, 300, 20), "Gợi ý: Mở bản Build trước, sau đó mở Unity bấm nút trên.");
if (GUI.Button(new Rect(innerX, innerY + 120, (contentWidth / 2) - 5, 50), "Tạo phòng\n(Host)"))
{
_ = StartGame(GameMode.Host, _roomName);
}
if (GUI.Button(new Rect(innerX + (contentWidth / 2) + 5, innerY + 120, (contentWidth / 2) - 5, 50), "Tham gia\n(Client)"))
{
_ = StartGame(GameMode.Client, _roomName);
}
GUI.Label(new Rect(innerX, innerY + 180, contentWidth, 50), "Gợi ý: Nhập cùng tên phòng để chơi chung.\nNếu phòng chưa có, máy sẽ tự tạo mới.");
}
else
{

View File

@@ -12,12 +12,13 @@ namespace OnlyScove.Scripts
public override void Enter()
{
// Play the Parkour animation (Step Up)
stateMachine.Anim.CrossFadeInFixedTime(parkourHash, 0.1f);
if (stateMachine.Anim != null && stateMachine.Anim.layerCount > 0)
{
// Play the Parkour animation (Step Up)
// Use the overload with layer index 0 to be explicit
stateMachine.Anim.CrossFadeInFixedTime(parkourHash, 0.1f, 0);
}
// We'll wait for the animation to finish.
// In a real project, you might get the exact duration from the Animator.
// For now, we'll assume a fixed duration or check state.
timer = 0f;
}