Syne is a psychological horror video game, played in a first-person perspective.
My role in this project is programming almost everything. Except for the VFX related stuff, I contribute in designing the code, creating gameplay mechanics or the AI behaviour, making the audios sound where they need to sound, facilitating the level design task of customisating things on a scene with some custom editors or gizmos and providing utility to the UI elements like the game menu.
A small example of something I have done in this project is the settings system. With this system, it is possible to interact with the UI (buttons, sliders, toggles and what I have called "selectors") and change the game configuration (for example, change the antialiasing or the audio volume).
public interface ISetting
{
void SetCurrentValueFromPrevious();
void SetCurrentValueFromBlueprint();
void SetPreviousValue();
void SetBlueprintValue();
void DiscardValue();
void ResetValue();
}
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
public class AntialiasingSetting : MonoBehaviour, ISetting
{
[SerializeField] SettingSelector[] selectors;
[SerializeField] HDAdditionalCameraData.AntialiasingMode defaultAntialias;
HDAdditionalCameraData.AntialiasingMode previousAntialias;
HDAdditionalCameraData.AntialiasingMode blueprintAntialias;
HDAdditionalCameraData.AntialiasingMode currentAntialias;
List<HDAdditionalCameraData.AntialiasingMode> antialiases = new List<HDAdditionalCameraData.AntialiasingMode>();
Camera mainCamera;
HDAdditionalCameraData cameraData;
/// <summary>
/// Awake is called when the script instance is being loaded.
/// </summary>
void Awake()
{
GrabComponents();
}
/// <summary>
/// Start is called on the frame when a script is enabled just before
/// any of the Update methods is called the first time.
/// </summary>
void Start()
{
SubscribeToEvents();
ObtainAntialiasesNames();
SendAntialiasesToSelector();
GrabValuesFromPlayerPrefs();
MoveSelectorTo(currentAntialias);
ApplySetting();
}
void GrabComponents()
{
mainCamera = Camera.main;
cameraData = mainCamera.GetComponent<HDAdditionalCameraData>();
}
void SubscribeToEvents()
{
foreach (SettingSelector selector in selectors)
{
selector.OnSelectorUpdated += SetBlueprintValue;
}
}
void DesubscribeFromEvents()
{
foreach (SettingSelector selector in selectors)
{
selector.OnSelectorUpdated -= SetBlueprintValue;
}
}
void ObtainAntialiasesNames()
{
foreach (HDAdditionalCameraData.AntialiasingMode antialiasing in Enum.GetValues(typeof(HDAdditionalCameraData.AntialiasingMode)))
{
antialiases.Add(antialiasing);
}
}
void SendAntialiasesToSelector()
{
foreach (HDAdditionalCameraData.AntialiasingMode antialiasing in Enum.GetValues(typeof(HDAdditionalCameraData.AntialiasingMode)))
{
foreach (SettingSelector selector in selectors)
{
selector.Add(antialiasing.ToString());
}
}
}
void MoveSelectorTo(HDAdditionalCameraData.AntialiasingMode antialiasing)
{
foreach (SettingSelector selector in selectors)
{
if (!selector.MoveTo(antialiasing.ToString()))
{
Debug.Log($"Nonexistent antialiasing: {antialiasing.ToString()}");
}
}
}
void GrabValuesFromPlayerPrefs()
{
currentAntialias = (HDAdditionalCameraData.AntialiasingMode)PlayerPrefs.GetInt("antialiasing", (int)defaultAntialias);
previousAntialias = currentAntialias;
blueprintAntialias = currentAntialias;
}
void StoreSetting()
{
PlayerPrefs.SetInt("antialiasing", (int)currentAntialias);
}
void ApplySetting()
{
cameraData.antialiasing = currentAntialias;
}
/// <summary>
/// This function is called when the MonoBehaviour will be destroyed.
/// </summary>
void OnDestroy() => DesubscribeFromEvents();
public void DiscardValue()
{
currentAntialias = previousAntialias;
blueprintAntialias = previousAntialias;
MoveSelectorTo(previousAntialias);
}
public void ResetValue()
{
currentAntialias = defaultAntialias;
previousAntialias = defaultAntialias;
blueprintAntialias = defaultAntialias;
MoveSelectorTo(defaultAntialias);
StoreSetting();
ApplySetting();
}
public void SetBlueprintValue()
{
int index = selectors[0].GetSelection();
blueprintAntialias = antialiases[index];
}
public void SetBlueprintValue(SettingSelector selector)
{
int index = selector.GetSelection();
blueprintAntialias = antialiases[index];
}
public void SetCurrentValueFromBlueprint()
{
currentAntialias = blueprintAntialias;
previousAntialias = blueprintAntialias;
MoveSelectorTo(blueprintAntialias);
StoreSetting();
ApplySetting();
}
public void SetCurrentValueFromPrevious()
{
currentAntialias = previousAntialias;
blueprintAntialias = previousAntialias;
MoveSelectorTo(previousAntialias);
}
public void SetPreviousValue()
{
int index = selectors[0].GetSelection();
previousAntialias = antialiases[index];
}
}