Selaa lähdekoodia

menu menu menu

SionAraAra 3 viikkoa sitten
vanhempi
commit
e3194316c4

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 888 - 34
Valley_Runner/Assets/Scenes/Game.unity


+ 24 - 16
Valley_Runner/Assets/Scenes/Menu.unity

@@ -316,9 +316,9 @@ MonoBehaviour:
   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_HighlightedColor: {r: 1, g: 0, b: 0, 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_SelectedColor: {r: 0, g: 1, b: 0.9489832, a: 1}
     m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
     m_ColorMultiplier: 1
     m_FadeDuration: 0.1
@@ -1305,7 +1305,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  m_FirstSelected: {fileID: 0}
+  m_FirstSelected: {fileID: 133780552}
   m_sendNavigationEvents: 1
   m_DragThreshold: 10
 --- !u!4 &881021236
@@ -1787,14 +1787,22 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: d1281cdca4b06934da224e517f4efd98, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  targets: []
-  score: 0
-  scoreText: {fileID: 0}
-  gameOverText: {fileID: 0}
-  restartButton: {fileID: 0}
+  timeRemainingText: {fileID: 0}
+  orbsCollectedText: {fileID: 0}
   isGameActive: 0
-  titleScreen: {fileID: 0}
-  diff: 0
+  GameOverScreen: {fileID: 0}
+  VictoryScreen: {fileID: 0}
+  playerPosX: 0
+  playerPosY: 0
+  playerPosZ: 0
+  playerRotX: 0
+  playerRotY: 0
+  playerRotZ: 0
+  orbsCollected: 0
+  seed: 0
+  orbs: []
+  timeRemaining: 100
+  settings: 0
 --- !u!114 &1172969850
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -1953,9 +1961,9 @@ MonoBehaviour:
   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_HighlightedColor: {r: 1, g: 0, b: 0, 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_SelectedColor: {r: 0, g: 1, b: 0.9489832, a: 1}
     m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
     m_ColorMultiplier: 1
     m_FadeDuration: 0.1
@@ -3136,9 +3144,9 @@ MonoBehaviour:
   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_HighlightedColor: {r: 1, g: 0, b: 0, 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_SelectedColor: {r: 0, g: 1, b: 0.9489832, a: 1}
     m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
     m_ColorMultiplier: 1
     m_FadeDuration: 0.1
@@ -3664,9 +3672,9 @@ MonoBehaviour:
   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_HighlightedColor: {r: 1, g: 0, b: 0, 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_SelectedColor: {r: 0, g: 1, b: 0.9489832, a: 1}
     m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
     m_ColorMultiplier: 1
     m_FadeDuration: 0.1

+ 1 - 0
Valley_Runner/Assets/Scripts/GameManager.cs

@@ -43,6 +43,7 @@ public class GameManager : MonoBehaviour
     void Start()
     {
         isGameActive = true;
+        
 
         for (int i = 0; i < orbs.Count; i++)
         {

+ 53 - 0
Valley_Runner/Assets/Scripts/LoadingScreen.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using Random = UnityEngine.Random;
+
+
+public class LoadingScreen : MonoBehaviour
+{
+    public GameObject LoadingScreenUI;
+    private Slider loadingSlider;
+    public List<GameObject> tooltips = new List<GameObject>();
+    public PauseMenu pauseMenu;
+    // Start is called once before the first execution of Update after the MonoBehaviour is created
+    void Start()
+    {
+        pauseMenu.SetIsLoading(true);
+        loadingSlider = LoadingScreenUI.GetComponentInChildren<Slider>();
+        loadingSlider.value = 0f;
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        loadingSlider.value += 0.05f*Time.deltaTime;
+        if (loadingSlider.value >= 1)
+        {
+            pauseMenu.SetIsLoading(false);
+            LoadingScreenUI.SetActive(false);
+        }
+    }
+
+    public void OnEnable()
+    {
+        ShowRandomTooltip();
+    }
+
+    void ShowRandomTooltip()
+    {
+        if (tooltips.Count == 0)
+            return;
+
+        // Disable all tooltips first
+        foreach (GameObject tooltip in tooltips)
+        {
+            tooltip.SetActive(false);
+        }
+
+        // Pick and enable one random tooltip
+        int randomIndex = Random.Range(0, tooltips.Count);
+        tooltips[randomIndex].SetActive(true);
+    }
+}

+ 2 - 0
Valley_Runner/Assets/Scripts/LoadingScreen.cs.meta

@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 757dde889486bba42900b319eb2a029d

+ 27 - 9
Valley_Runner/Assets/Scripts/PauseMenu.cs

@@ -1,22 +1,31 @@
 using UnityEngine;
+using UnityEngine.EventSystems;
 using UnityEngine.SceneManagement;
 public class PauseMenu : MonoBehaviour
 {
     public static bool GameIsPaused = false;
     public GameObject PauseMenuUI;
     public GameManager gameManager;
+    public GameObject ResumeButton;
+    private bool isLoading = true;
+    
+    
     void Update()
     {
-        if (Input.GetKeyDown(KeyCode.Escape))
+        if(isLoading == false)
         {
-            if (GameIsPaused)
+            if (Input.GetKeyDown(KeyCode.Escape))
             {
-                Resume();
-            }
-            else
-            {
-                Pause();
+                if (GameIsPaused)
+                {
+                    Resume();
+                }
+                else
+                {
+                    Pause();
+                }
             }
+        
         }
     }
 
@@ -35,6 +44,9 @@ public class PauseMenu : MonoBehaviour
         PauseMenuUI.SetActive(false);
         Time.timeScale = 1;
         GameIsPaused = false;
+        EventSystem.current.SetSelectedGameObject(null);
+        Cursor.lockState = CursorLockMode.Locked;
+        Cursor.visible = false;
     }
 
     void Pause()
@@ -42,6 +54,10 @@ public class PauseMenu : MonoBehaviour
         PauseMenuUI.SetActive(true);
         Time.timeScale = 0;
         GameIsPaused = true;
+        EventSystem.current.SetSelectedGameObject(null);
+        EventSystem.current.SetSelectedGameObject(ResumeButton);
+        Cursor.lockState = CursorLockMode.None;
+        Cursor.visible = true;
     }
     
     public void SaveGame()
@@ -57,8 +73,10 @@ public class PauseMenu : MonoBehaviour
         Debug.Log("Load Game");
         GameData data = SaveSystem.LoadGame();
 
+    }
 
-        
-
+    public void SetIsLoading(bool isLoading)
+    {
+        this.isLoading = isLoading;
     }
 }

+ 17 - 6
Valley_Runner/Assets/Scripts/ThirdPersonCam.cs

@@ -15,22 +15,33 @@ public class ThirdPersonCam : MonoBehaviour
     {
         Cursor.lockState = CursorLockMode.Locked;
         Cursor.visible = false;
+        
+        rb.freezeRotation = true;
     }
 
     private void Update()
     {
-        //rotate orientation
-        Vector3 viewDir = player.position - new Vector3(transform.position.x, transform.position.y, transform.position.z);
+        // -------- Camera → Orientation (Y-axis only) --------
+        Vector3 viewDir = player.position - transform.position;
+        viewDir.y = 0f;
+
         orientation.forward = viewDir.normalized;
-        
-        //rotate player object
+
+        // -------- Player Rotation --------
         float horizontalInput = Input.GetAxis("Horizontal");
         float verticalInput = Input.GetAxis("Vertical");
+
         Vector3 inputDir = orientation.forward * verticalInput + orientation.right * horizontalInput;
+        inputDir.y = 0f; // EXTRA SAFETY
 
-        if (inputDir != Vector3.zero)
+        if (inputDir.sqrMagnitude > 0.01f)
         {
-            playerObj.forward = Vector3.Lerp(playerObj.forward, inputDir.normalized, Time.deltaTime * rotationSpeed);
+            Quaternion targetRotation = Quaternion.LookRotation(inputDir);
+            playerObj.rotation = Quaternion.Slerp(
+                playerObj.rotation,
+                targetRotation,
+                rotationSpeed * Time.deltaTime
+            );
         }
     }
 }

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä