GlobalGameJam-2021/Assets/Scripts/PowerCubeManager.cs

60 lines
1.7 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
{
2021-01-30 19:04:43 +00:00
public enum PowerType {Nothing, Bigger, Faster, Jumper, Artefact};
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
private bool interact = false;
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;
}
2021-01-30 19:04:43 +00:00
else if (powerType == PowerType.Artefact)
{
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")
{
2021-01-30 19:56:04 +00:00
meshRenderer.materials[1].SetFloat("_Outline", 0.4f);
2021-01-30 19:04:43 +00:00
interact = true;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
{
meshRenderer.materials[1].SetFloat("_Outline", 0.0f);
interact = false;
}
2021-01-30 12:51:35 +00:00
}
}