58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using AZTECHWB.Core;
|
|
using UnityEngine;
|
|
|
|
namespace AZTECHWB
|
|
{
|
|
public class Building : MonoBehaviour
|
|
{
|
|
public List<Floor> floorList = new List<Floor>();
|
|
public List<Machine> machineList = new List<Machine>();
|
|
public Roof roof;
|
|
public bool isOnlyMachineFloorsEnabled;
|
|
public void Init()
|
|
{
|
|
roof = transform.GetComponentInChildren<Roof>(true);
|
|
|
|
machineList.Clear();
|
|
floorList.Clear();
|
|
|
|
var machines = GetComponentsInChildren<Machine>(true);
|
|
for (int i = 0; i < machines.Length; i++)
|
|
{
|
|
machines[i].Init();
|
|
machineList.Add(machines[i]);
|
|
}
|
|
|
|
var floor = GetComponentsInChildren<Floor>(true);
|
|
for (int i = 0; i < floor.Length; i++)
|
|
{
|
|
floorList.Add(floor[i]);
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (AZTECHAppMain.Instance.cameraController == null)
|
|
return;
|
|
|
|
var cam = AZTECHAppMain.Instance.cameraController;
|
|
isOnlyMachineFloorsEnabled = cam.IsCameraInsideBoundary() && cam.Camera.transform.localPosition.y < 20f ? true : false;
|
|
|
|
foreach(var floor in floorList)
|
|
{
|
|
if (floor.isEmptyFloor)
|
|
{
|
|
floor.gameObject.SetActive(!isOnlyMachineFloorsEnabled);
|
|
}
|
|
else
|
|
{
|
|
floor.gameObject.SetActive(isOnlyMachineFloorsEnabled);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|