Mostly finished, just needs sound, polish and hosting online

This commit is contained in:
2020-04-19 02:49:55 +10:00
parent a3b19da551
commit 499d572dfb
101 changed files with 14591 additions and 26 deletions

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Eyes : MonoBehaviour {
static LevelController levelController;
static GameObject characterObject;
SpriteRenderer spriteRenderer;
void Awake() {
spriteRenderer = GetComponent<SpriteRenderer>();
if (!levelController) {
levelController = GameObject.Find("Level Controller").GetComponent<LevelController>();
}
if (!characterObject) {
characterObject = GameObject.Find("Character");
}
}
void FixedUpdate() {
HandleAnimation();
}
void HandleAnimation() {
//determine the brightness based on distance from the center of the tilemap
float distance = Vector3.Distance(transform.localPosition, Vector3.zero) / 32f;
float brightness = Mathf.Log(distance, 10) - levelController.globalLightLevel;
float spooked = Mathf.Log(Vector3.Distance(transform.localPosition, characterObject.transform.localPosition) / 32, 2) - 0.8f;
if (spooked < 1f && brightness >= 0f) {
brightness *= spooked;
}
Color color = Color.white;
color.a = brightness;
spriteRenderer.color = color;
}
}