This commit is contained in:
정영민
2025-02-20 09:59:37 +09:00
parent 4dfe902e02
commit 2dd5d814a7
6244 changed files with 4671685 additions and 5 deletions

83
Assets/Scripts/Floor.cs Normal file
View File

@@ -0,0 +1,83 @@
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 => machines.Count == 0;
public Transform StartPoint;
public GameObject Outer;
public GameObject TopSurfaces;
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(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 = transform.GetComponents<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 = CeilingQuad.transform.position.y - ceilingActiveRange;
bool isUnder = pos.y < height;
Ceiling.SetActive(isUnder);
}
}
}