Added days
This commit is contained in:
parent
498105cd17
commit
15246a9af2
6 changed files with 114 additions and 75 deletions
|
@ -164071,6 +164071,10 @@ PrefabInstance:
|
|||
propertyPath: storyPanelUI
|
||||
value:
|
||||
objectReference: {fileID: 620624014}
|
||||
- target: {fileID: 7297253480383072062, guid: 2232353fd6a781a43a80ffae781ba792, type: 3}
|
||||
propertyPath: m_FarAttachMode
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7419541130731033687, guid: 2232353fd6a781a43a80ffae781ba792, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Broom_Reza
|
||||
|
|
|
@ -18247,8 +18247,8 @@ Transform:
|
|||
m_GameObject: {fileID: 109296006}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1.9763, y: 0, z: 38.391}
|
||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
||||
m_LocalPosition: {x: 2.0999, y: 0, z: 38.536}
|
||||
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 409307155}
|
||||
|
@ -41554,7 +41554,7 @@ MeshCollider:
|
|||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 671264381}
|
||||
m_Mesh: {fileID: 472840735}
|
||||
--- !u!33 &238973916
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 10
|
||||
|
@ -127313,7 +127313,7 @@ MeshCollider:
|
|||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 1115866272}
|
||||
m_Mesh: {fileID: 1878171918}
|
||||
--- !u!33 &691651230
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 10
|
||||
|
@ -136973,8 +136973,8 @@ Transform:
|
|||
m_GameObject: {fileID: 747649639}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1.9763, y: 0, z: -0.96042}
|
||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
||||
m_LocalPosition: {x: 2.0999, y: 0, z: -1.1051}
|
||||
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 409307155}
|
||||
|
@ -180905,7 +180905,7 @@ MeshCollider:
|
|||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 472840735}
|
||||
m_Mesh: {fileID: 1048103572}
|
||||
--- !u!33 &963648251
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 10
|
||||
|
@ -192420,6 +192420,16 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 068fbcec103081147a0588ec72e53ee0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
playerRig: {fileID: 1988509986}
|
||||
startPoint: {fileID: 1305339138}
|
||||
waypoints:
|
||||
- {fileID: 747649640}
|
||||
- {fileID: 109296007}
|
||||
- {fileID: 1339568708}
|
||||
- {fileID: 1108665898}
|
||||
speed: 6
|
||||
rotationSpeed: 3
|
||||
rotationOffset: {x: 0, y: 90, z: 0}
|
||||
--- !u!65 &1033478654
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -204872,8 +204882,8 @@ Transform:
|
|||
m_GameObject: {fileID: 1108665897}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -31.613, y: 0, z: -0.96042}
|
||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
||||
m_LocalPosition: {x: -31.736, y: 0, z: -1.1051}
|
||||
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 409307155}
|
||||
|
@ -219415,6 +219425,16 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 068fbcec103081147a0588ec72e53ee0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
playerRig: {fileID: 1988509986}
|
||||
startPoint: {fileID: 1305339138}
|
||||
waypoints:
|
||||
- {fileID: 1339568708}
|
||||
- {fileID: 1108665898}
|
||||
- {fileID: 747649640}
|
||||
- {fileID: 109296007}
|
||||
speed: 5.8
|
||||
rotationSpeed: 3
|
||||
rotationOffset: {x: 0, y: 90, z: 0}
|
||||
--- !u!65 &1180841227
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -231184,7 +231204,7 @@ MeshCollider:
|
|||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 1536359684}
|
||||
m_Mesh: {fileID: 2090146024}
|
||||
--- !u!33 &1243745926
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 10
|
||||
|
@ -248517,8 +248537,8 @@ Transform:
|
|||
m_GameObject: {fileID: 1339568707}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -31.613, y: 0, z: 38.391}
|
||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
||||
m_LocalPosition: {x: -31.736, y: 0, z: 38.536}
|
||||
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 409307155}
|
||||
|
@ -327549,7 +327569,7 @@ MeshCollider:
|
|||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 1953665037}
|
||||
m_Mesh: {fileID: 1917445076}
|
||||
--- !u!33 &1699035513
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 10
|
||||
|
|
|
@ -81,15 +81,49 @@ public class BedroomTask : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
// Hide the story panel at the start
|
||||
if (storyPanelUI != null)
|
||||
storyPanelUI.SetActive(false);
|
||||
|
||||
// Subscribe to the event from DayPanelManager
|
||||
CanvasFade.OnDayPanelHidden += ShowStoryText;
|
||||
|
||||
// if (storyPanelUI != null && storyText != null)
|
||||
// {
|
||||
// storyPanelUI.SetActive(true);
|
||||
// storyText.text = "My parents are still home... I should clean up first.";
|
||||
// StartCoroutine(ClearMessageAfterSeconds(7f));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
// Unsubscribe to prevent memory leaks
|
||||
CanvasFade.OnDayPanelHidden -= ShowStoryText;
|
||||
}
|
||||
|
||||
private void ShowStoryText()
|
||||
{
|
||||
// Activate story panel and show text after the Day Panel disappears
|
||||
StartCoroutine(DelayedStoryText());
|
||||
}
|
||||
|
||||
private IEnumerator DelayedStoryText()
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f); // Small delay to ensure smooth transition
|
||||
|
||||
if (storyPanelUI != null && storyText != null)
|
||||
{
|
||||
storyPanelUI.SetActive(true);
|
||||
storyText.text = "My parents are still home... I should clean up first.";
|
||||
StartCoroutine(ClearMessageAfterSeconds(7f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Functions when trash is collected/thrown
|
||||
public void CollectTrash()
|
||||
{
|
||||
|
|
|
@ -1,82 +1,52 @@
|
|||
/*
|
||||
Author : Wai Lam
|
||||
Date : 11/2/2025
|
||||
Description : Car obstacle
|
||||
Date : 13/2/2025
|
||||
Description : Counting days
|
||||
*/
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using TMPro;
|
||||
using System;
|
||||
|
||||
public class CanvasFade : MonoBehaviour
|
||||
{
|
||||
public CanvasGroup fadeCanvasGroup; // Assign in Inspector
|
||||
public float fadeDuration = 1f; // Duration for fade in/out
|
||||
public float displayDuration = 5f; // Time the UI stays fully visible
|
||||
public string nextSceneName; // Name of the scene to load
|
||||
public AudioSource[] audioSources;
|
||||
|
||||
private bool hasTriggered = false; // Prevent multiple triggers
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
public CanvasGroup dayPanel; // Assign the UI Panel
|
||||
public TextMeshProUGUI dayText; // Assign the TextMeshPro UI
|
||||
|
||||
public static event Action OnDayPanelHidden;
|
||||
private void Start()
|
||||
{
|
||||
// Check if the player entered the trigger
|
||||
if (!hasTriggered && other.CompareTag("Player"))
|
||||
if (GameManager.Instance != null)
|
||||
{
|
||||
hasTriggered = true;
|
||||
StartCoroutine(FadeInAndLoadScene());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator FadeInAndLoadScene()
|
||||
{
|
||||
// Fade In
|
||||
yield return StartCoroutine(Fade(0f, 1f, fadeDuration));
|
||||
|
||||
// Display UI for 5 seconds
|
||||
yield return new WaitForSeconds(displayDuration);
|
||||
|
||||
// Load the next scene
|
||||
SceneManager.LoadScene(nextSceneName);
|
||||
}
|
||||
|
||||
IEnumerator Fade(float startAlpha, float endAlpha, float duration)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
fadeCanvasGroup.alpha = startAlpha;
|
||||
|
||||
float[] startVolumes = new float[audioSources.Length];
|
||||
for (int i = 0; i < audioSources.Length; i++)
|
||||
{
|
||||
startVolumes[i] = audioSources[i] != null ? audioSources[i].volume : 1f;
|
||||
int dayNumber = GameManager.Instance.currentDay;
|
||||
dayText.text = "Day " + dayNumber;
|
||||
}
|
||||
|
||||
while (elapsed < duration)
|
||||
StartCoroutine(FadeOutPanel());
|
||||
}
|
||||
|
||||
private IEnumerator FadeOutPanel()
|
||||
{
|
||||
dayPanel.alpha = 1f;
|
||||
dayPanel.gameObject.SetActive(true);
|
||||
|
||||
yield return new WaitForSeconds(3f); // Display for 3 seconds
|
||||
|
||||
float fadeDuration = 1.5f;
|
||||
float elapsedTime = 0f;
|
||||
|
||||
while (elapsedTime < fadeDuration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = elapsed / duration;
|
||||
|
||||
fadeCanvasGroup.alpha = Mathf.Lerp(startAlpha, endAlpha, t);
|
||||
|
||||
for (int i = 0; i < audioSources.Length; i++)
|
||||
{
|
||||
if (audioSources[i] != null)
|
||||
{
|
||||
audioSources[i].volume = Mathf.Lerp(startVolumes[i], 0f, t);
|
||||
}
|
||||
}
|
||||
|
||||
elapsedTime += Time.deltaTime;
|
||||
dayPanel.alpha = Mathf.Lerp(1f, 0f, elapsedTime / fadeDuration);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
fadeCanvasGroup.alpha = endAlpha;
|
||||
dayPanel.gameObject.SetActive(false);
|
||||
|
||||
OnDayPanelHidden?.Invoke();
|
||||
|
||||
for (int i = 0; i < audioSources.Length; i++)
|
||||
{
|
||||
if (audioSources[i] != null)
|
||||
{
|
||||
audioSources[i].volume = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ public class GameManager : MonoBehaviour
|
|||
/// Define instance field for accessing the singleton elsewhere
|
||||
/// </summary>
|
||||
public static GameManager Instance;
|
||||
|
||||
public int currentDay = 1;
|
||||
|
||||
// Defines UI references
|
||||
[Header("UI References")]
|
||||
|
@ -145,4 +147,9 @@ public class GameManager : MonoBehaviour
|
|||
{
|
||||
goToSchool = true;
|
||||
}
|
||||
|
||||
public void IncrementDay()
|
||||
{
|
||||
currentDay++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,10 @@ public class GoToSchool : MonoBehaviour
|
|||
GameManager.Instance.GoToSchoolTaskComplete();
|
||||
|
||||
}
|
||||
if (GameManager.Instance != null)
|
||||
{
|
||||
GameManager.Instance.IncrementDay();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator FadeInAndLoadScene()
|
||||
|
|
Loading…
Add table
Reference in a new issue