This commit is contained in:
Gerard Gascón 2025-04-24 17:19:36 +02:00
commit 001bb14f16
951 changed files with 270074 additions and 0 deletions

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ef5e6a5f116832444b0f137ec3483abc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Humo : MonoBehaviour, IPooledObject{
int transparencia;
float currentTrans;
float scale;
public float speed;
public float fadeSpeed;
public float scaleSpeed;
HumoLookAt lookat;
RawImage image;
// Start is called before the first frame update
public void OnObjectSpawn(){
lookat = GetComponentInParent<HumoLookAt>();
image = GetComponent<RawImage>();
transparencia = Random.Range(25, 75);
currentTrans = transparencia;
scale = Random.Range(1f, 2.5f);
transform.localScale = new Vector3(scale, scale, scale);
image.color = new Color(image.color.r, image.color.g, image.color.b, currentTrans / 255);
transform.rotation = lookat.t;
}
// Update is called once per frame
void Update(){
transform.Translate(Vector2.up * speed * Time.deltaTime);
currentTrans = currentTrans - fadeSpeed;
image.color = new Color(image.color.r, image.color.g, image.color.b, currentTrans / 255);
image.transform.localScale = new Vector3(scale - scaleSpeed * Time.deltaTime, scale - scaleSpeed * Time.deltaTime, scale - scaleSpeed * Time.deltaTime);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a8bd9c4625299f49b9ed371a00c56a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HumoLookAt : MonoBehaviour{
public Quaternion t;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16d7bcebca6755b4e919596bec218166
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 64c63176651493a4c8623f70fd3984d4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyAim : MonoBehaviour{
Transform player;
void Start(){
player = GameObject.FindGameObjectWithTag("Player").transform;
}
// Update is called once per frame
void LateUpdate(){
transform.LookAt(player.position, Vector3.back);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 02fb908107453d54cab95cd1923504e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController : MonoBehaviour, IPooledObject{
public float speed;
public float maxSpeed;
public Material red;
public GameObject[] materialsApplied;
public LayerMask whatStops;
public Transform circlePos;
bool canDisappear;
Transform target;
Rigidbody2D rb2d;
Vector2 mov;
Animator anim;
// Start is called before the first frame update
void Start(){
rb2d = GetComponent<Rigidbody2D>();
target = GameObject.FindGameObjectWithTag("Player").transform;
anim = GetComponentInChildren<Animator>();
anim.SetBool("Walking", true);
}
public void OnObjectSpawn(){
canDisappear = false;
}
void FixedUpdate(){
/*if (target.position.x < transform.position.x){
rb2d.AddForce(Vector2.left * speed * Time.deltaTime);
}else{
rb2d.AddForce(Vector2.right * speed * Time.deltaTime);
}
if (target.position.y < transform.position.y){
rb2d.AddForce(Vector2.down * speed * Time.deltaTime);
}else{
rb2d.AddForce(Vector2.up * speed * Time.deltaTime);
}
float limitedSpeed = Mathf.Clamp(rb2d.velocity.x, -maxSpeed, maxSpeed);
float yLimitedSpeed = Mathf.Clamp(rb2d.velocity.y, -maxSpeed, maxSpeed);
rb2d.velocity = new Vector2(limitedSpeed, yLimitedSpeed);*/
mov = transform.position;
mov = Vector2.MoveTowards(rb2d.position, target.position, speed * Time.fixedDeltaTime);
rb2d.MovePosition(mov);
//print(rb2d.velocity.magnitude);
}
void OnTriggerEnter2D(Collider2D col){
if(col.gameObject.tag == "Attack"){
anim.SetBool("Attacking", true);
for (int i = 0; i < materialsApplied.Length; i++){
materialsApplied[i].GetComponent<SkinnedMeshRenderer>().material = red;
}
}
}
void OnBecameVisible(){
canDisappear = true;
}
void OnBecameInvisible(){
if (canDisappear){
gameObject.SetActive(false);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e05f835678ca1f4f8b0df2fee8eb5ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a03e06b1aaf91c44faa916377e54bf41
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameController : MonoBehaviour{
public bool spawnEnemies = true;
public Pool poolToCreate;
public Vector3 whereToSpawn;
public float spawnRate;
[Header("Game Over")]
public bool gameOver;
public GameObject gameOverScreen;
[Header("Win")]
public bool win;
public GameObject winScreen;
public HumoLookAt humo;
public Transform humoSpawn;
GameObject player;
public GameObject casa;
public GameObject target;
public GameObject[] casas;
EnemyController[] enemies;
[HideInInspector]
public bool readyToSpawn = false;
bool spawnHumo;
bool brujula;
float nextSpawn;
public LightBar lightBar;
void Awake(){
Pooler.CreatePools(poolToCreate);
}
// Start is called before the first frame update
void Start(){
Invoke(nameof(ReadyToSpawn), 2);
player = GameObject.FindGameObjectWithTag("Player");
if (!PlayerPrefs.HasKey("CheckPoint")){
int intCasa = Random.Range(0, casas.Length - 1);
casa.transform.position = casas[intCasa].transform.position;
casa.transform.rotation = casas[intCasa].transform.rotation;
casa.SetActive(true);
PlayerPrefs.SetInt("Casa", intCasa);
}else{
casa.transform.position = casas[PlayerPrefs.GetInt("Casa")].transform.position;
casa.transform.rotation = casas[PlayerPrefs.GetInt("Casa")].transform.rotation;
casas[PlayerPrefs.GetInt("Casa")].SetActive(false);
casa.SetActive(true);
}
AudioManager.instance.Play("Theme");
AudioManager.instance.PlayMuted("Theme2");
AudioManager.instance.Play("Vela");
AudioManager.instance.Stop("Menu");
enemies = GameObject.FindObjectsOfType<EnemyController>();
}
// Update is called once per frame
void Update(){
Vector2 bruj = casa.transform.position - player.transform.position;
float rot = Mathf.Atan2(bruj.y, bruj.x) * Mathf.Rad2Deg;
humo.t = Quaternion.Euler(humo.transform.rotation.x, humo.transform.rotation.y, rot - 90);
//target = new Vector3(closestEnemy.transform.position.x, closestEnemy.transform.position.y, closestEnemy.transform.position.z);
Debug.DrawLine(player.transform.position, casa.transform.position);
if (readyToSpawn){
if (Time.time > nextSpawn){
if (spawnEnemies){
nextSpawn = Time.time + spawnRate;
float xPos = Random.Range(player.transform.position.x - 40f, player.transform.position.x + 40f);
float yPos = Random.Range(player.transform.position.y - 40f, player.transform.position.y + 40f);
whereToSpawn = new Vector3(xPos, yPos, 0f);
Pooler.SpawnFromPool("Enemies", whereToSpawn, Quaternion.identity);
}
if (Input.GetButtonDown("Fire")){
if (brujula){
spawnHumo = false;
brujula = false;
}else{
spawnHumo = true;
brujula = true;
}
}
if (spawnHumo){
Pooler.SpawnFromPool("Humo", humoSpawn.position, Quaternion.identity, humo.transform);
}
}
}
if (win){
winScreen.SetActive(true);
Time.timeScale = 0;
}
if (gameOver){
gameOverScreen.SetActive(true);
}
}
void ReadyToSpawn(){
readyToSpawn = true;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5b3d7b6e2a8eb54199c2fe6e5e0ba2c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

48
Assets/Scripts/Juan.cs Normal file
View file

@ -0,0 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Juan : MonoBehaviour{
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777 Para Juan
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
//777777777777777777777777777777777777777777777777777777777777
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec5455052346ad24e895eb0bf99156be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fc58557f6232a514ca1bea421c63393c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CheckPoint : MonoBehaviour{
public GameObject lightToTurn;
[HideInInspector]
public int checkPointNumber;
public GameObject[] partesFarola;
public Material apagado;
public Material encendido;
PlayerController player;
public LayerMask whatIsPlayer;
bool triggered;
bool alreadyTriggered;
void Start(){
player = GameObject.FindObjectOfType<PlayerController>();
for (int i = 0; i < partesFarola.Length; i++){
partesFarola[i].GetComponent<MeshRenderer>().material = apagado;
}
}
void Update(){
triggered = Physics2D.OverlapCircle(transform.position, 6, whatIsPlayer);
if(triggered && !alreadyTriggered){
AudioManager.instance.Play("CheckPoint");
this.gameObject.layer = 10;
lightToTurn.SetActive(true);
PlayerPrefs.SetInt("CheckPoint", checkPointNumber);
alreadyTriggered = true;
for (int i = 0; i < partesFarola.Length; i++){
partesFarola[i].GetComponent<MeshRenderer>().material = encendido;
}
}
if (player.runOutOfLight){
lightToTurn.SetActive(false);
this.gameObject.layer = 13;
for (int i = 0; i < partesFarola.Length; i++){
partesFarola[i].GetComponent<MeshRenderer>().material = apagado;
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5eec18e0d6316de439e1371738a56158
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CheckPointManager : MonoBehaviour{
public GameObject[] checkPoints;
public LightBar lightBar;
public Transform player;
int checkPoint;
int time;
void Start(){
if (PlayerPrefs.HasKey("CheckPoint")){
PlayerPrefs.GetInt("CheckPoint", checkPoint);
player.position = new Vector3(checkPoints[checkPoint].transform.position.x, checkPoints[checkPoint].transform.position.y - 1, -1);
}
}
// Update is called once per frame
void Update(){
for (int i = 0; i < checkPoints.Length; i++){
checkPoints[i].GetComponent<CheckPoint>().checkPointNumber = i;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e93c8afebd62f2640b92b0dc2e59cb90
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HouseController : MonoBehaviour{
public GameController gameController;
bool lost;
void OnTriggerEnter2D(Collider2D col){
if(col.gameObject.tag == "Player" && !lost){
Win();
Time.timeScale = 0;
AudioManager.instance.Stop("Theme");
AudioManager.instance.Stop("Theme2");
AudioManager.instance.Play("Win");
lost = true;
}
}
void Win(){
gameController.win = true;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1dc49a6d625acb543a2d9aeeaa95a720
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,27 @@
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LevelLoader : MonoBehaviour{
public GameObject loadingScreen;
public Slider slider;
public void LoadLevel(int sceneIndex){
StartCoroutine(LoadAsychronously(sceneIndex));
}
IEnumerator LoadAsychronously (int sceneIndex){
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);
loadingScreen.SetActive(true);
while (!operation.isDone){
float progress = Mathf.Clamp01(operation.progress / .9f);
slider.value = progress;
yield return null;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85e51e532a058ce449d7c32e6b445254
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/Menu.meta Normal file
View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0b9f35bba0d127d42b7814f241986ee1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BackButton : MonoBehaviour{
public GameObject activate;
public GameObject desactivate;
// Update is called once per frame
void Update(){
if (Input.GetButtonDown("Cancel")){
if (desactivate.activeSelf){
AudioManager.instance.Play("Back");
}
activate.SetActive(true);
desactivate.SetActive(false);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04aae18cc1090b949a5749bd57c239fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class Creditos : MonoBehaviour{
public float time;
public LevelLoader levelLoader;
// Start is called before the first frame update
void Start(){
Invoke("Video", time);
AudioManager.instance.Stop("Menu");
}
void Update(){
if (Input.GetButtonDown("Cancel")){
Video();
}
}
void Video(){
levelLoader.LoadLevel(0);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86c935629cd5f0e418d0bf3f185a62d7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class Menu : MonoBehaviour{
public AudioMixer secondaryChannel;
// Start is called before the first frame update
void Start(){
AudioManager.instance.Play("Menu");
AudioManager.instance.Stop("Theme");
AudioManager.instance.Stop("Theme2");
AudioManager.instance.Stop("Vela");
secondaryChannel.SetFloat("secondaryVolume", -80);
PlayerPrefs.DeleteKey("Casa");
PlayerPrefs.DeleteKey("CheckPoint");
Time.timeScale = 1;
}
// Update is called once per frame
void Update(){
}
public void Quit(){
Application.Quit();
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c0598d087e0fa4c4ba4eae71481cc83f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour{
public GameObject pauseMenu;
bool gameIsPaused;
// Start is called before the first frame update
void Start(){
}
// Update is called once per frame
void Update(){
if (Input.GetKeyDown(KeyCode.Escape)){
if (gameIsPaused){
Time.timeScale = 1;
pauseMenu.SetActive(false);
gameIsPaused = false;
}else{
Time.timeScale = 0;
pauseMenu.SetActive(true);
gameIsPaused = true;
}
}
}
public void Continuar(){
Time.timeScale = 1;
pauseMenu.SetActive(false);
gameIsPaused = false;
}
public void Menu(){
Time.timeScale = 1;
gameIsPaused = false;
}
public void Quit(){
Application.Quit();
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7a6daf6a7f55ee48b7c33c93c39f86c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
public class SettingsMenu : MonoBehaviour{
public AudioMixer audioMixer;
public Dropdown resolutionDropdown;
Resolution[] resolutions;
void Start(){
audioMixer.SetFloat("volume", 0);
resolutions = Screen.resolutions;
List<string> options = new List<string>();
int currentResolutionIndex = 0;
for (int i = 0; i < resolutions.Length; i++){
string option = resolutions[i].width + "x" + resolutions[i].height;
options.Add(option);
if (resolutions[i].width == Screen.currentResolution.width &&
resolutions[i].height == Screen.currentResolution.height){
currentResolutionIndex = i;
}
}
resolutionDropdown.AddOptions(options);
resolutionDropdown.value = currentResolutionIndex;
resolutionDropdown.RefreshShownValue();
}
public void SetResolution(int resolutionIndex){
Resolution resolution = resolutions[resolutionIndex];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
}
public void SetQuality(int qualityIndex){
QualitySettings.SetQualityLevel(qualityIndex);
}
public void SetFullscreen(bool isFullScreen){
Screen.fullScreen = isFullScreen;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e518ab951c9300f489c6094e266786af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/New.meta Normal file
View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 62bb3289ba1b2ef498e7d5ac55813f06
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewCheckPoint : MonoBehaviour{
[SerializeField, Range(0f, 10f)] float radius = 6f;
[SerializeField] GameObject lightToTurn;
bool triggered;
bool alreadyTriggered;
public int checkPointNumber { set; get; }
[SerializeField] MeshRenderer[] partsToTurnOn = default;
[SerializeField] Material onMat = default;
[SerializeField] Material offMat = default;
[SerializeField] LayerMask playerMask = default;
PlayerMovement player;
// Start is called before the first frame update
void Awake(){
lightToTurn.SetActive(false);
player = FindObjectOfType<PlayerMovement>();
for (int i = 0; i < partsToTurnOn.Length; i++){
partsToTurnOn[i].material = offMat;
}
}
// Update is called once per frame
void Update(){
triggered = Physics.CheckSphere(transform.position, radius, playerMask);
if(triggered && !alreadyTriggered){
AudioManager.instance.Play("CheckPoint");
gameObject.layer = 10;
lightToTurn.SetActive(true);
PlayerPrefs.SetInt("CheckPoint", checkPointNumber);
alreadyTriggered = true;
for (int i = 0; i < partsToTurnOn.Length; i++){
partsToTurnOn[i].material = onMat;
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2714a0fc8430d234caac976f915bd9d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour{
CharacterController controller;
[SerializeField, Range(0f, 1f)] float inputDeadZone = .125f;
Vector2 playerInput;
[SerializeField] float speed = 5f;
Transform cam;
float turnVelocity;
// Start is called before the first frame update
void Awake(){
cam = Camera.main.transform;
controller = GetComponent<CharacterController>();
}
public void PlayerMove(InputAction.CallbackContext state){
Vector2 input = state.ReadValue<Vector2>();
if(input.magnitude > inputDeadZone){
playerInput = input;
}else{
playerInput = Vector2.zero;
}
playerInput = Vector2.ClampMagnitude(playerInput, 1);
}
// Update is called once per frame
void Update(){
if(playerInput.magnitude > inputDeadZone){
float targetAngle = Mathf.Atan2(playerInput.normalized.x, playerInput.normalized.y) * Mathf.Rad2Deg + cam.eulerAngles.y;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnVelocity, .1f);
transform.rotation = Quaternion.Euler(0f, angle, 0f);
controller.Move(new Vector3(playerInput.x, 0f, playerInput.y) * speed * Time.deltaTime);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 097cfa1879f24de4aa572b44e9e483cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f71d6769bc4b43547a502a6a7e39a1c6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FindLanguageSelector : MonoBehaviour{
public Dropdown dropdown;
private void Start(){
dropdown.value = PlayerPrefs.GetInt("Language");
}
public void OnLanguageChange(int languageSelected){
PlayerPrefs.SetInt("Language", languageSelected);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bc27923aab962ab4e8260d428699d3b0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ImageTranslator : MonoBehaviour{
public GameObject englishText;
public GameObject spanishText;
int language;
// Start is called before the first frame update
void OnEnable(){
language = PlayerPrefs.GetInt("Language");
if (language == 0){
englishText.SetActive(true);
spanishText.SetActive(false);
}
if (language == 1){
englishText.SetActive(false);
spanishText.SetActive(true);
}
}
// Update is called once per frame
void Update(){
if (language == 0){
englishText.SetActive(true);
spanishText.SetActive(false);
}
if (language == 1){
englishText.SetActive(false);
spanishText.SetActive(true);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 91f94dc2fb68f8446be28428dad9700f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class TextTranslator : MonoBehaviour{
[TextArea] public string englishText;
[TextArea] public string spanishText;
int language;
TextMeshProUGUI text;
// Start is called before the first frame update
public void OnEnable(){
text = GetComponent<TextMeshProUGUI>();
language = PlayerPrefs.GetInt("Language");
if (language == 0){
text.text = englishText;
}
if (language == 1){
text.text = spanishText;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8c57de335859cbd498fb9ed39931f3c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9a5c0d55c9e9fb64993a915a99ed1448
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FootSteps : MonoBehaviour{
public float spawnRate;
float nextSpawn;
bool step;
// Start is called before the first frame update
void Start(){
}
// Update is called once per frame
void Update(){
if (Input.GetButton("Walk")){
if (Time.time > nextSpawn){
nextSpawn = Time.time + spawnRate;
if (step){
AudioManager.instance.Play("Step1");
step = false;
}else{
AudioManager.instance.Play("Step2");
step = true;
}
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d1fce2dbd0a5b84d9aefd0dd3685e55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,43 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LightBar : MonoBehaviour{
public float maxTime;
[HideInInspector]
public float time;
public Animator anim;
float timeRest = 1;
bool brujula;
// Start is called before the first frame update
void Start(){
time = maxTime;
}
// Update is called once per frame
void Update(){
if (Input.GetButtonDown("Fire")){
if (brujula){
timeRest = 2;
}else{
timeRest = 1;
}
}
if (time > 0){
time = time - timeRest * Time.deltaTime;
}
if (time / maxTime < 0.75f){
anim.SetFloat("State", 2);
}
if (time / maxTime < 0.5f){
anim.SetFloat("State", 3);
}
if (time / maxTime < 0.25f){
anim.SetFloat("State", 4);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd008a5878df18e459011adaa536a18b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,119 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class PlayerController : MonoBehaviour{
public GameObject humo;
public float speed;
public Transform child;
public LightBar lightBar;
public GameObject aura;
public GameController gameController;
public GameObject trigger;
public GameObject circle;
public Animator anim;
public GameObject luz;
[HideInInspector] public bool runOutOfLight;
bool lost;
bool lighted;
Vector2 mov;
Rigidbody2D rb2d;
float defaultSpeed;
float turnSmoothVelocity;
bool brujula;
bool lowLight;
// Start is called before the first frame update
void Start(){
rb2d = GetComponent<Rigidbody2D>();
defaultSpeed = speed;
}
// Update is called once per frame
void Update(){
if (!lost){
if (Input.GetButtonDown("Fire")){
if (brujula){
Invoke(nameof(VelaOff), 2);
humo.SetActive(false);
brujula = false;
anim.SetBool("Vela", false);
}else{
VelaOn();
brujula = true;
}
}
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
mov = new Vector2(h, v);
if (mov.magnitude > .1f){
anim.SetBool("Walking", true);
float targetAngle = Mathf.Atan2(mov.x, mov.y) * Mathf.Rad2Deg;
float angle = Mathf.SmoothDampAngle(child.localEulerAngles.y, targetAngle, ref turnSmoothVelocity, .1f);
child.localRotation = Quaternion.Euler(0f, angle, 0f);
}else{
anim.SetBool("Walking", false);
}
}else{
mov = Vector2.zero;
}
if(lightBar.time <= lightBar.maxTime / 2 && lowLight){
AudioManager.instance.FadeMutedIn("Theme2", 2f);
lowLight = true;
}
if(lightBar.time <= 0 && !lighted){
luz.SetActive(false);
Invoke(nameof(FinalLight), 1);
trigger.SetActive(true);
gameController.readyToSpawn = false;
AudioManager.instance.Stop("Vela");
trigger.SetActive(true);
lighted = true;
}
}
void FixedUpdate(){
rb2d.MovePosition(rb2d.position + mov.normalized * speed * Time.fixedDeltaTime);
}
void FinalLight(){
aura.SetActive(false);
trigger.SetActive(false);
CancelInvoke();
runOutOfLight = true;
}
void VelaOn(){
humo.SetActive(true);
speed = 0;
anim.SetBool("Vela", true);
}
void VelaOff(){
speed = defaultSpeed;
}
void OnCollisionEnter2D(Collision2D col){
if(col.gameObject.CompareTag("Enemy") && !aura.activeSelf && !lost){
Invoke(nameof(GameOver), 5f);
anim.SetBool("Dead", true);
AudioManager.instance.Stop("Theme");
AudioManager.instance.Stop("Theme2");
AudioManager.instance.Play("Death");
lost = true;
}
}
void GameOver(){
gameController.gameOver = true;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a5612b4e4d6ebcc43a429c40d4955cc3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: