Files
EnglewoodLAB/Assets/Scripts/Objects/Building.cs
SOOBEEN HAN f1894889ee <refactor> Octopus Twin 템플릿 적용
- 기능 외 UI 구조만 적용
- 프로젝트에 걸맞는 UI는 재작업 필요
2026-02-23 18:20:09 +09:00

101 lines
3.0 KiB
C#

using Cysharp.Threading.Tasks;
using System.Collections.Generic;
using UnityEngine;
namespace EnglewoodLAB
{
public class Building : MonoBehaviour
{
// Machine
public List<Machine> GetMachines() { return machineList; }
private List<Machine> machineList = new List<Machine>();
// Thermostat
public List<Thermostat> GetThermostats() { return thermostatList; }
private List<Thermostat> thermostatList = new List<Thermostat>();
// Floor
public Floor GetCurFloor() { return floorList[curFloorIndex]; }
private List<Floor> floorList = new List<Floor>();
private int curFloorIndex;
public async UniTask Init()
{
machineList.Clear();
floorList.Clear();
thermostatList.Clear();
var machines = GetComponentsInChildren<Machine>(true);
for (int i = 0; i < machines.Length; i++)
{
await machines[i].Init();
machineList.Add(machines[i]);
}
var thermostats = GetComponentsInChildren<Thermostat>(true);
for (int i = 0; i < thermostats.Length; i++)
{
await thermostats[i].Init();
thermostatList.Add(thermostats[i]);
}
var floor = GetComponentsInChildren<Floor>(true);
for (int i = 0; i < floor.Length; i++)
{
await floor[i].Init();
floorList.Add(floor[i]);
}
var topFloorIndex = floorList.Count - 1;
//curFloorIndex = topFloorIndex;
//curFloorIndex = 1;
var rot = new Quaternion(6.537f, 229.529f, 0f, 0f);
AppMain.Instance.cameraController.SetTargetRotation(rot);
await UniTask.CompletedTask;
}
public Floor GetFloor(int index)
{
curFloorIndex = index;
return floorList[index];
}
public void SetFloor(int index)
{
for (int i = 1; i < floorList.Count; ++i)
{
bool bottom = i <= index;
floorList[i].gameObject.SetActive(bottom);
}
curFloorIndex = index;
var pos = AppMain.Instance.cameraController.cameraPivot.transform.position;
//var pos = new Vector3(6.16f, 5.82f, -17.17f);
pos.y = floorList[curFloorIndex].startPoint.position.y;
AppMain.Instance.cameraController.SetTargetPos(pos);
}
public void SetAllFloorExternalState(bool isActive)
{
foreach (Floor floor in floorList)
{
floor.SetCeilingActive(isActive);
}
}
private void LateUpdate()
{
if (AppMain.Instance.cameraController == null)
return;
var cam = AppMain.Instance.cameraController.Camera;
//if(>)
var isActive = cam.transform.localPosition.y<8f ? true : false;
}
}
}