114 lines
3.0 KiB
C#
114 lines
3.0 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 List<Thermostat> thermostats = new();
|
|
|
|
public bool isEmptyFloor;
|
|
public Transform StartPoint;
|
|
|
|
public GameObject Walls;
|
|
public GameObject Grounds;
|
|
public GameObject Decos;
|
|
|
|
public GameObject TopSurfaces;
|
|
public GameObject FloorGroundCollider;
|
|
public GameObject Ceiling;
|
|
|
|
public float ceilingActiveRange = 0;
|
|
|
|
private void Awake()
|
|
{
|
|
for(int i= 0; i < transform.childCount; ++i)
|
|
{
|
|
switch(transform.GetChild(i).name)
|
|
{
|
|
case nameof(Walls):
|
|
Walls = transform.GetChild(i).gameObject;
|
|
TopSurfaces = Walls.transform.GetChild(4).gameObject;
|
|
break;
|
|
case nameof(Grounds):
|
|
Grounds = transform.GetChild(i).gameObject;
|
|
break;
|
|
case nameof(Decos):
|
|
Decos = transform.GetChild(i).gameObject;
|
|
break;
|
|
case nameof(FloorGroundCollider):
|
|
FloorGroundCollider = transform.GetChild(i).gameObject;
|
|
break;
|
|
case nameof(Ceiling):
|
|
Ceiling = 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 ActiveFloor()
|
|
{
|
|
SetActiveWall(true);
|
|
SetActiveGround(true);
|
|
SetActiveDeco(true);
|
|
}
|
|
public void DeactiveFloor()
|
|
{
|
|
SetActiveWall(false);
|
|
SetActiveGround(false);
|
|
SetActiveDeco(false);
|
|
}
|
|
public void SetActiveWall(bool isOn)
|
|
{
|
|
if (Walls == null)
|
|
return;
|
|
|
|
Walls.SetActive(isOn);
|
|
}
|
|
public void SetActiveGround(bool isOn)
|
|
{
|
|
if (Grounds == null)
|
|
return;
|
|
|
|
Grounds.SetActive(isOn);
|
|
}
|
|
public void SetActiveDeco(bool isOn)
|
|
{
|
|
if (Decos == null)
|
|
return;
|
|
|
|
Decos.SetActive(isOn);
|
|
}
|
|
}
|
|
}
|
|
|