intro and start game location

This commit is contained in:
szczuras4
2025-07-18 16:44:42 +02:00
parent e64e44a9a1
commit 80bc1247f6
9 changed files with 4512 additions and 1875 deletions

View File

@@ -0,0 +1,71 @@
using UnityEngine;
using System.Collections;
public class LightTransition : MonoBehaviour
{
[Header("Ustawienia Œwiat³a")]
[Tooltip("Przeci¹gnij tutaj œwiat³o Directional Light, którym chcesz sterowaæ.")]
public Light directionalLight;
[Header("Wartoœci Docelowe")]
[Tooltip("Docelowa rotacja œwiat³a (w stopniach).")]
public Vector3 targetRotationEuler;
[Tooltip("Docelowy kolor œwiat³a.")]
public Color targetColor = Color.white;
[Tooltip("Docelowa intensywnoœæ œwiat³a.")]
[Range(0f, 8f)]
public float targetIntensity = 1f;
[Header("Ustawienia Przejœcia")]
[Tooltip("Czas trwania przejœcia w sekundach.")]
public float transitionDuration = 5.0f;
// Uruchamia przejœcie
public void StartLightTransition()
{
StopAllCoroutines();
StartCoroutine(TransitionRoutine());
}
private IEnumerator TransitionRoutine()
{
// 1. Zapisujemy wartoœci pocz¹tkowe
Quaternion initialRotation = directionalLight.transform.rotation;
Color initialColor = directionalLight.color;
float initialIntensity = directionalLight.intensity;
Quaternion targetRotation = Quaternion.Euler(targetRotationEuler);
float elapsedTime = 0f;
// 2. Pêtla przejœcia
while (elapsedTime < transitionDuration)
{
float progress = elapsedTime / transitionDuration;
// 3. Interpolacja wszystkich wartoœci jednoczeœnie
directionalLight.transform.rotation = Quaternion.Slerp(initialRotation, targetRotation, progress);
directionalLight.color = Color.Lerp(initialColor, targetColor, progress); // POPRAWIONA LINIA
directionalLight.intensity = Mathf.Lerp(initialIntensity, targetIntensity, progress);
elapsedTime += Time.deltaTime;
yield return null;
}
// 4. Ustawienie wartoœci koñcowych dla pewnoœci
directionalLight.transform.rotation = targetRotation;
directionalLight.color = targetColor;
directionalLight.intensity = targetIntensity;
}
// Opcjonalnie: Trigger do uruchamiania eventu
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Debug.Log("Gracz wszed³ w trigger. Uruchamiam zmianê œwiat³a!");
StartLightTransition();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3f78d66e058a7614889cc7a296fbd446

View File

@@ -1,3 +1,5 @@
// --- PE£NY I POPRAWIONY SKRYPT FOGZONE.CS ---
using System.Collections;
using UnityEngine;
@@ -42,7 +44,51 @@ public class FogZone : MonoBehaviour
s_coroutineRunner = null;
}
// --- LOGIKA TRYBU GRY ---
// --- NOWA LOGIKA - SPRAWDZENIE NA STARCIE GRY ---
/// <summary>
/// Sprawdza na starcie gry, czy gracz ju¿ znajduje siê w strefie.
/// Jeœli tak, aktywuje mg³ê natychmiast.
/// </summary>
private void Start()
{
// Upewniamy siê, ¿e ten kod dzia³a tylko w trybie gry, a nie w edytorze
if (!Application.isPlaying)
{
return;
}
// ZnajdŸ obiekt gracza na scenie za pomoc¹ tagu
GameObject playerObject = GameObject.FindWithTag(playerTag);
if (playerObject == null)
{
// Jeœli nie ma gracza na scenie (lub ma z³y tag), nic nie robimy
return;
}
// Pobierz collider tej strefy mg³y
Collider zoneCollider = GetComponent<Collider>();
// SprawdŸ, czy pozycja gracza znajduje siê wewn¹trz granic collidera tej strefy
if (zoneCollider.bounds.Contains(playerObject.transform.position))
{
Debug.Log($"Gracz '{playerObject.name}' rozpocz¹³ grê wewn¹trz strefy '{this.name}'. Ustawiam mg³ê natychmiast.", this);
// U¿ywamy ma³ej sztuczki: tymczasowo ustawiamy czas przejœcia na 0,
// aby mg³a pojawi³a siê od razu, a nie p³ynnie.
float originalDuration = transitionDuration;
transitionDuration = 0f;
// Uruchom logikê wejœcia do strefy
StartTransition(true);
// Przywróæ oryginalny czas przejœcia, aby póŸniejsze wejœcia/wyjœcia
// dzia³a³y z normaln¹, p³ynn¹ animacj¹.
transitionDuration = originalDuration;
}
}
// --- LOGIKA TRYBU GRY (BEZ ZMIAN) ---
private void OnTriggerEnter(Collider other)
{
@@ -74,7 +120,7 @@ public class FogZone : MonoBehaviour
StartTransition(false);
}
// --- G£ÓWNA LOGIKA PRZEJŒCIA ---
// --- G£ÓWNA LOGIKA PRZEJŒCIA (BEZ ZMIAN) ---
private void StartTransition(bool toZoneSettings)
{
@@ -129,6 +175,7 @@ public class FogZone : MonoBehaviour
float elapsed = 0f;
while (elapsed < transitionDuration)
{
// Jeœli czas przejœcia jest 0 (jak w naszym przypadku na starcie), 't' od razu bêdzie 1
float t = (transitionDuration > 0) ? Mathf.Clamp01(elapsed / transitionDuration) : 1f;
RenderSettings.fogColor = Color.Lerp(startColor, endColor, t);
@@ -140,6 +187,7 @@ public class FogZone : MonoBehaviour
yield return null;
}
// Upewniamy siê, ¿e na koñcu s¹ dok³adnie docelowe wartoœci
RenderSettings.fogColor = endColor;
RenderSettings.fogDensity = endDensity;
RenderSettings.fogStartDistance = endLinearStart;
@@ -156,7 +204,7 @@ public class FogZone : MonoBehaviour
}
// --- LOGIKA TYLKO DLA EDYTORA UNITY ---
// --- LOGIKA TYLKO DLA EDYTORA UNITY (BEZ ZMIAN) ---
#if UNITY_EDITOR
private static bool s_editorSettingsSaved = false;
private static FogZone s_editorActiveZone = null;
@@ -196,8 +244,6 @@ public class FogZone : MonoBehaviour
{
if (Application.isPlaying) return;
// *** POPRAWKA JEST TUTAJ ***
// Jeœli podgl¹d jest wy³¹czony, ale ta strefa jest wci¹¿ aktywna, przywróæ ustawienia
if (!enableEditorPreview)
{
if (s_editorActiveZone == this)
@@ -205,7 +251,7 @@ public class FogZone : MonoBehaviour
RestoreEditorSettings();
s_editorActiveZone = null;
}
return; // Zakoñcz dzia³anie metody, jeœli podgl¹d jest wy³¹czony
return;
}
var sceneView = SceneView.lastActiveSceneView;