final feedbacks fixed

This commit is contained in:
2026-04-20 14:36:51 +05:30
parent 4ba7623b13
commit f31f90034c
9 changed files with 570 additions and 1989 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+69 -11
View File
@@ -1,12 +1,70 @@
Logger initiated at 4/17/2026 4:44:02 PM Logger initiated at 4/20/2026 12:35:01 PM
[4/17/2026 4:44:02 PM] Invalid Room port [4/20/2026 12:35:01 PM] Invalid Room port
[4/17/2026 4:44:10 PM] Game started On Server [4/20/2026 12:35:07 PM] Game started On Server
[4/17/2026 4:44:25 PM] Selected team changed from Red to Blue [4/20/2026 12:35:16 PM] force = 70 * 0.9955804 = 69.69063
[4/17/2026 4:44:25 PM] Selected team changed from Red to Blue [4/20/2026 12:35:16 PM] launching puck at (-0.13, -5.00) with (8.73, 348.34) force
[4/17/2026 4:44:40 PM] Selected team changed from Blue to Red [4/20/2026 12:35:19 PM] Selected team changed from Red to Blue
[4/17/2026 4:44:40 PM] Selected team changed from Blue to Red [4/20/2026 12:35:19 PM] Selected team changed from Red to Blue
[4/17/2026 4:44:55 PM] Selected team changed from Red to Blue [4/20/2026 12:35:24 PM] force = 70 * 0.9955804 = 69.69063
[4/17/2026 4:44:55 PM] Selected team changed from Red to Blue [4/20/2026 12:35:24 PM] launching puck at (-4.87, 1.12) with (339.56, -78.24) force
[4/17/2026 4:45:10 PM] Selected team changed from Blue to Red [4/20/2026 12:35:27 PM] Selected team changed from Blue to Red
[4/17/2026 4:45:10 PM] Selected team changed from Blue to Red [4/20/2026 12:35:27 PM] Selected team changed from Blue to Red
[4/20/2026 12:35:31 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:35:31 PM] launching puck at (-0.16, -5.00) with (11.38, 348.27) force
[4/20/2026 12:35:34 PM] Selected team changed from Red to Blue
[4/20/2026 12:35:34 PM] Selected team changed from Red to Blue
[4/20/2026 12:35:38 PM] force = 70 * 0.9068644 = 63.48051
[4/20/2026 12:35:38 PM] launching puck at (1.95, -3.56) with (-123.52, 225.95) force
[4/20/2026 12:35:38 PM] Score changed from 0 to 1
[4/20/2026 12:35:38 PM] Score changed from 0 to 1
[4/20/2026 12:35:41 PM] Selected team changed from Blue to Red
[4/20/2026 12:35:41 PM] Selected team changed from Blue to Red
[4/20/2026 12:35:44 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:35:44 PM] launching puck at (-0.01, -5.00) with (0.88, 348.45) force
[4/20/2026 12:35:47 PM] Selected team changed from Red to Blue
[4/20/2026 12:35:47 PM] Selected team changed from Red to Blue
[4/20/2026 12:35:50 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:35:50 PM] launching puck at (2.67, 4.23) with (-185.81, -294.78) force
[4/20/2026 12:35:53 PM] Selected team changed from Blue to Red
[4/20/2026 12:35:53 PM] Selected team changed from Blue to Red
[4/20/2026 12:35:54 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:35:54 PM] launching puck at (0.71, -4.95) with (-49.46, 344.93) force
[4/20/2026 12:35:57 PM] Selected team changed from Red to Blue
[4/20/2026 12:35:57 PM] Selected team changed from Red to Blue
[4/20/2026 12:35:58 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:35:58 PM] launching puck at (1.66, -4.72) with (-115.84, 328.63) force
[4/20/2026 12:36:00 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:00 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:02 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:36:02 PM] launching puck at (1.10, -4.88) with (-76.67, 339.91) force
[4/20/2026 12:36:05 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:05 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:09 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:36:09 PM] launching puck at (1.23, -4.85) with (-85.93, 337.69) force
[4/20/2026 12:36:11 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:11 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:13 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:36:13 PM] launching puck at (-1.53, -4.76) with (106.34, 331.83) force
[4/20/2026 12:36:15 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:15 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:17 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:36:17 PM] launching puck at (-3.08, -3.94) with (214.66, 274.48) force
[4/20/2026 12:36:17 PM] Score changed from 1 to 2
[4/20/2026 12:36:17 PM] Score changed from 1 to 2
[4/20/2026 12:36:20 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:20 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:22 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:36:22 PM] launching puck at (0.01, -5.00) with (-0.52, 348.45) force
[4/20/2026 12:36:26 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:26 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:30 PM] force = 70 * 0.3522352 = 24.65646
[4/20/2026 12:36:30 PM] launching puck at (0.69, 0.88) with (-16.97, -21.63) force
[4/20/2026 12:36:33 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:33 PM] Selected team changed from Blue to Red
[4/20/2026 12:36:34 PM] force = 70 * 0.9955804 = 69.69063
[4/20/2026 12:36:34 PM] launching puck at (-0.44, -4.98) with (30.69, 347.10) force
[4/20/2026 12:36:34 PM] Score changed from 2 to 3
[4/20/2026 12:36:34 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:34 PM] Selected team changed from Red to Blue
[4/20/2026 12:36:34 PM] Score changed from 2 to 3
+6 -4
View File
@@ -266,8 +266,8 @@ Transform:
m_GameObject: {fileID: 17454381} m_GameObject: {fileID: 17454381}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.0146, y: -4.9612, z: 0} m_LocalPosition: {x: -0.0146, y: -5.0232, z: 0}
m_LocalScale: {x: 1.7868928, y: 0.74575037, z: 1} m_LocalScale: {x: 1.7868928, y: 0.62173206, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@@ -3612,6 +3612,7 @@ MonoBehaviour:
evaluationMethod: 0 evaluationMethod: 0
evaluationInterval: 3 evaluationInterval: 3
timeInterpolationGui: 0 timeInterpolationGui: 0
reconnectIntervalSeconds: 15
--- !u!114 &457077296 --- !u!114 &457077296
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -3786,8 +3787,8 @@ Transform:
m_GameObject: {fileID: 467609672} m_GameObject: {fileID: 467609672}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.0146, y: 4.917, z: 0} m_LocalPosition: {x: -0.0146, y: 4.9764, z: 0}
m_LocalScale: {x: 1.7868928, y: 0.70676565, z: 1} m_LocalScale: {x: 1.7868928, y: 0.5880415, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@@ -11432,6 +11433,7 @@ MonoBehaviour:
syncInterval: 0 syncInterval: 0
m_isMoving: 0 m_isMoving: 0
gameStarted: 0 gameStarted: 0
isGameEnded: 0
SelectedTeam: 0 SelectedTeam: 0
turnTimer: 15 turnTimer: 15
turnTimerCounter: 0 turnTimerCounter: 0
+21 -1
View File
@@ -67,6 +67,8 @@ public class GameManager : NetworkBehaviour
public bool m_isMoving =false; public bool m_isMoving =false;
[SyncVar(hook = nameof(OnGameStartedChanged))] [SyncVar(hook = nameof(OnGameStartedChanged))]
public bool gameStarted = false; public bool gameStarted = false;
[SyncVar]
public bool isGameEnded = false;
void OnGameStartedChanged(bool oldStarted, bool newStarted){ void OnGameStartedChanged(bool oldStarted, bool newStarted){
if(newStarted){ if(newStarted){
GameCanvas.instance.HideWaitingForOpponentPanel(); GameCanvas.instance.HideWaitingForOpponentPanel();
@@ -509,18 +511,33 @@ public class GameManager : NetworkBehaviour
} }
Team GetOpposingTeam(Team team){
return team == Team.Red ? Team.Blue : Team.Red;
}
void SetKickoffTeam(Team kickoffTeam){
turnTimerCounter = 0;
SelectedTeam = kickoffTeam;
OnTeamChanged?.Invoke(SelectedTeam);
}
public void OnGoal(Team team){ public void OnGoal(Team team){
if(!isServer){ if(!isServer){
Debug.LogWarning("OnGoal called on client, skipping"); Debug.LogWarning("OnGoal called on client, skipping");
return;} return;}
if(!CanProcessGoal){
return;
}
RpcPlayGoalScoredSfx(); RpcPlayGoalScoredSfx();
freezeInput=true; freezeInput=true;
Team concedingTeam = GetOpposingTeam(team);
if(hitCounter == 1){ if(hitCounter == 1){
//kickoff goal //kickoff goal
Logger.Log("Kickoff goal"); Logger.Log("Kickoff goal");
SetKickoffTeam(concedingTeam);
StartCoroutine(CoroutineOnGoal(team,true));//true = Kickoff goal, reset only the ball StartCoroutine(CoroutineOnGoal(team,true));//true = Kickoff goal, reset only the ball
hitCounter = 0; hitCounter = 0;
@@ -536,14 +553,16 @@ public class GameManager : NetworkBehaviour
PlayGoalEffects(Team.Red); PlayGoalEffects(Team.Red);
} }
SwitchTeams(); SetKickoffTeam(concedingTeam);
if(blueScore >= 3){ if(blueScore >= 3){
isGameEnded = true;
ReportDedicatedMatchGameOver(Team.Blue); ReportDedicatedMatchGameOver(Team.Blue);
RpcGameOver(Team.Blue); RpcGameOver(Team.Blue);
gameOver(Team.Blue); gameOver(Team.Blue);
}else if(redScore >= 3){ }else if(redScore >= 3){
isGameEnded = true;
ReportDedicatedMatchGameOver(Team.Red); ReportDedicatedMatchGameOver(Team.Red);
RpcGameOver(Team.Red); RpcGameOver(Team.Red);
gameOver(Team.Red); gameOver(Team.Red);
@@ -680,6 +699,7 @@ public class GameManager : NetworkBehaviour
} }
bool freezeInput = false; bool freezeInput = false;
public bool CanProcessGoal => isServer && !freezeInput && !isGameEnded;
IEnumerator CoroutineOnGoal(Team team, bool kickoff = false){ IEnumerator CoroutineOnGoal(Team team, bool kickoff = false){
if(coroutinePostLaunch!=null){ if(coroutinePostLaunch!=null){
+3
View File
@@ -9,6 +9,9 @@ public class Goal : NetworkBehaviour
if(!isServer){return;} if(!isServer){return;}
if(collision.gameObject.CompareTag("Player")){ if(collision.gameObject.CompareTag("Player")){
if(GameManager.instance == null || !GameManager.instance.CanProcessGoal){
return;
}
Debug.Log($"GOAL! {team}", gameObject); Debug.Log($"GOAL! {team}", gameObject);
Ball ball = collision.gameObject.GetComponent<Ball>(); Ball ball = collision.gameObject.GetComponent<Ball>();
Debug.Log(ball.name); Debug.Log(ball.name);
+61
View File
@@ -1,11 +1,72 @@
using System.Collections;
using UnityEngine; using UnityEngine;
using Mirror; using Mirror;
public class NetManager : NetworkManager public class NetManager : NetworkManager
{ {
[SerializeField] float reconnectIntervalSeconds = 15f;
Coroutine reconnectCoroutine;
public override void OnStopServer() public override void OnStopServer()
{ {
GameManager.ReportDedicatedMatchRoomClosed(); GameManager.ReportDedicatedMatchRoomClosed();
base.OnStopServer(); base.OnStopServer();
} }
public override void OnStopClient()
{
base.OnStopClient();
TryStartReconnectLoop();
}
public override void OnClientConnect()
{
base.OnClientConnect();
StopReconnectLoop();
}
void TryStartReconnectLoop()
{
if (!ShouldReconnect() || reconnectCoroutine != null)
return;
reconnectCoroutine = StartCoroutine(CoroutineReconnectLoop());
}
void StopReconnectLoop()
{
if (reconnectCoroutine == null)
return;
StopCoroutine(reconnectCoroutine);
reconnectCoroutine = null;
}
bool ShouldReconnect()
{
if (NetworkServer.active)
return false;
if (NetworkClient.isConnected)
return false;
if (GameManager.instance != null && GameManager.instance.isGameEnded)
return false;
return true;
}
IEnumerator CoroutineReconnectLoop()
{
while (ShouldReconnect())
{
if (!NetworkClient.active)
{
Debug.Log("Client disconnected. Reconnecting...");
StartClient();
}
yield return new WaitForSeconds(reconnectIntervalSeconds);
}
reconnectCoroutine = null;
}
} }
+13
View File
@@ -166,9 +166,22 @@ public class Puck : NetworkBehaviour
Debug.Log("Resetting puck", gameObject); Debug.Log("Resetting puck", gameObject);
Vector3 dir = position - transform.position; Vector3 dir = position - transform.position;
Vector3 centerDir = Vector3.zero - transform.position;
dir = dir.normalized; dir = dir.normalized;
centerDir = centerDir.normalized;
// Clamp direction to within 30 degrees of centerDir if needed
float maxAngle = 30f;
float angle = Vector3.Angle(dir, centerDir);
if (angle > maxAngle)
{
dir = Vector3.Slerp(centerDir, dir, maxAngle / angle).normalized;
}
position += dir * 1.25f; position += dir * 1.25f;
Reset(position, duration); Reset(position, duration);
} }
IEnumerator CoroutineReset(Vector3 pos, float duration){ IEnumerator CoroutineReset(Vector3 pos, float duration){