mirror of
https://github.com/Ratstail91/Keep-It-Alive.git
synced 2025-11-29 02:24:27 +11:00
Mostly finished, just needs sound, polish and hosting online
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Character : MonoBehaviour {
|
||||
//components
|
||||
@@ -16,9 +17,14 @@ public class Character : MonoBehaviour {
|
||||
const float maxSpeed = 60f;
|
||||
const float moveForce = 400f;
|
||||
|
||||
//hunting
|
||||
FadeToBlack fadeToBlack;
|
||||
float huntingTime;
|
||||
|
||||
void Awake() {
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
fadeToBlack = GetComponent<FadeToBlack>();
|
||||
}
|
||||
|
||||
void Update() {
|
||||
@@ -28,6 +34,7 @@ public class Character : MonoBehaviour {
|
||||
void FixedUpdate() {
|
||||
HandleMovement();
|
||||
HandleAnimation();
|
||||
HandleHunted();
|
||||
}
|
||||
|
||||
void HandleInput() {
|
||||
@@ -64,4 +71,16 @@ public class Character : MonoBehaviour {
|
||||
spriteRenderer.sortingOrder = -(int)Mathf.Floor(transform.localPosition.y * 100);
|
||||
spriteRenderer.flipX = lastHorizontalInput > 0f;
|
||||
}
|
||||
|
||||
void HandleHunted() {
|
||||
if (fadeToBlack.brightness < 0f) {
|
||||
huntingTime -= Time.deltaTime;
|
||||
} else {
|
||||
huntingTime = 3f;
|
||||
}
|
||||
|
||||
if (huntingTime <= 0f) {
|
||||
SceneManager.LoadScene("Claws");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user