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-31 01:35:47 +00:00
|
|
|
|
public enum PowerType {Nothing, Bigger, Faster, Jumper, Artefact, DubleJump, PushPull, Dash, Ladder};
|
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;
|
|
|
|
|
}
|
2021-01-31 01:35:47 +00:00
|
|
|
|
else if (powerType == PowerType.Artefact || powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash || powerType == PowerType.Ladder)
|
2021-01-30 19:04:43 +00:00
|
|
|
|
{
|
|
|
|
|
meshRenderer = GetComponentInChildren<MeshRenderer>();
|
2021-01-31 03:06:54 +00:00
|
|
|
|
meshRenderer.materials[0].DisableKeyword("_EMISSION");
|
2021-01-30 19:04:43 +00:00
|
|
|
|
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 21:19:31 +00:00
|
|
|
|
if (powerType == PowerType.Artefact)
|
|
|
|
|
{
|
2021-01-31 03:06:54 +00:00
|
|
|
|
meshRenderer.materials[0].EnableKeyword("_EMISSION");
|
|
|
|
|
meshRenderer.materials[0].SetColor("_EmissionColor", new Color(0.2735849f, 0.2018939f, 0.09162514f) * 0.8f);
|
2021-01-30 21:19:31 +00:00
|
|
|
|
meshRenderer.materials[1].SetFloat("_Outline", 0.4f);
|
|
|
|
|
}
|
2021-01-31 01:35:47 +00:00
|
|
|
|
else if (powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash || powerType == PowerType.Ladder)
|
2021-01-30 21:19:31 +00:00
|
|
|
|
{
|
2021-01-31 03:06:54 +00:00
|
|
|
|
meshRenderer.materials[1].SetFloat("_Outline", 6f);
|
|
|
|
|
meshRenderer.materials[0].EnableKeyword("_EMISSION");
|
|
|
|
|
meshRenderer.materials[0].SetColor("_EmissionColor", new Color(0.2735849f, 0.2018939f, 0.09162514f) * 0.8f);
|
2021-01-30 21:19:31 +00:00
|
|
|
|
}
|
2021-01-30 19:04:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
|
|
|
{
|
|
|
|
|
if (other.gameObject.tag == "Player")
|
|
|
|
|
{
|
2021-01-31 01:35:47 +00:00
|
|
|
|
if (powerType == PowerType.Artefact || powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash || powerType == PowerType.Ladder)
|
2021-01-30 21:19:31 +00:00
|
|
|
|
{
|
2021-01-31 03:06:54 +00:00
|
|
|
|
meshRenderer.materials[0].DisableKeyword("_EMISSION");
|
2021-01-30 21:19:31 +00:00
|
|
|
|
meshRenderer.materials[1].SetFloat("_Outline", 0.0f);
|
|
|
|
|
}
|
2021-01-30 19:04:43 +00:00
|
|
|
|
}
|
2021-01-30 12:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|