feat: pong reset scores on game start
This commit is contained in:
		@@ -64,8 +64,7 @@ public class PongManagerBehaviour : Behaviour, INetworkEntity, IFirstFrameUpdate
 | 
			
		||||
    {
 | 
			
		||||
        ScoreLeft = ScoreRight = 0;
 | 
			
		||||
 | 
			
		||||
        ball.ResetBall();
 | 
			
		||||
        ball.LaunchBall(GetBallLaunchDirection());
 | 
			
		||||
        PostScoreUpdate();
 | 
			
		||||
 | 
			
		||||
        OnReset?.Invoke(this);
 | 
			
		||||
    }
 | 
			
		||||
@@ -84,6 +83,7 @@ public class PongManagerBehaviour : Behaviour, INetworkEntity, IFirstFrameUpdate
 | 
			
		||||
        if (ScoreLeft > halfwayScore || ScoreRight > halfwayScore)
 | 
			
		||||
        {
 | 
			
		||||
            OnFinished?.Invoke(this);
 | 
			
		||||
            logger?.Log(this, $"Game finished");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -109,10 +109,13 @@ public class PongManagerBehaviour : Behaviour, INetworkEntity, IFirstFrameUpdate
 | 
			
		||||
 | 
			
		||||
    void IPacketListenerServer<RequestStartPacket>.OnServerPacketArrived(IConnection sender, RequestStartPacket packet)
 | 
			
		||||
    {
 | 
			
		||||
        logger?.Log(this, $"{sender} requested start");
 | 
			
		||||
        if (ball.RigidBody.Velocity.MagnitudeSquared > 0.01f)
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        Reset();
 | 
			
		||||
        ball.LaunchBall(GetBallLaunchDirection());
 | 
			
		||||
        logger?.Log(this, $"Game started");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private class RequestStartPacket : INetworkPacket;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user