上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

99 lines
3.9 KiB

using DG.Tweening;
using UniRx;
using UnityEngine;
using UnityEngine.AzureSky;
using UnityEngine.UI;
public class ToolBarPanel : UIView
{
public Text DateText;
public Text TimeText;
public Text CityText;
public Text WeatherText;
public Text TemperatureText;
public Text DirectionText;
public Text WindText;
public LongClickButton ForceButton;
public Button RotateButton;
public Toggle PlaneToggle;
public Toggle DistanceToggle;
public Toggle HeightToggle;
public Toggle AreaToggle;
public Button SettingButton;
public override void Awake()
{
base.Awake();
UIManager.Instance.Show<GameSettingPanel>();
Observable.EveryUpdate()
.Subscribe(_ => DateTime());
PlaneToggle.gameObject.SetActive(false);
//单击重置视图
ForceButton.OnClickAsObservable()
.Subscribe(_ => MainMenu.Instance.OnResetCamera());
//长按重置视图恢复楼层
ForceButton.onLongClick.AddListener(() => MainMenu.Instance.OnInterialClose());
//自动旋转
RotateButton.OnClickAsObservable()
.Subscribe(_ => AssetManager.Instance.MainCamera.GetComponent<CameraOrbit>().isAutoRotate = true);
//测距
DistanceToggle.onValueChanged.AddListener((bool value) => MeasureTools.Instance.MeasureLength(value));
//测高
HeightToggle.onValueChanged.AddListener((bool value) => MeasureTools.Instance.MeasureHeight(value));
//测面
AreaToggle.onValueChanged.AddListener((bool value) => MeasureTools.Instance.MeasureArea(value));
//平面图切换
PlaneToggle.GetComponent<Toggle>().onValueChanged.AddListener((bool value) => ViewModeSwitch(value));
SettingButton.onClick.AddListener(() =>
{
UIManager.Instance.GetView<GameSettingPanel>().GetComponent<RectTransform>().DOAnchorPos(new Vector2(0, 0), 0.1f);
});
}
private void ViewModeSwitch(bool isOn)
{
if (isOn)
{
UIManager.Instance.GetView<CompassPanel>().gameObject.GetComponent<RectTransform>().localEulerAngles = new Vector3(0, 0, 180 - AssetManager.Instance.InitialAngle);
MainMenu.Instance.ViewMode = FloorViewMode.TwoD;
AssetManager.Instance.MainCamera.SetActive(false);
AssetManager.Instance.PlaneCamera.SetActive(true);
AzureSkyController.Instance.lightTransform.GetComponent<Light>().enabled = false;
PlaneToggle.transform.Find("Label").GetComponent<Text>().text = "3D";
//PlaneToggle.transform.Find("Label").GetComponent<Text>().color = new Color(0f, 0.6f, 0.9f, 1f);
//UIManager.Instance.Hide<IntroductionMenuPanel>();
}
else
{
MainMenu.Instance.ViewMode = FloorViewMode.ThreeD;
AssetManager.Instance.MainCamera.SetActive(true);
AssetManager.Instance.PlaneCamera.SetActive(false);
AzureSkyController.Instance.lightTransform.GetComponent<Light>().enabled = true;
PlaneToggle.transform.Find("Label").GetComponent<Text>().text = "2D";
//PlaneToggle.transform.Find("Label").GetComponent<Text>().color = Color.white;
//Debug.Log(MainMenu.Instance.MenuMode);
//if (MainMenuPanel.Instance.transform.Find("MainButtons/BuildingStructure").GetComponent<Toggle>().isOn)
//{
// Show<BuildingStructurePanel>();
//}
}
}
//时间日期
private void DateTime()
{
int _year = System.DateTime.Now.Year;
int _month = System.DateTime.Now.Month;
int _day = System.DateTime.Now.Day;
DateText.text = string.Format("{0:D1}/{1:D2}/{2:D2}", _year, _month, _day);
int _hour = System.DateTime.Now.Hour;
int _minute = System.DateTime.Now.Minute;
TimeText.text = string.Format("{0:D2}:{1:D2}", _hour, _minute);
}
}