|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.AddressableAssets;
|
|
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using UniRx;
|
|
|
|
using AX.MessageSystem;
|
|
|
|
public class FloorController : MonoBehaviour
|
|
|
|
{
|
|
|
|
public string Prefix = "";
|
|
|
|
public int HighestFloor = 13;
|
|
|
|
public int LowestFloor = -1;
|
|
|
|
public int FloorNum;
|
|
|
|
//避难层
|
|
|
|
public bool isRefugeFloor;
|
|
|
|
//防火分区
|
|
|
|
public bool isFireCompartment;
|
|
|
|
[SerializeField] Transform FireCompartments;
|
|
|
|
//防火门
|
|
|
|
public bool isFireDoor;
|
|
|
|
[SerializeField] Transform FireDoors;
|
|
|
|
//防火卷帘
|
|
|
|
public bool isFireShutter;
|
|
|
|
[SerializeField] Transform FireShutters;
|
|
|
|
//室内消火栓
|
|
|
|
public bool isHydrant;
|
|
|
|
[SerializeField] Transform Hydrants;
|
|
|
|
//泵房水箱
|
|
|
|
public bool isPumpRoom;
|
|
|
|
//消控室
|
|
|
|
public bool isFireControlRoom;
|
|
|
|
|
|
|
|
public bool isInit;
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
AssetManager.Instance.Floors.Add(this);
|
|
|
|
//GetComponent<Toggle>().onValueChanged.AddListener((bool value) => OnValueChanged(value));
|
|
|
|
GetComponent<Toggle>().OnValueChangedAsObservable()
|
|
|
|
.Subscribe(value => OnValueChanged(value));
|
|
|
|
}
|
|
|
|
private void InitData(bool value)
|
|
|
|
{
|
|
|
|
AssetManager.Instance.SetLoadingPanel(true);
|
|
|
|
var floorname = this.name;
|
|
|
|
FloorNum = int.Parse(floorname.Substring(5));
|
|
|
|
Addressables.LoadAssetAsync<GameObject>(Prefix + "nei" + FloorNum).Completed += handle =>
|
|
|
|
{
|
|
|
|
var prefab = handle.Result;
|
|
|
|
var shinei = Instantiate(prefab, AssetManager.Instance.ShiNei.transform);
|
|
|
|
shinei.name = shinei.name.Replace("(Clone)", "");
|
|
|
|
if (isFireCompartment)
|
|
|
|
FireCompartments = shinei.transform.Find("FireCompartments").transform;
|
|
|
|
if (isFireDoor)
|
|
|
|
FireDoors = shinei.transform.Find("FireDoors").transform;
|
|
|
|
if (isFireShutter)
|
|
|
|
FireShutters = shinei.transform.Find("FireShutters").transform;
|
|
|
|
if (isHydrant)
|
|
|
|
Hydrants = shinei.transform.Find("Hydrants").transform;
|
|
|
|
isInit = true;
|
|
|
|
AssetManager.Instance.SetLoadingPanel(false);
|
|
|
|
OnChange(value);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
private void OnValueChanged(bool value)
|
|
|
|
{
|
|
|
|
if (!isInit)
|
|
|
|
InitData(value);
|
|
|
|
else
|
|
|
|
OnChange(value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnChange(bool value)
|
|
|
|
{
|
|
|
|
OnFloorChanged(!value);
|
|
|
|
FloorShortcuts.Instance.CurrentNumber = FloorNum;
|
|
|
|
if (value)
|
|
|
|
MessageDispatcher.SendMessage("FloorChanged", FloorNum);
|
|
|
|
|
|
|
|
//防火分区
|
|
|
|
if (isFireCompartment && FireCompartments != null)
|
|
|
|
{
|
|
|
|
if (MainMenu.ShowFireCompartments)
|
|
|
|
{
|
|
|
|
FireCompartments.SetChildren<MeshRenderer>(obj =>
|
|
|
|
{
|
|
|
|
obj.enabled = value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FireCompartments.SetChildren<MeshRenderer>(obj =>
|
|
|
|
{
|
|
|
|
obj.enabled = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//防火门
|
|
|
|
if (isFireDoor && FireDoors != null)
|
|
|
|
{
|
|
|
|
if (MainMenu.ShowFireDoors)
|
|
|
|
{
|
|
|
|
FireDoors.SetChildren<Lumos>(obj =>
|
|
|
|
{
|
|
|
|
obj.enabled = value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FireDoors.SetChildren<Lumos>(obj =>
|
|
|
|
{
|
|
|
|
obj.enabled = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//防火卷帘
|
|
|
|
if (isFireShutter && FireShutters != null)
|
|
|
|
{
|
|
|
|
if (MainMenu.ShowFireShutters)
|
|
|
|
{
|
|
|
|
FireShutters.SetChildren<Lumos>(obj =>
|
|
|
|
{
|
|
|
|
obj.enabled = value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FireShutters.SetChildren<Lumos>(obj =>
|
|
|
|
{
|
|
|
|
obj.enabled = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//室内消火栓
|
|
|
|
if (isHydrant && Hydrants != null)
|
|
|
|
{
|
|
|
|
if (MainMenu.ShowIndoorHydrants)
|
|
|
|
{
|
|
|
|
Hydrants.SetChildren<Animator>(obj =>
|
|
|
|
{
|
|
|
|
obj.SetBool("Playing", value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Hydrants.SetChildren<Animator>(obj =>
|
|
|
|
{
|
|
|
|
obj.SetBool("Playing", false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnFloorChanged(bool ShowAll)
|
|
|
|
{
|
|
|
|
for (int i = LowestFloor; i <= HighestFloor; i++)
|
|
|
|
{
|
|
|
|
string wai = Prefix + "wai" + i;
|
|
|
|
string nei = Prefix + "nei" + i;
|
|
|
|
string EquipmentsAddition = "Equipments" + i;
|
|
|
|
string EquipmentsBuiltIn = "Equipments" + i;
|
|
|
|
string Powers = "Powers" + i;
|
|
|
|
//外观
|
|
|
|
if (AssetManager.Instance.ZhuTi.transform.Find(wai))
|
|
|
|
{
|
|
|
|
GameObject m_wai = AssetManager.Instance.ZhuTi.transform.Find(wai).gameObject;
|
|
|
|
if (m_wai)
|
|
|
|
{
|
|
|
|
if (ShowAll) { m_wai.SetChildrenActive(true); }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i > FloorNum)
|
|
|
|
m_wai.SetChildrenActive(false);
|
|
|
|
else
|
|
|
|
m_wai.SetChildrenActive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//室内
|
|
|
|
if (AssetManager.Instance.ShiNei.transform.Find(nei))
|
|
|
|
{
|
|
|
|
GameObject m_nei = AssetManager.Instance.ShiNei.transform.Find(nei).gameObject;
|
|
|
|
if (m_nei)
|
|
|
|
{
|
|
|
|
switch (MainMenu.Instance.ViewMode)
|
|
|
|
{
|
|
|
|
case FloorViewMode.ThreeD:
|
|
|
|
if (ShowAll) { m_nei.SetChildrenActive(false); }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i > FloorNum) m_nei.SetChildrenActive(false);
|
|
|
|
else m_nei.SetChildrenActive(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FloorViewMode.TwoD:
|
|
|
|
if (ShowAll) { m_nei.SetChildrenActive(false); }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i == FloorNum) m_nei.SetChildrenActive(true);
|
|
|
|
else m_nei.SetChildrenActive(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Powers
|
|
|
|
if (PowerManager.Instance.transform.Find(Powers))
|
|
|
|
{
|
|
|
|
GameObject m_Powers = PowerManager.Instance.transform.Find(Powers).gameObject;
|
|
|
|
if (ShowAll) { m_Powers.SetChildrenActive(true); }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i != 0)
|
|
|
|
{
|
|
|
|
if (i > FloorNum) { m_Powers.SetChildrenActive(false); }
|
|
|
|
else { m_Powers.SetChildrenActive(true); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//设备
|
|
|
|
if (EquipmentManager.Instance.Addition.Find(EquipmentsAddition))
|
|
|
|
{
|
|
|
|
Transform m_Equipments = EquipmentManager.Instance.Addition.Find(EquipmentsAddition);
|
|
|
|
if (ShowAll)
|
|
|
|
{
|
|
|
|
|
|
|
|
m_Equipments.gameObject.SetChildrenActive(true);
|
|
|
|
m_Equipments.SetChildren<UIFollowTarget>(obj => obj.isRendering = true);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i != 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (i > FloorNum)
|
|
|
|
{
|
|
|
|
m_Equipments.SetChildren<UIFollowTarget>(obj => obj.Hide());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Equipments.gameObject.SetChildrenActive(true);
|
|
|
|
if (i == FloorNum)
|
|
|
|
m_Equipments.SetChildren<UIFollowTarget>(obj => obj.isRendering = true);
|
|
|
|
else
|
|
|
|
m_Equipments.SetChildren<UIFollowTarget>(obj => obj.isRendering = false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EquipmentManager.Instance.BuiltIn.Find(EquipmentsBuiltIn))
|
|
|
|
{
|
|
|
|
Transform m_Equipments = EquipmentManager.Instance.BuiltIn.Find(EquipmentsBuiltIn);
|
|
|
|
if (ShowAll)
|
|
|
|
{
|
|
|
|
m_Equipments.SetChildren<MeshRenderer>(obj => obj.enabled = true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i != 0)
|
|
|
|
{
|
|
|
|
if (i > FloorNum)
|
|
|
|
{
|
|
|
|
m_Equipments.SetChildren<MeshRenderer>(obj => obj.enabled = false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Equipments.SetChildren<MeshRenderer>(obj => obj.enabled = true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|