GlobalGameJam-2021/Assets/Scripts/PowerCubeManager.cs

67 lines
2.2 KiB
C#
Raw Normal View History

2021-01-30 12:51:35 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2021-01-30 19:04:43 +00:00
using UnityEngine.SceneManagement;
2021-01-30 12:51:35 +00:00
public class PowerCubeManager : MonoBehaviour
{
public enum PowerType {Nothing, Bigger, Faster, Jumper, Artefact, DubleJump, PushPull, Dash};
2021-01-30 12:51:35 +00:00
public PowerType powerType = PowerType.Nothing;
public float powerTime = 5f;
public float powerUnit = 10f;
2021-01-30 19:04:43 +00:00
public string nextSceneName;
private MeshRenderer meshRenderer;
2021-01-30 12:51:35 +00:00
void Start()
{
if (powerType == PowerType.Bigger) {
GetComponentInChildren<MeshRenderer>().material.color = Color.blue;
}
else if (powerType == PowerType.Faster)
{
GetComponentInChildren<MeshRenderer>().material.color = Color.red;
}
else if (powerType == PowerType.Jumper)
{
GetComponentInChildren<MeshRenderer>().material.color = Color.green;
}
else if (powerType == PowerType.Artefact || powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash)
2021-01-30 19:04:43 +00:00
{
meshRenderer = GetComponentInChildren<MeshRenderer>();
meshRenderer.materials[1].SetFloat("_Outline", 0.0f);
meshRenderer.materials[1].SetColor("_OutlineColor", new Color(0.5276349f, 0.5566038f, 0.118147f));
}
2021-01-30 12:51:35 +00:00
}
void Update()
{
2021-01-30 19:56:04 +00:00
2021-01-30 19:04:43 +00:00
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
if (powerType == PowerType.Artefact)
{
meshRenderer.materials[1].SetFloat("_Outline", 0.4f);
}
else if (powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash)
{
meshRenderer.materials[1].SetFloat("_Outline", 0.01f);
}
2021-01-30 19:04:43 +00:00
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
{
if (powerType == PowerType.Artefact || powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash)
{
meshRenderer.materials[1].SetFloat("_Outline", 0.0f);
}
2021-01-30 19:04:43 +00:00
}
2021-01-30 12:51:35 +00:00
}
}