89 lines
2.5 KiB
C#
89 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace CHN
|
|
{
|
|
public class Floor : MonoBehaviour
|
|
{
|
|
public int floorIndex;
|
|
public List<Machine> machines = new();
|
|
|
|
public bool isEmptyFloor;
|
|
public Transform StartPoint;
|
|
|
|
public GameObject Outer;
|
|
public GameObject TopSurfaces;
|
|
public GameObject FloorGroundCollider;
|
|
public GameObject Ceiling;
|
|
public GameObject VisualizationAreas;
|
|
Transform CeilingQuad;
|
|
|
|
public float ceilingActiveRange = 0;
|
|
|
|
private void Awake()
|
|
{
|
|
for(int i= 0; i < transform.childCount; ++i)
|
|
{
|
|
switch(transform.GetChild(i).name)
|
|
{
|
|
case nameof(Outer):
|
|
Outer = transform.GetChild(i).gameObject;
|
|
break;
|
|
case nameof(FloorGroundCollider):
|
|
FloorGroundCollider = transform.GetChild(i).gameObject;
|
|
break;
|
|
case nameof(Ceiling):
|
|
Ceiling = transform.GetChild(i).gameObject;
|
|
break;
|
|
case nameof(VisualizationAreas):
|
|
VisualizationAreas = transform.GetChild(i).gameObject;
|
|
break;
|
|
case nameof(TopSurfaces):
|
|
TopSurfaces = transform.GetChild(i).gameObject;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool FloorContainsPoint(Vector3 pos)
|
|
{
|
|
var floorColliders = FloorGroundCollider.GetComponentsInChildren<BoxCollider>();
|
|
|
|
foreach(var collider in floorColliders)
|
|
{
|
|
if (collider.bounds.Contains(pos))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void SetInternalState()
|
|
{
|
|
Ceiling.SetActive(true);
|
|
TopSurfaces.SetActive(false);
|
|
}
|
|
|
|
public void SetExternalState()
|
|
{
|
|
TopSurfaces.SetActive(false);
|
|
Ceiling.SetActive(false);
|
|
}
|
|
|
|
public void UnderCeilingControl(Vector3 pos)
|
|
{
|
|
//if (Ceiling == null)
|
|
// return;
|
|
|
|
//float height = Ceiling.transform.position.y - ceilingActiveRange;
|
|
|
|
//bool isUnder = pos.y < height;
|
|
//Debug.Log(isUnder);
|
|
//Ceiling.SetActive(isUnder);
|
|
}
|
|
}
|
|
}
|
|
|