Skip to content

Commit

Permalink
Comentando ando
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-aparicio-lopez committed May 23, 2024
1 parent f109f53 commit 0e57b0f
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 97 deletions.
27 changes: 24 additions & 3 deletions NYKTOS/Assets/Scripts/0_MANAGERS/BuildingManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// Gestiona la construcción de defensas
/// </summary>
public class BuildingManager : MonoBehaviour
{
private static BuildingManager _instance;
Expand Down Expand Up @@ -71,11 +73,18 @@ public float OffsetNotWall
#region methods

#region build defenses
/// <summary>
/// Establece la defensa seleccionada
/// </summary>
/// <param name="building">Prefab de la defensa seleccionada</param>
private void SetBuilding(GameObject building)
{
_selectedDefense = building;
}

/// <summary>
/// Construye la defensa seleccionada en la posicion de currentPlaceholder (cimiento seleccionado)
/// </summary>
private void BuildDefense()
{
if (_selectedDefense == _turret)
Expand Down Expand Up @@ -107,6 +116,9 @@ private void BuildDefense()
MenuManager.Instance.CloseAllMenus();
}

/// <summary>
/// Construye una baliza si se tienen cristales suficientes
/// </summary>
public void BuildBeacon()
{
if (_currentPlaceholder.TryGetComponent<PlaceholderLoadComponent>(out PlaceholderLoadComponent save))
Expand Down Expand Up @@ -145,6 +157,9 @@ public void BuildBeacon()
}
}

/// <summary>
/// Construye un señuelo si se tienen cristales suficientes
/// </summary>
public void BuildWall()
{
if (_currentPlaceholder.TryGetComponent<PlaceholderLoadComponent>(out PlaceholderLoadComponent save))
Expand Down Expand Up @@ -183,6 +198,10 @@ public void BuildWall()
}
}


/// <summary>
/// Construye una torreta si se tienen cristales suficientes
/// </summary>
public void BuildTurret()
{
if (_currentPlaceholder.TryGetComponent<PlaceholderLoadComponent>(out PlaceholderLoadComponent save))
Expand Down Expand Up @@ -225,12 +244,14 @@ public void BuildTurret()
#endregion

#region buildingArray
/// <summary>
/// Lista con los edificios construidos
/// </summary>
public List<GameObject> buildingArray { get { return _buildingArray; } }
private List<GameObject> _buildingArray = new List<GameObject>();

public void AddBuilding(GameObject obj)
{
//print(obj);
_buildingArray.Add(obj);
}

Expand Down
25 changes: 21 additions & 4 deletions NYKTOS/Assets/Scripts/0_MANAGERS/MenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
/// </summary>
public class MenuManager : MonoBehaviour
{
// [Andrea]
// - Cambiar el registro de menus a eventos

private static MenuManager _instance;
public static MenuManager Instance
Expand Down Expand Up @@ -101,6 +99,8 @@ public static MenuManager Instance

#region properties
private List<GameObject> _menuList = new List<GameObject>();

bool mapOpened = false;
#endregion

#region events
Expand All @@ -112,7 +112,9 @@ public static MenuManager Instance
#endregion

#region menuActions

/// <summary>
/// Acciones que se pueden realizar desde distintos menús en el juego
/// </summary>
public void ExitGame()
{
PlayClosedSound();
Expand Down Expand Up @@ -162,6 +164,12 @@ private void RegisterMenus()
}

#region open menus
/// <summary>
/// Método genérico para abrir un menú en el juego y seleccionar uno de sus botones por defecto
/// Cambia el mapa de acciones del jugador al de la UI
/// </summary>
/// <param name="menu">Canvas que se quiere abrir</param>
/// <param name="button">Botón que se va a seleccionar</param>
private void OpenMenu(GameObject menu, Button button)
{
PlayOpenedSound();
Expand All @@ -173,6 +181,9 @@ private void OpenMenu(GameObject menu, Button button)
SwitchToUIControls();
}

/// <summary>
/// Métodos específicos para cada menú del juego
/// </summary>
public void OpenPauseMenu() => OpenMenu(_pauseMenu, _pauseButton);
public void OpenNexusMenu() => OpenMenu(_nexusMenu, _nexusButton);
public void OpenDefenseMenu() => OpenMenu(_defenseMenu, _defenseButton);
Expand All @@ -182,6 +193,10 @@ private void OpenMenu(GameObject menu, Button button)
#endregion

#region close menus
/// <summary>
/// Recorre la lista de menús y los cierra todos
/// Cambia el mapa de acciones activo de la UI al jugador
/// </summary>
public void CloseAllMenus()
{
PlayClosedSound();
Expand All @@ -197,7 +212,9 @@ public void CloseMenu()
}
#endregion

bool mapOpened = false;
/// <summary>
/// Abre/Cierra el mapa
/// </summary>
private void OpenCloseMap()
{
_map.SetActive(!_map.activeSelf);
Expand Down
1 change: 1 addition & 0 deletions NYKTOS/Assets/Scripts/Defenses/Defense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;

// Plantilla de scriptable para las defensas
public enum Defensetype { beacon, wall, turret };

[CreateAssetMenu(fileName = "New Defense", menuName = "Defense")]
Expand Down
4 changes: 2 additions & 2 deletions NYKTOS/Assets/Scripts/Defenses/SelectedDefense.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// No se usa

[CreateAssetMenu(fileName = "New SelectedDefense", menuName = "SelectedDefense")]
public class SelectedDefense : ScriptableObject
{
Expand Down
2 changes: 1 addition & 1 deletion NYKTOS/Assets/Scripts/Environment/BuildingController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using UnityEngine;

/// <summary>
/// Todos los edificios del juego con los que se puede interactuar (cimientos, nexo, estatua) tienen este script
/// Todos los edificios del juego con los que se puede interactuar (cimientos, Nexo, estatua) tienen este script
/// Implementa la interfaz de interacción
/// </summary>
public class BuildingController : MonoBehaviour, IInteractable
Expand Down
4 changes: 2 additions & 2 deletions NYKTOS/Assets/Scripts/Environment/BuildingStateMachine.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using UnityEngine;

/// <summary>
/// M�quina de estados de los edificios
/// Máquina de estados de los edificios
/// 2 estados posibles: construido y no construido
/// Adem�s, determina si son interactuables o no
/// Además, determina si son interactuables o no
/// </summary>
public class BuildingStateMachine : MonoBehaviour
{
Expand Down
10 changes: 5 additions & 5 deletions NYKTOS/Assets/Scripts/Environment/Defenses/DefenseComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Actualiza la vida de la defensa
/// Guarda el placeholder en el que está construida
/// </summary>
public class DefenseComponent : MonoBehaviour
{
//VA ACTUALIZANDO EL ESTADO EN EL QUE SE ENCUENTRA LA DEFENSA
//ACTUALIZA LA CANTIDAD DE VIDA EN INT (ALTARHEALTHCOMPONENT)
//CONSTRUCCION AUTOMATICA CON UN BOOLEANO
//SI ESTA CONSTRUIDO, ATRAE ENEMIGOS, ACTIVA VIDA Y NO SE PUEDE INTERACTUAR CON EL HASTA QUE SEA DESTRUIDO (ALTARHEALTHCOMPONENT)
//SI ESTA DESTRUIDO, YA NO ATRAE ENEMIGOS, DESACTIVA EL FACTOR VIDA SE PUEDE INTERACTUAR CON EL (EN ESTE COMPONENTE)


[SerializeField] private VoidEmitter _healthRestore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
using UnityEngine;
using UnityEngine.InputSystem;

/// <summary>
/// Componente genérico que tienen todos los placeholders
/// Tiene acceso a su estado de construcción y de interacción (_state), y los actualiza en función de los eventos que reciba
/// También filtra cuándo puede abrirse el menú de construcción, y lo actualiza en función de su tipo
/// </summary>
public class PlaceholderComponent : MonoBehaviour, IBuilding
{
#region references
private BuildingStateMachine _state;
#endregion

#region properties
[SerializeField]
private placeholderType _type;
Expand Down Expand Up @@ -58,8 +64,6 @@ private void UpdateCurrentPlaceHolder()

private void UpdateDefenseMenu()
{
//Debug.Log("[PLACEHOLDER COMPONENT] cambio de color");
//Debug.Log("[PLACEHOLDER COMPONENT] " + _type);
_phTypeEmitter.InvokePerform(_type);
}

Expand Down
2 changes: 1 addition & 1 deletion NYKTOS/Assets/Scripts/Environment/IndividualInteraction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using UnityEngine;

/// <summary>
/// Permite suscribirse a un evento de tipo booleano que cambia el estado de interacción///
/// Permite suscribirse a un evento de tipo booleano que cambia el estado de interacción
/// </summary>
public class IndividualInteraction : MonoBehaviour
{
Expand Down
4 changes: 2 additions & 2 deletions NYKTOS/Assets/Scripts/Environment/InteractableObjects.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using UnityEngine;

/// <summary>
/// Todos los objetos interactuables del juego muestran un s�mbolo de interacci�n cuando el jugador est� cerca
/// Este script activa/desactiva dicho s�mbolo
/// Todos los objetos interactuables del juego muestran un símbolo de interacción cuando el jugador está cerca
/// Este script activa/desactiva dicho símbolo
/// </summary>
public class InteractableObjects : MonoBehaviour
{
Expand Down
9 changes: 4 additions & 5 deletions NYKTOS/Assets/Scripts/Environment/Nexus/NexusComponent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// Gestiona el estado del Nexo (si se puede o no interactuar, si el jugador puede o no revivir)
/// </summary>
public class NexusComponent : MonoBehaviour, IBuilding
{

Expand Down Expand Up @@ -31,9 +33,6 @@ public void OpenMenu()
{
if (_state.isInteractable)
{
//[Marco] Deprecated
//MenuManager.Instance.OpenNexusMenu();

_nexusMenuEmitter.InvokePerform();
TutorialCompleted?.InvokePerform();
}
Expand Down
15 changes: 1 addition & 14 deletions NYKTOS/Assets/Scripts/HealthSystem/Buildings/AltarDeath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@
using System.Collections.Generic;
using UnityEngine;

// No se usa
public class AltarDeath : MonoBehaviour, IDeath
{
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}



public void Death()
{
Destroy(gameObject);
Expand Down
20 changes: 2 additions & 18 deletions NYKTOS/Assets/Scripts/HealthSystem/Buildings/BuildingDeath.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// No se usa (mirar DefenseDeath en su lugar)
public class BuildingDeath : MonoBehaviour, IDeath
{
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}



public void Death()
{ public void Death()
{
BuildingManager.Instance.RemoveBuilding(this.gameObject);
Destroy(gameObject);
Expand Down
6 changes: 4 additions & 2 deletions NYKTOS/Assets/Scripts/HealthSystem/Buildings/DefenseDeath.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Al destruir una defensa, ésta se quita de la lista del Building Manager
/// y se actualiza el estado de construcción del placeholder
/// </summary>
public class DefenseDeath : MonoBehaviour, IDeath
{
#region references
Expand Down
6 changes: 3 additions & 3 deletions NYKTOS/Assets/Scripts/HealthSystem/Buildings/NexusDeath.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Cuando el Nexo es destruido, se llama al método Death(), que cambia el estado del juego
/// </summary>
public class NexusDeath : MonoBehaviour, IDeath
{
[SerializeField]
Expand All @@ -12,7 +13,6 @@ public class NexusDeath : MonoBehaviour, IDeath

public void Death()
{
// Lanzar evento de perder
_gameStateMachine.SetState(_loseState);
}
}
Loading

0 comments on commit 0e57b0f

Please sign in to comment.