120 lines
2.8 KiB
C#
120 lines
2.8 KiB
C#
using System;
|
|
using DefaultNamespace;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using Utils;
|
|
|
|
public class DoorManager : MonoBehaviour, IDescribable
|
|
{
|
|
public string type;
|
|
|
|
public string mod;
|
|
|
|
public Material blueMaterial;
|
|
public Material redMaterial;
|
|
|
|
private Light focusLight;
|
|
public int isfocussed;
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
if (mod == "BLUE")
|
|
{
|
|
this.GetComponentInChildren<Renderer>().material = blueMaterial;
|
|
}
|
|
else if (mod == "RED")
|
|
{
|
|
this.GetComponentInChildren<Renderer>().material = redMaterial;
|
|
}
|
|
|
|
focusLight = transform.FindChildRecursive("FocusLight").GetComponent<Light>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (isfocussed == 2 && focusLight.intensity < 200)
|
|
{
|
|
focusLight.intensity += Time.deltaTime * 100;
|
|
}
|
|
else if (isfocussed == 1 && focusLight.intensity < 100)
|
|
{
|
|
focusLight.intensity += Time.deltaTime * 100;
|
|
}
|
|
else if (isfocussed == 0 && focusLight.intensity > 30)
|
|
{
|
|
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()
|
|
{
|
|
return type;
|
|
}
|
|
|
|
public string GetDescribeName()
|
|
{
|
|
return mod;
|
|
}
|
|
|
|
public string GetDescription()
|
|
{
|
|
return "Describe " + type;
|
|
}
|
|
|
|
public string GetUnknownDescription()
|
|
{
|
|
if (mod == "RED" || mod == "BLUE" || mod == "PLAIN")
|
|
{
|
|
return $"the {mod} door";
|
|
}
|
|
|
|
if (mod == "#LEFT" || mod == "#CENTER" || mod == "#RIGHT")
|
|
{
|
|
return $"the {mod.Replace("#","")} door";
|
|
}
|
|
// add more modification here
|
|
|
|
return "the door";
|
|
}
|
|
}
|