198 lines
5.1 KiB
C#
198 lines
5.1 KiB
C#
using System;
|
|
using DefaultNamespace;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using Utils;
|
|
using UnityEngine;
|
|
using Unity.Cinemachine;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class DoorManager : MonoBehaviour, IDescribable
|
|
{
|
|
public string type;
|
|
|
|
public string mod;
|
|
|
|
private Light focusLight;
|
|
public int isfocussed;
|
|
|
|
private LightFlickerer indicatorLight;
|
|
|
|
public CinemachineCamera doorCamera;
|
|
public CinemachineSplineDolly doorSplineDolly;
|
|
|
|
public CinemachineCamera deathCamera;
|
|
public CinemachineSplineDolly deathSplineDolly;
|
|
|
|
public GameObject greenlight;
|
|
public GameObject redlight;
|
|
public GameObject bluelight;
|
|
public GameObject yellowlight;
|
|
|
|
public Material openMaterial;
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
indicatorLight = transform.FindChildRecursive("IndicatorLight").GetComponent<LightFlickerer>();
|
|
|
|
//trolley problerm indicatgor
|
|
var oneDeath = transform.FindChildRecursive("ONEDEATH");
|
|
var manyDeath = transform.FindChildRecursive("MANYDEATH");
|
|
oneDeath.gameObject.SetActive(false);
|
|
manyDeath.gameObject.SetActive(false);
|
|
|
|
|
|
|
|
if (mod.EndsWith("BLUE"))
|
|
{
|
|
// this.GetComponentInChildren<Renderer>().material = blueMaterial;
|
|
indicatorLight.initialColor = Color.blue;
|
|
bluelight.SetActive(true);
|
|
}
|
|
else if (mod.EndsWith("RED"))
|
|
{
|
|
// this.GetComponentInChildren<Renderer>().material = redMaterial;
|
|
indicatorLight.initialColor = Color.red;
|
|
redlight.SetActive(true);
|
|
}
|
|
else if (mod.EndsWith("GREEN"))
|
|
{
|
|
// this.GetComponentInChildren<Renderer>().material = redMaterial;
|
|
indicatorLight.initialColor = Color.green;
|
|
greenlight.SetActive(true);
|
|
}
|
|
else if (mod == "#ONE")
|
|
{
|
|
oneDeath.gameObject.SetActive(true);
|
|
}
|
|
else if (mod == "#MANY")
|
|
{
|
|
manyDeath.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
yellowlight.SetActive(true);
|
|
}
|
|
|
|
focusLight = transform.FindChildRecursive("FocusLight").GetComponent<Light>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (isfocussed == 2 && focusLight.intensity < 250)
|
|
{
|
|
focusLight.intensity += Time.deltaTime * 100;
|
|
}
|
|
else if (isfocussed == 1 && focusLight.intensity < 150)
|
|
{
|
|
focusLight.intensity += Time.deltaTime * 100;
|
|
}
|
|
else if (isfocussed == 0 && focusLight.intensity > 100)
|
|
{
|
|
focusLight.intensity -= Time.deltaTime * 100;
|
|
}
|
|
}
|
|
|
|
private void OnDrawGizmos()
|
|
{
|
|
#if UNITY_EDITOR
|
|
Handles.Label(
|
|
transform.position + Vector3.up * 2f,
|
|
type
|
|
);
|
|
#endif
|
|
}
|
|
|
|
public QuestionAnswer GetProperty(string property)
|
|
{
|
|
var answer = QuestionAnswer.NO_YES;
|
|
if (property.StartsWith("safe"))
|
|
{
|
|
answer = type switch
|
|
{
|
|
"LIFE" => QuestionAnswer.YES,
|
|
"DEATH" => QuestionAnswer.NO,
|
|
_ => QuestionAnswer.NO_YES
|
|
};
|
|
}
|
|
|
|
if (property.EndsWith("!"))
|
|
{
|
|
//we want opposite, so switch
|
|
return answer switch
|
|
{
|
|
QuestionAnswer.YES => QuestionAnswer.NO,
|
|
QuestionAnswer.NO => QuestionAnswer.YES,
|
|
QuestionAnswer.NO_YES => QuestionAnswer.NO_YES // i think? since we cannot confidently lie?
|
|
};
|
|
}
|
|
|
|
//else return base
|
|
return answer;
|
|
}
|
|
|
|
public string GetName()
|
|
{
|
|
if (type == "LIFE")
|
|
{
|
|
return "Door of Eden";
|
|
}
|
|
else if (type == "DEATH")
|
|
{
|
|
return "Door of Oblivion";
|
|
}
|
|
else
|
|
{
|
|
return "Door no one has ever tried";
|
|
}
|
|
}
|
|
|
|
public string GetDescribeName()
|
|
{
|
|
if (!string.IsNullOrEmpty(mod))
|
|
{
|
|
return "The " + mod.ToLower() + " door";
|
|
}
|
|
else
|
|
{
|
|
return "Normal door";
|
|
}
|
|
}
|
|
|
|
public string GetDescription()
|
|
{
|
|
if (type == "LIFE")
|
|
{
|
|
return "Leads to the next level of the castle.";
|
|
}
|
|
else if (type == "DEATH")
|
|
{
|
|
return "Leads to certain death, in some brutal fashion.";
|
|
}
|
|
else
|
|
{
|
|
return "Dunno whats behind it..";
|
|
}
|
|
}
|
|
|
|
public string GetUnknownDescription()
|
|
{
|
|
if (mod == "RED" || mod == "BLUE" || mod == "GREEN")
|
|
{
|
|
return $"the {mod.ToLower()} door";
|
|
}
|
|
|
|
if (mod == "#LEFT" || mod == "#CENTER" || mod == "#RIGHT")
|
|
{
|
|
return $"the {mod.Replace("#","").ToLower()} door";
|
|
}
|
|
// add more modification here
|
|
|
|
return "the door";
|
|
}
|
|
}
|