test commit
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class DynamicTime : MonoBehaviour
|
||||
{
|
||||
public static DynamicTime Instance;
|
||||
|
||||
public const string PlayerPrefsKey = "SelectedTOD";
|
||||
|
||||
[Serializable]
|
||||
public class TimePreset
|
||||
{
|
||||
[Header("Sky")]
|
||||
public Material Skybox;
|
||||
[Header("Ambient Lighting")]
|
||||
public float AmbientIntensity;
|
||||
public Color AmbientSkyColor;
|
||||
public Color AmbientEquatorColor;
|
||||
public Color AmbientGroundColor;
|
||||
public AmbientMode AmbientMode;
|
||||
[Header("Fog")]
|
||||
public bool Fog;
|
||||
public float FogDensity;
|
||||
public float FogStartDistance;
|
||||
public float FogEndDistance;
|
||||
public Color FogColor;
|
||||
public FogMode FogMode;
|
||||
[Header("Objects")]
|
||||
public GameObject[] ObjectsToEnable;
|
||||
public GameObject[] ObjectsToDisable;
|
||||
|
||||
internal TimeOfDay tod;
|
||||
}
|
||||
|
||||
public enum TimeOfDay
|
||||
{
|
||||
Day,
|
||||
Dusk,
|
||||
Dawn,
|
||||
Night,
|
||||
Nightmare
|
||||
}
|
||||
|
||||
public TimePreset DayPreset = new();
|
||||
public TimePreset DuskPreset = new();
|
||||
public TimePreset DawnPreset = new();
|
||||
public TimePreset NightPreset = new();
|
||||
public TimePreset NightmarePreset = new();
|
||||
|
||||
public TimeOfDay ActiveTOD;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
DayPreset.tod = TimeOfDay.Day;
|
||||
DuskPreset.tod = TimeOfDay.Dusk;
|
||||
DawnPreset.tod = TimeOfDay.Dawn;
|
||||
NightPreset.tod = TimeOfDay.Night;
|
||||
NightmarePreset.tod = TimeOfDay.Nightmare;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (PlayerPrefs.HasKey(PlayerPrefsKey))
|
||||
ActiveTOD = (TimeOfDay)PlayerPrefs.GetInt(PlayerPrefsKey, 0);
|
||||
SetTime(ActiveTOD);
|
||||
}
|
||||
|
||||
private TimePreset GetTimePreset(TimeOfDay tod)
|
||||
{
|
||||
switch (tod)
|
||||
{
|
||||
case TimeOfDay.Day:
|
||||
return DayPreset;
|
||||
case TimeOfDay.Dusk:
|
||||
return DuskPreset;
|
||||
case TimeOfDay.Dawn:
|
||||
return DawnPreset;
|
||||
case TimeOfDay.Night:
|
||||
return NightPreset;
|
||||
case TimeOfDay.Nightmare:
|
||||
return NightmarePreset;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetTime(TimeOfDay tod)
|
||||
{
|
||||
var preset = GetTimePreset(tod);
|
||||
if (preset != null)
|
||||
ApplyTimePreset(preset);
|
||||
}
|
||||
|
||||
private void ApplyTimePreset(TimePreset preset)
|
||||
{
|
||||
RenderSettings.skybox = preset.Skybox;
|
||||
|
||||
RenderSettings.ambientIntensity = preset.AmbientIntensity;
|
||||
RenderSettings.ambientMode = preset.AmbientMode;
|
||||
RenderSettings.ambientSkyColor = preset.AmbientSkyColor;
|
||||
RenderSettings.ambientEquatorColor = preset.AmbientEquatorColor;
|
||||
RenderSettings.ambientGroundColor = preset.AmbientGroundColor;
|
||||
|
||||
RenderSettings.fog = preset.Fog;
|
||||
RenderSettings.fogColor = preset.FogColor;
|
||||
RenderSettings.fogDensity = preset.FogDensity;
|
||||
RenderSettings.fogStartDistance = preset.FogStartDistance;
|
||||
RenderSettings.fogEndDistance = preset.FogEndDistance;
|
||||
RenderSettings.fogMode = preset.FogMode;
|
||||
|
||||
foreach (var obj in preset.ObjectsToEnable)
|
||||
obj.SetActive(true);
|
||||
foreach (var obj in preset.ObjectsToDisable)
|
||||
obj.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6461d4e68515944cab4c02ec103c266
|
||||
@@ -0,0 +1,37 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class PopUp : MonoBehaviour
|
||||
{
|
||||
public TMP_Text Text;
|
||||
public float DestroyTime = 5;
|
||||
|
||||
float timeSinceCreation;
|
||||
|
||||
Vector3 offset;
|
||||
bool dropDown;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
timeSinceCreation = Time.time;
|
||||
offset.y = -100;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!Player.Instance) return;
|
||||
|
||||
if (dropDown)
|
||||
offset.y = Mathf.Lerp(offset.y, -100, Time.deltaTime / 2f);
|
||||
else
|
||||
offset.y = Mathf.Lerp(offset.y, 0, Time.deltaTime * 5f);
|
||||
|
||||
this.transform.position = Vector3.Lerp(this.transform.position, Player.Instance.Camera.transform.position + (Player.Instance.Camera.transform.forward * 5) + offset, Time.deltaTime * 10f);
|
||||
this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Player.Instance.Camera.transform.rotation, Time.deltaTime * 10f);
|
||||
|
||||
if (Time.time > timeSinceCreation + (DestroyTime - 1))
|
||||
dropDown = true;
|
||||
if (Time.time > timeSinceCreation + DestroyTime)
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1c53045ddfc26a41bcc0f670daee19a
|
||||
@@ -0,0 +1,29 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class PopUps : MonoBehaviour
|
||||
{
|
||||
public static PopUps Instance;
|
||||
|
||||
public GameObject PopUpPrefab;
|
||||
GameObject currentObject;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public static void Create(string text = "hello world", float duration = 8)
|
||||
{
|
||||
if (!Instance)
|
||||
return;
|
||||
if (Instance.currentObject)
|
||||
Destroy(Instance.currentObject);
|
||||
|
||||
Instance.currentObject = Instantiate(Instance.PopUpPrefab);
|
||||
|
||||
var popUp = Instance.currentObject.GetComponent<PopUp>();
|
||||
popUp.Text.text = text;
|
||||
popUp.DestroyTime = duration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 623944eda42f405499d92a0b05832064
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Spookys : MonoBehaviour
|
||||
{
|
||||
public AudioSource AudioSource;
|
||||
public RawImage RawImage;
|
||||
public Texture2D[] Textures;
|
||||
public Texture2D TinkyNear;
|
||||
|
||||
public bool doNow;
|
||||
|
||||
float extraTime = 0;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
extraTime += Time.deltaTime / 10;
|
||||
if (extraTime > 60)
|
||||
extraTime = 60;
|
||||
}
|
||||
|
||||
IEnumerator Loop()
|
||||
{
|
||||
AudioSource.Stop();
|
||||
RawImage.enabled = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
float nextTime = Time.time + Random.Range(30f + extraTime, 60f + extraTime);
|
||||
yield return new WaitUntil(() => Time.time > nextTime || doNow);
|
||||
|
||||
if (doNow)
|
||||
doNow = false;
|
||||
|
||||
bool useNearby = false;
|
||||
|
||||
if (TinkyWinky.Instance) {
|
||||
float dist = Vector3.Distance(Player.Instance.transform.position, TinkyWinky.Instance.transform.position);
|
||||
if (dist < 50 && TinkyWinky.Instance.ActiveState >= TinkyWinky.States.Stalk)
|
||||
{
|
||||
useNearby = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useNearby)
|
||||
{
|
||||
AudioSource.pitch = 0.5f;
|
||||
RawImage.texture = TinkyNear;
|
||||
} else
|
||||
{
|
||||
RawImage.texture = Textures[Random.Range(0, Textures.Length)];
|
||||
AudioSource.pitch = 1f;
|
||||
}
|
||||
|
||||
RawImage.enabled = true;
|
||||
AudioSource.Play();
|
||||
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
|
||||
AudioSource.Stop();
|
||||
RawImage.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(Loop());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b6a35140760b3b4f918e7d1e7311eb0
|
||||
Reference in New Issue
Block a user