fix: Network Problems on Ball Synchronization
This commit is contained in:
parent
70ac012a83
commit
edd2dd8511
|
@ -14,6 +14,7 @@ public class PongManagerBehaviour : BehaviourOverride
|
|||
{
|
||||
public Action<PongManagerBehaviour>? OnReset { get; set; } = null;
|
||||
public Action<PongManagerBehaviour>? OnFinished { get; set; } = null;
|
||||
public Action<PongManagerBehaviour>? OnScoresUpdated { get; set; } = null;
|
||||
public Action<PongManagerBehaviour>? OnScored { get; set; } = null;
|
||||
|
||||
private INetworkCommunicator communicator = null!;
|
||||
|
@ -47,7 +48,7 @@ public class PongManagerBehaviour : BehaviourOverride
|
|||
{
|
||||
ScoreLeft = reader.GetInt();
|
||||
ScoreRight = reader.GetInt();
|
||||
OnScored?.Invoke(this);
|
||||
OnScoresUpdated?.Invoke(this);
|
||||
|
||||
CheckFinish();
|
||||
}
|
||||
|
@ -55,6 +56,7 @@ public class PongManagerBehaviour : BehaviourOverride
|
|||
public void ScoreToLeft()
|
||||
{
|
||||
ScoreLeft++;
|
||||
OnScoresUpdated?.Invoke(this);
|
||||
OnScored?.Invoke(this);
|
||||
|
||||
SendData();
|
||||
|
@ -65,6 +67,7 @@ public class PongManagerBehaviour : BehaviourOverride
|
|||
public void ScoreToRight()
|
||||
{
|
||||
ScoreRight++;
|
||||
OnScoresUpdated?.Invoke(this);
|
||||
OnScored?.Invoke(this);
|
||||
|
||||
SendData();
|
||||
|
@ -75,6 +78,7 @@ public class PongManagerBehaviour : BehaviourOverride
|
|||
public void Reset()
|
||||
{
|
||||
ScoreLeft = ScoreRight = 0;
|
||||
OnScoresUpdated?.Invoke(this);
|
||||
OnReset?.Invoke(this);
|
||||
|
||||
SendData();
|
||||
|
|
|
@ -14,9 +14,7 @@ public class TextScoreBehaviour : TextBehaviour
|
|||
if (!GameObject.GameManager.TryFindBehaviour(out pongManager))
|
||||
return;
|
||||
|
||||
pongManager.OnFinished += UpdateScores;
|
||||
pongManager.OnScored += UpdateScores;
|
||||
pongManager.OnReset += UpdateScores;
|
||||
pongManager.OnScoresUpdated += UpdateScores;
|
||||
|
||||
UpdateScores(pongManager);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue