Commit 5dd86ee9 by alsunj

Added testscene and modified detection range for enemies

parent ed599a24
Showing with 262 additions and 95 deletions
fileFormatVersion: 2
guid: c6df4ae9c33e9d845b39f72d64a79c7f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 15600000
userData:
assetBundleName:
assetBundleVariant:
......@@ -5,11 +5,13 @@ public class DamageCollision : NetworkBehaviour
{
[SerializeField] private DamageCollisionSettings _damageCollisionSettings;
private int _targetLayer;
private int _terrainLayer;
private int _damage;
public override void OnNetworkSpawn()
{
_targetLayer = GetLayerFromLayerMask(_damageCollisionSettings.targetLayer);
_terrainLayer = GetLayerFromLayerMask(_damageCollisionSettings.terrainLayer);
_damage = _damageCollisionSettings.damageAmount;
}
......@@ -24,17 +26,37 @@ public class DamageCollision : NetworkBehaviour
if (gameObject.TryGetComponent(out Slime enemyComponent))
{
TargetingManager.Instance.RemoveEnemyFromTargetingList(enemyComponent);
gameObject.GetComponent<NetworkObject>().Despawn();
Destroy(this);
}
DisableGameObjectClientRpc();
if (gameObject.TryGetComponent(out Arrow arrowComponent))
{
NetworkObjectReference arrowNetworkObjectReference =
arrowComponent.GetComponent<NetworkObject>();
DisableArrowClientRpc(arrowNetworkObjectReference);
}
}
if (other.gameObject.layer == _terrainLayer)
{
if (gameObject.TryGetComponent(out Arrow arrowComponent))
{
NetworkObjectReference arrowNetworkObjectReference =
arrowComponent.GetComponent<NetworkObject>();
DisableArrowClientRpc(arrowNetworkObjectReference);
}
}
}
}
[ClientRpc]
private void DisableGameObjectClientRpc()
private void DisableArrowClientRpc(NetworkObjectReference arrowReference)
{
gameObject.SetActive(false);
if (arrowReference.TryGet(out NetworkObject arrowToEnable))
{
arrowToEnable.gameObject.SetActive(false);
}
}
public static int GetLayerFromLayerMask(LayerMask layerMask)
......
......@@ -5,4 +5,5 @@ public class DamageCollisionSettings : ScriptableObject
{
public int damageAmount;
public LayerMask targetLayer;
public LayerMask terrainLayer;
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ public class Rogue : AnimatedEnemy
[SerializeField] private GameObject arrow;
[SerializeField] private GameObject weapon;
private Arrow _arrowComponent;
private float _shootingTimer;
private float _shootingCooldown;
private bool _isAiming;
private Vector3 _lookingDirection;
private NetworkObject _instantiatedArrow;
......@@ -78,9 +78,9 @@ public class Rogue : AnimatedEnemy
private void Update()
{
if (!IsServer) return;
if (_shootingTimer > 0)
if (_shootingCooldown > 0)
{
_shootingTimer -= Time.deltaTime;
_shootingCooldown -= Time.deltaTime;
return;
}
......@@ -113,7 +113,7 @@ public class Rogue : AnimatedEnemy
private void ShootTarget()
{
_enemyManager.enemyEvents.EnemyAttack();
_shootingTimer = enemySettings.shootingDelay;
_shootingCooldown = enemySettings.shootingDelay;
}
private void TargetShotEvent()
......@@ -131,6 +131,7 @@ public class Rogue : AnimatedEnemy
EnableArrowClientRpc(arrowReference);
}
[ClientRpc]
private void EnableArrowClientRpc(NetworkObjectReference arrowReference)
{
......
......@@ -115,13 +115,8 @@ public class ConnectionManager : NetworkBehaviour
private void SetupGameConfig()
{
GameObject cameStartConfigHolder = new GameObject("GameStartConfigHolder");
GameStartConfig gameStartConfig = cameStartConfigHolder.AddComponent<GameStartConfig>();
gameStartConfig.PlayerAmount = PlayerAmount;
gameConfigHolder = new GameObject("GameConfigHolder");
GameDataConfig configComponent = gameConfigHolder.AddComponent<GameDataConfig>();
configComponent.RogueEnemyAmount = RogueEnemyAmount;
configComponent.SlimeEnemyAmount = SlimeEnemyAmount;
......@@ -220,7 +215,7 @@ public class ConnectionManager : NetworkBehaviour
private void PrepareGameLoadSceneForServerAsync()
{
NetworkManager.Singleton.SceneManager.LoadScene("SC", LoadSceneMode.Additive);
NetworkManager.Singleton.SceneManager.LoadScene("TestScene", LoadSceneMode.Additive);
NetworkManager.Singleton.SceneManager.OnLoadEventCompleted += OnSceneLoadCompleted;
}
......
......@@ -61,7 +61,7 @@ Rigidbody:
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 0
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
......@@ -99,7 +99,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 3822488857
GlobalObjectIdHash: 3027223928
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 1
......
......@@ -17,7 +17,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &6791121256323726822
Transform:
m_ObjectHideFlags: 0
......@@ -203,7 +203,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 425717663
GlobalObjectIdHash: 3775582031
InScenePlacedSourceGlobalObjectIdHash: 425717663
DeferredDespawnTick: 0
Ownership: 1
......@@ -290,7 +290,7 @@ MonoBehaviour:
SyncPositionY: 0
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 0
SyncRotAngleY: 1
SyncRotAngleZ: 0
SyncScaleX: 0
SyncScaleY: 0
......
fileFormatVersion: 2
guid: 85a67925f85b36d439766829f6227a68
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3c867eb1a6214d046b131537cbefab76
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -97,8 +97,8 @@ BoxCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 0.1, y: 0.1, z: 0.8}
m_Center: {x: 0, y: 0, z: 0}
m_Size: {x: 0.1, y: 0.1, z: 0.2}
m_Center: {x: 0, y: 0, z: -0.24}
--- !u!114 &8058832186752717783
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -111,7 +111,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 3486418551
GlobalObjectIdHash: 2011270040
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 1
......
......@@ -334,8 +334,8 @@ MonoBehaviour:
SlimeAmountContainer: {fileID: 1544296584}
_connectButton: {fileID: 251032852}
_gameStartCountDownTime: 2
_slimeSpawnCooldownTime: 0.1
_rogueSpawnCooldownTime: 1
_slimeSpawnCooldownTime: 0.01
_rogueSpawnCooldownTime: 0.3
playerPrefab: {fileID: 7039287367920326276, guid: 702bb31d143eeaa4792be36b28160445, type: 3}
playerHealth: 100
_startGameCountdownTimer: 10
......
......@@ -93,7 +93,7 @@ LightmapSettings:
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 112000000, guid: 410f7abc66cc623489d6e75ec776cd2a, type: 2}
m_LightingDataAsset: {fileID: 112000000, guid: f3d9af6dd8a11af4a82dd0ef1f19a085, type: 2}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
......@@ -119,7 +119,7 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &796216484
--- !u!1 &55657783
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -127,9 +127,9 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 796216487}
- component: {fileID: 796216486}
- component: {fileID: 796216485}
- component: {fileID: 55657786}
- component: {fileID: 55657785}
- component: {fileID: 55657784}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
......@@ -137,13 +137,13 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &796216485
--- !u!114 &55657784
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 796216484}
m_GameObject: {fileID: 55657783}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
......@@ -159,14 +159,14 @@ MonoBehaviour:
m_ShadowRenderingLayers: 1
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
m_SoftShadowQuality: 1
--- !u!108 &796216486
m_SoftShadowQuality: 0
--- !u!108 &55657785
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 796216484}
m_GameObject: {fileID: 55657783}
m_Enabled: 1
serializedVersion: 11
m_Type: 1
......@@ -177,7 +177,7 @@ Light:
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
......@@ -225,13 +225,13 @@ Light:
m_LightUnit: 1
m_LuxAtDistance: 1
m_EnableSpotReflector: 1
--- !u!4 &796216487
--- !u!4 &55657786
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 796216484}
m_GameObject: {fileID: 55657783}
serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
......@@ -1002,10 +1002,6 @@ PrefabInstance:
propertyPath: GlobalObjectIdHash
value: 2157953702
objectReference: {fileID: 0}
- target: {fileID: 2796792720919597229, guid: 2533a95934a9ea044a5454189730090b, type: 3}
propertyPath: m_LocalPosition.y
value: -0.7
objectReference: {fileID: 0}
- target: {fileID: 3251327355353088423, guid: 2533a95934a9ea044a5454189730090b, type: 3}
propertyPath: m_LocalPosition.x
value: 0
......@@ -1070,6 +1066,10 @@ PrefabInstance:
propertyPath: m_LocalPosition.y
value: 0.2
objectReference: {fileID: 0}
- target: {fileID: 5647974449618258513, guid: 2533a95934a9ea044a5454189730090b, type: 3}
propertyPath: m_LocalPosition.y
value: 0.2
objectReference: {fileID: 0}
- target: {fileID: 5718679709133256066, guid: 2533a95934a9ea044a5454189730090b, type: 3}
propertyPath: m_LocalPosition.y
value: 0
......@@ -1106,6 +1106,10 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4464205841933766465, guid: c3c6003d148e24045a5699c460b258c9, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4994959905079220019, guid: c3c6003d148e24045a5699c460b258c9, type: 3}
propertyPath: m_Name
value: Managers
......@@ -1172,7 +1176,7 @@ SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 1275561979}
- {fileID: 796216487}
- {fileID: 55657786}
- {fileID: 1909091473}
- {fileID: 4656849397191549919}
- {fileID: 865924118}
......
fileFormatVersion: 2
guid: c9210174b7033b54aa7acc8f8810a967
guid: f3d9af6dd8a11af4a82dd0ef1f19a085
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 112000000
......
fileFormatVersion: 2
guid: 95e5316d0719812478d8bc5db7b1125c
guid: f3a299729df34e948847fc912ce10fc6
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
......
fileFormatVersion: 2
guid: e2ffb8fa12caaab47a7bca2d0672f063
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -16,3 +16,6 @@ MonoBehaviour:
targetLayer:
serializedVersion: 2
m_Bits: 512
terrainLayer:
serializedVersion: 2
m_Bits: 4096
......@@ -15,7 +15,7 @@ MonoBehaviour:
targetLayer:
serializedVersion: 2
m_Bits: 512
detectionRange: 10
detectionRange: 80
shootingRange: 15
shootingDelay: 5
speed: 0
......@@ -16,3 +16,6 @@ MonoBehaviour:
targetLayer:
serializedVersion: 2
m_Bits: 512
terrainLayer:
serializedVersion: 2
m_Bits: 0
......@@ -15,8 +15,7 @@ MonoBehaviour:
targetLayer:
serializedVersion: 2
m_Bits: 512
detectionRange: 7
detectionRange: 80
shootingRange: 0
shootingDelay: 0
speed: 5
damage: 10
......@@ -21,46 +21,4 @@ public class GameDataConfig : MonoBehaviour
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
......@@ -7,6 +7,7 @@
"com.unity.inputsystem": "1.11.2",
"com.unity.multiplayer.center": "1.0.0",
"com.unity.multiplayer.playmode": "1.3.3",
"com.unity.multiplayer.tools": "2.2.3",
"com.unity.netcode.gameobjects": "2.1.1",
"com.unity.render-pipelines.universal": "17.0.3",
"com.unity.test-framework": "1.4.5",
......
......@@ -11,7 +11,7 @@
},
"com.unity.burst": {
"version": "1.8.18",
"depth": 2,
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.2.1",
......@@ -28,7 +28,7 @@
},
"com.unity.collections": {
"version": "2.5.1",
"depth": 2,
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.burst": "1.8.17",
......@@ -74,7 +74,7 @@
},
"com.unity.mathematics": {
"version": "1.3.2",
"depth": 2,
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
......@@ -96,6 +96,21 @@
},
"url": "https://packages.unity.com"
},
"com.unity.multiplayer.tools": {
"version": "2.2.3",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.burst": "1.8.18",
"com.unity.collections": "2.5.1",
"com.unity.mathematics": "1.3.2",
"com.unity.profiling.core": "1.0.2",
"com.unity.nuget.mono-cecil": "1.11.4",
"com.unity.modules.uielements": "1.0.0",
"com.unity.nuget.newtonsoft-json": "3.2.1"
},
"url": "https://packages.unity.com"
},
"com.unity.netcode.gameobjects": {
"version": "2.1.1",
"depth": 0,
......@@ -120,6 +135,13 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.profiling.core": {
"version": "1.0.2",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.render-pipelines.core": {
"version": "17.0.3",
"depth": 1,
......@@ -192,7 +214,7 @@
},
"com.unity.test-framework.performance": {
"version": "3.0.3",
"depth": 3,
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.31",
......
......@@ -14,6 +14,9 @@ EditorBuildSettings:
- enabled: 1
path: Assets/_Game/Scenes/SC.unity
guid: 4bdbbb25aff08a54098c34d6f75b201b
- enabled: 1
path: Assets/_Game/Scenes/TestScene.unity
guid: e2ffb8fa12caaab47a7bca2d0672f063
m_configObjects:
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3}
m_UseUCBPForAssetBundles: 0
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 53
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6762c37d3236e2a4382cd018dcdf221e, type: 3}
m_Name:
m_EditorClassIdentifier:
colors:
m_Keys:
m_Values: []
......@@ -17,7 +17,7 @@ TagManager:
- Player
- Enemy
- Dead
-
- Terrain
-
-
-
......
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