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
|
propertyPath: storyPanelUI
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 620624014}
|
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}
|
- target: {fileID: 7419541130731033687, guid: 2232353fd6a781a43a80ffae781ba792, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Broom_Reza
|
value: Broom_Reza
|
||||||
|
|
|
@ -18247,8 +18247,8 @@ Transform:
|
||||||
m_GameObject: {fileID: 109296006}
|
m_GameObject: {fileID: 109296006}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 1.9763, y: 0, z: 38.391}
|
m_LocalPosition: {x: 2.0999, y: 0, z: 38.536}
|
||||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 409307155}
|
m_Father: {fileID: 409307155}
|
||||||
|
@ -41554,7 +41554,7 @@ MeshCollider:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Convex: 0
|
m_Convex: 0
|
||||||
m_CookingOptions: 30
|
m_CookingOptions: 30
|
||||||
m_Mesh: {fileID: 671264381}
|
m_Mesh: {fileID: 472840735}
|
||||||
--- !u!33 &238973916
|
--- !u!33 &238973916
|
||||||
MeshFilter:
|
MeshFilter:
|
||||||
m_ObjectHideFlags: 10
|
m_ObjectHideFlags: 10
|
||||||
|
@ -127313,7 +127313,7 @@ MeshCollider:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Convex: 0
|
m_Convex: 0
|
||||||
m_CookingOptions: 30
|
m_CookingOptions: 30
|
||||||
m_Mesh: {fileID: 1115866272}
|
m_Mesh: {fileID: 1878171918}
|
||||||
--- !u!33 &691651230
|
--- !u!33 &691651230
|
||||||
MeshFilter:
|
MeshFilter:
|
||||||
m_ObjectHideFlags: 10
|
m_ObjectHideFlags: 10
|
||||||
|
@ -136973,8 +136973,8 @@ Transform:
|
||||||
m_GameObject: {fileID: 747649639}
|
m_GameObject: {fileID: 747649639}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 1.9763, y: 0, z: -0.96042}
|
m_LocalPosition: {x: 2.0999, y: 0, z: -1.1051}
|
||||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 409307155}
|
m_Father: {fileID: 409307155}
|
||||||
|
@ -180905,7 +180905,7 @@ MeshCollider:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Convex: 0
|
m_Convex: 0
|
||||||
m_CookingOptions: 30
|
m_CookingOptions: 30
|
||||||
m_Mesh: {fileID: 472840735}
|
m_Mesh: {fileID: 1048103572}
|
||||||
--- !u!33 &963648251
|
--- !u!33 &963648251
|
||||||
MeshFilter:
|
MeshFilter:
|
||||||
m_ObjectHideFlags: 10
|
m_ObjectHideFlags: 10
|
||||||
|
@ -192420,6 +192420,16 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 068fbcec103081147a0588ec72e53ee0, type: 3}
|
m_Script: {fileID: 11500000, guid: 068fbcec103081147a0588ec72e53ee0, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
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
|
--- !u!65 &1033478654
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -204872,8 +204882,8 @@ Transform:
|
||||||
m_GameObject: {fileID: 1108665897}
|
m_GameObject: {fileID: 1108665897}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -31.613, y: 0, z: -0.96042}
|
m_LocalPosition: {x: -31.736, y: 0, z: -1.1051}
|
||||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 409307155}
|
m_Father: {fileID: 409307155}
|
||||||
|
@ -219415,6 +219425,16 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 068fbcec103081147a0588ec72e53ee0, type: 3}
|
m_Script: {fileID: 11500000, guid: 068fbcec103081147a0588ec72e53ee0, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
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
|
--- !u!65 &1180841227
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -231184,7 +231204,7 @@ MeshCollider:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Convex: 0
|
m_Convex: 0
|
||||||
m_CookingOptions: 30
|
m_CookingOptions: 30
|
||||||
m_Mesh: {fileID: 1536359684}
|
m_Mesh: {fileID: 2090146024}
|
||||||
--- !u!33 &1243745926
|
--- !u!33 &1243745926
|
||||||
MeshFilter:
|
MeshFilter:
|
||||||
m_ObjectHideFlags: 10
|
m_ObjectHideFlags: 10
|
||||||
|
@ -248517,8 +248537,8 @@ Transform:
|
||||||
m_GameObject: {fileID: 1339568707}
|
m_GameObject: {fileID: 1339568707}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -31.613, y: 0, z: 38.391}
|
m_LocalPosition: {x: -31.736, y: 0, z: 38.536}
|
||||||
m_LocalScale: {x: 1.0571343, y: 1.0571343, z: 1.0571343}
|
m_LocalScale: {x: 1.0649408, y: 1.0649408, z: 1.0649408}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 409307155}
|
m_Father: {fileID: 409307155}
|
||||||
|
@ -327549,7 +327569,7 @@ MeshCollider:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Convex: 0
|
m_Convex: 0
|
||||||
m_CookingOptions: 30
|
m_CookingOptions: 30
|
||||||
m_Mesh: {fileID: 1953665037}
|
m_Mesh: {fileID: 1917445076}
|
||||||
--- !u!33 &1699035513
|
--- !u!33 &1699035513
|
||||||
MeshFilter:
|
MeshFilter:
|
||||||
m_ObjectHideFlags: 10
|
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)
|
if (storyPanelUI != null && storyText != null)
|
||||||
{
|
{
|
||||||
storyPanelUI.SetActive(true);
|
storyPanelUI.SetActive(true);
|
||||||
storyText.text = "My parents are still home... I should clean up first.";
|
storyText.text = "My parents are still home... I should clean up first.";
|
||||||
StartCoroutine(ClearMessageAfterSeconds(7f));
|
StartCoroutine(ClearMessageAfterSeconds(7f));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Functions when trash is collected/thrown
|
// Functions when trash is collected/thrown
|
||||||
public void CollectTrash()
|
public void CollectTrash()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,82 +1,52 @@
|
||||||
/*
|
/*
|
||||||
Author : Wai Lam
|
Author : Wai Lam
|
||||||
Date : 11/2/2025
|
Date : 13/2/2025
|
||||||
Description : Car obstacle
|
Description : Counting days
|
||||||
*/
|
*/
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
using TMPro;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class CanvasFade : MonoBehaviour
|
public class CanvasFade : MonoBehaviour
|
||||||
{
|
{
|
||||||
public CanvasGroup fadeCanvasGroup; // Assign in Inspector
|
public CanvasGroup dayPanel; // Assign the UI Panel
|
||||||
public float fadeDuration = 1f; // Duration for fade in/out
|
public TextMeshProUGUI dayText; // Assign the TextMeshPro UI
|
||||||
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
|
public static event Action OnDayPanelHidden;
|
||||||
|
private void Start()
|
||||||
private void OnTriggerEnter(Collider other)
|
|
||||||
{
|
{
|
||||||
// Check if the player entered the trigger
|
if (GameManager.Instance != null)
|
||||||
if (!hasTriggered && other.CompareTag("Player"))
|
|
||||||
{
|
{
|
||||||
hasTriggered = true;
|
int dayNumber = GameManager.Instance.currentDay;
|
||||||
StartCoroutine(FadeInAndLoadScene());
|
dayText.text = "Day " + dayNumber;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
elapsedTime += Time.deltaTime;
|
||||||
float t = elapsed / duration;
|
dayPanel.alpha = Mathf.Lerp(1f, 0f, elapsedTime / fadeDuration);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return null;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ public class GameManager : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static GameManager Instance;
|
public static GameManager Instance;
|
||||||
|
|
||||||
|
public int currentDay = 1;
|
||||||
|
|
||||||
// Defines UI references
|
// Defines UI references
|
||||||
[Header("UI References")]
|
[Header("UI References")]
|
||||||
public GameObject storyPanelUI;
|
public GameObject storyPanelUI;
|
||||||
|
@ -145,4 +147,9 @@ public class GameManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
goToSchool = true;
|
goToSchool = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void IncrementDay()
|
||||||
|
{
|
||||||
|
currentDay++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,10 @@ public class GoToSchool : MonoBehaviour
|
||||||
GameManager.Instance.GoToSchoolTaskComplete();
|
GameManager.Instance.GoToSchoolTaskComplete();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (GameManager.Instance != null)
|
||||||
|
{
|
||||||
|
GameManager.Instance.IncrementDay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator FadeInAndLoadScene()
|
IEnumerator FadeInAndLoadScene()
|
||||||
|
|
Loading…
Add table
Reference in a new issue