Browse Source

Now with winning

Axel Nordh 5 năm trước cách đây
mục cha
commit
0fcc7d7a7c

+ 52 - 12
Assets/NewDropZoneScript.cs

@@ -5,6 +5,7 @@ using UnityEngine;
 using UnityEngine.Events;
 using UnityEngine.Events;
 using UnityEngine.EventSystems;
 using UnityEngine.EventSystems;
 using UnityEngine.UI;
 using UnityEngine.UI;
+using System.Linq;
 
 
 public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandler, IPointerExitHandler
 public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandler, IPointerExitHandler
 {
 {
@@ -12,7 +13,7 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
     public bool RightmostSpacer;
     public bool RightmostSpacer;
     public bool LeftmostSpacer;
     public bool LeftmostSpacer;
     public GameObject AnswerLineQuestionCardPrefab;
     public GameObject AnswerLineQuestionCardPrefab;
-    public float preferedWidth = 30;
+    private float preferedWidth;
 
 
     private AnswerLineQuestionCard leftSibling;
     private AnswerLineQuestionCard leftSibling;
     private AnswerLineQuestionCard rightSibling;
     private AnswerLineQuestionCard rightSibling;
@@ -20,6 +21,13 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
     private GameObject draggedQuestion;
     private GameObject draggedQuestion;
 
 
     private bool answeredCorrectly = false;
     private bool answeredCorrectly = false;
+    private RectTransform newQuestionRect;
+
+    private bool preferedWidthUpdated = false;
+    private void Start() {
+        newQuestionRect = GameObject.Find("NewQuestion").GetComponent<RectTransform>();
+        preferedWidth = newQuestionRect.rect.width;
+    }
     public void OnDrop(PointerEventData eventData)
     public void OnDrop(PointerEventData eventData)
     {
     {
         if (eventData != null && draggedQuestion != null)
         if (eventData != null && draggedQuestion != null)
@@ -48,6 +56,20 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
         }
         }
     }
     }
 
 
+    private void UpdatePreferedWidth() {
+        if (preferedWidth <= 10) {
+            preferedWidth = GameObject.Find("NewQuestion").GetComponent<RectTransform>().rect.width;
+        } else {
+            preferedWidthUpdated = true;
+        }
+    }
+
+    private void Update() {
+        if (!preferedWidthUpdated) {
+            UpdatePreferedWidth();
+        }
+    }
+
     private void CheckAnswerFunction()
     private void CheckAnswerFunction()
     {
     {
         if (answeredCorrectly) {
         if (answeredCorrectly) {
@@ -59,19 +81,22 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
             newAnsweredQuestion.SetId(questionData.Id);
             newAnsweredQuestion.SetId(questionData.Id);
             GameObject AnswerLine = GameObject.FindGameObjectWithTag("AnswerLine");
             GameObject AnswerLine = GameObject.FindGameObjectWithTag("AnswerLine");
             int newAnswerPos = transform.GetSiblingIndex();
             int newAnswerPos = transform.GetSiblingIndex();
+            newAnsweredQuestion.SetQuestionUnSafe();
             newAnsweredQuestion.transform.SetParent(AnswerLine.transform);
             newAnsweredQuestion.transform.SetParent(AnswerLine.transform);
             newAnsweredQuestion.transform.SetSiblingIndex(newAnswerPos);
             newAnsweredQuestion.transform.SetSiblingIndex(newAnswerPos);
             newAnsweredQuestion.transform.localScale = new Vector3(1,1,1);
             newAnsweredQuestion.transform.localScale = new Vector3(1,1,1);
+            newAnsweredQuestion.GetComponent<LayoutElement>().preferredHeight = newQuestionRect.rect.height;
+            newAnsweredQuestion.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
 
 
             if (LeftmostSpacer)
             if (LeftmostSpacer)
             {
             {
                 CreateNewSpacer(AnswerLine, newAnswerPos + 2);
                 CreateNewSpacer(AnswerLine, newAnswerPos + 2);
-                CreateLeftSpacer(AnswerLine);
+                CreateLeftSpacer(AnswerLine, newQuestionRect.rect.width);
             }
             }
             else if (RightmostSpacer)
             else if (RightmostSpacer)
             {
             {
                 CreateNewSpacer(AnswerLine, newAnswerPos);
                 CreateNewSpacer(AnswerLine, newAnswerPos);
-                CreateRightSpacer(AnswerLine);
+                CreateRightSpacer(AnswerLine, newQuestionRect.rect.width);
             }
             }
             else
             else
             {
             {
@@ -81,18 +106,34 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
             Destroy(gameObject);
             Destroy(gameObject);
             GameObject.Find("GameManager").GetComponent<GameManagerScript>().StopTimer();
             GameObject.Find("GameManager").GetComponent<GameManagerScript>().StopTimer();
             // TODO Check win condition, if met show Congratulations and send loss message to others
             // TODO Check win condition, if met show Congratulations and send loss message to others
+            GameObject.Find("GameManager").GetComponent<GameManagerScript>().CheckWin(AnswerLine.GetComponentsInChildren<QuestionCard>().ToList());
+            
             draggedQuestion.GetComponentInParent<NewQuestionCardController>().GenerateNewQuestion();
             draggedQuestion.GetComponentInParent<NewQuestionCardController>().GenerateNewQuestion();
         } else { // Wrong answer
         } else { // Wrong answer
-        // TODO Visa fel svar dialog
-            GameObject.Find("GameManager").GetComponent<GameManagerScript>().RemoveUnlockedQuestions();
-            GameObject.Find("GameManager").GetComponent<GameManagerScript>().NextRound();
+            GameObject.Find("GameManager").GetComponent<GameManagerScript>().StopTimer();
+            questionData = draggedQuestion.GetComponentInParent<NewQuestionDragController>()
+                .NewQuestion.GetComponentInParent<NewQuestionsPanel>()
+                .QuestionData;
+            GenericDialog dialog = GenericDialog.Instance();
+            string title = string.Format(LocalizationManager.Instance.GetText("DROPPED_QUESTION_WRONG_ANSWER_TITLE"), questionData.Answer);
+            dialog.SetTitle(title);
+            string message = LocalizationManager.Instance.GetText("DROPPED_QUESTION_WRONG_ANSWER_MESSAGE");
+            dialog.SetMessage(String.Format(message, GameObject.Find("GameManager").GetComponent<GameManagerScript>().GetUnlockedQuestionsCount()));
+            dialog.SetOnAccept(LocalizationManager.Instance.GetText("OK"), () => {
+
+                GameObject.Find("GameManager").GetComponent<GameManagerScript>().RemoveUnlockedQuestions();
+                GameObject.Find("GameManager").GetComponent<GameManagerScript>().NextRound();
+                dialog.Hide();
+            });
+            dialog.SetOnDecline("", () => dialog.Hide());
+            dialog.Show();
         }
         }
     }
     }
     
     
-    private void CreateLeftSpacer(GameObject AnswerLine)
+    private void CreateLeftSpacer(GameObject AnswerLine, float width)
     {
     {
         GameObject newSpacerLeft = Instantiate(gameObject);     
         GameObject newSpacerLeft = Instantiate(gameObject);     
-        newSpacerLeft.GetComponent<LayoutElement>().preferredWidth = preferedWidth;
+        newSpacerLeft.GetComponent<LayoutElement>().preferredWidth = width;
         newSpacerLeft.name = "LeftDropZone";
         newSpacerLeft.name = "LeftDropZone";
         newSpacerLeft.GetComponent<NewDropZoneScript>().LeftmostSpacer = true;
         newSpacerLeft.GetComponent<NewDropZoneScript>().LeftmostSpacer = true;
         newSpacerLeft.transform.SetParent(AnswerLine.transform);
         newSpacerLeft.transform.SetParent(AnswerLine.transform);
@@ -100,10 +141,10 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
         newSpacerLeft.transform.localScale = new Vector3(1,1,1);
         newSpacerLeft.transform.localScale = new Vector3(1,1,1);
     }
     }
 
 
-    private void CreateRightSpacer(GameObject AnswerLine)
+    private void CreateRightSpacer(GameObject AnswerLine, float width)
     {
     {
         GameObject newSpacerRight = Instantiate(gameObject);     
         GameObject newSpacerRight = Instantiate(gameObject);     
-        newSpacerRight.GetComponent<LayoutElement>().preferredWidth = preferedWidth;
+        newSpacerRight.GetComponent<LayoutElement>().preferredWidth = width;
         newSpacerRight.name = "RightDropZone";
         newSpacerRight.name = "RightDropZone";
         newSpacerRight.GetComponent<NewDropZoneScript>().RightmostSpacer = true;
         newSpacerRight.GetComponent<NewDropZoneScript>().RightmostSpacer = true;
         newSpacerRight.transform.SetParent(AnswerLine.transform);
         newSpacerRight.transform.SetParent(AnswerLine.transform);
@@ -117,7 +158,7 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
         GameObject newSpacer = Instantiate(gameObject);
         GameObject newSpacer = Instantiate(gameObject);
         newSpacer.GetComponent<NewDropZoneScript>().LeftmostSpacer = false;
         newSpacer.GetComponent<NewDropZoneScript>().LeftmostSpacer = false;
         newSpacer.GetComponent<NewDropZoneScript>().RightmostSpacer = false;
         newSpacer.GetComponent<NewDropZoneScript>().RightmostSpacer = false;
-        newSpacer.GetComponent<LayoutElement>().preferredWidth = preferedWidth;
+        newSpacer.GetComponent<LayoutElement>().preferredWidth = 30f;
         newSpacer.name = "DropZone";
         newSpacer.name = "DropZone";
         newSpacer.transform.SetParent(AnswerLine.transform);
         newSpacer.transform.SetParent(AnswerLine.transform);
         newSpacer.transform.SetSiblingIndex(newAnswerPos);
         newSpacer.transform.SetSiblingIndex(newAnswerPos);
@@ -128,7 +169,6 @@ public class NewDropZoneScript : MonoBehaviour, IDropHandler, IPointerEnterHandl
     {
     {
         draggedQuestion = NewQuestionDragController.itemBeeingDragged;
         draggedQuestion = NewQuestionDragController.itemBeeingDragged;
         if (draggedQuestion != null) {
         if (draggedQuestion != null) {
-
             // Expandera aktuell drop yta
             // Expandera aktuell drop yta
             LayoutElement le = transform.GetComponent<LayoutElement>();
             LayoutElement le = transform.GetComponent<LayoutElement>();
             le.preferredWidth = le.preferredWidth + preferedWidth;
             le.preferredWidth = le.preferredWidth + preferedWidth;

+ 28 - 7
Assets/Prefab/AnswerlineQuestion.prefab

@@ -135,7 +135,7 @@ MonoBehaviour:
   m_PrefabInstance: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 4662818861115959987}
   m_GameObject: {fileID: 4662818861115959987}
-  m_Enabled: 0
+  m_Enabled: 1
   m_EditorHideFlags: 0
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
   m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
   m_Name: 
   m_Name: 
@@ -148,9 +148,9 @@ MonoBehaviour:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
-  m_Type: 1
+  m_Type: 2
   m_PreserveAspect: 0
   m_PreserveAspect: 0
-  m_FillCenter: 1
+  m_FillCenter: 0
   m_FillMethod: 4
   m_FillMethod: 4
   m_FillAmount: 1
   m_FillAmount: 1
   m_FillClockwise: 1
   m_FillClockwise: 1
@@ -197,10 +197,10 @@ MonoBehaviour:
   m_Name: 
   m_Name: 
   m_EditorClassIdentifier: 
   m_EditorClassIdentifier: 
   m_IgnoreLayout: 0
   m_IgnoreLayout: 0
-  m_MinWidth: 60
-  m_MinHeight: 100
-  m_PreferredWidth: 120
-  m_PreferredHeight: 200
+  m_MinWidth: 120
+  m_MinHeight: 200
+  m_PreferredWidth: -1
+  m_PreferredHeight: -1
   m_FlexibleWidth: -1
   m_FlexibleWidth: -1
   m_FlexibleHeight: -1
   m_FlexibleHeight: -1
   m_LayoutPriority: 1
   m_LayoutPriority: 1
@@ -723,6 +723,7 @@ GameObject:
   - component: {fileID: 311079892285430443}
   - component: {fileID: 311079892285430443}
   - component: {fileID: 8596713993905610413}
   - component: {fileID: 8596713993905610413}
   - component: {fileID: 1112255313417007316}
   - component: {fileID: 1112255313417007316}
+  - component: {fileID: 5337283622437680365}
   m_Layer: 5
   m_Layer: 5
   m_Name: CardFront
   m_Name: CardFront
   m_TagString: Untagged
   m_TagString: Untagged
@@ -788,6 +789,26 @@ MonoBehaviour:
   m_FillOrigin: 0
   m_FillOrigin: 0
   m_UseSpriteMesh: 0
   m_UseSpriteMesh: 0
   m_PixelsPerUnitMultiplier: 1
   m_PixelsPerUnitMultiplier: 1
+--- !u!114 &5337283622437680365
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 5307012865466936910}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_IgnoreLayout: 0
+  m_MinWidth: -1
+  m_MinHeight: -1
+  m_PreferredWidth: -1
+  m_PreferredHeight: -1
+  m_FlexibleWidth: -1
+  m_FlexibleHeight: -1
+  m_LayoutPriority: 1
 --- !u!1 &8190035091965959887
 --- !u!1 &8190035091965959887
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0

+ 11 - 24
Assets/Prefab/OnlineGamePlayerInfo.prefab

@@ -62,11 +62,10 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_Sprite: {fileID: 21300000, guid: 43c2693555401c8469caa1027a66ff40, type: 3}
   m_Sprite: {fileID: 21300000, guid: 43c2693555401c8469caa1027a66ff40, type: 3}
   m_Type: 0
   m_Type: 0
   m_PreserveAspect: 1
   m_PreserveAspect: 1
@@ -120,8 +119,6 @@ MonoBehaviour:
   m_OnClick:
   m_OnClick:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, Unity.ugui, Version=1.0.0.0,
-      Culture=neutral, PublicKeyToken=null
 --- !u!1 &733526124466213112
 --- !u!1 &733526124466213112
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -184,11 +181,10 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 0}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Type: 1
   m_Type: 1
   m_PreserveAspect: 0
   m_PreserveAspect: 0
@@ -261,11 +257,10 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_Sprite: {fileID: 21300000, guid: e5c71c3784d578c40a141b3d867c9d64, type: 3}
   m_Sprite: {fileID: 21300000, guid: e5c71c3784d578c40a141b3d867c9d64, type: 3}
   m_Type: 0
   m_Type: 0
   m_PreserveAspect: 1
   m_PreserveAspect: 1
@@ -319,8 +314,6 @@ MonoBehaviour:
   m_OnClick:
   m_OnClick:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, Unity.ugui, Version=1.0.0.0,
-      Culture=neutral, PublicKeyToken=null
 --- !u!1 &1272758750496627887
 --- !u!1 &1272758750496627887
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -381,11 +374,10 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_FontData:
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_FontSize: 14
     m_FontSize: 14
@@ -460,11 +452,10 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_FontData:
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_FontSize: 14
     m_FontSize: 14
@@ -541,13 +532,12 @@ MonoBehaviour:
   m_Name: 
   m_Name: 
   m_EditorClassIdentifier: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 0.392}
+  m_Color: {r: 1, g: 1, b: 1, a: 0}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Type: 1
   m_Type: 1
   m_PreserveAspect: 0
   m_PreserveAspect: 0
@@ -655,18 +645,17 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_FontData:
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_FontSize: 14
     m_FontSize: 14
     m_FontStyle: 0
     m_FontStyle: 0
     m_BestFit: 1
     m_BestFit: 1
     m_MinSize: 10
     m_MinSize: 10
-    m_MaxSize: 28
+    m_MaxSize: 18
     m_Alignment: 4
     m_Alignment: 4
     m_AlignByGeometry: 0
     m_AlignByGeometry: 0
     m_RichText: 1
     m_RichText: 1
@@ -738,11 +727,10 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 0.392}
   m_Color: {r: 1, g: 1, b: 1, a: 0.392}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
   m_Type: 1
   m_Type: 1
   m_PreserveAspect: 0
   m_PreserveAspect: 0
@@ -871,11 +859,10 @@ MonoBehaviour:
   m_Material: {fileID: 0}
   m_Material: {fileID: 0}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
   m_RaycastTarget: 1
   m_RaycastTarget: 1
+  m_Maskable: 1
   m_OnCullStateChanged:
   m_OnCullStateChanged:
     m_PersistentCalls:
     m_PersistentCalls:
       m_Calls: []
       m_Calls: []
-    m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, Unity.ugui,
-      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   m_FontData:
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
     m_FontSize: 14
     m_FontSize: 14

+ 2 - 2
Assets/Scenes/MainMenu.unity

@@ -6812,8 +6812,8 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0, y: -15}
-  m_SizeDelta: {x: 0, y: -30}
+  m_AnchoredPosition: {x: 0, y: 10}
+  m_SizeDelta: {x: 0, y: -80}
   m_Pivot: {x: 0.5, y: 0.5}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1886195440
 --- !u!114 &1886195440
 MonoBehaviour:
 MonoBehaviour:

+ 522 - 137
Assets/Scenes/NewGame.unity

@@ -1014,7 +1014,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
   m_AnchorMax: {x: 1, y: 1}
   m_AnchoredPosition: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 0}
+  m_SizeDelta: {x: -4, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &73246510
 --- !u!114 &73246510
 MonoBehaviour:
 MonoBehaviour:
@@ -1647,6 +1647,42 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 136959681}
   m_GameObject: {fileID: 136959681}
   m_CullTransparentMesh: 0
   m_CullTransparentMesh: 0
+--- !u!1 &138570172
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 138570173}
+  m_Layer: 5
+  m_Name: Sliding Area
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &138570173
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 138570172}
+  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_Children:
+  - {fileID: 244890614}
+  m_Father: {fileID: 1003233262}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 1, y: 1}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: -20, y: -20}
+  m_Pivot: {x: 0.5, y: 0.5}
 --- !u!1 &141292943
 --- !u!1 &141292943
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -1735,7 +1771,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 78e7dcec242b8e54db8994e443fcf679, type: 3}
   m_Script: {fileID: 11500000, guid: 78e7dcec242b8e54db8994e443fcf679, type: 3}
   m_Name: 
   m_Name: 
   m_EditorClassIdentifier: 
   m_EditorClassIdentifier: 
-  key: INVITE_PANEL_DIALOG_BUTTON
+  key: INVITE_PANEL_DIALOG_RANDOM_BUTTON
 --- !u!114 &143712429
 --- !u!114 &143712429
 MonoBehaviour:
 MonoBehaviour:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -2219,6 +2255,80 @@ MonoBehaviour:
   m_Name: 
   m_Name: 
   m_EditorClassIdentifier: 
   m_EditorClassIdentifier: 
   questionCardPrefab: {fileID: 0}
   questionCardPrefab: {fileID: 0}
+--- !u!1 &244890613
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 244890614}
+  - component: {fileID: 244890616}
+  - component: {fileID: 244890615}
+  m_Layer: 5
+  m_Name: Handle
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &244890614
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 244890613}
+  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_Children: []
+  m_Father: {fileID: 138570173}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 1, y: 1}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 20, y: 20}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!114 &244890615
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 244890613}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 1
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
+  m_Type: 1
+  m_PreserveAspect: 0
+  m_FillCenter: 1
+  m_FillMethod: 4
+  m_FillAmount: 1
+  m_FillClockwise: 1
+  m_FillOrigin: 0
+  m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
+--- !u!222 &244890616
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 244890613}
+  m_CullTransparentMesh: 0
 --- !u!1 &257771297
 --- !u!1 &257771297
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -2863,6 +2973,82 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 350180539}
   m_GameObject: {fileID: 350180539}
   m_CullTransparentMesh: 0
   m_CullTransparentMesh: 0
+--- !u!1 &362991290
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 362991292}
+  - component: {fileID: 362991291}
+  - component: {fileID: 362991293}
+  m_Layer: 5
+  m_Name: SelectCategoriesSelectionPanel
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &362991291
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 362991290}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_HorizontalFit: 0
+  m_VerticalFit: 2
+--- !u!224 &362991292
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 362991290}
+  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_Children: []
+  m_Father: {fileID: 931732881}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 1, y: 1}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
+  m_Pivot: {x: 0, y: 1}
+--- !u!114 &362991293
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 362991290}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Padding:
+    m_Left: 10
+    m_Right: 0
+    m_Top: 0
+    m_Bottom: 0
+  m_ChildAlignment: 0
+  m_Spacing: 0
+  m_ChildForceExpandWidth: 1
+  m_ChildForceExpandHeight: 1
+  m_ChildControlWidth: 1
+  m_ChildControlHeight: 0
+  m_ChildScaleWidth: 0
+  m_ChildScaleHeight: 0
 --- !u!1 &364473401
 --- !u!1 &364473401
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -3594,6 +3780,113 @@ RectTransform:
   m_AnchoredPosition: {x: -5, y: 0}
   m_AnchoredPosition: {x: -5, y: 0}
   m_SizeDelta: {x: -20, y: 0}
   m_SizeDelta: {x: -20, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
   m_Pivot: {x: 0.5, y: 0.5}
+--- !u!1 &511402647
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 511402648}
+  - component: {fileID: 511402651}
+  - component: {fileID: 511402650}
+  - component: {fileID: 511402649}
+  m_Layer: 5
+  m_Name: SelectCategoriesSelectionPanelSV
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &511402648
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 511402647}
+  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_Children:
+  - {fileID: 931732881}
+  - {fileID: 1003233262}
+  m_Father: {fileID: 1272715544}
+  m_RootOrder: 1
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 1, y: 1}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: -60}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!114 &511402649
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 511402647}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Content: {fileID: 362991292}
+  m_Horizontal: 0
+  m_Vertical: 1
+  m_MovementType: 1
+  m_Elasticity: 0.1
+  m_Inertia: 1
+  m_DecelerationRate: 0.135
+  m_ScrollSensitivity: 1
+  m_Viewport: {fileID: 931732881}
+  m_HorizontalScrollbar: {fileID: 0}
+  m_VerticalScrollbar: {fileID: 1003233263}
+  m_HorizontalScrollbarVisibility: 2
+  m_VerticalScrollbarVisibility: 2
+  m_HorizontalScrollbarSpacing: -3
+  m_VerticalScrollbarSpacing: -3
+  m_OnValueChanged:
+    m_PersistentCalls:
+      m_Calls: []
+--- !u!114 &511402650
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 511402647}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 0.392}
+  m_RaycastTarget: 1
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
+  m_Type: 1
+  m_PreserveAspect: 0
+  m_FillCenter: 1
+  m_FillMethod: 4
+  m_FillAmount: 1
+  m_FillClockwise: 1
+  m_FillOrigin: 0
+  m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
+--- !u!222 &511402651
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 511402647}
+  m_CullTransparentMesh: 0
 --- !u!1 &518841081
 --- !u!1 &518841081
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -6934,7 +7227,7 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 919080018}
   m_GameObject: {fileID: 919080018}
   m_CullTransparentMesh: 0
   m_CullTransparentMesh: 0
---- !u!1 &947883158
+--- !u!1 &931732880
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
   m_CorrespondingSourceObject: {fileID: 0}
@@ -6942,24 +7235,113 @@ GameObject:
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   serializedVersion: 6
   serializedVersion: 6
   m_Component:
   m_Component:
-  - component: {fileID: 947883159}
-  - component: {fileID: 947883161}
-  - component: {fileID: 947883160}
+  - component: {fileID: 931732881}
+  - component: {fileID: 931732884}
+  - component: {fileID: 931732883}
+  - component: {fileID: 931732882}
   m_Layer: 5
   m_Layer: 5
-  m_Name: Text
+  m_Name: Viewport
   m_TagString: Untagged
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
   m_StaticEditorFlags: 0
   m_IsActive: 1
   m_IsActive: 1
---- !u!224 &947883159
+--- !u!224 &931732881
 RectTransform:
 RectTransform:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
   m_CorrespondingSourceObject: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 947883158}
-  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_GameObject: {fileID: 931732880}
+  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_Children:
+  - {fileID: 362991292}
+  m_Father: {fileID: 511402648}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 1, y: 1}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: -17, y: 0}
+  m_Pivot: {x: 0, y: 1}
+--- !u!114 &931732882
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 931732880}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_ShowMaskGraphic: 0
+--- !u!114 &931732883
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 931732880}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 1
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0}
+  m_Type: 1
+  m_PreserveAspect: 0
+  m_FillCenter: 1
+  m_FillMethod: 4
+  m_FillAmount: 1
+  m_FillClockwise: 1
+  m_FillOrigin: 0
+  m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
+--- !u!222 &931732884
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 931732880}
+  m_CullTransparentMesh: 0
+--- !u!1 &947883158
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 947883159}
+  - component: {fileID: 947883161}
+  - component: {fileID: 947883160}
+  m_Layer: 5
+  m_Name: Text
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &947883159
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 947883158}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children: []
   m_Children: []
@@ -7090,6 +7472,130 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 996187386}
   m_GameObject: {fileID: 996187386}
   m_CullTransparentMesh: 0
   m_CullTransparentMesh: 0
+--- !u!1 &1003233261
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1003233262}
+  - component: {fileID: 1003233265}
+  - component: {fileID: 1003233264}
+  - component: {fileID: 1003233263}
+  m_Layer: 5
+  m_Name: Scrollbar Vertical
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &1003233262
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1003233261}
+  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_Children:
+  - {fileID: 138570173}
+  m_Father: {fileID: 511402648}
+  m_RootOrder: 1
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 1, y: 0}
+  m_AnchorMax: {x: 1, y: 1}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 20, y: -17}
+  m_Pivot: {x: 1, y: 1}
+--- !u!114 &1003233263
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1003233261}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 2a4db7a114972834c8e4117be1d82ba3, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Navigation:
+    m_Mode: 3
+    m_SelectOnUp: {fileID: 0}
+    m_SelectOnDown: {fileID: 0}
+    m_SelectOnLeft: {fileID: 0}
+    m_SelectOnRight: {fileID: 0}
+  m_Transition: 1
+  m_Colors:
+    m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
+    m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
+    m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
+    m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
+    m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
+    m_ColorMultiplier: 1
+    m_FadeDuration: 0.1
+  m_SpriteState:
+    m_HighlightedSprite: {fileID: 0}
+    m_PressedSprite: {fileID: 0}
+    m_SelectedSprite: {fileID: 0}
+    m_DisabledSprite: {fileID: 0}
+  m_AnimationTriggers:
+    m_NormalTrigger: Normal
+    m_HighlightedTrigger: Highlighted
+    m_PressedTrigger: Pressed
+    m_SelectedTrigger: Selected
+    m_DisabledTrigger: Disabled
+  m_Interactable: 1
+  m_TargetGraphic: {fileID: 244890615}
+  m_HandleRect: {fileID: 244890614}
+  m_Direction: 2
+  m_Value: 0
+  m_Size: 1
+  m_NumberOfSteps: 0
+  m_OnValueChanged:
+    m_PersistentCalls:
+      m_Calls: []
+--- !u!114 &1003233264
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1003233261}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 1
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
+  m_Type: 1
+  m_PreserveAspect: 0
+  m_FillCenter: 1
+  m_FillMethod: 4
+  m_FillAmount: 1
+  m_FillClockwise: 1
+  m_FillOrigin: 0
+  m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
+--- !u!222 &1003233265
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1003233261}
+  m_CullTransparentMesh: 0
 --- !u!1 &1014093999
 --- !u!1 &1014093999
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -7624,8 +8130,8 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 399.99997, y: -209.99998}
-  m_SizeDelta: {x: 499.99994, y: 319.99997}
+  m_AnchoredPosition: {x: 400, y: -210}
+  m_SizeDelta: {x: 500, y: 320}
   m_Pivot: {x: 0.5, y: 0.5}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1068393618
 --- !u!114 &1068393618
 MonoBehaviour:
 MonoBehaviour:
@@ -8992,7 +9498,7 @@ RectTransform:
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children:
   m_Children:
   - {fileID: 21398510}
   - {fileID: 21398510}
-  - {fileID: 1596031694}
+  - {fileID: 511402648}
   - {fileID: 1530473169}
   - {fileID: 1530473169}
   m_Father: {fileID: 1068393617}
   m_Father: {fileID: 1068393617}
   m_RootOrder: 1
   m_RootOrder: 1
@@ -9953,7 +10459,7 @@ MonoBehaviour:
   CategoryToSelectPrefab: {fileID: 1371924421486162242, guid: 0db0465e0b7d9ed4898de28a6b83a1b7,
   CategoryToSelectPrefab: {fileID: 1371924421486162242, guid: 0db0465e0b7d9ed4898de28a6b83a1b7,
     type: 3}
     type: 3}
   SelectCategoryPanel: {fileID: 728032754}
   SelectCategoryPanel: {fileID: 728032754}
-  ContentPanel: {fileID: 1596031693}
+  ContentPanel: {fileID: 362991290}
 --- !u!114 &1437860097
 --- !u!114 &1437860097
 MonoBehaviour:
 MonoBehaviour:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -10470,8 +10976,8 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 399.99997, y: -209.99998}
-  m_SizeDelta: {x: 499.99994, y: 319.99997}
+  m_AnchoredPosition: {x: 400, y: -210}
+  m_SizeDelta: {x: 500, y: 320}
   m_Pivot: {x: 0.5, y: 0.5}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1556559697
 --- !u!114 &1556559697
 MonoBehaviour:
 MonoBehaviour:
@@ -10691,127 +11197,6 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 1566012891}
   m_GameObject: {fileID: 1566012891}
   m_CullTransparentMesh: 0
   m_CullTransparentMesh: 0
---- !u!1 &1596031693
-GameObject:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  serializedVersion: 6
-  m_Component:
-  - component: {fileID: 1596031694}
-  - component: {fileID: 1596031698}
-  - component: {fileID: 1596031697}
-  - component: {fileID: 1596031696}
-  - component: {fileID: 1596031695}
-  m_Layer: 5
-  m_Name: SelectCategoriesSelectionPanel
-  m_TagString: Untagged
-  m_Icon: {fileID: 0}
-  m_NavMeshLayer: 0
-  m_StaticEditorFlags: 0
-  m_IsActive: 1
---- !u!224 &1596031694
-RectTransform:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1596031693}
-  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_Children: []
-  m_Father: {fileID: 1272715544}
-  m_RootOrder: 1
-  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 0, y: 0.01991272}
-  m_SizeDelta: {x: 500, y: -60.039833}
-  m_Pivot: {x: 0, y: 0.5}
---- !u!114 &1596031695
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1596031693}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_Padding:
-    m_Left: 5
-    m_Right: 5
-    m_Top: 0
-    m_Bottom: 0
-  m_ChildAlignment: 0
-  m_Spacing: 5
-  m_ChildForceExpandWidth: 1
-  m_ChildForceExpandHeight: 0
-  m_ChildControlWidth: 1
-  m_ChildControlHeight: 0
-  m_ChildScaleWidth: 0
-  m_ChildScaleHeight: 0
---- !u!114 &1596031696
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1596031693}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_IgnoreLayout: 0
-  m_MinWidth: -1
-  m_MinHeight: -1
-  m_PreferredWidth: -1
-  m_PreferredHeight: 200
-  m_FlexibleWidth: -1
-  m_FlexibleHeight: 1
-  m_LayoutPriority: 1
---- !u!114 &1596031697
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1596031693}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 0.392}
-  m_RaycastTarget: 1
-  m_Maskable: 1
-  m_OnCullStateChanged:
-    m_PersistentCalls:
-      m_Calls: []
-  m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
-  m_Type: 1
-  m_PreserveAspect: 0
-  m_FillCenter: 1
-  m_FillMethod: 4
-  m_FillAmount: 1
-  m_FillClockwise: 1
-  m_FillOrigin: 0
-  m_UseSpriteMesh: 0
-  m_PixelsPerUnitMultiplier: 1
---- !u!222 &1596031698
-CanvasRenderer:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1596031693}
-  m_CullTransparentMesh: 0
 --- !u!1 &1604292276
 --- !u!1 &1604292276
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0

+ 6 - 5
Assets/Scenes/narKampen.unity

@@ -543,7 +543,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
   m_AnchorMax: {x: 1, y: 1}
   m_AnchoredPosition: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: -12}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &189632755
 --- !u!114 &189632755
 MonoBehaviour:
 MonoBehaviour:
@@ -601,7 +601,7 @@ MonoBehaviour:
   m_MinHeight: -1
   m_MinHeight: -1
   m_PreferredWidth: -1
   m_PreferredWidth: -1
   m_PreferredHeight: -1
   m_PreferredHeight: -1
-  m_FlexibleWidth: -1
+  m_FlexibleWidth: 1
   m_FlexibleHeight: -1
   m_FlexibleHeight: -1
   m_LayoutPriority: 1
   m_LayoutPriority: 1
 --- !u!114 &222124799 stripped
 --- !u!114 &222124799 stripped
@@ -742,7 +742,7 @@ RectTransform:
   m_AnchorMax: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
-  m_Pivot: {x: 0, y: 1}
+  m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &249496649
 --- !u!114 &249496649
 MonoBehaviour:
 MonoBehaviour:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -856,7 +856,7 @@ MonoBehaviour:
   m_UiScaleMode: 1
   m_UiScaleMode: 1
   m_ReferencePixelsPerUnit: 100
   m_ReferencePixelsPerUnit: 100
   m_ScaleFactor: 1
   m_ScaleFactor: 1
-  m_ReferenceResolution: {x: 1280, y: 720}
+  m_ReferenceResolution: {x: 1920, y: 1080}
   m_ScreenMatchMode: 0
   m_ScreenMatchMode: 0
   m_MatchWidthOrHeight: 0
   m_MatchWidthOrHeight: 0
   m_PhysicalUnit: 3
   m_PhysicalUnit: 3
@@ -3022,7 +3022,8 @@ MonoBehaviour:
   answerlineQuestionPrefab: {fileID: 4662818861115959987, guid: e91b5c1a341f8be469b7bab25ee954d7,
   answerlineQuestionPrefab: {fileID: 4662818861115959987, guid: e91b5c1a341f8be469b7bab25ee954d7,
     type: 3}
     type: 3}
   contentPanel: {fileID: 189632754}
   contentPanel: {fileID: 189632754}
-  newQuestionsPanel: {fileID: 1119394965}
+  newQuestionsPanel: {fileID: 1781451649244772801, guid: e91b5c1a341f8be469b7bab25ee954d7,
+    type: 3}
   currentPlayer: 
   currentPlayer: 
   leftDropZone: {fileID: 2671252238156376074, guid: 02b4c72ca3390ac4fbcf79027941398d,
   leftDropZone: {fileID: 2671252238156376074, guid: 02b4c72ca3390ac4fbcf79027941398d,
     type: 3}
     type: 3}

+ 15 - 9
Assets/Scripts/Database/Database.cs

@@ -50,13 +50,13 @@ public class Database : MonoBehaviour {
             while (reader.Read()) {
             while (reader.Read()) {
                 CategoryPanel.Category cat = new CategoryPanel.Category();
                 CategoryPanel.Category cat = new CategoryPanel.Category();
 
 
-                byte r = (byte)reader.GetInt32(1);
-                byte g = (byte)reader.GetInt32(2);
-                byte b = (byte)reader.GetInt32(3);
-                byte a = (byte)reader.GetInt32(4);
+                byte r = (byte)reader.GetInt32(2);
+                byte g = (byte)reader.GetInt32(3);
+                byte b = (byte)reader.GetInt32(4);
+                byte a = (byte)reader.GetInt32(5);
                 cat.color = new Color32(r, g, b, a);
                 cat.color = new Color32(r, g, b, a);
-                cat.name = reader.GetString(0);
-                cat.id = reader.GetInt32(5);
+                cat.name = reader.GetString(1);
+                cat.id = reader.GetInt32(0);
                 cat.questionCount = reader.GetInt32(6);
                 cat.questionCount = reader.GetInt32(6);
 
 
                 list.Add(cat);
                 list.Add(cat);
@@ -208,6 +208,15 @@ public class Database : MonoBehaviour {
         CloseConnection();
         CloseConnection();
     }
     }
 
 
+    internal void SetGameFinished(int gameId, string gameMode)
+    {
+        if (gameMode.Equals("Online")) {
+            OnlineDatabase.Instance.SetGameFinished(gameId, gameMode);
+        } else {
+
+        }
+    }
+
     internal bool IsKeepSignedIn() {
     internal bool IsKeepSignedIn() {
         string sql = "SELECT keepSignedIn FROM userSettings";
         string sql = "SELECT keepSignedIn FROM userSettings";
         IDbCommand cmd = GetConnection();
         IDbCommand cmd = GetConnection();
@@ -702,9 +711,6 @@ public class Database : MonoBehaviour {
 
 
             cmd.Dispose();
             cmd.Dispose();
             conn.Close();
             conn.Close();
-        } else { // Connect Through db
-            Debug.Log("Online Call");
-            StartCoroutine(GetQuestionData(false));
         }
         }
         NewQuestionData q = new NewQuestionData(answerString, questionString, categoryName, categoryId, id, questionCategoryColor);
         NewQuestionData q = new NewQuestionData(answerString, questionString, categoryName, categoryId, id, questionCategoryColor);
 
 

+ 30 - 0
Assets/Scripts/Database/OnlineDatabase.cs

@@ -204,6 +204,25 @@ public class OnlineDatabase : MonoBehaviour {
 
 
     public string QuestionString { get => questionString; set => questionString = value; }
     public string QuestionString { get => questionString; set => questionString = value; }
 
 
+    internal void SendGameOverMessage(int gameId, List<KeyValuePair<string, int>> players, string currentPlayer)
+    {
+        string message = "Den som van var " + currentPlayer + "!"; //TODO
+        string title = "Spelet slut!";                              //TODO 
+
+        WWWForm form = new WWWForm();
+        form.AddField("gameId", gameId);
+        form.AddField("message", message);
+        form.AddField("title", title);
+        form.AddField("winningPlayer", currentPlayer);
+        form.AddField("messageType", "gameFinishedMessage");
+
+        int index = 0;
+        foreach (KeyValuePair<String, int> player in players) {
+            form.AddField("player" + index++, player.Key);
+        }
+
+        CallDatabase("FCMMessageing.php", form);
+    }
 
 
     private void Start() {
     private void Start() {
         if (instance == null) {
         if (instance == null) {
@@ -223,6 +242,15 @@ public class OnlineDatabase : MonoBehaviour {
         }
         }
     }
     }
 
 
+    internal void SetGameFinished(int gameId, string gameMode)
+    {
+        WWWForm formData = new WWWForm();
+        formData.AddField("gameId", gameId);
+        formData.AddField("f", "GameFinished");
+
+        CallDatabase("OnlineGames.php", formData);
+    }
+
     internal void DeclineOnlineGame(string userName, int gameId) {
     internal void DeclineOnlineGame(string userName, int gameId) {
         WWWForm formData = new WWWForm();
         WWWForm formData = new WWWForm();
         formData.AddField("userId", -1);
         formData.AddField("userId", -1);
@@ -623,9 +651,11 @@ public class OnlineDatabase : MonoBehaviour {
         WWWForm form = new WWWForm();
         WWWForm form = new WWWForm();
         form.AddField("gameId", gameId);
         form.AddField("gameId", gameId);
         int index = 0;
         int index = 0;
+
         foreach(String player in Players) {
         foreach(String player in Players) {
             form.AddField("player" + index++, player);
             form.AddField("player" + index++, player);
         }
         }
+
         form.AddField("title", LocalizationManager.Instance.GetText("FCM_NEW_GAME_TITLE"));
         form.AddField("title", LocalizationManager.Instance.GetText("FCM_NEW_GAME_TITLE"));
         form.AddField("message", String.Format(LocalizationManager.Instance.GetText("FCM_NEW_GAME_MESSAGE"), inviter));
         form.AddField("message", String.Format(LocalizationManager.Instance.GetText("FCM_NEW_GAME_MESSAGE"), inviter));
         form.AddField("type", "InviteMessage");
         form.AddField("type", "InviteMessage");

+ 44 - 6
Assets/Scripts/GameManagerScript.cs

@@ -11,6 +11,8 @@ public class GameManagerScript : MonoBehaviour {
     private int questionTimer;
     private int questionTimer;
     private string gameMode;
     private string gameMode;
 
 
+    private int neededForWin;
+
     public Database db;
     public Database db;
     public OnlineDatabase odb;
     public OnlineDatabase odb;
     StatsScript statsScript;
     StatsScript statsScript;
@@ -25,6 +27,7 @@ public class GameManagerScript : MonoBehaviour {
     public int GameId { get; internal set; }
     public int GameId { get; internal set; }
 
 
     public int QuestionTimer { get => questionTimer; set => questionTimer = value; }
     public int QuestionTimer { get => questionTimer; set => questionTimer = value; }
+    public int NeededForWin { get => neededForWin; set => neededForWin = value; }
 
 
     static string currentPlayer;
     static string currentPlayer;
 
 
@@ -39,6 +42,7 @@ public class GameManagerScript : MonoBehaviour {
         GameId = PlayerPrefs.GetInt("GameId");
         GameId = PlayerPrefs.GetInt("GameId");
         GameMode = PlayerPrefs.GetString("GameMode");
         GameMode = PlayerPrefs.GetString("GameMode");
         QuestionTimer = PlayerPrefs.GetInt("QuestionTimer");
         QuestionTimer = PlayerPrefs.GetInt("QuestionTimer");
+        NeededForWin = PlayerPrefs.GetInt("NeededForWin");
 
 
         if (GameMode.Equals("Local")) {
         if (GameMode.Equals("Local")) {
             db = Database.Instance;
             db = Database.Instance;
@@ -105,6 +109,8 @@ public class GameManagerScript : MonoBehaviour {
             yield return new WaitForSeconds(0.1f);
             yield return new WaitForSeconds(0.1f);
         }
         }
 
 
+        RectTransform newQuestionRect = GameObject.Find("NewQuestion").GetComponent<RectTransform>();
+
         NewQuestionData newQuestionData = NewQuestionCard.transform.parent.GetComponent<NewQuestionsPanel>().QuestionData;
         NewQuestionData newQuestionData = NewQuestionCard.transform.parent.GetComponent<NewQuestionsPanel>().QuestionData;
         GameObject go = Instantiate(AnswerLineQuestionCard, Vector3.zero, Quaternion.identity);
         GameObject go = Instantiate(AnswerLineQuestionCard, Vector3.zero, Quaternion.identity);
         AnswerLineQuestionCard firstAnswerLineQuestion = go.GetComponent<AnswerLineQuestionCard>();
         AnswerLineQuestionCard firstAnswerLineQuestion = go.GetComponent<AnswerLineQuestionCard>();
@@ -113,18 +119,43 @@ public class GameManagerScript : MonoBehaviour {
         firstAnswerLineQuestion.SetId(newQuestionData.Id);
         firstAnswerLineQuestion.SetId(newQuestionData.Id);
         firstAnswerLineQuestion.SetQuestionSafe();
         firstAnswerLineQuestion.SetQuestionSafe();
 
 
+        firstAnswerLineQuestion.GetComponent<LayoutElement>().preferredHeight = newQuestionRect.rect.height;
+        firstAnswerLineQuestion.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
         firstAnswerLineQuestion.transform.SetParent(AnswerLine.transform);
         firstAnswerLineQuestion.transform.SetParent(AnswerLine.transform);
         firstAnswerLineQuestion.transform.SetSiblingIndex(0);
         firstAnswerLineQuestion.transform.SetSiblingIndex(0);
         firstAnswerLineQuestion.transform.localScale = new Vector3(1,1,1);
         firstAnswerLineQuestion.transform.localScale = new Vector3(1,1,1);
 
 
-        CreateLeftSpacer();
-        CreateRightSpacer();
+        CreateLeftSpacer(newQuestionRect.rect.width);
+        CreateRightSpacer(newQuestionRect.rect.width);
 
 
         NewQuestionCard.GetComponent<NewQuestionCardController>().GenerateNewQuestion();
         NewQuestionCard.GetComponent<NewQuestionCardController>().GenerateNewQuestion();
         // Destroy(NewQuestionCard.gameObject);
         // Destroy(NewQuestionCard.gameObject);
         StopTimer();
         StopTimer();
     }
     }
 
 
+    internal void CheckWin(List<QuestionCard> answerLine)
+    {
+        if (answerLine.Count == NeededForWin) {
+            GenericDialog dialog = GenericDialog.Instance();
+            dialog.SetTitle(LocalizationManager.Instance.GetText("WINNER_DIALOG_TITLE"));
+            string message = LocalizationManager.Instance.GetText("WINNER_DIALOG_MESSAGE");
+            dialog.SetMessage(String.Format(message, NeededForWin, 
+                Database.Instance.GetQuestionsLost(GameId, currentPlayer, GameMode), 
+                Database.Instance.GetRoundValue(GameId, GameMode)));
+            dialog.SetOnAccept(LocalizationManager.Instance.GetText("OK"), () => {
+                Database.Instance.SetGameFinished(GameId, GameMode);
+
+                if (GameMode.Equals("Online")) {
+                    OnlineDatabase.Instance.SendGameOverMessage(GameId, players, currentPlayer);
+                }
+
+                dialog.Hide();
+            });
+            dialog.SetOnDecline("", () => dialog.Hide());
+            dialog.Show();
+        }
+    }
+
     internal void RemoveUnlockedQuestions()
     internal void RemoveUnlockedQuestions()
     {
     {
         if (scrollViewScript == null) {
         if (scrollViewScript == null) {
@@ -133,10 +164,17 @@ public class GameManagerScript : MonoBehaviour {
         scrollViewScript.RemoveUnlockedQuestions();
         scrollViewScript.RemoveUnlockedQuestions();
     }
     }
 
 
-    private void CreateLeftSpacer()
+    internal int GetUnlockedQuestionsCount() {
+                if (scrollViewScript == null) {
+            scrollViewScript = GameObject.FindGameObjectWithTag("AnswerLine").transform.parent.parent.GetComponent<ScrollViewScript>();
+        }
+        return scrollViewScript.GetUnlockedQuestionCount();
+    }
+
+    private void CreateLeftSpacer(float width)
     {
     {
         GameObject newSpacerLeft = Instantiate(DropZonePrefab);     
         GameObject newSpacerLeft = Instantiate(DropZonePrefab);     
-        newSpacerLeft.GetComponent<LayoutElement>().preferredWidth = 30f;
+        newSpacerLeft.GetComponent<LayoutElement>().preferredWidth = width;
         newSpacerLeft.name = "LeftDropZone";
         newSpacerLeft.name = "LeftDropZone";
         newSpacerLeft.GetComponent<NewDropZoneScript>().LeftmostSpacer = true;
         newSpacerLeft.GetComponent<NewDropZoneScript>().LeftmostSpacer = true;
         newSpacerLeft.transform.SetParent(AnswerLine.transform);
         newSpacerLeft.transform.SetParent(AnswerLine.transform);
@@ -144,10 +182,10 @@ public class GameManagerScript : MonoBehaviour {
         newSpacerLeft.transform.localScale = new Vector3(1,1,1);
         newSpacerLeft.transform.localScale = new Vector3(1,1,1);
     }
     }
 
 
-    private void CreateRightSpacer()
+    private void CreateRightSpacer(float width)
     {
     {
         GameObject newSpacerRight = Instantiate(DropZonePrefab);     
         GameObject newSpacerRight = Instantiate(DropZonePrefab);     
-        newSpacerRight.GetComponent<LayoutElement>().preferredWidth = 30f;
+        newSpacerRight.GetComponent<LayoutElement>().preferredWidth = width;
         newSpacerRight.name = "RightDropZone";
         newSpacerRight.name = "RightDropZone";
         newSpacerRight.GetComponent<NewDropZoneScript>().RightmostSpacer = true;
         newSpacerRight.GetComponent<NewDropZoneScript>().RightmostSpacer = true;
         newSpacerRight.transform.SetParent(AnswerLine.transform);
         newSpacerRight.transform.SetParent(AnswerLine.transform);

+ 8 - 3
Assets/Scripts/MainGame/NewQuestionsPanel.cs

@@ -28,13 +28,18 @@ public class NewQuestionsPanel : MonoBehaviour
         //string gameMode = Database.Instance.GetGameMode(gameId);
         //string gameMode = Database.Instance.GetGameMode(gameId);
         string currentPlayer = Database.Instance.GetCurrentPlayer(gameId, gameMode);
         string currentPlayer = Database.Instance.GetCurrentPlayer(gameId, gameMode);
 
 
-        if (currentPlayer.Equals(Database.Instance.GetSignedInUser().Value, StringComparison.InvariantCultureIgnoreCase ) && Database.Instance.GetRoundValue(gameManagerScript.GameId, gameManagerScript.GameMode) <= 1) {
+        if (gameMode.Equals("Online") && 
+                currentPlayer.Equals(Database.Instance.GetSignedInUser().Value, StringComparison.InvariantCultureIgnoreCase ) && 
+                Database.Instance.GetRoundValue(gameManagerScript.GameId, gameManagerScript.GameMode) <= 1 ||
+            (gameMode.Equals("Local") && 
+                Database.Instance.GetRoundValue(gameManagerScript.GameId, gameManagerScript.GameMode) <= 1)) {
             List<NewQuestionData> usersQuestions = Database.Instance.GetPlayerQuestions(gameId, currentPlayer, gameManagerScript.GameMode);
             List<NewQuestionData> usersQuestions = Database.Instance.GetPlayerQuestions(gameId, currentPlayer, gameManagerScript.GameMode);
             NewQuestionData qd = usersQuestions[0];
             NewQuestionData qd = usersQuestions[0];
             AnswerText.text = qd.Answer;
             AnswerText.text = qd.Answer;
             QuestionText.text = qd.Question;
             QuestionText.text = qd.Question;
             QuestionData = qd;
             QuestionData = qd;
-        } else if (!currentPlayer.Equals(Database.Instance.GetSignedInUser().Value, StringComparison.InvariantCultureIgnoreCase)) {
+        } else if (gameMode.Equals("Online") && 
+                !currentPlayer.Equals(Database.Instance.GetSignedInUser().Value, StringComparison.InvariantCultureIgnoreCase)) {
             SetNotYourTurn();
             SetNotYourTurn();
         }
         }
     }
     }
@@ -50,7 +55,7 @@ public class NewQuestionsPanel : MonoBehaviour
     // Update is called once per frame
     // Update is called once per frame
     void Update()
     void Update()
     {
     {
-        if (!GameManagerScript.GetCurrentPlayer().Equals(Database.Instance.GetSignedInUser().Value, StringComparison.InvariantCultureIgnoreCase)) {
+        if (gameManagerScript.GameMode.Equals("Online") && !GameManagerScript.GetCurrentPlayer().Equals(Database.Instance.GetSignedInUser().Value, StringComparison.InvariantCultureIgnoreCase)) {
             SetNotYourTurn();
             SetNotYourTurn();
         }
         }
     }
     }

+ 27 - 1
Assets/Scripts/MainGame/ScrollViewScript.cs

@@ -18,6 +18,7 @@ public class ScrollViewScript : MonoBehaviour {
     private int gameId;
     private int gameId;
     private string gameMode;
     private string gameMode;
 
 
+    private bool sizeUpdated = false;
     StatsScript statsScript;
     StatsScript statsScript;
     GameManagerScript gameManagerScript;
     GameManagerScript gameManagerScript;
     TimerScript ts;
     TimerScript ts;
@@ -47,6 +48,12 @@ public class ScrollViewScript : MonoBehaviour {
         statsScript.SetQuestionsLost(Database.Instance.GetQuestionsLost(gameId, currentPlayer, GetGameMode()));
         statsScript.SetQuestionsLost(Database.Instance.GetQuestionsLost(gameId, currentPlayer, GetGameMode()));
     }
     }
 
 
+    private void Update() {
+        if (!sizeUpdated){
+            UpdateAnswerlineCardSize();
+        }
+    }
+
     public string GetGameMode() {
     public string GetGameMode() {
         if (gameMode == null) {
         if (gameMode == null) {
             gameMode = PlayerPrefs.GetString("GameMode");
             gameMode = PlayerPrefs.GetString("GameMode");
@@ -60,19 +67,22 @@ public class ScrollViewScript : MonoBehaviour {
     public void SetQuestionsInAnswerLine(List<NewQuestionData> questions) {
     public void SetQuestionsInAnswerLine(List<NewQuestionData> questions) {
         int i = 0;
         int i = 0;
 
 
+        RectTransform newQuestionRect = GameObject.Find("NewQuestion").GetComponent<RectTransform>();
         GameObject ldz = Instantiate(leftDropZone,Vector2.zero, Quaternion.identity);
         GameObject ldz = Instantiate(leftDropZone,Vector2.zero, Quaternion.identity);
         GameObject rdz = Instantiate(rightDropZone,Vector2.zero, Quaternion.identity);
         GameObject rdz = Instantiate(rightDropZone,Vector2.zero, Quaternion.identity);
         ldz.transform.SetParent(contentPanel);
         ldz.transform.SetParent(contentPanel);
         ldz.transform.SetSiblingIndex(i++);
         ldz.transform.SetSiblingIndex(i++);
         ldz.transform.localScale = new Vector3(1,1,1);
         ldz.transform.localScale = new Vector3(1,1,1);
+        ldz.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
 
 
         KeyValuePair<int, string> signedInUser = Database.Instance.GetSignedInUser();
         KeyValuePair<int, string> signedInUser = Database.Instance.GetSignedInUser();
-
         foreach (NewQuestionData q in questions) {
         foreach (NewQuestionData q in questions) {
             GameObject answerLineQuestion = Instantiate(answerlineQuestionPrefab, Vector3.zero, Quaternion.identity);
             GameObject answerLineQuestion = Instantiate(answerlineQuestionPrefab, Vector3.zero, Quaternion.identity);
             answerLineQuestion.transform.SetParent(contentPanel, false);
             answerLineQuestion.transform.SetParent(contentPanel, false);
             answerLineQuestion.transform.SetSiblingIndex(i++);
             answerLineQuestion.transform.SetSiblingIndex(i++);
             answerLineQuestion.transform.localScale = new Vector3(1,1,1);
             answerLineQuestion.transform.localScale = new Vector3(1,1,1);
+            answerLineQuestion.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
+            answerLineQuestion.GetComponent<LayoutElement>().preferredHeight = newQuestionRect.rect.height;
 
 
             QuestionCard answerLineQuestionCard = answerLineQuestion.GetComponent<QuestionCard>();
             QuestionCard answerLineQuestionCard = answerLineQuestion.GetComponent<QuestionCard>();
             answerLineQuestionCard.SetAnswerText(q.Answer);
             answerLineQuestionCard.SetAnswerText(q.Answer);
@@ -100,10 +110,25 @@ public class ScrollViewScript : MonoBehaviour {
         rdz.transform.SetParent(contentPanel);
         rdz.transform.SetParent(contentPanel);
         rdz.transform.SetSiblingIndex(i);
         rdz.transform.SetSiblingIndex(i);
         rdz.transform.localScale = new Vector3(1,1,1);
         rdz.transform.localScale = new Vector3(1,1,1);
+        rdz.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
 
 
         SetAllQuestionsLocked(false);
         SetAllQuestionsLocked(false);
     }
     }
 
 
+    private void UpdateAnswerlineCardSize() {
+        RectTransform newQuestionRect = GameObject.Find("NewQuestion").GetComponent<RectTransform>();
+        List<QuestionCard> questions = contentPanel.GetComponentsInChildren<QuestionCard>().ToList();
+
+        foreach (QuestionCard q in questions) {
+            q.GetComponent<LayoutElement>().preferredWidth = newQuestionRect.rect.width;
+            q.GetComponent<LayoutElement>().preferredHeight = newQuestionRect.rect.height;
+        }
+
+        if (questions[0].GetComponent<LayoutElement>().preferredWidth >= 0) {
+            sizeUpdated = true;
+        }
+    }
+
     public int GetUnlockedQuestionCount() {
     public int GetUnlockedQuestionCount() {
         /*int unlockedQuestionCount = 0;
         /*int unlockedQuestionCount = 0;
         for (int i = 0; i < contentPanel.childCount; i++) {
         for (int i = 0; i < contentPanel.childCount; i++) {
@@ -167,6 +192,7 @@ public class ScrollViewScript : MonoBehaviour {
  
  
 
 
     void TimerRunOutEvent() { // Should be moved to some gameController
     void TimerRunOutEvent() { // Should be moved to some gameController
+        ts.StopTimer();
         GenericDialog dialog = GenericDialog.Instance();
         GenericDialog dialog = GenericDialog.Instance();
         string message = LocalizationManager.Instance.GetText("TIMER_DIALOG_MESSAGE");
         string message = LocalizationManager.Instance.GetText("TIMER_DIALOG_MESSAGE");
         dialog.SetTitle(LocalizationManager.Instance.GetText("TIMER_DIALOG_TITLE"));
         dialog.SetTitle(LocalizationManager.Instance.GetText("TIMER_DIALOG_TITLE"));

+ 2 - 2
Assets/Scripts/MainGame/StatsScript.cs

@@ -116,8 +116,8 @@ public class StatsScript : MonoBehaviour {
     }
     }
 
 
     public void SetQuestionsLost(int value) {
     public void SetQuestionsLost(int value) {
-        StatsLine sl =  statLines.Find(s => s.GetName().Equals(questionsLostText));
-        sl.SetStatValue(value);
+        StatsLine sl = statLines.Find(s => s.GetName().Equals(questionsLostText));
+        sl.SetStatValue(sl.GetIntValue() + value);
     }
     }
 
 
     public int GetQuestionsLost() {
     public int GetQuestionsLost() {

+ 3 - 1
Assets/Scripts/NewGameScene/GameInfoScript.cs

@@ -17,7 +17,7 @@ public class GameInfoScript : MonoBehaviour {
 
 
     private int gameId;
     private int gameId;
     private int questionTimer;
     private int questionTimer;
-
+    private int winNumber;
     [SerializeField] Text answerTimeValueText;
     [SerializeField] Text answerTimeValueText;
     [SerializeField] Text questionsToWinValueText;
     [SerializeField] Text questionsToWinValueText;
     [SerializeField] Text DaysToStartRoundValueText;
     [SerializeField] Text DaysToStartRoundValueText;
@@ -38,6 +38,7 @@ public class GameInfoScript : MonoBehaviour {
         String currentPlayer = Database.Instance.GetSignedInUser().Value;
         String currentPlayer = Database.Instance.GetSignedInUser().Value;
         gameId = onlineGameScript.GetId();
         gameId = onlineGameScript.GetId();
         questionTimer = onlineGameScript.AnswerTimer;
         questionTimer = onlineGameScript.AnswerTimer;
+        winNumber = onlineGameScript.WinNumber;
 
 
         answerTimeValueText.text = onlineGameScript.AnswerTimer.ToString();
         answerTimeValueText.text = onlineGameScript.AnswerTimer.ToString();
         questionsToWinValueText.text = onlineGameScript.WinNumber.ToString();
         questionsToWinValueText.text = onlineGameScript.WinNumber.ToString();
@@ -69,6 +70,7 @@ public class GameInfoScript : MonoBehaviour {
         PlayerPrefs.SetString("GameMode", "Online");
         PlayerPrefs.SetString("GameMode", "Online");
         PlayerPrefs.SetInt("GameId", gameId);
         PlayerPrefs.SetInt("GameId", gameId);
         PlayerPrefs.SetInt("QuestionTimer", questionTimer);
         PlayerPrefs.SetInt("QuestionTimer", questionTimer);
+        PlayerPrefs.SetInt("NeededForWin", winNumber);
         SceneManager.LoadSceneAsync("narKampen");
         SceneManager.LoadSceneAsync("narKampen");
     }
     }
 
 

+ 1 - 1
Assets/Scripts/NewGameScene/NewOnlineGameScript.cs

@@ -40,7 +40,7 @@ public class NewOnlineGameScript : MonoBehaviour
 
 
         List<int> selectedCategoryIds = selectedCategories.Select(c => c.id).ToList();
         List<int> selectedCategoryIds = selectedCategories.Select(c => c.id).ToList();
 
 
-        OnlineDatabase.Instance.SetupNewOnlineGame((int)correctsToWinSlider.value, (int)daysToAnswerSlider.value, (int)correctsToWinSlider.value, inviteUsers, selectedCategoryIds);
+        OnlineDatabase.Instance.SetupNewOnlineGame((int)answerTimeSlider.value, (int)daysToAnswerSlider.value, (int)correctsToWinSlider.value, inviteUsers, selectedCategoryIds);
         SceneManager.LoadScene("MainMenu");
         SceneManager.LoadScene("MainMenu");
     }
     }
 }
 }

+ 1 - 0
Assets/Scripts/NewGameScene/NewStartLocalGameScript.cs

@@ -38,6 +38,7 @@ public class NewStartLocalGameScript : MonoBehaviour
         PlayerPrefs.SetString("GameMode", "Local");
         PlayerPrefs.SetString("GameMode", "Local");
         PlayerPrefs.SetInt("GameId", gameId);
         PlayerPrefs.SetInt("GameId", gameId);
         PlayerPrefs.SetInt("QuestionTimer", secondsToAnswerInt);
         PlayerPrefs.SetInt("QuestionTimer", secondsToAnswerInt);
+        PlayerPrefs.SetInt("NeededForWin", correctsToWinInt);
         SceneManager.LoadSceneAsync("narKampen");
         SceneManager.LoadSceneAsync("narKampen");
     }
     }
 
 

+ 2 - 0
Assets/Scripts/NewGameScene/OnlineGameScript.cs

@@ -55,6 +55,7 @@ public class OnlineGameScript : MonoBehaviour {
     private string ACTIVE_TITLE = "ONLINE_GAME_STATUS_TITLE_ACTIVE";
     private string ACTIVE_TITLE = "ONLINE_GAME_STATUS_TITLE_ACTIVE";
     private string DECLINED_TITLE = "ONLINE_GAME_STATUS_TITLE_DECLINED";
     private string DECLINED_TITLE = "ONLINE_GAME_STATUS_TITLE_DECLINED";
     private string INVITED_TITLE = "ONLINE_GAME_STATUS_TITLE_INVITED";
     private string INVITED_TITLE = "ONLINE_GAME_STATUS_TITLE_INVITED";
+    private string FINISHED_TITLE = "ONLINE_GAME_STATUS_TITLE_INVITED";
 
 
     private string PENDING = "ONLINE_GAME_STATUS_PENDING";
     private string PENDING = "ONLINE_GAME_STATUS_PENDING";
     private string DECLINED = "ONLINE_GAME_STATUS_DECLINED";
     private string DECLINED = "ONLINE_GAME_STATUS_DECLINED";
@@ -64,6 +65,7 @@ public class OnlineGameScript : MonoBehaviour {
     private string OTHERS_TURN = "ONLINE_GAME_STATUS_OTHERS_TURN";
     private string OTHERS_TURN = "ONLINE_GAME_STATUS_OTHERS_TURN";
     private string YOUR_TURN = "ONLINE_GAME_STATUS_YOUR_TURN";
     private string YOUR_TURN = "ONLINE_GAME_STATUS_YOUR_TURN";
 
 
+// BEHÖVS EN FINISHED OCKSÅ.
     // behövs nog en partialy declined status också, om en av fyra tackar nej kanske man viss spela ändå.
     // behövs nog en partialy declined status också, om en av fyra tackar nej kanske man viss spela ändå.
     // behövs också en med dina inbjudningar.
     // behövs också en med dina inbjudningar.
 
 

+ 15 - 7
Assets/SelectCategoryScript.cs

@@ -18,27 +18,34 @@ public class SelectCategoryScript : MonoBehaviour
     // Start is called before the first frame update
     // Start is called before the first frame update
 
 
     private List<CategoryPanel.Category> categories;
     private List<CategoryPanel.Category> categories;
-    private void Start() {
+    private void Start()
+    {
         doneButton.onClick.AddListener(CloseDialogAction);
         doneButton.onClick.AddListener(CloseDialogAction);
         closeButton.onClick.AddListener(CloseDialogAction);
         closeButton.onClick.AddListener(CloseDialogAction);
 
 
-        if (categories == null) {
-            categories = new List<CategoryPanel.Category>();
-        }
-
-        categories = OnlineDatabase.Instance.GetCategories(categories, -1);
+        GetCategories();
 
 
+        int pos = 0;
         foreach (CategoryPanel.Category cat in categories)
         foreach (CategoryPanel.Category cat in categories)
         {
         {
             GameObject go = Instantiate(CategoryToSelectPrefab, Vector3.zero, Quaternion.identity);
             GameObject go = Instantiate(CategoryToSelectPrefab, Vector3.zero, Quaternion.identity);
             CategorySelection c = go.GetComponent<CategorySelection>();
             CategorySelection c = go.GetComponent<CategorySelection>();
             c.SetSelected(true);
             c.SetSelected(true);
             c.SetCategoryText(cat.name, cat.questionCount);
             c.SetCategoryText(cat.name, cat.questionCount);
-            c.transform.localScale = new Vector3(1,1,1);
+            c.transform.SetSiblingIndex(pos++);
+            c.transform.localScale = new Vector3(1, 1, 1);
             c.transform.SetParent(ContentPanel.transform, false);
             c.transform.SetParent(ContentPanel.transform, false);
         }
         }
     }
     }
 
 
+    private void GetCategories()
+    {
+        if (categories == null || categories.Count == 0) {
+            categories = new List<CategoryPanel.Category>();
+            categories = OnlineDatabase.Instance.GetCategories(categories, -1);
+        }
+    }
+
     internal void CloseDialogAction() {
     internal void CloseDialogAction() {
         SelectCategoryPanel.GetComponent<selectCategoriesPanelController>().UpdateCategoryText();
         SelectCategoryPanel.GetComponent<selectCategoriesPanelController>().UpdateCategoryText();
         gameObject.SetActive(false);
         gameObject.SetActive(false);
@@ -72,6 +79,7 @@ public class SelectCategoryScript : MonoBehaviour
     }
     }
 
 
     public List<CategoryPanel.Category> GetSelectedCategories() {
     public List<CategoryPanel.Category> GetSelectedCategories() {
+        GetCategories();
         List<string> categoriesName = categories.Select(c1 => c1.name).ToList();
         List<string> categoriesName = categories.Select(c1 => c1.name).ToList();
         List<string> selectedCategoyNames = GetSelectedCategoriesAsList().Select(c2 => c2.getCategoryName()).ToList();
         List<string> selectedCategoyNames = GetSelectedCategoriesAsList().Select(c2 => c2.getCategoryName()).ToList();
         List<string> names = categoriesName.Intersect(selectedCategoyNames).ToList();
         List<string> names = categoriesName.Intersect(selectedCategoyNames).ToList();

+ 2 - 1
Assets/Translations/ENGLISH.xml

@@ -62,6 +62,7 @@
   <text key="INVITE_DIALOG_SEARCH_FIELD_PLACEHOLDER">Search players</text>
   <text key="INVITE_DIALOG_SEARCH_FIELD_PLACEHOLDER">Search players</text>
   <text key="INVITE_DIALOG_NAME_DIALOG_TEXT">Playername</text>
   <text key="INVITE_DIALOG_NAME_DIALOG_TEXT">Playername</text>
   <text key="INVITE_DIALOG_INVITE_TEXT">Invite</text>
   <text key="INVITE_DIALOG_INVITE_TEXT">Invite</text>
+  <text key="INVITE_PANEL_DIALOG_RANDOM_BUTTON">Find random players</text>
   <text key="INVITE_PANEL_DIALOG_BUTTON">Done</text>
   <text key="INVITE_PANEL_DIALOG_BUTTON">Done</text>
   <text key="INVITE_COUNT_TEXT">Invite {0} players</text>
   <text key="INVITE_COUNT_TEXT">Invite {0} players</text>
   <text key="INVITED_PLAYERS_TEXT">players invited</text>
   <text key="INVITED_PLAYERS_TEXT">players invited</text>
@@ -89,7 +90,7 @@
   <text key="ONLINE_PLAYER_STATUS_WAITING">Waiting for answer</text>
   <text key="ONLINE_PLAYER_STATUS_WAITING">Waiting for answer</text>
   <text key="ONLINE_PLAYER_STATUS_ACCEPTED">Accepted</text>
   <text key="ONLINE_PLAYER_STATUS_ACCEPTED">Accepted</text>
   <text key="ONLINE_PLAYER_STATUS_DECLINED">Denied</text>
   <text key="ONLINE_PLAYER_STATUS_DECLINED">Denied</text>
-  <text key="LOCK_QUESTIONS">Lock questions</text>
+  <text key="LOCK_QUESTIONS">Lock answers</text>
   <text key="FCM_NEXT_PLAYER_TITLE">It's your turn</text>
   <text key="FCM_NEXT_PLAYER_TITLE">It's your turn</text>
   <text key="FCM_NEXT_PLAYER_MESSAGE">It is your turn to play in the match against {0}</text>
   <text key="FCM_NEXT_PLAYER_MESSAGE">It is your turn to play in the match against {0}</text>
   <text key="NOT_YOUR_TURN">It's not your turn</text>
   <text key="NOT_YOUR_TURN">It's not your turn</text>

+ 2 - 1
Assets/Translations/SWEDISH.xml

@@ -63,6 +63,7 @@
   <text key="INVITE_DIALOG_SEARCH_FIELD_PLACEHOLDER">Sök spelare</text>
   <text key="INVITE_DIALOG_SEARCH_FIELD_PLACEHOLDER">Sök spelare</text>
   <text key="INVITE_DIALOG_NAME_DIALOG_TEXT">Spelarnamn</text>
   <text key="INVITE_DIALOG_NAME_DIALOG_TEXT">Spelarnamn</text>
   <text key="INVITE_DIALOG_INVITE_TEXT">Bjud in</text>
   <text key="INVITE_DIALOG_INVITE_TEXT">Bjud in</text>
+  <text key="INVITE_PANEL_DIALOG_RANDOM_BUTTON">Sök slumpade spelare</text>
   <text key="INVITE_PANEL_DIALOG_BUTTON">Färdig</text>
   <text key="INVITE_PANEL_DIALOG_BUTTON">Färdig</text>
   <text key="INVITE_COUNT_TEXT">Bjud in {0} spelare</text>
   <text key="INVITE_COUNT_TEXT">Bjud in {0} spelare</text>
   <text key="INVITED_PLAYERS_TEXT">spelare inbjudna</text>
   <text key="INVITED_PLAYERS_TEXT">spelare inbjudna</text>
@@ -90,7 +91,7 @@
   <text key="ONLINE_PLAYER_STATUS_WAITING">Väntar på svar</text>
   <text key="ONLINE_PLAYER_STATUS_WAITING">Väntar på svar</text>
   <text key="ONLINE_PLAYER_STATUS_ACCEPTED">Accepterad</text>
   <text key="ONLINE_PLAYER_STATUS_ACCEPTED">Accepterad</text>
   <text key="ONLINE_PLAYER_STATUS_DECLINED">Nekat</text>
   <text key="ONLINE_PLAYER_STATUS_DECLINED">Nekat</text>
-  <text key="LOCK_QUESTIONS">Lås frågor</text>
+  <text key="LOCK_QUESTIONS">Lås svar</text>
   <text key="FCM_NEXT_PLAYER_TITLE">Det är din tur</text>
   <text key="FCM_NEXT_PLAYER_TITLE">Det är din tur</text>
   <text key="FCM_NEXT_PLAYER_MESSAGE">Det är din tur i matchen mot {0}</text>
   <text key="FCM_NEXT_PLAYER_MESSAGE">Det är din tur i matchen mot {0}</text>
   <text key="NOT_YOUR_TURN">Det är inte din tur</text>
   <text key="NOT_YOUR_TURN">Det är inte din tur</text>

BIN
Assets/narKampenLocal.db


+ 4 - 18
ProjectSettings/ProjectSettings.asset

@@ -111,6 +111,8 @@ PlayerSettings:
   switchNVNShaderPoolsGranularity: 33554432
   switchNVNShaderPoolsGranularity: 33554432
   switchNVNDefaultPoolsGranularity: 16777216
   switchNVNDefaultPoolsGranularity: 16777216
   switchNVNOtherPoolsGranularity: 16777216
   switchNVNOtherPoolsGranularity: 16777216
+  stadiaPresentMode: 0
+  stadiaTargetFramerate: 0
   vulkanNumSwapchainBuffers: 3
   vulkanNumSwapchainBuffers: 3
   vulkanEnableSetSRGBWrite: 0
   vulkanEnableSetSRGBWrite: 0
   m_SupportedAspectRatios:
   m_SupportedAspectRatios:
@@ -119,7 +121,7 @@ PlayerSettings:
     16:10: 1
     16:10: 1
     16:9: 1
     16:9: 1
     Others: 1
     Others: 1
-  bundleVersion: 0.47
+  bundleVersion: 0.48
   preloadedAssets: []
   preloadedAssets: []
   metroInputSource: 0
   metroInputSource: 0
   wsaTransparentSwapchain: 0
   wsaTransparentSwapchain: 0
@@ -165,7 +167,7 @@ PlayerSettings:
   applicationIdentifier:
   applicationIdentifier:
     Android: se.axelnordh.narkampen
     Android: se.axelnordh.narkampen
   buildNumber: {}
   buildNumber: {}
-  AndroidBundleVersionCode: 17
+  AndroidBundleVersionCode: 18
   AndroidMinSdkVersion: 19
   AndroidMinSdkVersion: 19
   AndroidTargetSdkVersion: 0
   AndroidTargetSdkVersion: 0
   AndroidPreferredInstallLocation: 1
   AndroidPreferredInstallLocation: 1
@@ -191,22 +193,6 @@ PlayerSettings:
   uIStatusBarHidden: 1
   uIStatusBarHidden: 1
   uIExitOnSuspend: 0
   uIExitOnSuspend: 0
   uIStatusBarStyle: 0
   uIStatusBarStyle: 0
-  iPhoneSplashScreen: {fileID: 0}
-  iPhoneHighResSplashScreen: {fileID: 0}
-  iPhoneTallHighResSplashScreen: {fileID: 0}
-  iPhone47inSplashScreen: {fileID: 0}
-  iPhone55inPortraitSplashScreen: {fileID: 0}
-  iPhone55inLandscapeSplashScreen: {fileID: 0}
-  iPhone58inPortraitSplashScreen: {fileID: 0}
-  iPhone58inLandscapeSplashScreen: {fileID: 0}
-  iPadPortraitSplashScreen: {fileID: 0}
-  iPadHighResPortraitSplashScreen: {fileID: 0}
-  iPadLandscapeSplashScreen: {fileID: 0}
-  iPadHighResLandscapeSplashScreen: {fileID: 0}
-  iPhone65inPortraitSplashScreen: {fileID: 0}
-  iPhone65inLandscapeSplashScreen: {fileID: 0}
-  iPhone61inPortraitSplashScreen: {fileID: 0}
-  iPhone61inLandscapeSplashScreen: {fileID: 0}
   appleTVSplashScreen: {fileID: 0}
   appleTVSplashScreen: {fileID: 0}
   appleTVSplashScreen2x: {fileID: 0}
   appleTVSplashScreen2x: {fileID: 0}
   tvOSSmallIconLayers: []
   tvOSSmallIconLayers: []

+ 1 - 1
dbFiles/Categories.php

@@ -15,7 +15,7 @@
 
 
 	$categoryFilter = "";
 	$categoryFilter = "";
 	if ($gameId == -1) {
 	if ($gameId == -1) {
-		$categoryFilter = "(SELECT categoryId FROM categories)";
+		$categoryFilter = "(SELECT id FROM category)";
 	} else {
 	} else {
 		$categoryFilter = "(SELECT categoryId FROM gameCategories WHERE gameId = $gameId)";
 		$categoryFilter = "(SELECT categoryId FROM gameCategories WHERE gameId = $gameId)";
 	}
 	}

+ 10 - 5
dbFiles/FCMMessageing.php

@@ -28,18 +28,24 @@
 	
 	
 	if ($messageType === "FCMNextPlayer") {
 	if ($messageType === "FCMNextPlayer") {
 		$playerName = $conn->real_escape_string($_POST['playerName']);
 		$playerName = $conn->real_escape_string($_POST['playerName']);
-		$token = getToken();
+		$token = getToken($gameId, $playerName);
 		
 		
 		if ($token != null && $token != "") {
 		if ($token != null && $token != "") {
-			sendMessage($token);
+			sendMessage($httpClient, $token, $title, $messageToSend);
 		}
 		}
 	} else if ($messageType === "InviteMessage") {
 	} else if ($messageType === "InviteMessage") {
 		$i = 0;
 		$i = 0;
 		while ($_POST['player' . $i] != null) {
 		while ($_POST['player' . $i] != null) {
 			$token = getToken($gameId, $conn->real_escape_string($_POST['player' . $i]));
 			$token = getToken($gameId, $conn->real_escape_string($_POST['player' . $i]));
-			sendMessage($token);
+			sendMessage($httpClient, $token, $title, $messageToSend);
 		}
 		}
 
 
+	} else if ($messageType === "gameFinishedMessage") {
+		$i = 0;
+		while ($_POST['player' . $i] != null) {
+			$token = getToken($gameId, $conn->real_escape_string($_POST['player' . $i]));
+			sendMessage($httpClient, $token, $title, $messageToSend);
+		}
 	}
 	}
 	
 	
 	function getToken($gameId, $playerName) {
 	function getToken($gameId, $playerName) {
@@ -53,11 +59,10 @@
 		} else {
 		} else {
 			echo "No games found for user";
 			echo "No games found for user";
 		}
 		}
-		
 		return $token;
 		return $token;
 	}
 	}
 	
 	
-	function sendMessage($token) {
+	function sendMessage($httpClient, $token, $title, $messageToSend) {
 		// Your Firebase project ID
 		// Your Firebase project ID
 		$project = "narkampen";
 		$project = "narkampen";
 		// Creates a notification for subscribers to the debug topic
 		// Creates a notification for subscribers to the debug topic

+ 10 - 2
dbFiles/OnlineGames.php

@@ -18,7 +18,11 @@
 	$userId = $conn->query("SELECT id FROM users where username = '$userName'")->fetch_assoc()['id'];
 	$userId = $conn->query("SELECT id FROM users where username = '$userName'")->fetch_assoc()['id'];
 	
 	
 	if ($callFunction === "list"){	
 	if ($callFunction === "list"){	
-		$sql = "SELECT game.*, users.username as playerToAct FROM game LEFT JOIN users on currentPlayer = users.id WHERE game.id IN (SELECT gameId FROM gamePlayers WHERE playerId = $userId) ORDER BY FIELD(PlayerToAct, '$userName') DESC, lastPlayedDate DESC";
+		$sql = "SELECT game.*, users.username as playerToAct FROM game " +
+				"LEFT JOIN users on currentPlayer = users.id " +
+				"WHERE game.id IN (SELECT gameId FROM gamePlayers WHERE playerId = $userId) " + 
+				"AND game.status != 'FINISHED' "+
+				"ORDER BY FIELD(PlayerToAct, '$userName') DESC, lastPlayedDate DESC";
 		$result = $conn->query($sql);
 		$result = $conn->query($sql);
 
 
 		if ($result->num_rows > 0) {
 		if ($result->num_rows > 0) {
@@ -43,7 +47,7 @@
 		} else {
 		} else {
 			$sql = "SELECT count(*) as c FROM gamePlayers WHERE gameId = $gameId AND status NOT LIKE 'DECLINED'";
 			$sql = "SELECT count(*) as c FROM gamePlayers WHERE gameId = $gameId AND status NOT LIKE 'DECLINED'";
 			$result = $conn->query($sql);
 			$result = $conn->query($sql);
-			while ($data = $result->fetch_assoc()) {
+			while ($data = $result->fetch_assoc()) { // TODO Kommer ge fel om man inte har några spel kvar i listan.
 				if ($data['c'] == 1) { // Alla utom den som startade spelet har nekat, ta bort spelet från game
 				if ($data['c'] == 1) { // Alla utom den som startade spelet har nekat, ta bort spelet från game
 					$sql = "DELETE FROM game WHERE id = $gameId";
 					$sql = "DELETE FROM game WHERE id = $gameId";
 					$result = $conn->query($sql);
 					$result = $conn->query($sql);
@@ -216,6 +220,10 @@
 		$userId = $_POST['userId'];
 		$userId = $_POST['userId'];
 		$updateTokenSql = "UPDATE users SET messageToken = '$messageToken' WHERE id = " . $userId;
 		$updateTokenSql = "UPDATE users SET messageToken = '$messageToken' WHERE id = " . $userId;
 		$conn->query($updateTokenSql);
 		$conn->query($updateTokenSql);
+	} else if ($callFunction === "GameFinished") {
+		$setFinishedStatusSql = "UPDATE game SET status = 'FINISHED' WHERE id = $gameId";
+
+		$conn->query($setFinishedStatusSql);
 	}
 	}
 	
 	
 	
 	

+ 1 - 1
dbFiles/Question.php

@@ -14,7 +14,7 @@
 	}
 	}
 	mysqli_set_charset($conn,'utf8');
 	mysqli_set_charset($conn,'utf8');
 	
 	
-	$sql = 'SELECT questions.id, question, answer, categoryId as category, name, r,g,b,a FROM questions INNER JOIN questionToCategory ON questions.id = questionToCategory.questionId INNER JOIN category on category.id = questionToCategory.categoryId WHERE questionToCategory.categoryId IN (SELECT categoryId FROM gameCategories WHERE gameId = $gameId) ORDER BY RAND() limit 1';
+	$sql = "SELECT questions.id, question, answer, categoryId as category, name, r,g,b,a FROM questions INNER JOIN questionToCategory ON questions.id = questionToCategory.questionId INNER JOIN category on category.id = questionToCategory.categoryId WHERE questionToCategory.categoryId IN (SELECT categoryId FROM gameCategories WHERE gameId = $gameId) ORDER BY RAND() limit 1";
 	
 	
 	$result = mysqli_query($conn, $sql);
 	$result = mysqli_query($conn, $sql);