Merge branch 'main' of github.com:LeGall29/GGJ2024
This commit is contained in:
commit
8b035e6a30
@ -625,10 +625,10 @@ RectTransform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1908036955}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 512, y: 512}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1128585036
|
||||
MonoBehaviour:
|
||||
@ -643,6 +643,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
webCamTexture: {fileID: 0}
|
||||
freezeButton: {fileID: 1776746473}
|
||||
resumeButton: {fileID: 1872873213}
|
||||
--- !u!114 &1128585037
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -217,6 +217,65 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &1160494271
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1160494274}
|
||||
- component: {fileID: 1160494273}
|
||||
- component: {fileID: 1160494272}
|
||||
m_Layer: 0
|
||||
m_Name: GameObject
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1160494272
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1160494271}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: de098f8fd5f884a1aa55db7874246b92, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
propositionTime: 60
|
||||
votingTime: 20
|
||||
--- !u!114 &1160494273
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1160494271}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 153bd176c0ad8f82692512264f5245ba, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!4 &1160494274
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1160494271}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1330841196
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -309,72 +368,10 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1963197093
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1963197096}
|
||||
- component: {fileID: 1963197095}
|
||||
- component: {fileID: 1963197094}
|
||||
m_Layer: 0
|
||||
m_Name: GameObject
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1963197094
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1963197093}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0735c225bee4c490bbef74cb455fa748, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
promptList: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2}
|
||||
addPrompt:
|
||||
<id>k__BackingField: 8c52bab5-726b-42d6-bc54-42ed1898a50c
|
||||
<fr>k__BackingField: hello
|
||||
<en>k__BackingField: coucou
|
||||
--- !u!114 &1963197095
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1963197093}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 153bd176c0ad8f82692512264f5245ba, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!4 &1963197096
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1963197093}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 1330841199}
|
||||
- {fileID: 272045953}
|
||||
- {fileID: 1963197096}
|
||||
- {fileID: 1160494274}
|
||||
|
@ -11,14 +11,34 @@ public class CameraManager : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
webCamTexture = new WebCamTexture();
|
||||
//gameObject.transform.rotation = transform.rotation * Quaternion.AngleAxis(webCamTexture.videoRotationAngle, Vector3.up);
|
||||
WebcamResume();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
gameObject.GetComponent<RawImage>().texture = webCamTexture;
|
||||
gameObject.GetComponent<RawImage>().material.mainTexture = webCamTexture;
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var size = webCamTexture.height;
|
||||
|
||||
if (webCamTexture.height > webCamTexture.width)
|
||||
{
|
||||
size = webCamTexture.width;
|
||||
y = (webCamTexture.height - webCamTexture.width) / 2;
|
||||
}
|
||||
else if (webCamTexture.height < webCamTexture.width)
|
||||
{
|
||||
size = webCamTexture.height;
|
||||
x = (webCamTexture.width - webCamTexture.height) / 2;
|
||||
}
|
||||
|
||||
Texture2D cropped = new(size, size);
|
||||
cropped.SetPixels(webCamTexture.GetPixels(x, y, size, size));
|
||||
cropped.Apply();
|
||||
|
||||
gameObject.GetComponent<RawImage>().texture = cropped;
|
||||
gameObject.GetComponent<RawImage>().material.mainTexture = cropped;
|
||||
}
|
||||
|
||||
public void WebcamResume()
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class Room
|
||||
@ -7,5 +8,15 @@ public class Room
|
||||
public List<Question> questions;
|
||||
public List<Player> players;
|
||||
public int currentQuestion;
|
||||
public int creationDate;
|
||||
public double creationDate;
|
||||
|
||||
|
||||
public Room(string _code)
|
||||
{
|
||||
this.code = _code;
|
||||
this.creationDate = System.DateTime.Now.ToOADate();
|
||||
this.players = new List<Player>();
|
||||
this.questions = new List<Question>();
|
||||
this.currentQuestion = 0;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine.Android;
|
||||
|
||||
public class FirebaseInitializer : MonoBehaviour
|
||||
{
|
||||
@ -14,8 +15,10 @@ void Awake()
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
IEnumerable Start()
|
||||
void Start()
|
||||
{
|
||||
AskForCameraAuthorizationForAndroid();
|
||||
|
||||
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
|
||||
{
|
||||
var dependencyStatus = task.Result;
|
||||
@ -33,8 +36,6 @@ IEnumerable Start()
|
||||
Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}");
|
||||
}
|
||||
});
|
||||
|
||||
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@ -61,4 +62,30 @@ void Authenticate()
|
||||
onFirebaseReady?.Invoke();
|
||||
});
|
||||
}
|
||||
|
||||
private void AskForCameraAuthorizationForAndroid()
|
||||
{
|
||||
if (Permission.HasUserAuthorizedPermission(Permission.Microphone))
|
||||
{
|
||||
// The user authorized use of the microphone.
|
||||
}
|
||||
else
|
||||
{
|
||||
bool useCallbacks = false;
|
||||
if (!useCallbacks)
|
||||
{
|
||||
// We do not have permission to use the microphone.
|
||||
// Ask for permission or proceed without the functionality enabled.
|
||||
Permission.RequestUserPermission(Permission.Microphone);
|
||||
}
|
||||
else
|
||||
{
|
||||
var callbacks = new PermissionCallbacks();
|
||||
//callbacks.PermissionDenied += PermissionCallbacks_PermissionDenied;
|
||||
//callbacks.PermissionGranted += PermissionCallbacks_PermissionGranted;
|
||||
//callbacks.PermissionDeniedAndDontAskAgain += PermissionCallbacks_PermissionDeniedAndDontAskAgain;
|
||||
Permission.RequestUserPermission(Permission.Microphone, callbacks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: -50
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
@ -1,10 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Firebase;
|
||||
using Firebase.Database;
|
||||
using Firebase.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public class RoomManager : MonoBehaviour
|
||||
{
|
||||
private RoomState currentState;
|
||||
private Room currentRoom = null;
|
||||
private List<Player> players;
|
||||
|
||||
public float propositionTime = 60;
|
||||
@ -25,13 +31,108 @@ public class RoomManager : MonoBehaviour
|
||||
/// </summary>
|
||||
private int numberOfQuestionVoted = 0;
|
||||
|
||||
DatabaseReference realtimeDB;
|
||||
|
||||
/// <summary>
|
||||
/// TextMeshPro that show the value of the current rooom code
|
||||
/// </summary>
|
||||
public TextMeshProUGUI roomCodeLabel;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
FirebaseInitializer.Instance.onFirebaseReady += Initialize;
|
||||
}
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
propositionCurrentTime = propositionTime;
|
||||
votingCurrentTime = votingTime;
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
realtimeDB.Child("rooms").Child(currentRoom.code).RemoveValueAsync();
|
||||
Debug.Log($"delete room {currentRoom.code}");
|
||||
currentRoom = null;
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
FirebaseInitializer.Instance.onFirebaseReady -= Initialize;
|
||||
realtimeDB = FirebaseDatabase.DefaultInstance.RootReference;
|
||||
Debug.Log("Realtime DB initialized");
|
||||
CreateNewRoom();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check all the rooms in the server and give back the number already taken
|
||||
/// </summary>
|
||||
private void WhichCodesAreAlreadyUsed(Action<List<int>> callback_OnCodesChecked)
|
||||
{
|
||||
List<int> alreadyUsedCodes = new List<int>();
|
||||
realtimeDB.Child("rooms").GetValueAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
if (task.IsFaulted)
|
||||
{
|
||||
Debug.LogException(task.Exception);
|
||||
}
|
||||
else if (task.IsCompleted)
|
||||
{
|
||||
DataSnapshot snapshot = task.Result;
|
||||
List<Room> onlineRooms = JsonUtility.FromJson<List<Room>>(snapshot.GetRawJsonValue());
|
||||
foreach (Room r in onlineRooms)
|
||||
{
|
||||
alreadyUsedCodes.Add(int.Parse(r.code));
|
||||
}
|
||||
}
|
||||
callback_OnCodesChecked?.Invoke(alreadyUsedCodes);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically called at start of game
|
||||
/// </summary>
|
||||
[ContextMenu("Create New Room")]
|
||||
public void CreateNewRoom()
|
||||
{
|
||||
WhichCodesAreAlreadyUsed(codes =>
|
||||
{
|
||||
Room newRoom = new Room(GenerateRandomAvailableCode(codes).ToString("D4"));
|
||||
currentRoom = newRoom;
|
||||
string JSON = JsonUtility.ToJson(newRoom);
|
||||
realtimeDB.Child("rooms").Child(newRoom.code).SetRawJsonValueAsync(JSON).ContinueWithOnMainThread(task =>
|
||||
{
|
||||
Debug.Log($"room {currentRoom.code} has been created on the server");
|
||||
//TODO MARINE : uncomment and reference the correct game object
|
||||
//roomCodeLabel.text = currentRoom.code;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a code between 0 and 1000 that is not in the list
|
||||
/// </summary>
|
||||
/// <param name="_impossibleCodes">the list of code you don"t want to get</param>
|
||||
/// <returns></returns>
|
||||
private int GenerateRandomAvailableCode(List<int> _impossibleCodes)
|
||||
{
|
||||
int random = UnityEngine.Random.Range(0, 1000);
|
||||
while (_impossibleCodes.Contains(random))
|
||||
{
|
||||
Debug.Log($"{random} is already taken, choosing another room code", this);
|
||||
random = UnityEngine.Random.Range(0, 1000);
|
||||
}
|
||||
return random;
|
||||
}
|
||||
|
||||
private void DisplayRoomCode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void PlayerSendProposition(Proposition _proposition)
|
||||
{
|
||||
|
||||
|
@ -8,7 +8,7 @@ PlayerSettings:
|
||||
AndroidProfiler: 0
|
||||
AndroidFilterTouchesWhenObscured: 0
|
||||
AndroidEnableSustainedPerformanceMode: 0
|
||||
defaultScreenOrientation: 4
|
||||
defaultScreenOrientation: 0
|
||||
targetDevice: 2
|
||||
useOnDemandResources: 0
|
||||
accelerometerFrequency: 60
|
||||
@ -48,7 +48,6 @@ PlayerSettings:
|
||||
defaultScreenHeightWeb: 600
|
||||
m_StereoRenderingPath: 0
|
||||
m_ActiveColorSpace: 1
|
||||
unsupportedMSAAFallback: 0
|
||||
m_SpriteBatchVertexThreshold: 300
|
||||
m_MTRendering: 1
|
||||
mipStripping: 0
|
||||
@ -76,7 +75,6 @@ PlayerSettings:
|
||||
androidMinimumWindowWidth: 400
|
||||
androidMinimumWindowHeight: 300
|
||||
androidFullscreenMode: 1
|
||||
androidAutoRotationBehavior: 1
|
||||
defaultIsNativeResolution: 1
|
||||
macRetinaSupport: 1
|
||||
runInBackground: 1
|
||||
@ -88,7 +86,6 @@ PlayerSettings:
|
||||
hideHomeButton: 0
|
||||
submitAnalytics: 1
|
||||
usePlayerLog: 1
|
||||
dedicatedServerOptimizations: 0
|
||||
bakeCollisionMeshes: 0
|
||||
forceSingleInstance: 0
|
||||
useFlipModelSwapchain: 1
|
||||
@ -128,7 +125,6 @@ PlayerSettings:
|
||||
switchNVNMaxPublicTextureIDCount: 0
|
||||
switchNVNMaxPublicSamplerIDCount: 0
|
||||
switchNVNGraphicsFirmwareMemory: 32
|
||||
switchMaxWorkerMultiple: 8
|
||||
stadiaPresentMode: 0
|
||||
stadiaTargetFramerate: 0
|
||||
vulkanNumSwapchainBuffers: 3
|
||||
@ -137,8 +133,6 @@ PlayerSettings:
|
||||
vulkanEnableLateAcquireNextImage: 0
|
||||
vulkanEnableCommandBufferRecycling: 1
|
||||
loadStoreDebugModeEnabled: 0
|
||||
visionOSBundleVersion: 1.0
|
||||
tvOSBundleVersion: 1.0
|
||||
bundleVersion: 0.1
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
@ -151,7 +145,6 @@ PlayerSettings:
|
||||
isWsaHolographicRemotingEnabled: 0
|
||||
enableFrameTimingStats: 0
|
||||
enableOpenGLProfilerGPURecorders: 1
|
||||
allowHDRDisplaySupport: 0
|
||||
useHDRDisplay: 0
|
||||
hdrBitDepth: 0
|
||||
m_ColorGamuts: 00000000
|
||||
@ -163,6 +156,7 @@ PlayerSettings:
|
||||
applicationIdentifier:
|
||||
Android: fr.snaparazzi
|
||||
Standalone: fr.spnaparazzi
|
||||
iPhone: fr.snaparazzi
|
||||
buildNumber:
|
||||
Standalone: 0
|
||||
VisionOS: 0
|
||||
@ -596,7 +590,7 @@ PlayerSettings:
|
||||
switchSocketConcurrencyLimit: 14
|
||||
switchScreenResolutionBehavior: 2
|
||||
switchUseCPUProfiler: 0
|
||||
switchEnableFileSystemTrace: 0
|
||||
switchUseGOLDLinker: 0
|
||||
switchLTOSetting: 0
|
||||
switchApplicationID: 0x01004b9000490000
|
||||
switchNSODependencies:
|
||||
@ -726,6 +720,7 @@ PlayerSettings:
|
||||
switchSocketBufferEfficiency: 4
|
||||
switchSocketInitializeEnabled: 1
|
||||
switchNetworkInterfaceManagerInitializeEnabled: 1
|
||||
switchPlayerConnectionEnabled: 1
|
||||
switchUseNewStyleFilepaths: 1
|
||||
switchUseLegacyFmodPriorities: 0
|
||||
switchUseMicroSleepForYield: 1
|
||||
|
Loading…
Reference in New Issue
Block a user