style: refacto

This commit is contained in:
Michel Roux 2024-01-27 21:07:49 +01:00
parent 94c3daa525
commit 96bc36cf5e
2 changed files with 9 additions and 31 deletions

View File

@ -1,12 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Firebase.Database;
using Firebase.Extensions;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
/// <summary>
/// This is the game state manager on the phone side
@ -14,10 +11,9 @@
public class GameManager : MonoBehaviour
{
private GameState currentState;
private List<Player> players = new List<Player>();
private List<Player> players = new();
public Player currentPlayer = null;
public Question currentQuestion = null;
[Header("Other component")]
public float explanationTime = 4f;
@ -30,12 +26,10 @@ public class GameManager : MonoBehaviour
public TextMeshProUGUI nameError;
public UnityEngine.UI.Button submitNewPlayer;
[Header("WaitingRoom Component")]
public TextMeshProUGUI listPlayersUI;
public GameObject submitStartGame;
[Header("Pages")]
public GameObject HomeConnection;
public GameObject WaitingRoom;
@ -45,8 +39,6 @@ public class GameManager : MonoBehaviour
public GameObject WaitingOtherPlayers;
public GameObject EndGame;
private DatabaseReference realtimeDB;
public Room myRoom;
private DatabaseReference myOnlineRoom;
@ -63,7 +55,6 @@ private void Start()
submitNewPlayer.interactable = false;
}
public GameState GetCurrentState()
{
return currentState;
@ -85,6 +76,7 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
{
nameError.gameObject.SetActive(false);
roomError.gameObject.SetActive(false);
if (string.IsNullOrEmpty(_name))
{
Debug.LogError("Player name is empty", this);
@ -105,6 +97,7 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
//TODO : MARINE : use the error label to explain to the user that they have forget to put a room code
return;
}
currentPlayer = new Player(_name);
//check if the room exists, if not display an error message
@ -123,7 +116,6 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
JoinRoom(() =>
{
//then subscribe to it
myOnlineRoom.ValueChanged += OnRoomUpdate;
currentState = GameState.WaitingForOtherPlayersToJoin;
players.Add(currentPlayer);
@ -132,14 +124,9 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
HomeConnection.SetActive(false);
UpdateDisplayedListUser();
});
}
});
}
private void CheckIfRoomExists(string _roomCode, Action<Room> callback_Room)
@ -192,8 +179,6 @@ private void JoinRoom(Action callback_OnRoomJoined)
{
Debug.LogException(ex);
}
}
/// <summary>
@ -202,13 +187,9 @@ private void JoinRoom(Action callback_OnRoomJoined)
public void StartGame()
{
// send Start Game
currentState = GameState.Explanation;
WaitingRoom.SetActive(false);
BeforeStart.SetActive(true);
}
/// <summary>
@ -219,8 +200,6 @@ public void StartGame()
public void MakeAProposition(Prompt _prompt)
{
currentState = GameState.MakeProposition;
}
/// <summary>
@ -230,7 +209,6 @@ public void MakeAProposition(Prompt _prompt)
public void SubmitProposition()
{
Proposition temp = new Proposition();
}
/// <summary>

View File

@ -1,3 +1,4 @@
using Firebase.Database;
using Firebase.Storage;
using System;
using System.Threading.Tasks;
@ -8,6 +9,7 @@ public class StorageManager : MonoBehaviour
public GameObject PicturePlayer;
public GameObject Canvas;
private FirebaseStorage storage;
private DatabaseReference realtimeDB;
void Awake()
{
@ -18,6 +20,7 @@ void Initialize()
{
FirebaseInitializer.Instance.onFirebaseReady -= Initialize;
storage = FirebaseStorage.DefaultInstance;
realtimeDB = FirebaseDatabase.DefaultInstance.RootReference;
}
// Start is called before the first frame update
@ -47,16 +50,13 @@ public void UploadPhoto()
{
if (task.IsFaulted || task.IsCanceled)
{
Debug.Log(task.Exception.ToString());
Debug.LogException(task.Exception);
// Uh-oh, an error occurred!
}
else
{
// Metadata contains file metadata such as size, content-type, and md5hash.
StorageMetadata metadata = task.Result;
string md5Hash = metadata.Md5Hash;
Debug.Log("Finished uploading...");
Debug.Log("md5 hash = " + md5Hash);
}
});