Added MainMenu, Bootstrap and Factory scenes
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b1635a8bbb265d4fac387628ddd4c26
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,216 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &2724913065371725993
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1483718432771122008}
|
||||
- component: {fileID: 1682638732317101433}
|
||||
- component: {fileID: 4069312895261827504}
|
||||
- component: {fileID: 8756866276098507255}
|
||||
- component: {fileID: 301346209279679251}
|
||||
- component: {fileID: 1357666804646257111}
|
||||
- component: {fileID: 1153956066580973303}
|
||||
- component: {fileID: 8282202320765908976}
|
||||
m_Layer: 0
|
||||
m_Name: NetworkPlayer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1483718432771122008
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &1682638732317101433
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!136 &4069312895261827504
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.5
|
||||
m_Height: 2
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &8756866276098507255
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 1
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!114 &301346209279679251
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GlobalObjectIdHash: 2848357538
|
||||
InScenePlacedSourceGlobalObjectIdHash: 0
|
||||
DeferredDespawnTick: 0
|
||||
Ownership: 1
|
||||
AlwaysReplicateAsRoot: 0
|
||||
SynchronizeTransform: 1
|
||||
m_InScenePlaced: 0
|
||||
ActiveSceneSynchronization: 0
|
||||
SceneMigrationSynchronization: 0
|
||||
SpawnWithObservers: 1
|
||||
DontDestroyWithOwner: 0
|
||||
AutoObjectParentSync: 1
|
||||
SyncOwnerTransformWhenParented: 1
|
||||
AllowOwnerToParent: 0
|
||||
--- !u!114 &1357666804646257111
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
NetworkTransformExpanded: 0
|
||||
AutoOwnerAuthorityTickOffset: 1
|
||||
PositionInterpolationType: 0
|
||||
RotationInterpolationType: 0
|
||||
ScaleInterpolationType: 0
|
||||
PositionLerpSmoothing: 1
|
||||
PositionMaxInterpolationTime: 0.1
|
||||
RotationLerpSmoothing: 1
|
||||
RotationMaxInterpolationTime: 0.1
|
||||
ScaleLerpSmoothing: 1
|
||||
ScaleMaxInterpolationTime: 0.1
|
||||
AuthorityMode: 0
|
||||
TickSyncChildren: 0
|
||||
UseUnreliableDeltas: 0
|
||||
SyncPositionX: 1
|
||||
SyncPositionY: 1
|
||||
SyncPositionZ: 1
|
||||
SyncRotAngleX: 1
|
||||
SyncRotAngleY: 1
|
||||
SyncRotAngleZ: 1
|
||||
SyncScaleX: 1
|
||||
SyncScaleY: 1
|
||||
SyncScaleZ: 1
|
||||
PositionThreshold: 0.001
|
||||
RotAngleThreshold: 0.01
|
||||
ScaleThreshold: 0.01
|
||||
UseQuaternionSynchronization: 0
|
||||
UseQuaternionCompression: 0
|
||||
UseHalfFloatPrecision: 0
|
||||
InLocalSpace: 0
|
||||
SwitchTransformSpaceWhenParented: 0
|
||||
Interpolate: 1
|
||||
SlerpPosition: 0
|
||||
--- !u!114 &1153956066580973303
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3b718b186a728344ab8c35780b227699, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
initializationOrder: []
|
||||
--- !u!114 &8282202320765908976
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2724913065371725993}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f8af29dd6e4daa6479ef978bdd3b2e6d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
movementSpeed: 4.5
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0d720ad6d7581844a2cf98deeac1e9a
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe11cc7d57042f14d9c27104ec68e6cc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a940c46e5ab12f347a2eddcc30785021
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Server-authoritative prototype movement.
|
||||
/// The owner reads input, the server applies it, and NetworkTransform replicates the result.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(NetworkObject))]
|
||||
public sealed class FriendslopPlayerMotor : NetworkBehaviour
|
||||
{
|
||||
[SerializeField, Min(0.1f)] private float moveSpeed = 4.5f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!IsOwner || !IsSpawned || Keyboard.current == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 input = ReadMoveInput();
|
||||
if (IsServer)
|
||||
{
|
||||
MoveOnServer(input);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveServerRpc(input);
|
||||
}
|
||||
}
|
||||
|
||||
[ServerRpc]
|
||||
private void MoveServerRpc(Vector2 input)
|
||||
{
|
||||
MoveOnServer(input);
|
||||
}
|
||||
|
||||
private void MoveOnServer(Vector2 input)
|
||||
{
|
||||
if (input.sqrMagnitude > 1f)
|
||||
{
|
||||
input.Normalize();
|
||||
}
|
||||
|
||||
Vector3 direction = new Vector3(input.x, 0f, input.y);
|
||||
transform.position += direction * (moveSpeed * Time.deltaTime);
|
||||
|
||||
if (direction.sqrMagnitude > 0.001f)
|
||||
{
|
||||
transform.forward = Vector3.Slerp(transform.forward, direction, 14f * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector2 ReadMoveInput()
|
||||
{
|
||||
Keyboard keyboard = Keyboard.current;
|
||||
float horizontal = (keyboard.dKey.isPressed || keyboard.rightArrowKey.isPressed ? 1f : 0f)
|
||||
- (keyboard.aKey.isPressed || keyboard.leftArrowKey.isPressed ? 1f : 0f);
|
||||
float vertical = (keyboard.wKey.isPressed || keyboard.upArrowKey.isPressed ? 1f : 0f)
|
||||
- (keyboard.sKey.isPressed || keyboard.downArrowKey.isPressed ? 1f : 0f);
|
||||
|
||||
return new Vector2(horizontal, vertical);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa9cb02e9bb4c4542aeeb0d7024b2d9d
|
||||
@@ -0,0 +1,60 @@
|
||||
using Unity.Netcode;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
[RequireComponent(typeof(NetworkManager), typeof(UnityTransport))]
|
||||
public sealed class FriendslopSession : MonoBehaviour
|
||||
{
|
||||
public static FriendslopSession Instance { get; private set; }
|
||||
[SerializeField] private NetworkObject playerPrefab;
|
||||
[SerializeField] private string menuScene = "MainMenu";
|
||||
[SerializeField] private string gameplayScene = "Factory";
|
||||
public string Status { get; private set; } = "Ready.";
|
||||
public bool IsOnline => NetworkManager.Singleton != null && NetworkManager.Singleton.IsListening;
|
||||
|
||||
private NetworkManager manager;
|
||||
private UnityTransport transport;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null) { Destroy(gameObject); return; }
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
manager = GetComponent<NetworkManager>();
|
||||
transport = GetComponent<UnityTransport>();
|
||||
manager.NetworkConfig.NetworkTransport = transport;
|
||||
manager.NetworkConfig.PlayerPrefab = playerPrefab.gameObject;
|
||||
manager.NetworkConfig.EnableSceneManagement = true;
|
||||
manager.OnServerStarted += LoadGameplayForHost;
|
||||
}
|
||||
|
||||
private void Start() => SceneManager.LoadScene(menuScene);
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (manager != null) manager.OnServerStarted -= LoadGameplayForHost;
|
||||
if (Instance == this) Instance = null;
|
||||
}
|
||||
|
||||
public bool StartHost(ushort port)
|
||||
{
|
||||
transport.SetConnectionData("0.0.0.0", port, "0.0.0.0");
|
||||
Status = manager.StartHost() ? $"Host started on {port}." : "Host failed to start.";
|
||||
return manager.IsHost;
|
||||
}
|
||||
|
||||
public bool StartClient(string address, ushort port)
|
||||
{
|
||||
transport.SetConnectionData(address.Trim(), port);
|
||||
bool started = manager.StartClient();
|
||||
Status = started ? $"Connecting to {address}:{port}..." : "Client failed to start.";
|
||||
return started;
|
||||
}
|
||||
|
||||
private void LoadGameplayForHost()
|
||||
{
|
||||
Status = "Loading factory...";
|
||||
manager.SceneManager.LoadScene(gameplayScene, LoadSceneMode.Single);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 885bc2a800341c0479b5e41a114f3948
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cc579f5c1f6e6a41b2fa6d4de3fd5fb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class FriendslopMainMenu : MonoBehaviour
|
||||
{
|
||||
private string address = "127.0.0.1";
|
||||
private string portText = "7777";
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
var session = FriendslopSession.Instance;
|
||||
GUI.Box(new Rect(24, 24, 380, 285), string.Empty);
|
||||
GUILayout.BeginArea(new Rect(44, 44, 340, 245));
|
||||
GUILayout.Label("FRIENDSLOP // MOUNTAIN FACTORY");
|
||||
GUILayout.Space(10);
|
||||
if (session == null) { GUILayout.Label("Bootstrap is unavailable."); GUILayout.EndArea(); return; }
|
||||
if (session.IsOnline) { GUILayout.Label(session.Status); GUILayout.EndArea(); return; }
|
||||
GUILayout.Label("Host LAN IP");
|
||||
address = GUILayout.TextField(address);
|
||||
GUILayout.Label("Port");
|
||||
portText = GUILayout.TextField(portText);
|
||||
GUILayout.Space(12);
|
||||
if (GUILayout.Button("Start Host", GUILayout.Height(36))) StartHost(session);
|
||||
if (GUILayout.Button("Join Factory", GUILayout.Height(36))) StartClient(session);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(session.Status);
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
|
||||
private void StartHost(FriendslopSession session)
|
||||
{
|
||||
if (TryReadPort(out ushort port)) session.StartHost(port);
|
||||
else Debug.LogWarning("Friendslop: invalid port.");
|
||||
}
|
||||
|
||||
private void StartClient(FriendslopSession session)
|
||||
{
|
||||
if (TryReadPort(out ushort port) && !string.IsNullOrWhiteSpace(address)) session.StartClient(address, port);
|
||||
else Debug.LogWarning("Friendslop: enter a valid IP and port.");
|
||||
}
|
||||
|
||||
private bool TryReadPort(out ushort port) => ushort.TryParse(portText, out port) && port > 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaf978c3df4c1364083bd8a1f7d08861
|
||||
Reference in New Issue
Block a user