Skip to content

Commit

Permalink
SettingsMenu implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos96mdq committed Feb 25, 2022
1 parent 2cc575d commit 34b958d
Show file tree
Hide file tree
Showing 13 changed files with 3,597 additions and 339 deletions.
3,669 changes: 3,343 additions & 326 deletions Assets/Scenes/MainMenu.unity

Large diffs are not rendered by default.

37 changes: 35 additions & 2 deletions Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

public class GameManager : MonoBehaviour
{
int width; // Estas tres variables manejan la resolución y modo de la pantalla
int height;
FullScreenMode fullscreenMode;

public static GameManager instance;

void Awake()
Expand All @@ -16,18 +20,47 @@ void Awake()
}
instance = this;
DontDestroyOnLoad(gameObject);

InitialConfig(); // Configuración inicial del nivel
}

void Start()
{
// Configuración inicial del juego
void InitialConfig() {
QualitySettings.vSyncCount = 1;
Application.targetFrameRate = 60;
width = 1200;
height = 720;
fullscreenMode = FullScreenMode.ExclusiveFullScreen;
ChangeScreen();
}

// Cambiar resolución y modo de pantalla
void ChangeScreen() {
Screen.SetResolution(width, height, fullscreenMode);
}

public void ChangeScreenResolution(int w, int h) {
width = w;
height = h;
ChangeScreen();
}

public void ChangeScreenMode(FullScreenMode fs) {
fullscreenMode = fs;
ChangeScreen();
}

// Carga nueva escena/nivel
public void LoadScene(int sceneIndex) {
SceneManager.LoadScene(sceneIndex);
}

// Cambia el volumen general
public void VolumeUpdate(float newVolume) {
AudioListener.volume = newVolume;
}

// Sale del juego
public void QuitGame() {
Debug.Log("Exit game");
// Si nos encontramos en el modo editor, para la reproducción del juego
Expand Down
5 changes: 0 additions & 5 deletions Assets/Scripts/MainMenu/MainMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ void Awake()

InitialConfig(); // Configuración inicial del nivel
}

void Start()
{

}

// Update is called once per frame
void Update()
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Player/PlayerMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
public class PlayerMovement : MonoBehaviour
{

const float gravity = -9.81f; // Valor de gravedad, necesario para aplicarle a falta de rigidbody

float gravity; // Valor de gravedad, necesario para aplicarle a falta de rigidbody
float movementSpeed;
float runningFactor; // Indica en cuantas veces aumenta la velocidad al correr
//bool isGrounded = false; // Indica verdadero si se está tocando el piso
Expand All @@ -20,6 +19,7 @@ public class PlayerMovement : MonoBehaviour

void Start()
{
gravity = constants.gravity;
movementSpeed = constants.movementSpeed;
runningFactor = constants.runningFactor;

Expand Down
11 changes: 7 additions & 4 deletions Assets/Scripts/ScriptableObjects/CharacterConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/CharacterConstants", order = 1)]
public class CharacterConstants : ScriptableObject
{
// General
public float gravity; // Gravedad

// Movement
public float movementSpeed; // Velocidad de movimiento
public float runningFactor; // Indica en cuantas veces aumenta la velocidad al correr
public float movementSpeed; // Velocidad de movimiento
public float runningFactor; // Indica en cuantas veces aumenta la velocidad al correr

// Animation
public float walkingFrecuency; // Velocidad de pazos en caminata
public float runningFrecuency; // Velocidad de pazos en corrida
public float walkingFrecuency; // Velocidad de pazos en caminata
public float runningFrecuency; // Velocidad de pazos en corrida
}
1 change: 1 addition & 0 deletions Assets/Scripts/ScriptableObjects/MinotaurConstants.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 91d774c21975a8c428527ee8b427267d, type: 3}
m_Name: MinotaurConstants
m_EditorClassIdentifier:
gravity: -9.81
movementSpeed: 7
runningFactor: 3
walkingFrecuency: 0.7
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/ScriptableObjects/PlayerConstants.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 91d774c21975a8c428527ee8b427267d, type: 3}
m_Name: PlayerConstants
m_EditorClassIdentifier:
gravity: -9.81
movementSpeed: 5
runningFactor: 2
walkingFrecuency: 0.7
Expand Down
66 changes: 66 additions & 0 deletions Assets/Scripts/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;


public class Settings : MonoBehaviour
{
public Slider volumeSlider; // Slider del volumen
public ToggleGroup resolutionToggles; // Toggles que manejan la resolución

// Handler de los Toggles de Resolución
public void OnScreenResolutionChangedHandled(int mode) {
int width = 1200;
int height = 720;

// Choose resolution
switch (mode)
{
case 0:
width = 800;
height = 600;
break;
case 1:
width = 1200;
height = 720;
break;
case 2:
width = 1366;
height = 768;
break;
case 3:
width = 1920;
height = 1080;
break;
}

GameManager.instance.ChangeScreenResolution(width, height);
}

// Handler de los Toggles de Modo de ventana
public void OnScreenModeChangedHandled(int mode) {
FullScreenMode screenMode = FullScreenMode.ExclusiveFullScreen;

// Choose resolution
switch (mode)
{
case 0:
screenMode = FullScreenMode.ExclusiveFullScreen;
break;
case 1:
screenMode = FullScreenMode.Windowed;
break;
}

GameManager.instance.ChangeScreenMode(screenMode);
}

// Handler del Slider de Volumen
public void OnVolumeValueChangedHandled() {
GameManager.instance.VolumeUpdate(volumeSlider.value);
Debug.Log("Handler OnVolumeValueChangedHandled llamado por evento OnValueChanged del Volume Slider");
Debug.Log("Nuevo valor de volumen: " + volumeSlider.value);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Settings.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Sprites.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Sprites/CheckMark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions Assets/Sprites/CheckMark.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions ProjectSettings/TimelineSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60

0 comments on commit 34b958d

Please sign in to comment.