init
This commit is contained in:
commit
001bb14f16
951 changed files with 270074 additions and 0 deletions
32
Assets/Scripts/Player/FootSteps.cs
Normal file
32
Assets/Scripts/Player/FootSteps.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Player/FootSteps.cs.meta
Normal file
11
Assets/Scripts/Player/FootSteps.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d1fce2dbd0a5b84d9aefd0dd3685e55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Assets/Scripts/Player/LightBar.cs
Normal file
43
Assets/Scripts/Player/LightBar.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Player/LightBar.cs.meta
Normal file
11
Assets/Scripts/Player/LightBar.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd008a5878df18e459011adaa536a18b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
119
Assets/Scripts/Player/PlayerController.cs
Normal file
119
Assets/Scripts/Player/PlayerController.cs
Normal 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;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Player/PlayerController.cs.meta
Normal file
11
Assets/Scripts/Player/PlayerController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a5612b4e4d6ebcc43a429c40d4955cc3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue