70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using RR.Common.UI;
|
|
using RR.Common.Utility;
|
|
using RR.Game2D.Core.Managers;
|
|
using UnityEngine;
|
|
|
|
namespace RR.Common.Behaviour.ScriptableObjects
|
|
{
|
|
[CreateAssetMenu(fileName = "GameSettings", menuName = "Game/GameSettings")]
|
|
public class GameSettings : ScriptableObject
|
|
{
|
|
// General settings
|
|
public bool isFullscreen;
|
|
// ATTENTION: Music between 0f and 1f
|
|
public float musicVolume;
|
|
public float sfxVolume;
|
|
|
|
// Payment/prizing settings
|
|
public bool isFreeGame;
|
|
public bool isGivingPrizes;
|
|
public string phoneNumber;
|
|
|
|
// Player settings
|
|
public int startLivesCount;
|
|
public int livesIncreasedByCredits;
|
|
|
|
public void SetDefaultValues()
|
|
{
|
|
isFullscreen = true;
|
|
musicVolume = 1f;
|
|
sfxVolume = 1f;
|
|
|
|
isFreeGame = false;
|
|
isGivingPrizes = true;
|
|
phoneNumber = "9123456789";
|
|
|
|
startLivesCount = 3;
|
|
livesIncreasedByCredits = 1;
|
|
}
|
|
|
|
public void ValidateSettings()
|
|
{
|
|
if (musicVolume is < 0f or > 1f)
|
|
musicVolume = Mathf.Clamp01(musicVolume);
|
|
|
|
if (sfxVolume is < 0f or > 1f)
|
|
sfxVolume = Mathf.Clamp01(sfxVolume);
|
|
|
|
if (startLivesCount < 1)
|
|
startLivesCount = 3;
|
|
|
|
if (livesIncreasedByCredits < 0)
|
|
livesIncreasedByCredits = 0;
|
|
|
|
phoneNumber = PhoneNumberUtils.ValidatePhoneNumber(phoneNumber);
|
|
}
|
|
|
|
public void ApplySettings()
|
|
{
|
|
if (isFullscreen)
|
|
FullscreenToggle.SetFullscreen(isFullscreen);
|
|
|
|
if (GameManager.Instance != null)
|
|
{
|
|
GameManager.Instance.Audio.SetMusicVolume(musicVolume);
|
|
GameManager.Instance.Audio.SetSfxVolume(sfxVolume);
|
|
}
|
|
}
|
|
}
|
|
}
|