Переглянути джерело

Fixar efter remodelering och kod uppdatering

Axel Nordh 7 роки тому
батько
коміт
0612bd5acf

+ 1 - 3
Assets/Scripts/GameManagerScript.cs

@@ -7,7 +7,6 @@ public class GameManagerScript : MonoBehaviour {
 
     private int playerCount;
     private string gameMode;
-    private int gameId;
 
     public Database db;
      
@@ -22,10 +21,9 @@ public class GameManagerScript : MonoBehaviour {
         GameId = PlayerPrefs.GetInt("GameId");
 
         db.SetLocalOrOnline("Local");
-        db.SetLastPlayedDate(gameId);
+        db.SetLastPlayedDate(GameId);
         StatsScript statsScript = GameObject.Find("StatsPanel").GetComponent<StatsScript>();
 
-        statsScript.AddPlayersToStats(GetPlayersForGame());
     }
 
     private List<KeyValuePair<string,int>> GetPlayersForGame() {

+ 18 - 0
Assets/Scripts/InformationPanelScript.cs

@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class InformationPanelScript : MonoBehaviour
+{
+    // Start is called before the first frame update
+    void Start()
+    {
+        
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        
+    }
+}

+ 11 - 0
Assets/Scripts/InformationPanelScript.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6ae6755aa613f534c8c5b5481c953a6d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 0
Assets/RoundButtonsScript.cs → Assets/Scripts/RoundButtonsScript.cs


+ 0 - 0
Assets/RoundButtonsScript.cs.meta → Assets/Scripts/RoundButtonsScript.cs.meta


+ 5 - 0
Assets/Scripts/ScrollViewScript.cs

@@ -103,6 +103,11 @@ public class ScrollViewScript : MonoBehaviour, IDropHandler {
             return;
         }
         nq = d.GetComponent<NewQuestion>();
+        
+        if ("???? - ????".Equals(nq.GetAnswerText().text)) {
+            ResetNewQuestionPosition();
+            return;
+        }
         newQuestionSiblingIndex = d.placeholder.transform.GetSiblingIndex();
 
         GenericDialog dialog = GenericDialog.Instance();

+ 4 - 0
Assets/StatsLine.cs → Assets/Scripts/StatsLine.cs

@@ -17,6 +17,10 @@ public class StatsLine : MonoBehaviour
         statValue.text = value;
     }
 
+
+    public string GetName() {
+        return statName.text;
+    }
     public string GetValue() {
         return statValue.text;
     }

+ 0 - 0
Assets/StatsLine.cs.meta → Assets/Scripts/StatsLine.cs.meta


+ 27 - 40
Assets/Scripts/StatsScript.cs

@@ -13,20 +13,23 @@ public class StatsScript : MonoBehaviour {
     private Text[] statsTextNames;
     private Text[] statsTextValues;
 
-    private List<StatsLine> statLines;
+    private List<StatsLine> statLines = new List<StatsLine>();
 
     GameManagerScript gms;
 
     private void Start() {
-        statLines = new List<StatsLine>();
         gms = GameObject.Find("GameManager").GetComponent<GameManagerScript>();
         CreateStandardStats();
+
+        AddPlayersToStats(gms.GetPlayers());
     }
 
     private void CreateStandardStats() {
         StatsLine round = CreateStatLine();
         round.SetStatName("Round");
-        round.SetStatValue("1");
+        int roundValue = gms.GetDatabase().GetRoundValue(gms.GameId);
+
+        round.SetStatValue(roundValue.ToString());
         round.name = "roundStat";
 
         StatsLine lostQuestions = CreateStatLine();
@@ -54,7 +57,7 @@ public class StatsScript : MonoBehaviour {
 
     public void AddPlayersToStats(List<KeyValuePair<string, int>> players) {
 
-        foreach (KeyValuePair<string,int> player in players) {
+        foreach (KeyValuePair<string, int> player in players) {
             StatsLine p = CreateStatLine();
             p.SetStatName(player.Key);
             p.SetStatValue(player.Value.ToString());
@@ -63,50 +66,34 @@ public class StatsScript : MonoBehaviour {
         }
     }
 
-    private void AddTextComponent(GameObject parent, string text, bool alignCenter, int index) {
-        GameObject playerHeaderGameObject = new GameObject();
-        playerHeaderGameObject.transform.parent = parent.transform;
-
-        Text newTextObject = playerHeaderGameObject.AddComponent<Text>();
-        newTextObject.text = text;
-        newTextObject.font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
-        newTextObject.color = new Color32(50, 50, 50, 255);
-
-        newTextObject.resizeTextForBestFit = true;
-        newTextObject.resizeTextMinSize = 10;
-        newTextObject.resizeTextMaxSize = 14;
-
-        if (index >= 0) {
-            newTextObject.name = "Player" + index;
-        }
-
-        if (alignCenter) {
-            newTextObject.alignment = TextAnchor.MiddleCenter;
-        }
-
-        RectTransform rectTransform = newTextObject.GetComponent<RectTransform>();
-        rectTransform.sizeDelta = new Vector2(0, 15);
-        rectTransform.localPosition = new Vector3(0, 0, 0);
-        rectTransform.localScale = new Vector3(1, 1, 1);
-    }
-
     public void IncreaseRoundValue() {
-        foreach (Text text in statsTextValues) {
-            if (text.name.Equals("Stats Value Round")) {
-                Int32.TryParse(text.text, out int round);
+        foreach (StatsLine sl in statLines) {
+            if (sl.GetName().Equals("Round")) {
+                Int32.TryParse(sl.GetValue(), out int round);
                 round++;
-                text.text = round.ToString();
-                gms.GetDatabase().SetRoundValue(gms.GameId, round);
+                sl.SetStatValue(round.ToString());
                 break;
             }
         }
     }
 
-    public void SetQuestionsInAnswerLine(string playerName, int count) {
-        for (int i = 0; i < statsTextNames.Length; i++) {
-            if (statsTextNames[i].text.Equals(playerName)) {
-                statsTextValues[i].text = count.ToString();
+    public void MakeBold(string playerName) {
+        foreach (StatsLine sl in statLines) {
+            if (sl.GetName().Equals(playerName)) {
+                sl.MakeBold();
+            } else {
+                sl.UnBold();
             }
         }
     }
+
+    public void SetQuestionsInAnswerLine(string playerName, int count) {
+        foreach (StatsLine sl in statLines) {
+            if (sl.GetName().Equals(playerName)) {
+                sl.SetStatValue(count.ToString()) ;
+                break;
+            } 
+        }
+        return;
+    }
 }

+ 35 - 3
Assets/narKampen.unity

@@ -583,7 +583,7 @@ CanvasGroup:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 162320633}
   m_Enabled: 1
-  m_Alpha: 0
+  m_Alpha: 1
   m_Interactable: 1
   m_BlocksRaycasts: 0
   m_IgnoreParentGroups: 0
@@ -1148,6 +1148,7 @@ GameObject:
   - component: {fileID: 614296913}
   - component: {fileID: 614296912}
   - component: {fileID: 614296911}
+  - component: {fileID: 614296914}
   m_Layer: 5
   m_Name: AcceptButton
   m_TagString: Untagged
@@ -1257,6 +1258,21 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 614296909}
   m_CullTransparentMesh: 0
+--- !u!114 &614296914
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 614296909}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5}
+  m_EffectDistance: {x: 1, y: -1}
+  m_UseGraphicAlpha: 1
 --- !u!1 &624053428
 GameObject:
   m_ObjectHideFlags: 0
@@ -1269,6 +1285,7 @@ GameObject:
   - component: {fileID: 624053432}
   - component: {fileID: 624053431}
   - component: {fileID: 624053430}
+  - component: {fileID: 624053433}
   m_Layer: 5
   m_Name: DeclineButton
   m_TagString: Untagged
@@ -1378,6 +1395,21 @@ CanvasRenderer:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 624053428}
   m_CullTransparentMesh: 0
+--- !u!114 &624053433
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 624053428}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5}
+  m_EffectDistance: {x: 1, y: -1}
+  m_UseGraphicAlpha: 1
 --- !u!1 &815165975
 GameObject:
   m_ObjectHideFlags: 0
@@ -1895,7 +1927,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 0.392}
+  m_Color: {r: 0.509434, g: 0.509434, b: 0.509434, a: 0.5882353}
   m_RaycastTarget: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
@@ -1955,7 +1987,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: -100}
+  m_SizeDelta: {x: -10, y: -100}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1091517009
 MonoBehaviour:

BIN
Assets/narKampenLocal.db