上海虹口龙之梦项目
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.
 
 
 
 

98 lines
3.3 KiB

using System.Collections;
using System.Collections.Generic;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public enum WaterSupplyCalculationType { ShiJiYongShuiLiang, ShuiQiangShuLiang, GongShuiNengLi }
public class WaterConsumptionPanel : UIView
{
public WaterSupplyCalculationType WSCType;
//用水量
public Toggle YongShuiLiangToggle;
//水枪数量
public Toggle ShuiQiangShuLiangToggle;
//供水能力
public Toggle GongShuiNengLiToggle;
//用水量面板
public GameObject YongShuiLiangPanel;
//水枪数量面板
public GameObject ShuiQiangShuLiangPanel;
//供水能力面板
public GameObject GongShuiNengLiPanel;
public Button CalculationButton;
public Button ClearButton;
public YongShuiLiangCalculation YSLCalculation;
public ShuiQiangCalculation SQCalculation;
public GongShuiNengLiCalculation GSNLCalculation;
public override void Awake()
{
base.Awake();
transform.Find("TitleBar/CloseButton").GetComponent<Button>().onClick.AddListener(() =>
{
Hide();
});
//用水量面板
YongShuiLiangToggle.OnValueChangedAsObservable()
.Subscribe(value =>
{
YongShuiLiangPanel.SetActive(value);
if (value)
WSCType = WaterSupplyCalculationType.ShiJiYongShuiLiang;
});
//水枪数量面板
ShuiQiangShuLiangToggle.OnValueChangedAsObservable()
.Subscribe(value =>
{
ShuiQiangShuLiangPanel.SetActive(value);
if (value)
WSCType = WaterSupplyCalculationType.ShuiQiangShuLiang;
});
//供水能力面板
GongShuiNengLiToggle.OnValueChangedAsObservable()
.Subscribe(value =>
{
GongShuiNengLiPanel.SetActive(value);
if (value)
WSCType = WaterSupplyCalculationType.GongShuiNengLi;
});
//计算
CalculationButton.OnClickAsObservable()
.Subscribe(_ =>
{
switch (WSCType)
{
case WaterSupplyCalculationType.ShiJiYongShuiLiang:
YSLCalculation.OnCalculation();
break;
case WaterSupplyCalculationType.ShuiQiangShuLiang:
SQCalculation.OnCalculation();
break;
case WaterSupplyCalculationType.GongShuiNengLi:
GSNLCalculation.OnCalculation();
break;
}
});
//清空
ClearButton.OnClickAsObservable()
.Subscribe(_ =>
{
switch (WSCType)
{
case WaterSupplyCalculationType.ShiJiYongShuiLiang:
YSLCalculation.OnClear();
break;
case WaterSupplyCalculationType.ShuiQiangShuLiang:
SQCalculation.OnClear();
break;
case WaterSupplyCalculationType.GongShuiNengLi:
GSNLCalculation.OnClear();
break;
}
});
}
}