Demasiadas cosas
This commit is contained in:
parent
55b18c6def
commit
3d9aad6211
81 changed files with 7438 additions and 890 deletions
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using MyBox;
|
||||
using SimpleTools.DialogueSystem;
|
||||
using SimpleTools.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
@ -30,6 +31,7 @@ public class Cutscene : MonoBehaviour {
|
|||
_start = Time.time;
|
||||
yield return new WaitForSeconds(fadeDuration);
|
||||
}
|
||||
Loader.Load(2);
|
||||
}
|
||||
|
||||
float _start;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using GometGames.Tools;
|
||||
using MyBox;
|
||||
using SimpleTools.AudioManager;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
@ -36,24 +38,51 @@ public class GameManager : MonoBehaviour {
|
|||
[SerializeField] int doorTime = 30;
|
||||
|
||||
[SerializeField] RectTransform clockPivot;
|
||||
|
||||
bool _doorOpened, _dead;
|
||||
|
||||
[SerializeField] UnityEvent doorOpenEvent;
|
||||
[SerializeField] UnityEvent timeEndEvent;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Start() {
|
||||
AudioManager.instance.FadeIn("Viento", 1f);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (_stopped) return;
|
||||
|
||||
CurrentTime += Time.deltaTime;
|
||||
float ratio = CurrentTime / time;
|
||||
clockPivot.rotation = Quaternion.Euler(0f, 0f, ratio * 360f - 180f);
|
||||
if (CurrentTime >= time - doorTime) {
|
||||
Debug.Log("DoorOpened");
|
||||
if (CurrentTime >= time) {
|
||||
Debug.Log("TimesUp");
|
||||
if (!_doorOpened) {
|
||||
_doorOpened = true;
|
||||
AudioManager.instance.Play("Puerta");
|
||||
AudioManager.instance.FadeOut("Puerta", 1f);
|
||||
doorOpenEvent.Invoke();
|
||||
}
|
||||
if (CurrentTime >= time && !_dead) {
|
||||
_dead = true;
|
||||
timeEndEvent.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] CanvasGroup group;
|
||||
[SerializeField] CanvasController controller;
|
||||
bool _stopped;
|
||||
public void DisableManager() {
|
||||
group.DOFade(0, 1f);
|
||||
controller.AbortCoroutine();
|
||||
group.interactable = false;
|
||||
_stopped = true;
|
||||
}
|
||||
|
||||
public OrbTypes SelectRandomEffect() {
|
||||
OrbTypes selected;
|
||||
do {
|
||||
|
@ -64,13 +93,6 @@ public class GameManager : MonoBehaviour {
|
|||
return selected;
|
||||
}
|
||||
|
||||
[Space, SerializeField] OrbTypes forceEventChangeType = OrbTypes.None;
|
||||
[ButtonMethod]
|
||||
void ForceEventChange() {
|
||||
if (!Application.isPlaying) return;
|
||||
ChangeEventCall(forceEventChangeType);
|
||||
}
|
||||
|
||||
void ChangeEventCall(OrbTypes type) {
|
||||
if(currentType != OrbTypes.None) orbEndEffects[currentType].Invoke();
|
||||
_lastType = currentType;
|
||||
|
|
|
@ -2,10 +2,14 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cinemachine;
|
||||
using DG.Tweening;
|
||||
using MyBox;
|
||||
using SimpleTools.AudioManager;
|
||||
using SimpleTools.Cinemachine;
|
||||
using SimpleTools.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerController : MonoBehaviour {
|
||||
|
||||
|
@ -66,6 +70,15 @@ public class PlayerController : MonoBehaviour {
|
|||
PlayerPrefs.SetInt("OrbsFound", 0);
|
||||
}
|
||||
|
||||
Coroutine _stepsRoutine;
|
||||
|
||||
IEnumerator Steps() {
|
||||
while (true) {
|
||||
yield return new WaitForSeconds(.25f);
|
||||
AudioManager.instance.PlayOneShot("Pasos");
|
||||
}
|
||||
}
|
||||
|
||||
void Update() {
|
||||
Vector3 localScale;
|
||||
if (_dead) {
|
||||
|
@ -93,6 +106,21 @@ public class PlayerController : MonoBehaviour {
|
|||
_anim.SetBool(Grounded, _isGrounded);
|
||||
if (_isGrounded && _rb2d.velocity.y <= 0f) _coyoteTime = coyoteTime;
|
||||
|
||||
if (_isGrounded) {
|
||||
switch (Mathf.Abs(_input.x)) {
|
||||
case > 0f when _stepsRoutine == null:
|
||||
_stepsRoutine = StartCoroutine(Steps());
|
||||
break;
|
||||
case 0f when _stepsRoutine != null:
|
||||
StopCoroutine(_stepsRoutine);
|
||||
_stepsRoutine = null;
|
||||
break;
|
||||
}
|
||||
}else if (_stepsRoutine != null) {
|
||||
StopCoroutine(_stepsRoutine);
|
||||
_stepsRoutine = null;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space)) _jumpBuffer = jumpBuffer;
|
||||
if (Input.GetKeyUp(KeyCode.Space)) _cancelJump = true;
|
||||
|
||||
|
@ -115,6 +143,7 @@ public class PlayerController : MonoBehaviour {
|
|||
if (_coyoteTime > 0f && _jumpBuffer > 0f) {
|
||||
_rb2d.velocity = new Vector2(_rb2d.velocity.x, 0f);
|
||||
_rb2d.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
|
||||
AudioManager.instance.PlayOneShot("Jump");
|
||||
_coyoteTime = _jumpBuffer = 0f;
|
||||
}
|
||||
|
||||
|
@ -131,16 +160,45 @@ public class PlayerController : MonoBehaviour {
|
|||
|
||||
void OnTriggerEnter2D(Collider2D col) {
|
||||
if (col.CompareTag("Ghost")) {
|
||||
col.GetComponent<GhostController>().Kill();
|
||||
_anim.SetTrigger(Die);
|
||||
_dead = true;
|
||||
ScreenShake.Shake(20f, .5f);
|
||||
Kill(col.GetComponent<GhostController>());
|
||||
}else if (col.CompareTag("Orb")) {
|
||||
AudioManager.instance.PlayOneShot("Orbe");
|
||||
PlayerPrefs.SetInt("OrbsFound", PlayerPrefs.GetInt("OrbsFound", 0) + 1);
|
||||
Destroy(col.gameObject);
|
||||
}else if (col.CompareTag("Door")) {
|
||||
StartCoroutine(Win(FindObjectOfType<GhostController>()));
|
||||
}
|
||||
}
|
||||
|
||||
bool _won;
|
||||
[SerializeField] Image fadeImage;
|
||||
IEnumerator Win(GhostController ghost) {
|
||||
if (_dead || _won) yield break;
|
||||
_won = true;
|
||||
ghost.Kill();
|
||||
if(_stepsRoutine != null) StopCoroutine(_stepsRoutine);
|
||||
fadeImage.DOFade(1, 1f);
|
||||
yield return new WaitForSeconds(1f);
|
||||
AudioManager.instance.FadeOut("Viento", 1f);
|
||||
Loader.Load(3);
|
||||
}
|
||||
|
||||
[SerializeField] CanvasGroup group;
|
||||
public void Kill(GhostController ghost) {
|
||||
if (_dead || _won) return;
|
||||
AudioManager.instance.PlayOneShot("Congela");
|
||||
ghost.Kill();
|
||||
if(_stepsRoutine != null) StopCoroutine(_stepsRoutine);
|
||||
group.DOFade(1, 1f);
|
||||
group.interactable = true;
|
||||
|
||||
GameManager.instance.DisableManager();
|
||||
|
||||
_anim.SetTrigger(Die);
|
||||
_dead = true;
|
||||
ScreenShake.Shake(20f, .5f);
|
||||
}
|
||||
|
||||
#region OrbEffects
|
||||
int _controlsDirection = 1;
|
||||
public void InvertControls(bool inverted) {
|
||||
|
|
13
Assets/Scripts/SceneLoad.cs
Normal file
13
Assets/Scripts/SceneLoad.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using SimpleTools.AudioManager;
|
||||
using SimpleTools.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
public class SceneLoad : MonoBehaviour{
|
||||
|
||||
public void LoadScene(int sceneIndex) {
|
||||
AudioManager.instance.FadeOut("Viento", 1f);
|
||||
Loader.Load(sceneIndex);
|
||||
}
|
||||
}
|
11
Assets/Scripts/SceneLoad.cs.meta
Normal file
11
Assets/Scripts/SceneLoad.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 775b962b28fe0d149927748937e2e8c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using SimpleTools.AudioManager;
|
||||
using SimpleTools.Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -46,6 +47,7 @@ public class Thunder : MonoBehaviour{
|
|||
private void LightningStrike(){
|
||||
//ScreenshakeHandler.AddScreenShake(5, 5, 0.5f);
|
||||
ScreenShake.Shake(15, .5f);
|
||||
AudioManager.instance.PlayOneShot($"Trueno{Random.Range(1, 4)}");
|
||||
|
||||
//thunderSound.pitch = Random.Range(0.5f, 1f);
|
||||
//thunderSound.Play();
|
||||
|
|
|
@ -26,10 +26,14 @@ public class CanvasController : MonoBehaviour {
|
|||
|
||||
}
|
||||
|
||||
bool _abort;
|
||||
public void AbortCoroutine() => _abort = true;
|
||||
|
||||
IEnumerator Countdown() {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
orb.sprite = orbCountdown[i];
|
||||
yield return new WaitForSeconds(1f);
|
||||
if (_abort) yield break;
|
||||
}
|
||||
|
||||
_effectImage.sprite = effectSprites[(int)GameManager.instance.SelectRandomEffect() - 1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue