Commit e60515eb authored by Abdulrahman Mohammed's avatar Abdulrahman Mohammed

Fix all issues

parent c831d64b
......@@ -13,5 +13,5 @@ MonoBehaviour:
m_Name: GameSetting
m_EditorClassIdentifier: Assembly-CSharp::GameSetting
<MaxAnimalsInRound>k__BackingField: 20
<TimeOfRound>k__BackingField: 60
<TimeOfRound>k__BackingField: 30
<NumberOfRounds>k__BackingField: 5
......@@ -4222,6 +4222,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &9180733274907734800
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -4234,8 +4235,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: c5751bd233fcb604aab73e364bf81882, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &7239363159011139443
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -4248,6 +4251,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 3421631764649136143}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -4255,6 +4259,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 646967056338719950}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &750448506894433358
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -4279,7 +4285,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -735,6 +735,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &7440580058684414760
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -747,8 +748,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: d0cff163ca026c74b8900eca3bfbe4a9, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &6092317265662781462
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -761,6 +764,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 1527134247205224634}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -768,6 +772,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 3369560982145558529}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &1203584073287534396
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -792,7 +798,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -565,6 +565,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &4268953564234010434
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -577,8 +578,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: ba49ab0ffd1e5f947b131bc56fb61faa, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &778063317746192726
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -591,6 +594,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 4913624049280128176}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -598,6 +602,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 7666945456229301054}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &8602419029893464424
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -622,7 +628,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -212,6 +212,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &2124509925014609588
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -224,8 +225,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: 4b160f0ac0bdd5b42ad01a593cf2894d, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &7977733509209312240
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -238,6 +241,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 730077370306469771}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -245,6 +249,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 7213738999383922802}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &5677288889425026893
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -269,7 +275,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -1727,6 +1727,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &1812193164498966169
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -1739,8 +1740,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: 489e7b2410467b5478e7479a243f9888, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &2096040867519590702
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -1753,6 +1756,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 5329826028574046622}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -1760,6 +1764,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 8856589872205351049}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &9183291462547310532
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -1784,7 +1790,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -3340,6 +3340,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &40797814380045437
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -3352,8 +3353,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: aede0ffd3c1e09445a39f5b8a5f40568, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &5564318125892087809
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -3366,6 +3369,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 4374812564204227090}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -3373,6 +3377,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 2289348640615392363}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &7864252769378625448
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -3397,7 +3403,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -825,6 +825,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &313242795030673799
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -837,8 +838,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: c5a46d38ee8ca2f46927676a9c31b7b7, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &8323765429530532640
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -851,6 +854,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 3497648408865298523}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -858,6 +862,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 3651862403165494120}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &1423116922813539718
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -882,7 +888,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -567,6 +567,7 @@ MonoBehaviour:
ShowTopMostFoldoutHeaderGroup: 1
currentState: 0
debugMode: 0
_hunter: {fileID: 0}
--- !u!114 &1868278021961101916
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -579,8 +580,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84b375991e3c87246ba0791c32d0f830, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::AnimalDetails
ShowTopMostFoldoutHeaderGroup: 1
<animalProperties>k__BackingField: {fileID: 11400000, guid: d3547736a5d0c7540bbd29c28348d080, type: 2}
<isCorrect>k__BackingField: 0
isCorrect:
m_InternalValue: 0
--- !u!114 &8329710285400560417
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -593,6 +596,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 399b1bb18cfa48943ae8b85e7116f294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Health
ShowTopMostFoldoutHeaderGroup: 1
healthPrefab: {fileID: 3357499539741238442, guid: 4bdf65673483f254a9a4e41744c81167, type: 3}
healthParent: {fileID: 8673244954702284343}
healthColor: {r: 0, g: 0.8039216, b: 0.043137256, a: 1}
......@@ -600,6 +604,8 @@ MonoBehaviour:
dieParticleSystem: {fileID: 1212170556263768825}
_healthCounts:
m_InternalValue: 0
_firstPlayer: {fileID: 0}
_lastPlayer: {fileID: 0}
--- !u!114 &4785301330124650245
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -624,7 +630,7 @@ MonoBehaviour:
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
AuthorityMode: 0
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
......
......@@ -61,7 +61,7 @@ RectTransform:
m_GameObject: {fileID: 1344429576652111916}
m_LocalRotation: {x: -0, y: 0.663317, z: -0, w: 0.7483385}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9999999, y: 1, z: 0.9999999}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5341389692507909387}
......@@ -551,7 +551,6 @@ GameObject:
- component: {fileID: 4213376746885646846}
- component: {fileID: 4343223469952472967}
- component: {fileID: 8643326269112809739}
- component: {fileID: 2981595010778208317}
- component: {fileID: 80164591121225352}
- component: {fileID: 5761587338744970414}
m_Layer: 0
......@@ -574,8 +573,8 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2774262070360309853}
- {fileID: 7413609536204353893}
- {fileID: 2774262070360309853}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: -22.045, z: 0}
--- !u!33 &2330927234672204424
......@@ -718,7 +717,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkObject
GlobalObjectIdHash: 2996614975
GlobalObjectIdHash: 2566835037
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 1
......@@ -744,6 +743,11 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PlayerScore
ShowTopMostFoldoutHeaderGroup: 1
_score:
m_InternalValue: 0
isNPC: 1
_id: 0
_NPCsId: 0
--- !u!114 &4343223469952472967
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -776,55 +780,6 @@ MonoBehaviour:
gunParent: {fileID: 2774262070360309853}
rotationSpeed: 10
_animal: {fileID: 0}
--- !u!114 &2981595010778208317
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6869359625592689313}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5d7d6b6aa5a393e40a69d8bb4d05b43e, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PlayerDetails
ShowTopMostFoldoutHeaderGroup: 1
PlayerName:
m_InternalValue:
utf8LengthInBytes: 0
bytes:
offset0000:
byte0000: 0
byte0001: 0
byte0002: 0
byte0003: 0
byte0004: 0
byte0005: 0
byte0006: 0
byte0007: 0
byte0008: 0
byte0009: 0
byte0010: 0
byte0011: 0
byte0012: 0
byte0013: 0
byte0014: 0
byte0015: 0
byte0016: 0
byte0017: 0
byte0018: 0
byte0019: 0
byte0020: 0
byte0021: 0
byte0022: 0
byte0023: 0
byte0024: 0
byte0025: 0
byte0026: 0
byte0027: 0
byte0028: 0
byte0029: 0
nameText: {fileID: 7462257593087947900}
--- !u!114 &80164591121225352
MonoBehaviour:
m_ObjectHideFlags: 0
......
This diff is collapsed.
This diff is collapsed.
fileFormatVersion: 2
guid: 3e56ca6796df8164c946c1e398109b90
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -15,5 +15,5 @@ MonoBehaviour:
<MovementSpeed>k__BackingField: 3.5
<patrolRange>k__BackingField: 20
<AttackRange>k__BackingField: 10
<TimeBetweenShoot>k__BackingField: 1
<TimeBetweenShoot>k__BackingField: 2
<StillFollowAnimal>k__BackingField: 1
......@@ -17,17 +17,12 @@ public class InputManager : MonoBehaviour
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
return;
}
_inputActions = new InputSystem();
DontDestroyOnLoad(gameObject);
}
private void OnEnable()
......@@ -37,7 +32,8 @@ public class InputManager : MonoBehaviour
private void OnDisable()
{
_inputActions.Disable();
if (_inputActions != null)
_inputActions.Disable();
}
private void Start()
......
......@@ -80,8 +80,9 @@ public class AnimalsSpawner : MonoBehaviour
if (NavMesh.SamplePosition(spwanPos, out NavMeshHit hit, 2, NavMesh.AllAreas))
{
GameObject animalGameobject = Instantiate(animal, hit.position, Quaternion.identity, animalsParent);
GameObject animalGameobject = Instantiate(animal, hit.position, Quaternion.identity);
animalGameobject.GetComponent<NetworkObject>().Spawn();
animalGameobject.transform.SetParent(animalsParent);
animalGameobject.GetComponent<AnimalDetails>().isCorrect.Value = isCorrect;
}
}
......@@ -94,3 +95,9 @@ public class AnimalsSpawner : MonoBehaviour
}
}
}
//bool correct = randomTags.All(tag => animalTagToEnumList.Contains(tag));
//if (correct)
// _correctAnimal.Add(animal);
//else
// _incorrectAnimal.Add(animal);
\ No newline at end of file
......@@ -15,6 +15,7 @@ public class GameManager : NetworkBehaviour
[field: SerializeField] public ScoreManager ScoreManager { get; private set; }
[field: SerializeField] public CursorVisible cursorVisible { get; private set; }
[field: SerializeField] public MatchManager MatchManager { get; private set; }
[field: SerializeField] public LeaderboardUI LeaderboardUI { get; private set; }
public InputManager InputManager { get; private set; }
private void Awake()
......@@ -27,9 +28,11 @@ public class GameManager : NetworkBehaviour
private void Start()
{
InputManager = InputManager.Instance;
}
public void StartMatch()
{
StartCoroutine(StartTimer());
}
IEnumerator StartTimer()
{
int timer = startRoundAfter;
......@@ -41,15 +44,12 @@ public class GameManager : NetworkBehaviour
yield return waitForSeconds;
}
timerText.gameObject.SetActive(false);
StartMatch();
}
public void StartMatch()
{
if (NetworkManager.Singleton.IsHost)
InputManager.enabled = true;
if (IsServer)
{
MatchManager.StartMatch();
AnimalsQuestionGenerator.gameObject.SetActive(true);
AnimalsSpawner.gameObject.SetActive(true);
MatchManager.gameObject.SetActive(true);
}
}
}
......@@ -2,9 +2,10 @@ using EasyTransition;
using System;
using System.Collections;
using TMPro;
using Unity.Netcode;
using UnityEngine;
public class MatchManager : MonoBehaviour
public class MatchManager : NetworkBehaviour
{
[SerializeField] Transform animalsParent;
[SerializeField] Transform NPCsParent;
......@@ -16,30 +17,32 @@ public class MatchManager : MonoBehaviour
TransitionManager _transitionManager;
int _currentMatch;
float _currentTimer;
void Start()
private void Start()
{
_transitionManager = TransitionManager.Instance();
_currentMatch = 1;
_currentTimer = GameManager.Instance.GameSetting.TimeOfRound;
_scoreManager = GameManager.Instance.ScoreManager;
matchRoundText.text = $"Round: {_currentMatch}/{GameManager.Instance.GameSetting.NumberOfRounds}";
}
public void StartMatch()
{
StartCoroutine(startTimer());
}
IEnumerator startTimer()
{
while (_currentTimer > 0)
{
_currentTimer -= Time.deltaTime;
roundTimerText.text = $"Timer: {_currentTimer.ToString("F0")}";
UpdateTimeClientRpc(_currentTimer);
yield return null;
}
if(_currentMatch < GameManager.Instance.GameSetting.NumberOfRounds)
{
fadeScreen.FadeIn();
_currentMatch++;
_transitionManager.onTransitionCutPointReached += ChangeRound;
_transitionManager.Transition(transitionSettings, 3);
ShowFadeMenuClientRpc(false);
}
else
_scoreManager.ShowWinMenu();
......@@ -47,17 +50,32 @@ public class MatchManager : MonoBehaviour
DestroyAnimals();
StopNPC(true);
}
[Rpc(SendTo.ClientsAndHost)]
void UpdateTimeClientRpc(float _currentTimer)
{
roundTimerText.text = $"Timer: {_currentTimer.ToString("F0")}";
}
void ChangeRound()
{
fadeScreen.FadeOut();
ShowFadeMenuClientRpc(true);
GameManager.Instance.AnimalsQuestionGenerator.GengenerateNewQuestions(_currentMatch);
GameManager.Instance.AnimalsSpawner.Spawn();
StopNPC(false);
matchRoundText.text = $"Round: {_currentMatch}/{GameManager.Instance.GameSetting.NumberOfRounds}";
_currentTimer = GameManager.Instance.GameSetting.TimeOfRound;
string currectMatch = $"Round: {_currentMatch}/{GameManager.Instance.GameSetting.NumberOfRounds}";
UpdateCurrentMatchClientRpc(currectMatch);
StartCoroutine(startTimer());
_transitionManager.onTransitionCutPointReached -= ChangeRound;
}
[Rpc(SendTo.ClientsAndHost)]
void UpdateCurrentMatchClientRpc(string _currentMatch)
{
matchRoundText.text = _currentMatch;
_currentTimer = GameManager.Instance.GameSetting.TimeOfRound;
}
void DestroyAnimals()
{
foreach (Health animal in animalsParent.GetComponentsInChildren<Health>())
......@@ -72,4 +90,17 @@ public class MatchManager : MonoBehaviour
npc.EndRound(status);
}
}
[Rpc(SendTo.ClientsAndHost)]
void ShowFadeMenuClientRpc(bool fadeOut)
{
if (fadeOut)
{
fadeScreen.FadeOut();
}
else
{
fadeScreen.FadeIn();
_transitionManager.Transition(transitionSettings, 3);
}
}
}
using System.Collections.Generic;
using Unity.Netcode;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ScoreManager : NetworkBehaviour
{
[SerializeField] Transform leaderboardParent;
[SerializeField] LeaderboardText leaderboardPrefab;
[SerializeField] Transform leaderboardWinParent;
[SerializeField] Button restartButton;
[SerializeField] Button exitButton;
private void UpdateLeaderboard()
private void Start()
{
restartButton.onClick.AddListener(RestartGame);
exitButton.onClick.AddListener(LeaveRound);
}
private void RestartGame()
{
RestartServerRpc();
}
//var leaderboard = scoreList.OrderByDescending(x => x.Value).ToList();
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
void RestartServerRpc()
{
RestartByServer();
}
void RestartByServer()
{
foreach (var client in NetworkManager.Singleton.ConnectedClientsList)
{
client.PlayerObject.Despawn(true);
}
if (NetworkManager.Singleton != null)
NetworkManager.Singleton.SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
}
//for (int i = 0; i < leaderboard.Count; i++)
//{
// var score = leaderboard[i];
// leaderboardParent.GetChild(i).GetComponent<LeaderboardText>().UpdatePlayerScore(score.Key, score.Value);
//}
private void LeaveRound()
{
SceneManager.LoadScene(0);
NetworkManager.Singleton.Shutdown();
}
public void ShowWinMenu()
{
if (IsServer)
ShowWinMenuClientRpc();
}
[Rpc(SendTo.ClientsAndHost)]
void ShowWinMenuClientRpc()
{
GameManager.Instance.InputManager.enabled = false;
GameManager.Instance.cursorVisible.ShowMouseCursor();
leaderboardWinParent.parent.gameObject.SetActive(true);
for (int i = 0; i < leaderboardWinParent.childCount; i++)
for (int i = 0; i < leaderboardParent.childCount; i++)
{
LeaderboardText player = leaderboardWinParent.GetChild(i).gameObject.GetComponent<LeaderboardText>();
string text = (i + 1).ToString() + " " + leaderboardParent.GetChild(i).GetComponent<LeaderboardText>().GetPlayerScore();
player.SetText(text);
LeaderboardText player = leaderboardParent.GetChild(i).gameObject.GetComponent<LeaderboardText>();
LeaderboardText winlist = leaderboardWinParent.GetChild(i).gameObject.GetComponent<LeaderboardText>();
string text = leaderboardParent.GetChild(i).GetSiblingIndex() + 1 + " " + player.GetPlayerScore();
winlist.SetText(text);
}
}
}
......@@ -23,12 +23,19 @@ public class HandlePlayersConnection : NetworkBehaviour
{
foreach (var item in approvRequest.clientData)
{
PlayerNetworkData playerData = new PlayerNetworkData
{
PlayerAuthId = item.Value.AuthId,
playerName = item.Value.playerName,
PlayerAvatar = int.Parse(item.Value.playerAvatar),
};
NetworkObject player = Instantiate(approvRequest.playerPrefab);
player.SpawnAsPlayerObject(item.Key);
player.GetComponent<PlayerDetails>().InitPlayerData(item.Value);
player.GetComponent<PlayerDetails>().InitPlayerData(playerData);
}
}
gameManagerScript.gameObject.SetActive(true);
gameManagerScript.StartMatch();
fadeScript.FadeOut();
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Unity.Netcode;
using UnityEditor.PackageManager;
using UnityEngine;
public class ApprovRequest : MonoBehaviour
......@@ -12,7 +10,7 @@ public class ApprovRequest : MonoBehaviour
public Dictionary<ulong, PlayerData> clientData { get; private set; } = new Dictionary<ulong, PlayerData>();
[field: SerializeField] public NetworkObject playerPrefab { get; private set; }
[SerializeField] NetworkManager networkManager;
NetworkManager _networkManager;
private void Awake()
......@@ -23,9 +21,13 @@ public class ApprovRequest : MonoBehaviour
Destroy(this);
DontDestroyOnLoad(this);
networkManager.ConnectionApprovalCallback = ApprovConnection;
}
private void Start()
{
_networkManager = NetworkManager.Singleton;
_networkManager.ConnectionApprovalCallback = ApprovConnection;
}
private void ApprovConnection(NetworkManager.ConnectionApprovalRequest request, NetworkManager.ConnectionApprovalResponse response)
{
string bytes = Encoding.UTF8.GetString(request.Payload);
......
using System;
using Unity.Collections;
using Unity.Netcode;
public struct PlayerNetworkData : INetworkSerializable, IEquatable<PlayerNetworkData>
{
public FixedString32Bytes PlayerAuthId;
public FixedString32Bytes playerName;
public int PlayerAvatar;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref PlayerAuthId);
serializer.SerializeValue(ref playerName);
serializer.SerializeValue(ref PlayerAvatar);
}
public bool Equals(PlayerNetworkData other)
{
return other.PlayerAuthId == PlayerAuthId && other.playerName.Equals(playerName) && other.PlayerAvatar == PlayerAvatar;
}
}
fileFormatVersion: 2
guid: 13c1cbafd10fd9648853ae16bb0b944d
\ No newline at end of file
using System.Threading.Tasks;
using Unity.Services.Lobbies;
using System.Collections;
using Unity.Services.Lobbies.Models;
using UnityEngine;
using UnityEngine.UI;
......@@ -33,12 +32,17 @@ public class LobbyList : MonoBehaviour
lobbyDetails.AddDetailsToLobby(lobby.Name, playersCount, lobby.Id);
lobbyDetails.gameObject.SetActive(npcCounter < lobby.MaxPlayers);
}
await Task.Delay(2000);
FadeWithText.Instance.FadeOut();
refreshButton.interactable = true;
StartCoroutine(FadeOutAfterDelay());
}
private IEnumerator FadeOutAfterDelay()
{
yield return new WaitForSeconds(1.5f);
FadeWithText.Instance.FadeOut();
refreshButton.interactable = true;
}
void DestroyLastLobbysList()
{
if (lobbyParent.childCount > 0)
......
......@@ -2,7 +2,6 @@ using DG.Tweening;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters;
public class AnimalAi : NetworkBehaviour
{
......@@ -175,7 +174,7 @@ public class AnimalAi : NetworkBehaviour
GetComponent<Collider>().enabled = false;
transform.DOMoveY(-3, 3).SetDelay(3).OnComplete(() => DestroyAnimal()).SetEase(Ease.Linear);
DestroyAnimalClientRpc();
foreach (MonoBehaviour scripts in GetComponents<MonoBehaviour>())
{
......@@ -186,14 +185,16 @@ public class AnimalAi : NetworkBehaviour
_changeVariableOnce = true;
}
}
void DestroyAnimal()
[Rpc(SendTo.ClientsAndHost)]
void DestroyAnimalClientRpc()
{
DestroyServerRpc();
transform.DOMoveY(-3, 3).SetDelay(3).OnComplete(() => Destroy()).SetEase(Ease.Linear);
}
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
void DestroyServerRpc()
void Destroy()
{
GetComponent<NetworkObject>().Despawn();
if (IsServer)
GetComponent<NetworkObject>().Despawn(true);
}
void ChangeAnimation(int stateName)
......@@ -214,6 +215,7 @@ public class AnimalAi : NetworkBehaviour
public void ChangeState(AnimalAiState state, Transform target)
{
if (target == null)
{
ChangeStateNoTargetServerRpc(state);
......@@ -267,7 +269,7 @@ public class AnimalAi : NetworkBehaviour
}
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
void HitHunterServerRpc()
void HitHunterServerRpc()
{
HitHunterClientRpc();
......
......@@ -36,14 +36,15 @@ public class Health : NetworkBehaviour
ChangeScoreServerRpc(count);
}
}
public override void OnNetworkSpawn()
{
_healthCounts.OnValueChanged += ChangeHealth;
_healthCounts.OnValueChanged += UpdataHealthBar;
}
private void ChangeHealth(int previousValue, int newValue)
private void UpdataHealthBar(int previousValue, int newValue)
{
ChangeColorOfHealthBar();
ChangeColorOfHealthBar(newValue);
}
private void ColoringHealthBar()
......@@ -61,11 +62,15 @@ public class Health : NetworkBehaviour
HandlePlayerServerRpc(player.GetComponent<NetworkObject>());
int prevValue = _healthCounts.Value;
ChangeScoreServerRpc(prevValue -= amount);
int newHelth = Mathf.Max(0, _healthCounts.Value - amount);
ChangeColorOfHealthBar(newHelth);
ChangeScoreServerRpc(newHelth);
if (_healthCounts.Value <= 0) Die();
if (newHelth <= 0) Die();
}
private void ChangeAnimalState(Transform player)
......@@ -91,13 +96,13 @@ public class Health : NetworkBehaviour
_lastPlayer = netObj.GetComponent<RaycastWeapon>();
}
}
private void ChangeColorOfHealthBar()
private void ChangeColorOfHealthBar(int value)
{
for (int i = 0; i < healthParent.childCount; i++)
{
Image img = healthParent.GetChild(i).GetComponent<Image>();
if (i < _healthCounts.Value)
if (i < value)
img.color = healthColor;
else
img.color = healthBackgroundColor;
......
using RTLTMPro;
using System;
using System.Collections;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
public class PlayerDetails : NetworkBehaviour
{
public NetworkVariable<FixedString32Bytes> PlayerName = new NetworkVariable<FixedString32Bytes>("Unknown",NetworkVariableReadPermission.Everyone,NetworkVariableWritePermission.Server);
public NetworkVariable<PlayerNetworkData> playerNetworkData = new NetworkVariable<PlayerNetworkData>(default, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server);
[SerializeField] RTLTextMeshPro nameText;
public NetworkVariable<FixedString32Bytes> PlayerName = new NetworkVariable<FixedString32Bytes>("Null", readPerm: NetworkVariableReadPermission.Everyone, writePerm: NetworkVariableWritePermission.Owner);
[SerializeField] bool isNPC;
public void InitPlayerData(PlayerData playerData)
[SerializeField] RTLTextMeshPro nameText;
[SerializeField] string avatar;
public void InitPlayerData(PlayerNetworkData playerNetworkData)
{
if (IsServer)
{
PlayerName.Value = playerData.playerName;
this.playerNetworkData.Value = playerNetworkData;
}
}
public override void OnNetworkSpawn()
{
PlayerName.OnValueChanged += onNameChanged;
playerNetworkData.OnValueChanged += UpdatedData;
PlayerName.OnValueChanged += UpdatedName;
onNameChanged(default, PlayerName.Value);
}
public override void OnNetworkDespawn()
private void UpdatedName(FixedString32Bytes previousValue, FixedString32Bytes newValue)
{
PlayerName.OnValueChanged -= onNameChanged;
nameText.text = newValue.Value.ToString();
}
private void onNameChanged(FixedString32Bytes previousValue, FixedString32Bytes newValue)
private void UpdatedData(PlayerNetworkData previousValue, PlayerNetworkData newValue)
{
nameText.text = newValue.ToString();
if (IsOwner)
{
PlayerName.Value = playerNetworkData.Value.playerName;
nameText.text = PlayerName.Value.ToString();
}
}
}
using System;
using TMPro;
using RTLTMPro;
using System.Collections;
using Unity.Netcode;
using UnityEngine;
public class Score : NetworkBehaviour
{
[SerializeField] TextMeshProUGUI scoreText;
[field: SerializeField] public NetworkVariable<int> _score = new NetworkVariable<int>(readPerm: NetworkVariableReadPermission.Everyone, writePerm: NetworkVariableWritePermission.Server);
[SerializeField] bool isNPC;
RaycastWeapon _raycastWeapon;
[SerializeField] ulong _NPCsId;
string _playerName;
private void OnEnable()
{
_raycastWeapon = GetComponent<RaycastWeapon>();
......@@ -16,41 +16,44 @@ public class Score : NetworkBehaviour
}
public override void OnNetworkSpawn()
{
_score.OnValueChanged += OnScoreChanged;
}
public override void OnNetworkDespawn()
{
_score.OnValueChanged -= OnScoreChanged;
}
private void OnScoreChanged(int previousValue, int newValue)
{
if (scoreText != null)
scoreText.text = newValue.ToString();
StartCoroutine(InitScore());
}
private void OnDisable()
{
_raycastWeapon.onAnimalDie -= AnimalDie;
}
private void AnimalDie(int score)
{
if (!IsOwner) return;
UpdateScoreServerRpc(score);
}
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Owner)]
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
private void UpdateScoreServerRpc(int scoreToAdd)
{
int newScore = _score.Value + scoreToAdd;
newScore = Mathf.Max(0, newScore);
_score.Value = newScore;
AddScoreToLeaderboard();
}
private void AddScoreToLeaderboard()
{
if (isNPC)
GameManager.Instance.LeaderboardUI.AddPlayerToLeaderboard("NPC#" + _NPCsId, _score.Value, _NPCsId);
else
GameManager.Instance.LeaderboardUI.AddPlayerToLeaderboard(_playerName, _score.Value, OwnerClientId);
}
IEnumerator InitScore()
{
yield return new WaitForSeconds(1);
if (isNPC)
{
_NPCsId = (ulong)Random.Range(1000, 9999);
GameManager.Instance.LeaderboardUI.AddPlayerToLeaderboard("NPC#" + _NPCsId, 0, _NPCsId);
GetComponentInChildren<RTLTextMeshPro>().text = $"NPC#{_NPCsId}";
}
if (TryGetComponent<PlayerDetails>(out PlayerDetails playerDetails))
{
_playerName = playerDetails.playerNetworkData.Value.playerName.ToString();
GameManager.Instance.LeaderboardUI.AddPlayerToLeaderboard(_playerName, 0, OwnerClientId);
}
}
}
......@@ -4,10 +4,14 @@ using RTLTMPro;
public class LeaderboardText : MonoBehaviour
{
[SerializeField] RTLTextMeshPro playerScoreText;
public void InitData(string playerName, int score)
public int Score { get; private set; }
public void InitData(string playerName, int score, bool isOwner)
{
Score = score;
playerScoreText.text = $"{playerName}: {score}";
if (isOwner)
playerScoreText.color = Color.red;
}
public string GetPlayerScore()
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using Unity.Netcode;
using UnityEngine;
......@@ -10,40 +11,53 @@ public class LeaderboardUI : NetworkBehaviour
Dictionary<ulong, LeaderboardText> leaderboardUIElements = new Dictionary<ulong, LeaderboardText>();
ApprovRequest approvRequest;
public override void OnNetworkSpawn()
{
if (IsServer)
{
NetworkManager.Singleton.OnClientConnectedCallback += ClientConnected;
NetworkManager.Singleton.OnClientDisconnectCallback += ClientDisconnect;
approvRequest = ApprovRequest.Instance;
}
}
public override void OnNetworkDespawn()
public void AddPlayerToLeaderboard(string playerName, int score, ulong clinetId)
{
if (IsServer)
{
NetworkManager.Singleton.OnClientDisconnectCallback += ClientDisconnect;
NetworkManager.Singleton.OnClientConnectedCallback -= ClientConnected;
// Debug.Log($"Client Id: {clinetId} + Score: {score} + Name: {playerName}");
//
UpdateUiClienRpc(playerName, score, clinetId);
}
}
private void ClientConnected(ulong obj)
[Rpc(SendTo.ClientsAndHost)]
private void UpdateUiClienRpc(string playerName, int score, ulong clinetId)
{
if (!leaderboardUIElements.ContainsKey(obj))
bool isOwner = NetworkManager.Singleton.LocalClientId == clinetId;
if (!leaderboardUIElements.ContainsKey(clinetId))
{
string clientName = NetworkManager.Singleton.ConnectedClients[obj].PlayerObject.GetComponent<PlayerDetails>().PlayerName.ToString();
LeaderboardText leaderboardText = Instantiate(leaderboardPrefab,leaderboardParent);
leaderboardText.InitData(clientName,0);
leaderboardUIElements.Add(obj, leaderboardText);
LeaderboardText leaderboardText = Instantiate(leaderboardPrefab, leaderboardParent);
leaderboardText.InitData(playerName, score, isOwner);
leaderboardUIElements.Add(clinetId, leaderboardText);
}
else
{
leaderboardUIElements[clinetId].InitData(playerName, score, isOwner);
}
sortList();
}
private void ClientDisconnect(ulong obj)
private void sortList()
{
if (leaderboardUIElements.ContainsKey(obj))
List<LeaderboardText> list = new List<LeaderboardText>(leaderboardUIElements.Values);
var sortedList = list.OrderByDescending(a => a.Score).ToList();
for (int i = 0; i < sortedList.Count; i++)
{
leaderboardUIElements.Remove(obj);
sortedList[i].transform.SetSiblingIndex(i);
}
}
}
......@@ -6,14 +6,17 @@ EditorBuildSettings:
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/_project/Scenes/Game.unity
guid: ed75d94d1c2d6934f9aa9556db95a098
path: Assets/_project/Scenes/MainMenu.unity
guid: 9a357ab131db7bd4d8e56aa52459b9a4
- enabled: 1
path: Assets/_project/Scenes/LobbyScene.unity
guid: 352bf19a87eb5f84da505d6b76a39310
- enabled: 1
path: Assets/_project/Scenes/MainMenu.unity
guid: 9a357ab131db7bd4d8e56aa52459b9a4
path: Assets/_project/Scenes/Game.unity
guid: ed75d94d1c2d6934f9aa9556db95a098
- enabled: 1
path: Assets/_project/Scenes/NewLobby.unity
guid: 3e56ca6796df8164c946c1e398109b90
m_configObjects:
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3}
m_UseUCBPForAssetBundles: 0
......@@ -812,7 +812,7 @@ PlayerSettings:
webGLExceptionSupport: 1
webGLNameFilesAsHashes: 0
webGLShowDiagnostics: 0
webGLDataCaching: 1
webGLDataCaching: 0
webGLDebugSymbols: 0
webGLEmscriptenArgs:
webGLModulesDirectory:
......
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 to comment