Commit f32f751b by alsunj

Add connection menu and disable automatic player prefab instantiation

parent 2a0aa184
......@@ -44,3 +44,8 @@ MonoBehaviour:
SourcePrefabToOverride: {fileID: 0}
SourceHashToOverride: 0
OverridingTargetPrefab: {fileID: 0}
- Override: 0
Prefab: {fileID: 273039182630653378, guid: 347c9a55bcfa08347bc5fb513a0e9ad4, type: 3}
SourcePrefabToOverride: {fileID: 0}
SourceHashToOverride: 0
OverridingTargetPrefab: {fileID: 0}
......@@ -64,9 +64,12 @@ public class Enemy : NetworkBehaviour
_arrowSpawnPoint = weapon.transform.Find("ArrowSpawnPoint");
if (_arrowSpawnPoint == null)
{
throw new Exception("ArrowSpawnPoint is not found as a child of Weapon");
}
InstantiateArrowServer();
}
public void InstantiateArrowServer()
......@@ -74,7 +77,7 @@ public class Enemy : NetworkBehaviour
_instantiatedArrow = Instantiate(arrow, _arrowSpawnPoint.position, _arrowSpawnPoint.rotation)
.GetComponent<NetworkObject>();
_instantiatedArrow.Spawn();
_instantiatedArrow.transform.SetParent(weapon.transform);
// _instantiatedArrow.transform.SetParent(weapon.transform);
_isCrossbowLoaded = true;
}
......@@ -108,8 +111,8 @@ public class Enemy : NetworkBehaviour
{
if (arrowReference.TryGet(out NetworkObject arrowObject))
{
// arrowObject.transform.position = position;
// arrowObject.transform.rotation = rotation;
arrowObject.transform.position = position;
arrowObject.transform.rotation = rotation;
}
_enemyManager.enemyEvents.EnemyReload();
......@@ -122,7 +125,7 @@ public class Enemy : NetworkBehaviour
// _instantiatedArrow.gameObject.SetActive(false);
_instantiatedArrow.transform.position = _arrowSpawnPoint.position;
_instantiatedArrow.transform.rotation = _arrowSpawnPoint.rotation;
_instantiatedArrow.transform.SetParent(weapon.transform);
// _instantiatedArrow.transform.SetParent(weapon.transform);
_targetLocked = false;
_isCrossbowLoaded = true;
}
......
......@@ -16,14 +16,6 @@ public class EnemyAnimator : MonoBehaviour
public event Action receiveTargetAimedEventFromAnimator;
public event Action receiveTargetReloadEventFromAnimator;
private void Start()
{
_animator = GetComponentInChildren<Animator>();
if (_animator == null)
{
Debug.LogError("Animator component not found in children.");
}
}
private void OnDisable()
{
......@@ -37,6 +29,12 @@ public class EnemyAnimator : MonoBehaviour
public void InitializeEvents(EnemyEvents enemyEvents)
{
_animator = GetComponentInChildren<Animator>();
if (_animator == null)
{
Debug.LogError("Animator component not found in children.");
}
this._enemyEvents = enemyEvents;
if (_enemyEvents != null)
{
......@@ -68,7 +66,14 @@ public class EnemyAnimator : MonoBehaviour
private void SetEnemyAim()
{
_animator.SetTrigger(IS_AIMING);
if (_animator != null)
{
_animator.SetTrigger(IS_AIMING);
}
else
{
Debug.LogError("Animator is null when SetEnemyAim is called on " + gameObject.name);
}
}
private void SetEnemyAttack()
......
using System.Collections;
using Unity.Netcode;
using UnityEditor;
using UnityEngine;
public class EnemySpawner : MonoBehaviour
{
[SerializeField] private GameObject _rogueEnemyPrefab;
[SerializeField] private GameObject _slimeEnemyPrefab;
private Transform[] _enemySpawnLocations;
#region EnemyConfig
private int _RougeEnemySpawnAmount;
private int _SlimeEnemySpawnAmount;
private float _RogueEnemySpawnCooldown;
private float _SlimeEnemySpawnCooldown;
#endregion
#region runtimeEnemyProperties
private float _RogueEnemySpawnTimer;
private float _SlimeEnemySpawnTimer;
private int _spawnedRogueEnemyCount;
private int _spawnedSlimeEnemyCount;
#endregion
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
......@@ -24,8 +50,94 @@ public class EnemySpawner : MonoBehaviour
[ServerRpc]
private void OnServerStartedServerRpc()
{
// SpawnEnemyArrows();
ApplyExistingEnemyArrows();
FindEnemySpawnPositions();
FindEnemyConfig();
StartEnemySpawnTimers();
}
private void StartEnemySpawnTimers()
{
StartCoroutine(RogueSpawnTimerCoroutine());
StartCoroutine(SlimeSpawnTimerCoroutine());
}
private IEnumerator RogueSpawnTimerCoroutine()
{
while (_spawnedRogueEnemyCount < _RougeEnemySpawnAmount)
{
if (_RogueEnemySpawnTimer <= 0f)
{
Vector3 spawnPosition = GetSpawnPosition(_spawnedSlimeEnemyCount);
SpawnRogueEnemyServerRpc(spawnPosition);
_spawnedRogueEnemyCount++;
_RogueEnemySpawnTimer = _RogueEnemySpawnCooldown;
}
_RogueEnemySpawnTimer -= Time.fixedDeltaTime; // Use Time.fixedDeltaTime for physics updates
yield return new WaitForFixedUpdate(); // Wait for the next physics update
}
}
private IEnumerator SlimeSpawnTimerCoroutine()
{
while (_spawnedSlimeEnemyCount < _SlimeEnemySpawnAmount)
{
if (_SlimeEnemySpawnTimer <= 0f)
{
Vector3 spawnPosition = GetSpawnPosition(_spawnedSlimeEnemyCount);
SpawnSlimeEnemyServerRpc(spawnPosition);
_spawnedSlimeEnemyCount++;
_SlimeEnemySpawnTimer = _SlimeEnemySpawnCooldown;
}
_SlimeEnemySpawnTimer -= Time.fixedDeltaTime; // Use Time.fixedDeltaTime for physics updates
yield return new WaitForFixedUpdate(); // Wait for the next physics update
}
}
[ServerRpc]
private void SpawnRogueEnemyServerRpc(Vector3 spawnPosition)
{
if (_rogueEnemyPrefab != null)
{
GameObject spawnedEnemy =
Instantiate(_rogueEnemyPrefab, spawnPosition, Quaternion.identity, gameObject.transform);
spawnedEnemy.GetComponent<NetworkObject>().Spawn();
}
}
[ServerRpc]
private void SpawnSlimeEnemyServerRpc(Vector3 spawnPosition)
{
if (_slimeEnemyPrefab != null)
{
GameObject spawnedEnemy = Instantiate(_slimeEnemyPrefab, spawnPosition, Quaternion.identity);
spawnedEnemy.GetComponent<NetworkObject>().Spawn();
}
}
private Vector3 GetSpawnPosition(int spawnedCount)
{
int index = spawnedCount % _enemySpawnLocations.Length;
return _enemySpawnLocations[index].position;
}
private void FindEnemyConfig()
{
_RougeEnemySpawnAmount = GameDataConfig.Instance.RogueEnemyAmount;
_SlimeEnemySpawnAmount = GameDataConfig.Instance.SlimeEnemyAmount;
_RogueEnemySpawnCooldown = GameDataConfig.Instance.RogueEnemySpawnTimer;
_SlimeEnemySpawnCooldown = GameDataConfig.Instance.SlimeEnemySpawnTimer;
_RogueEnemySpawnTimer = _RogueEnemySpawnCooldown;
_SlimeEnemySpawnTimer = _SlimeEnemySpawnCooldown;
}
private void ApplyExistingEnemyArrows()
{
// SpawnEnemyArrows();
var enemiesTransform = GameObject.Find("Enemies")?.transform;
if (enemiesTransform != null)
{
......@@ -40,6 +152,31 @@ public class EnemySpawner : MonoBehaviour
}
}
private void FindEnemySpawnPositions()
{
GameObject spawnLocationParent = GameObject.Find("EnemySpawnLocations");
if (spawnLocationParent == null)
{
Debug.LogError("Could not find GameObject named 'EnemySpawnLocations'!");
return;
}
_enemySpawnLocations = new Transform[spawnLocationParent.transform.childCount];
for (int i = 0; i < spawnLocationParent.transform.childCount; i++)
{
_enemySpawnLocations[i] = spawnLocationParent.transform.GetChild(i);
}
Vector3[] spawnPositions = new Vector3[_enemySpawnLocations.Length];
for (int i = 0; i < _enemySpawnLocations.Length; i++)
{
spawnPositions[i] = _enemySpawnLocations[i].position;
}
}
// private void SpawnEnemyArrows()
// {
// var enemiesTransform = GameObject.Find("Enemies")?.transform;
......
fileFormatVersion: 2
guid: 9c53962885c2c4f449125a979d6ad240
guid: 64984b368aba04e4a8997ce6f139906a
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
#if UNITY_EDITOR
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Helpers
{
public class LoadConnectionSceneMono : MonoBehaviour
{
private void Start()
{
if (SceneManager.GetActiveScene().buildIndex == 0)
{
Destroy(gameObject); // Optional: Destroy this loader if it's in the correct scene
return;
}
SceneManager.LoadScene(0);
Destroy(gameObject);
}
}
}
#endif
\ No newline at end of file
fileFormatVersion: 2
guid: 9484dda6623b48b4999b76e13e6dd9cc
\ No newline at end of file
......@@ -128,7 +128,7 @@ public class PlayerController : NetworkBehaviour
_playerAnimator.InitializeEvents(_playerManager.playerEvents);
}
_camera = FindFirstObjectByType<Camera>();
_camera = Camera.main;
if (_camera == null)
{
Debug.LogError("Camera is null");
......
using System;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using Unity.Networking.Transport;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ClientConnectionManager : MonoBehaviour
{
[SerializeField] private TMP_InputField _addressField;
[SerializeField] private TMP_InputField _portField;
[SerializeField] private TMP_Dropdown _connectionModeDropdown;
[SerializeField] private TMP_InputField _playerAmountField;
[SerializeField] private TMP_InputField _RogueEnemyAmountField;
[SerializeField] private TMP_InputField _SlimeEnemyAmountField;
[SerializeField] private GameObject LobbyAmountContainer;
[SerializeField] private GameObject RangerAmountContainer;
[SerializeField] private GameObject SlimeAmountContainer;
[SerializeField] private Button _connectButton;
[SerializeField] private int _gameStartCountDownTime;
[SerializeField] private float _slimeSpawnCooldownTime;
[SerializeField] private float _rogueSpawnCooldownTime;
private ushort Port => ushort.Parse(_portField.text);
private int PlayerAmount => int.Parse(_playerAmountField.text);
private int RogueEnemyAmount => int.Parse(_RogueEnemyAmountField.text);
private int SlimeEnemyAmount => int.Parse(_SlimeEnemyAmountField.text);
private string Address => _addressField.text;
private void OnEnable()
{
_connectionModeDropdown.onValueChanged.AddListener(OnConnectionModeChanged);
_connectButton.onClick.AddListener(OnButtonConnect);
OnConnectionModeChanged(_connectionModeDropdown.value);
}
private void OnDisable()
{
_connectionModeDropdown.onValueChanged.RemoveAllListeners();
_connectButton.onClick.RemoveAllListeners();
}
private void OnConnectionModeChanged(int connectionMode)
{
string buttonLabel;
_connectButton.enabled = true;
switch (connectionMode)
{
case 0:
buttonLabel = "Start Host";
LobbyAmountContainer.SetActive(true);
RangerAmountContainer.SetActive(true);
SlimeAmountContainer.SetActive(true);
break;
case 1:
buttonLabel = "Start Client";
LobbyAmountContainer.SetActive(false);
RangerAmountContainer.SetActive(false);
SlimeAmountContainer.SetActive(false);
break;
default:
buttonLabel = "<ERROR>";
_connectButton.enabled = false;
break;
}
var buttonText = _connectButton.GetComponentInChildren<TextMeshProUGUI>();
buttonText.text = buttonLabel;
}
private async void OnButtonConnect()
{
GameObject networkManagerObject = NetworkManager.Singleton.gameObject;
// AsyncOperation loadOperation = SceneManager.LoadSceneAsync("SC", LoadSceneMode.Additive);
// while (!loadOperation.isDone)
// {
// await System.Threading.Tasks.Task.Yield();
// }
//
// Scene gameScene = SceneManager.GetSceneByName("SC");
//
// SceneManager.MoveGameObjectToScene(networkManagerObject, gameScene);
//
// SceneManager.SetActiveScene(gameScene);
//
// SceneManager.UnloadSceneAsync("ConnectionScene");
switch (_connectionModeDropdown.value)
{
case 0:
StartServer();
SetupGameConfig();
break;
case 1:
StartClient();
break;
default:
Debug.LogError("Error: Unknown connection mode", gameObject);
break;
}
}
private void SetupGameConfig()
{
GameObject cameStartConfigHolder = new GameObject("GameStartConfigHolder");
GameStartConfig gameStartConfig = cameStartConfigHolder.AddComponent<GameStartConfig>();
gameStartConfig.PlayerAmount = PlayerAmount;
GameObject gameConfigHolder = new GameObject("GameConfigHolder");
GameDataConfig configComponent = gameConfigHolder.AddComponent<GameDataConfig>();
configComponent.RogueEnemyAmount = RogueEnemyAmount;
configComponent.SlimeEnemyAmount = SlimeEnemyAmount;
// SceneManager.MoveGameObjectToScene(gameConfigHolder, targetScene);
}
private void StartServer()
{
UnityTransport transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
if (transport != null)
{
transport.SetConnectionData(Address, Port);
NetworkManager.Singleton.StartHost();
NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnected;
}
else
{
Debug.LogError("Unity Transport component not found on the NetworkManager!");
}
}
private void OnClientConnected(ulong obj)
{
GameStartConfig.Instance.IncrementConnectedPlayers();
Debug.Log(GameStartConfig.Instance.GetConnectedPlayers() + "amount connected");
}
private void StartClient()
{
UnityTransport transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
if (transport != null)
{
transport.SetConnectionData(Address, Port);
NetworkManager.Singleton.StartClient();
}
else
{
Debug.LogError("Unity Transport component not found on the NetworkManager!");
}
}
private void OnDestroy()
{
NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnected;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 073290f5692bc3e468889c25d8a4f3e4
\ No newline at end of file
using UnityEngine;
using System.Collections;
using TMPro;
using Unity.Netcode;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameStartUIControllerGO : MonoBehaviour
{
[SerializeField] private GameObject _beginGamePanel;
[SerializeField] private GameObject _confirmQuitPanel;
[SerializeField] private GameObject _countdownPanel;
[SerializeField] private Button _quitWaitingButton;
[SerializeField] private Button _confirmQuitButton;
[SerializeField] private Button _cancelQuitButton;
[SerializeField] private TMP_Text _waitingText;
[SerializeField] private TMP_Text _countdownText;
private NetworkManager _networkManager;
private void OnEnable()
{
_beginGamePanel.SetActive(true);
_confirmQuitPanel.SetActive(false);
_countdownPanel.SetActive(false);
_quitWaitingButton.onClick.AddListener(AttemptQuitWaiting);
_confirmQuitButton.onClick.AddListener(ConfirmQuit);
_cancelQuitButton.onClick.AddListener(CancelQuit);
_networkManager = NetworkManager.Singleton;
if (_networkManager != null)
{
// Subscribe to a custom event or check NetworkManager state directly
// We'll assume you have a way to track players remaining on the server
// and update clients via RPC or NetworkVariable.
// Example: Subscribe to an event that the server triggers
// if (NetworkGameManager.Instance != null)
// {
// NetworkGameManager.Instance.OnPlayersRemainingToStartUpdated += UpdatePlayerRemainingText;
// NetworkGameManager.Instance.OnStartGameCountdown += BeginCountdown;
// }
//
// // Example: If countdown is a NetworkVariable on a NetworkBehaviour
// if (NetworkGameManager.Instance != null)
// {
// NetworkGameManager.Instance.CountdownTime.OnValueChanged += UpdateCountdownTextFromNetworkVariable;
// if (NetworkGameManager.Instance.IsCountdownActive.Value)
// {
// BeginCountdown();
// }
// }
}
else
{
Debug.LogError("NetworkManager not found!");
}
}
private void OnDisable()
{
_quitWaitingButton.onClick.RemoveAllListeners();
_confirmQuitButton.onClick.RemoveAllListeners();
_cancelQuitButton.onClick.RemoveAllListeners();
//
// if (NetworkGameManager.Instance != null)
// {
// NetworkGameManager.Instance.OnPlayersRemainingToStartUpdated -= UpdatePlayerRemainingText;
// NetworkGameManager.Instance.OnStartGameCountdown -= BeginCountdown;
// NetworkGameManager.Instance.CountdownTime.OnValueChanged -= UpdateCountdownTextFromNetworkVariable;
// }
}
private void UpdatePlayerRemainingText(int playersRemainingToStart)
{
var playersText = playersRemainingToStart == 1 ? "player" : "players";
_waitingText.text = $"Waiting for {playersRemainingToStart.ToString()} more {playersText} to join...";
}
private void UpdateCountdownText(int countdownTime)
{
_countdownText.text = countdownTime.ToString();
}
private void UpdateCountdownTextFromNetworkVariable(int previousValue, int newValue)
{
_countdownText.text = newValue.ToString();
}
private void AttemptQuitWaiting()
{
_beginGamePanel.SetActive(false);
_confirmQuitPanel.SetActive(true);
}
private void ConfirmQuit()
{
StartCoroutine(DisconnectDelay());
}
IEnumerator DisconnectDelay()
{
yield return new WaitForSeconds(1f);
if (_networkManager != null && _networkManager.IsClient)
{
_networkManager.Shutdown();
SceneManager.LoadScene(0); // Load your main menu scene
}
else if (_networkManager != null && _networkManager.IsServer)
{
_networkManager.Shutdown();
SceneManager.LoadScene(0); // Load your main menu scene
}
else
{
SceneManager.LoadScene(0); // If no network is active, just go to main menu
}
}
private void CancelQuit()
{
_confirmQuitPanel.SetActive(false);
_beginGamePanel.SetActive(true);
}
private void BeginCountdown()
{
_beginGamePanel.SetActive(false);
_confirmQuitPanel.SetActive(false);
_countdownPanel.SetActive(true);
}
private void EndCountdown()
{
_countdownPanel.SetActive(false);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: a58a38ffa1fae6f45b64398121459d3e
\ No newline at end of file
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3889523558811156720
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5059658329123755283}
- component: {fileID: 1707247849784179353}
- component: {fileID: 5116499677113064615}
m_Layer: 5
m_Name: Start_Game
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5059658329123755283
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3889523558811156720}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, 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}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 262.3946, y: 108.8129}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1707247849784179353
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3889523558811156720}
m_CullTransparentMesh: 1
--- !u!114 &5116499677113064615
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3889523558811156720}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Start Game
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 1166126335
m_fontColor: {r: 1, g: 0.6733512, b: 0.504717, a: 0.27058825}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 50.3
m_fontSizeBase: 50.3
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
fileFormatVersion: 2
guid: 16d7240a2d17c43469b5dff96aa59205
NativeFormatImporter:
guid: 84eabe7aba8647c49b89ea03223acaa3
PrefabImporter:
externalObjects: {}
mainObjectFileID: 112000000
userData:
assetBundleName:
assetBundleVariant:
......@@ -9,6 +9,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 462326326808441748}
- component: {fileID: 8313319675349312869}
- component: {fileID: 4151337880934277662}
- component: {fileID: 4208536349724091019}
m_Layer: 0
......@@ -34,6 +35,31 @@ Transform:
- {fileID: 2932600720215003264}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8313319675349312869
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 273039182630653378}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 1098436237
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 1
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 1
ActiveSceneSynchronization: 0
SceneMigrationSynchronization: 1
SpawnWithObservers: 1
DontDestroyWithOwner: 0
AutoObjectParentSync: 1
SyncOwnerTransformWhenParented: 1
AllowOwnerToParent: 0
--- !u!114 &4151337880934277662
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -215,13 +241,7 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: c88a69f7965560c47b6ffa4eed82887f, type: 3}
insertIndex: -1
addedObject: {fileID: 3797023941742593236}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: c88a69f7965560c47b6ffa4eed82887f, type: 3}
insertIndex: -1
addedObject: {fileID: 9162807971884904140}
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: c88a69f7965560c47b6ffa4eed82887f, type: 3}
insertIndex: -1
addedObject: {fileID: 173412709027186461}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c88a69f7965560c47b6ffa4eed82887f, type: 3}
--- !u!4 &5942464512878880573 stripped
Transform:
......@@ -233,67 +253,6 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: c88a69f7965560c47b6ffa4eed82887f, type: 3}
m_PrefabInstance: {fileID: 6196221362579685590}
m_PrefabAsset: {fileID: 0}
--- !u!114 &9162807971884904140
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6430031212675530119}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 0
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 1
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 1
ActiveSceneSynchronization: 0
SceneMigrationSynchronization: 1
SpawnWithObservers: 1
DontDestroyWithOwner: 0
AutoObjectParentSync: 1
SyncOwnerTransformWhenParented: 1
AllowOwnerToParent: 0
--- !u!114 &173412709027186461
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6430031212675530119}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
ShowTopMostFoldoutHeaderGroup: 1
NetworkTransformExpanded: 0
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 0
SyncScaleY: 0
SyncScaleZ: 0
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
SwitchTransformSpaceWhenParented: 0
Interpolate: 1
SlerpPosition: 0
--- !u!1001 &6595050288222494873
PrefabInstance:
m_ObjectHideFlags: 0
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &354072136138752549
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5647974449618258513}
m_Layer: 0
m_Name: EnemySpawnLocations
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5647974449618258513
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354072136138752549}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8235182949935651672}
- {fileID: 7280036145531595758}
- {fileID: 1099222921294071345}
- {fileID: 5019612241553091319}
m_Father: {fileID: 3251327355353088423}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &381795952518723057
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7280036145531595758}
m_Layer: 0
m_Name: EnemySpawnLocation (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7280036145531595758
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 381795952518723057}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 19.7, y: 0, z: 19.9}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5647974449618258513}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &650624935253927002
GameObject:
m_ObjectHideFlags: 0
......@@ -68,6 +134,7 @@ Transform:
- {fileID: 5001222007940412494}
- {fileID: 5581542974833947271}
- {fileID: 5981432708657565925}
- {fileID: 5647974449618258513}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1342101318069946295
......@@ -102,6 +169,37 @@ Transform:
- {fileID: 5718679709133256066}
m_Father: {fileID: 3251327355353088423}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4219040416155913401
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8235182949935651672}
m_Layer: 0
m_Name: EnemySpawnLocation
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8235182949935651672
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4219040416155913401}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -22.2, y: 0, z: 19.1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5647974449618258513}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5250389714568146909
GameObject:
m_ObjectHideFlags: 0
......@@ -167,6 +265,37 @@ Transform:
- {fileID: 6214961402451407269}
m_Father: {fileID: 3251327355353088423}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7200124850217018876
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5019612241553091319}
m_Layer: 0
m_Name: EnemySpawnLocation (3)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5019612241553091319
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7200124850217018876}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -23.02, y: 0, z: -20.97}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5647974449618258513}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7261106503907252533
GameObject:
m_ObjectHideFlags: 0
......@@ -288,6 +417,37 @@ Transform:
- {fileID: 5798277484775124278}
m_Father: {fileID: 3251327355353088423}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &8073686428607757322
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1099222921294071345}
m_Layer: 0
m_Name: EnemySpawnLocation (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1099222921294071345
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8073686428607757322}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 20.45, y: 0, z: -20.07}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5647974449618258513}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &565620134248262404
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -298,7 +458,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 163114042722539874, guid: 835d789898f8f3a4d97189425e75e8f6, type: 3}
propertyPath: GlobalObjectIdHash
value: 1837939063
value: 3307046875
objectReference: {fileID: 0}
- target: {fileID: 163114042722539874, guid: 835d789898f8f3a4d97189425e75e8f6, type: 3}
propertyPath: InScenePlacedSourceGlobalObjectIdHash
......@@ -1500,7 +1660,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 1580681325717503087, guid: 525df842114a50742b87e2282140ad02, type: 3}
propertyPath: GlobalObjectIdHash
value: 364363177
value: 1549677047
objectReference: {fileID: 0}
- target: {fileID: 4727207244663773237, guid: 525df842114a50742b87e2282140ad02, type: 3}
propertyPath: m_Name
......@@ -1658,7 +1818,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 1580681325717503087, guid: 525df842114a50742b87e2282140ad02, type: 3}
propertyPath: GlobalObjectIdHash
value: 2089084133
value: 1334992784
objectReference: {fileID: 0}
- target: {fileID: 4727207244663773237, guid: 525df842114a50742b87e2282140ad02, type: 3}
propertyPath: m_Name
......@@ -1936,7 +2096,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 657873038
GlobalObjectIdHash: 2408943373
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 1
......@@ -2398,7 +2558,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3719657908984160168, guid: dc502d59cef13ed40b07aa18bd1a4167, type: 3}
propertyPath: GlobalObjectIdHash
value: 41515216
value: 870031014
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
......@@ -2460,7 +2620,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3668773499323874180, guid: 1d9ae894a89fd38449f1ce889f52d1ad, type: 3}
propertyPath: GlobalObjectIdHash
value: 2868596387
value: 2909008999
objectReference: {fileID: 0}
- target: {fileID: 8050255731901760503, guid: 1d9ae894a89fd38449f1ce889f52d1ad, type: 3}
propertyPath: m_Name
......
fileFormatVersion: 2
guid: fb476371a58224b439cbcc569f3d86f0
guid: 35f5ba35afc11fe488eb6e61be211c43
DefaultImporter:
externalObjects: {}
userData:
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &254241339303478313
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1032440509486951724}
- component: {fileID: 7022544978650153336}
- component: {fileID: 7412417249423064013}
m_Layer: 0
m_Name: NetworkManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1032440509486951724
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 254241339303478313}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 1.0838255, z: -0.0023028553}
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!114 &7022544978650153336
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 254241339303478313}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 593a2fe42fa9d37498c96f9a383b6521, type: 3}
m_Name:
m_EditorClassIdentifier:
NetworkManagerExpanded: 0
NetworkConfig:
ProtocolVersion: 0
NetworkTransport: {fileID: 7412417249423064013}
PlayerPrefab: {fileID: 7039287367920326276, guid: 702bb31d143eeaa4792be36b28160445, type: 3}
Prefabs:
NetworkPrefabsLists:
- {fileID: 11400000, guid: 7cb9a24c41187064292effc7e95bbab6, type: 2}
TickRate: 30
ClientConnectionBufferTimeout: 10
ConnectionApproval: 0
ConnectionData:
EnableTimeResync: 0
TimeResyncInterval: 30
EnsureNetworkVariableLengthSafety: 0
EnableSceneManagement: 1
ForceSamePrefabs: 1
RecycleNetworkIds: 1
NetworkIdRecycleDelay: 120
RpcHashSize: 0
LoadSceneTimeOut: 120
SpawnTimeout: 10
EnableNetworkLogs: 1
NetworkTopology: 0
UseCMBService: 0
AutoSpawnPlayerPrefabClientSide: 1
NetworkProfilingMetrics: 1
OldPrefabList: []
RunInBackground: 1
LogLevel: 1
--- !u!114 &7412417249423064013
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 254241339303478313}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6960e84d07fb87f47956e7a81d71c4e6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ProtocolType: 0
m_UseWebSockets: 0
m_UseEncryption: 0
m_MaxPacketQueueSize: 128
m_MaxPayloadSize: 6144
m_HeartbeatTimeoutMS: 500
m_ConnectTimeoutMS: 1000
m_MaxConnectAttempts: 60
m_DisconnectTimeoutMS: 30000
ConnectionData:
Address: 127.0.0.1
Port: 7777
ServerListenAddress: 127.0.0.1
DebugSimulator:
PacketDelayMS: 0
PacketJitterMS: 0
PacketDropRate: 0
fileFormatVersion: 2
guid: aa5a710977822ef419bd6d43bba6a363
folderAsset: yes
DefaultImporter:
guid: f6024856153867c408043e682ddcac1e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
......
using System;
using UnityEngine;
public class GameDataConfig : MonoBehaviour
{
public static GameDataConfig Instance { get; private set; }
public int RogueEnemyAmount;
public int SlimeEnemyAmount;
public float RogueEnemySpawnTimer = 2f;
public float SlimeEnemySpawnTimer = 0.5f;
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
}
}
public class GameStartConfig : MonoBehaviour
{
public int PlayerAmount;
public static GameStartConfig Instance { get; private set; }
public event Action<int> OnPlayerConnected;
public event Action<int> OnRequiredPlayersReached;
private int _connectedPlayers = 0;
private void Awake()
{
if (Instance == null)
{
Instance = this;
// Optionally, if you want this to persist across scene loads:
// DontDestroyOnLoad(gameObject);
}
else
{
Debug.LogError("Multiple GameStartConfig instances found!");
Destroy(gameObject);
}
}
public void IncrementConnectedPlayers()
{
_connectedPlayers++;
OnPlayerConnected?.Invoke(_connectedPlayers);
if (_connectedPlayers >= PlayerAmount)
{
OnRequiredPlayersReached?.Invoke(PlayerAmount);
}
}
public int GetConnectedPlayers()
{
return _connectedPlayers;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: cd36e06dfd1e94e48a109f12aa38515d
\ No newline at end of file
......@@ -6,6 +6,7 @@
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.inputsystem": "1.11.2",
"com.unity.multiplayer.center": "1.0.0",
"com.unity.multiplayer.playmode": "1.3.3",
"com.unity.netcode.gameobjects": "2.1.1",
"com.unity.render-pipelines.universal": "17.0.3",
"com.unity.test-framework": "1.4.5",
......
......@@ -87,6 +87,15 @@
"com.unity.modules.uielements": "1.0.0"
}
},
"com.unity.multiplayer.playmode": {
"version": "1.3.3",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "2.0.2"
},
"url": "https://packages.unity.com"
},
"com.unity.netcode.gameobjects": {
"version": "2.1.1",
"depth": 0,
......@@ -104,6 +113,13 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.nuget.newtonsoft-json": {
"version": "3.2.1",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.render-pipelines.core": {
"version": "17.0.3",
"depth": 1,
......
......@@ -8,9 +8,9 @@ EditorBuildSettings:
- enabled: 0
path: Assets/Scenes/SampleScene.unity
guid: 99c9720ab356a0642a771bea13969a05
- enabled: 0
path: Assets/Scenes/Scene.unity
guid: fb476371a58224b439cbcc569f3d86f0
- enabled: 1
path: Assets/_Game/Scenes/ConnectionScene.unity
guid: 35f5ba35afc11fe488eb6e61be211c43
- enabled: 1
path: Assets/_Game/Scenes/SC.unity
guid: 4bdbbb25aff08a54098c34d6f75b201b
......
{
"PlayerTags": [],
"version": "1.3.3"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment