No me acuerdo

This commit is contained in:
Gerard Gascón 2023-02-28 18:02:31 +01:00
parent aabe5457e2
commit 9ecec372ce
143 changed files with 21409 additions and 2042 deletions

View file

@ -0,0 +1,46 @@
using System;
using System.Collections;
using System.Collections.Generic;
using MyBox;
using SimpleTools.DialogueSystem;
using UnityEngine;
using UnityEngine.UI;
public class Cutscene : MonoBehaviour {
[SerializeField] Dialogue _dialogue;
[SerializeField] float fadeDuration;
[SerializeField] float[] times;
bool _visible = true;
[SerializeField] Image occluder;
// Start is called before the first frame update
IEnumerator Start() {
foreach (float t in times) {
yield return new WaitForSeconds(fadeDuration);
if (!_visible) {
_visible = true;
_start = Time.time;
}
DialogueManager.instance.Dialogue(_dialogue);
yield return new WaitForSeconds(t);
_visible = false;
_start = Time.time;
yield return new WaitForSeconds(fadeDuration);
}
}
float _start;
void Update() {
float alpha = _visible
? Mathf.Lerp(1, 0, (Time.time - _start) / fadeDuration)
: Mathf.Lerp(0, 1, (Time.time - _start) / fadeDuration);
alpha = Mathf.Round(alpha * 5);
alpha = alpha / 5f;
occluder.SetAlpha(alpha);
}
}

View file

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

View file

@ -7,15 +7,27 @@ public class GhostController : MonoBehaviour {
[SerializeField] float speed;
[SerializeField] Transform player;
Animator _anim;
Rigidbody2D _rb2d;
// Start is called before the first frame update
void Awake() {
_anim = GetComponent<Animator>();
_rb2d = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void FixedUpdate() {
if (_hasKilled) return;
_rb2d.position = Vector2.MoveTowards(_rb2d.position, player.position, Time.deltaTime * speed);
}
bool _hasKilled;
static readonly int Kill1 = Animator.StringToHash("Kill");
public void Kill() {
_hasKilled = true;
_anim.SetTrigger(Kill1);
}
}

View file

@ -1,22 +1,23 @@
using System;
using System.Collections;
using System.Collections.Generic;
using GometGames.Tools;
using MyBox;
using UnityEngine;
using UnityEngine.Events;
using Random = UnityEngine.Random;
[System.Serializable]
public enum OrbTypes {
None,
Blue,
Red,
Purple,
InvertedControls,
HighGravity,
LowGravity,
InvertedGravity,
DarkRoom,
HighSpeed,
LowSpeed
Freeze
};
public class GameManager : MonoBehaviour {
@ -24,15 +25,25 @@ public class GameManager : MonoBehaviour {
[SerializeField] GenericDictionary<OrbTypes, UnityEvent> orbStartEffects;
[SerializeField] GenericDictionary<OrbTypes, UnityEvent> orbEndEffects;
[SerializeField] OrbTypes currentType = OrbTypes.None;
OrbTypes _lastType = OrbTypes.None;
public static GameManager instance;
// Start is called before the first frame update
void Start(){
void Awake() {
instance = this;
}
// Update is called once per frame
void Update(){
public OrbTypes SelectRandomEffect() {
OrbTypes selected;
Array values = Enum.GetValues(typeof(OrbTypes));
do {
selected = (OrbTypes)values.GetValue(Random.Range(1, values.Length));
} while (selected == currentType || selected == _lastType);
Debug.Log(selected);
ChangeEventCall(selected);
return selected;
}
[Space, SerializeField] OrbTypes forceEventChangeType = OrbTypes.None;
@ -44,6 +55,7 @@ public class GameManager : MonoBehaviour {
void ChangeEventCall(OrbTypes type) {
if(currentType != OrbTypes.None) orbEndEffects[currentType].Invoke();
_lastType = currentType;
currentType = type;
if(type != OrbTypes.None) orbStartEffects[currentType].Invoke();
}

View file

@ -52,8 +52,8 @@ public class PlayerController : MonoBehaviour {
_cameraTarget = new GameObject("Camera Target").transform;
vCam.m_Follow = _cameraTarget;
ResetSpeed();
_currentSpeed = speed;
}
void Update() {
@ -121,18 +121,10 @@ 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);
}
}
#region OrbPowerups
public void ResetSpeed() {
_currentSpeed = speed;
}
public void SetSpeed(float newSpeed) {
_currentSpeed = newSpeed;
}
#endregion
}

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

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

View file

@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using MyBox;
using UnityEngine;
using UnityEngine.UI;
public class CanvasController : MonoBehaviour {
[SerializeField] Sprite[] orbCountdown;
[SerializeField] Image orb;
// Start is called before the first frame update
[ButtonMethod]
void Start() {
StartCoroutine(Countdown());
}
// Update is called once per frame
void Update(){
}
IEnumerator Countdown() {
for (int i = 0; i < 10; ++i) {
orb.sprite = orbCountdown[i];
yield return new WaitForSeconds(1f);
}
GameManager.instance.SelectRandomEffect();
}
}

View file

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