网上演练贵港万达广场(人员密集)
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.
 
 
 

955 lines
39 KiB

using AX.InputSystem;
using AX.MessageSystem;
using AX.NetworkSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public enum SprayMode
{
PS30,
PS20,
WaterGun19
}
/// <summary>
/// 用来获取流量压力
/// </summary>
public class SprayParameter
{
public float minpower;
public float maxpower;
public float minflow;
public float maxflow;
public float minsize;
public float maxsize;
/// <summary>
/// 出水流量压力数据
/// </summary>
/// <param name="spraymode"></param>
/// <returns></returns>
public static SprayParameter GetInfo(SprayMode spraymode)
{
SprayParameter result = new SprayParameter();
switch (spraymode)
{
case SprayMode.PS20:
result.minpower = 0.5f;
result.maxpower = 1.2f;
result.minflow = 10f;
result.maxflow = 20f;
result.minsize = 0.3f;
result.maxsize = 0.9f;
break;
case SprayMode.PS30:
result.minpower = 0.5f;
result.maxpower = 1.2f;
result.minflow = 14f;
result.maxflow = 30f;
result.minsize = 0.4f;
result.maxsize = 1.1f;
break;
case SprayMode.WaterGun19:
result.minpower = 9f;
result.maxpower = 59f;
result.minflow = 3.8f;
result.maxflow = 9.6f;
result.minsize = 0.1f;
result.maxsize = 0.3f;
break;
}
return result;
}
}
public class LayWaterPanel : MonoBehaviour
{
public Transform laywater;
//private ButtonRecordByAC addbutton;
//private ButtonRecordByAC minusbutton;
private Slider slider;
/// <summary>
/// 当前喷水物体
/// </summary>
public GameObject SelectSparyObj;
private Transform Pointer;
private ToggleRecordByAC StraightToggle;
private ToggleRecordByAC FlowerToggle;
private ToggleRecordByAC FogToggle;
private SliderRecordByAC SliderAC;
private Text PowerText;
private Text FlowText;
private Text WaterText;
private Text TimeText;
private ButtonRecordByAC UpButton;
private ButtonRecordByAC DownButton;
private ButtonRecordByAC LeftButton;
private ButtonRecordByAC RightBurron;
public float WaterRemain;
public int TimeRemain;
// private Transform pointer;
// private float argue;
//private SprayParticleType NowSprayType;
private float timer = 1f;
// Use this for initialization
void Start()
{
slider = laywater.transform.Find("Slider").GetComponent<Slider>();
SliderAC = slider.GetComponent<SliderRecordByAC>();
//addbutton = laywater.transform.Find("AddButton").GetComponent<ButtonRecordByAC>();
// minusbutton = laywater.transform.Find("MinusButton").GetComponent<ButtonRecordByAC>();
StraightToggle = laywater.transform.Find("StraightToggle").GetComponent<ToggleRecordByAC>();
FlowerToggle = laywater.transform.Find("FlowerToggle").GetComponent<ToggleRecordByAC>();
FogToggle = laywater.transform.Find("FogToggle").GetComponent<ToggleRecordByAC>();
//pointer = laywater.transform.Find("Pointer");
//addbutton.OutInterFaceButton = addbuttonClick;
// minusbutton.OutInterFaceButton = minusbuttonClick;
StraightToggle.OutInterFaceToggle = StraightToggleChange;
FlowerToggle.OutInterFaceToggle = FlowerToggleChange;
FogToggle.OutInterFaceToggle = FogToggleChange;
SliderAC.OutInterFaceSlider = SliderChange;
PowerText = laywater.transform.Find("Power/PowerText").GetComponent<Text>();
WaterText = laywater.transform.Find("Water/WaterText").GetComponent<Text>();
FlowText = laywater.transform.Find("Flow/FlowText").GetComponent<Text>();
TimeText = laywater.transform.Find("Time/TimeText").GetComponent<Text>();
UpButton = laywater.transform.Find("Up").GetComponent<ButtonRecordByAC>();
DownButton = laywater.transform.Find("Down").GetComponent<ButtonRecordByAC>();
LeftButton = laywater.transform.Find("Left").GetComponent<ButtonRecordByAC>();
RightBurron = laywater.transform.Find("Right").GetComponent<ButtonRecordByAC>();
UpButton.OutInterFaceButton = UpClick;
DownButton.OutInterFaceButton = DownClick;
LeftButton.OutInterFaceButton = LeftClick;
RightBurron.OutInterFaceButton = RightClick;
}
void Update()
{
if (SelectSparyObj != null)
{
timer -= Time.deltaTime;
if (timer <= 0)
{
var timewater = GetTimeAndWater(SelectSparyObj);
int time = timewater.Key;//GetTimeAndWater(SelectSparyObj).Key;
float water = timewater.Value;//GetTimeAndWater(SelectSparyObj).Value;
TimeText.text = SecondToHMS(time);
WaterText.text = water == -100 ? "充足" : GetTimeAndWater(SelectSparyObj).Value.ToString();
if (water != -100)
{
if (time <= 0)
{
TimeText.text = "00:00:00";
WaterText.text = "0";
}
if (water <= 0)
{
TimeText.text = "00:00:00";
WaterText.text = "0";
}
}
timer = 1f;
}
}
}
/// <summary>
/// 根据选中物体设置出水UI初始显示
/// </summary>
public void SetShowEnable()
{
//根据消防员或者车辆设置初始显示
if (SelectSparyObj != null && SelectSparyObj.GetComponentInChildren<ParticleControlOfType>())
{
if (!LeftButton.GetComponent<Button>().interactable)
{
LeftButton.GetComponent<Button>().interactable = true;
}
if (!RightBurron.GetComponent<Button>().interactable)
{
RightBurron.GetComponent<Button>().interactable = true;
}
//float size = 0;
//slider.value = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() / 2.00f;
// argue = 90 - slider.value * 180f;
//pointer.transform.rotation = Quaternion.Euler(0, 0, argue);
//StraightToggle.GetComponent<Toggle>().isOn = true;
if (SelectSparyObj.GetComponent<FireManControl>())
{//人
StraightToggle.gameObject.SetActive(true);
FlowerToggle.gameObject.SetActive(true);
FogToggle.gameObject.SetActive(true);
switch (SelectSparyObj.GetComponent<FireManControl>().SelectParticleType)
{
case SprayParticleType.Froth:
StraightToggle.gameObject.SetActive(false);
FlowerToggle.gameObject.SetActive(false);
FogToggle.gameObject.SetActive(false);
slider.value = (SelectSparyObj.GetComponent<FireManControl>().ParticleSize - 0.8f) / 0.300f;
break;
case SprayParticleType.WaterFlower:
FlowerToggle.GetComponent<Toggle>().isOn = true;
StraightToggle.GetComponent<Toggle>().isOn = false;
FogToggle.GetComponent<Toggle>().isOn = false;
slider.value = (SelectSparyObj.GetComponent<FireManControl>().ParticleSize - 1) / 2.00f;
break;
case SprayParticleType.WaterFog:
FogToggle.GetComponent<Toggle>().isOn = true;
StraightToggle.GetComponent<Toggle>().isOn = false;
FlowerToggle.GetComponent<Toggle>().isOn = false;
slider.value = (SelectSparyObj.GetComponent<FireManControl>().ParticleSize - 1.4f) / 0.6f;
break;
case SprayParticleType.WaterStraight:
StraightToggle.GetComponent<Toggle>().isOn = true;
FlowerToggle.GetComponent<Toggle>().isOn = false;
FogToggle.GetComponent<Toggle>().isOn = false;
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.1f) / 0.200f;
break;
}
}
if (SelectSparyObj.GetComponent<TruckMessage>())
{//车
//StraightToggle.GetComponent<Toggle>().isOn = true;
StraightToggle.gameObject.SetActive(false);
FlowerToggle.gameObject.SetActive(false);
FogToggle.gameObject.SetActive(false);
if (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.Froth)
{
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.8f) / 0.6f;
}
else if(SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.WaterStraight)
{
if (SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.HighSprayingTruck)
{
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.4f) / 0.7f;
}
else
{
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.3f) / 0.6f ;
}
}
}
if (SelectSparyObj.GetComponent<WaterConnonController>())
{
//移动水泡
StraightToggle.gameObject.SetActive(false);
FlowerToggle.gameObject.SetActive(false);
FogToggle.gameObject.SetActive(false);
if (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.WaterStraight)
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.4f) / 0.7f;
if (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.Froth)
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.8f) / 0.6f;
}
if(SelectSparyObj.GetComponent<SnowConnonController>())
{
//暴风雪炮
StraightToggle.gameObject.SetActive(false);
FlowerToggle.gameObject.SetActive(false);
FogToggle.gameObject.SetActive(false);
LeftButton.GetComponent<Button>().interactable = false;
RightBurron.GetComponent<Button>().interactable = false;
if (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.WaterStraight)
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.4f) / 0.7f;
if (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.Froth)
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.8f) / 0.6f;
}
if (SelectSparyObj.GetComponent<GuDingShuiPaoControl>())
{//固定水泡
StraightToggle.gameObject.SetActive(false);
FlowerToggle.gameObject.SetActive(false);
FogToggle.gameObject.SetActive(false);
slider.value = (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() - 0.4f) / 0.7f;
WaterText.text = "充足";
TimeText.text = "99:00:00";
}
if (SelectSparyObj.GetComponent<FireRobotController>())
{//机器人
StraightToggle.gameObject.SetActive(false);
FlowerToggle.gameObject.SetActive(false);
FogToggle.gameObject.SetActive(false);
if (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.Froth)
slider.value = (SelectSparyObj.GetComponent<FireRobotController>().ParticleSize - 0.8f) / 0.300f;
if (SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.WaterStraight)
slider.value = (SelectSparyObj.GetComponent<FireRobotController>().ParticleSize - 0.1f) / 0.200f;
}
SprayParameter spray = GetSprayParameter(SelectSparyObj);
float power = GetPower(spray, slider.value);
float flow = GetFlow(spray, slider.value);
PowerText.text = power.ToString();
FlowText.text = flow.ToString();
//设置喷水物体流量
SetSelectFlow(SelectSparyObj, flow);
//GetTimeAndWater(SelectSparyObj);
//水量时间显示
TimeText.text = SecondToHMS(GetTimeAndWater(SelectSparyObj).Key);
WaterText.text = GetTimeAndWater(SelectSparyObj).Value == -100 ? "充足" : GetTimeAndWater(SelectSparyObj).Value.ToString();
}
}
/// <summary>
/// 切换车跟消防员是更改显示
/// </summary>
//public void SetSparyShow()
//{
// if (SelectSparyObj.GetComponent<FireManControl>())
// {
// StraightToggle.gameObject.SetActive(true);
// FlowerToggle.gameObject.SetActive(true);
// FogToggle.gameObject.SetActive(true);
// }
// if (SelectSparyObj.GetComponent<TruckMessage>())
// {
// StraightToggle.gameObject.SetActive(true);
// FlowerToggle.gameObject.SetActive(false);
// FogToggle.gameObject.SetActive(false);
// }
// if (SelectSparyObj != null && SelectSparyObj.GetComponentInChildren<ParticleControlOfType>())
// {
// slider.value = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().GetScaleValue() / 2.00f;
// StraightToggle.GetComponent<Toggle>().isOn = true;
// }
//}
private void FlowerToggleChange(bool value)
{
if (!value)
{
return;
}
if (SelectSparyObj.GetComponent<TruckMessage>())
{
return;
}
ParticleControlOfType currentparticle;
if (SelectSparyObj.GetComponent<FireManControl>().SelectParticleType == SprayParticleType.WaterFlower)
{
currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>();
slider.value = (currentparticle.GetScaleValue() - 1) / 2.00f;
}
else
{
SelectSparyObj.GetComponent<FireManControl>().SetParticleType(SprayParticleType.WaterFlower);
currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>();
slider.value = 0.5f;
}
//SelectSparyObj.GetComponent<FireManControl>().SetParticleType(SprayParticleType.WaterFlower);
/*ParticleControlOfType */ //currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>(true);
//argue = 90 - slider.value * 180f;
//pointer.transform.rotation = Quaternion.Euler(0, 0, argue);
// NowSprayType = SprayParticleType.WaterFlower;
if (currentparticle!=null)
{
//出水信息同步
SpraySyncData spraysync = new SpraySyncData();
spraysync.IsOn = true;
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
spraysync.spraytype = SprayParticleType.WaterFlower;
spraysync.size = currentparticle.GetScaleValue();
spraysync.gameObjID = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjID;
//spraysync.UserID = SelectSparyObj.GetComponent<BaseGameObjInfo>().UserID;
// spraysync.gameObjType = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjType;
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id, */"SPRAY_WATER_SYNC", spraysync);
}
}
private void FogToggleChange(bool value)
{
if (!value)
{
return;
}
if (SelectSparyObj.GetComponent<TruckMessage>())
{
return;
}
ParticleControlOfType currentparticle;
if (SelectSparyObj.GetComponent<FireManControl>().SelectParticleType == SprayParticleType.WaterFog)
{
currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>();
slider.value = (currentparticle.GetScaleValue() - 1) / 2.00f;
}
else
{
SelectSparyObj.GetComponent<FireManControl>().SetParticleType(SprayParticleType.WaterFog);
currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>();
slider.value = 0.5f;
}
//SelectSparyObj.GetComponent<FireManControl>().SetParticleType(SprayParticleType.WaterFog);
//ParticleControlOfType currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>(true);
//argue = 90 - slider.value * 180f;
//pointer.transform.rotation = Quaternion.Euler(0, 0, argue);
// NowSprayType = SprayParticleType.WaterFog;
if (currentparticle!=null)
{
//出水信息同步
SpraySyncData spraysync = new SpraySyncData();
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
spraysync.spraytype = SprayParticleType.WaterFog;
spraysync.IsOn = true;
spraysync.size = currentparticle.GetScaleValue();
spraysync.gameObjID = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjID;
// spraysync.UserID = SelectSparyObj.GetComponent<BaseGameObjInfo>().UserID;
//spraysync.gameObjType = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjType;
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
}
}
private void StraightToggleChange(bool value)
{
if (!value)
{
return;
}
if (SelectSparyObj.GetComponent<TruckMessage>())
{
return;
}
//SelectSparyObj.GetComponent<FireManControl>().SetParticleType(SprayParticleType.WaterStraight);
//ParticleControlOfType currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>(true);
ParticleControlOfType currentparticle;
if (SelectSparyObj.GetComponent<FireManControl>().SelectParticleType == SprayParticleType.WaterStraight)
{
currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>();
// slider.value = currentparticle.GetScaleValue() / 2.00f;
SprayParameter spray = GetSprayParameter(SelectSparyObj);
slider.value = GetSlideValue(spray, currentparticle.GetScaleValue());
PowerText.text = GetPower(spray, slider.value).ToString();
FlowText.text = GetFlow(spray, slider.value).ToString();
}
else
{
SelectSparyObj.GetComponent<FireManControl>().SetParticleType(SprayParticleType.WaterStraight);
currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>();
SprayParameter spray = GetSprayParameter(SelectSparyObj);
slider.value = GetSlideValue(spray, 0.2f);
PowerText.text = GetPower(spray, slider.value).ToString();
FlowText.text = GetFlow(spray, slider.value).ToString();
// slider.value = 0.5f;
}
if (currentparticle!=null)
{
//出水信息同步
SpraySyncData spraysync = new SpraySyncData();
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
spraysync.spraytype = SprayParticleType.WaterStraight;
spraysync.IsOn = true;
spraysync.size = currentparticle.GetScaleValue();
spraysync.gameObjID = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjID;
//spraysync.UserID = SelectSparyObj.GetComponent<BaseGameObjInfo>().UserID;
//spraysync.gameObjType = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjType;
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
}
//argue = 90 - slider.value * 180f;
//pointer.transform.rotation = Quaternion.Euler(0, 0, argue);
//NowSprayType = SprayParticleType.WaterStraight;
}
#region
//private void minusbuttonClick()
//{
// slider.value = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>(true).GetScaleValue() / 2;
// //slider.value = Mathf.Clamp((slider.value - (1 / 6)),0, 1);
// slider.value -= (1 / 6.00f);
// if (slider.value < 0.01)
// {
// slider.value = 0.01f;
// }
// //argue = 90 - slider.value * 180f;
// //pointer.transform.rotation = Quaternion.Euler(0, 0, argue);
// ParticleControlOfType currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>(true);
// if (currentparticle != null)
// {
// currentparticle.SetScaleValue(slider.value * 2);
// }
// if (SelectSparyObj.GetComponent<TruckBindWaterSource>())
// {
// SelectSparyObj.GetComponent<TruckBindWaterSource>().ParticleSize = slider.value * 2;
// }
// if (SelectSparyObj.GetComponent<FireManControl>())
// {
// SelectSparyObj.GetComponent<FireManControl>().ParticleSize = slider.value * 2;
// }
// if (slider.value < 0.01)
// {
// if (SelectSparyObj.GetComponent<TruckBindWaterSource>())
// {
// SelectSparyObj.GetComponent<TruckBindWaterSource>().ParticleSize = 0.1f * 2;
// }
// if (SelectSparyObj.GetComponent<FireManControl>())
// {
// SelectSparyObj.GetComponent<FireManControl>().ParticleSize = 0.1f * 2;
// }
// }
// //出水信息同步
// SpraySyncData spraysync = new SpraySyncData();
// spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
// // spraysync.spraytype = NowSprayType;
// spraysync.IsOn = true;
// spraysync.size = slider.value * 2;//currentparticle.GetScaleValue();
// spraysync.gameObjID = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjID;
// spraysync.UserID = SelectSparyObj.GetComponent<BaseGameObjInfo>().UserID;
// spraysync.gameObjType = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjType;
// NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
//}
//private void addbuttonClick()
//{
// slider.value = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>(true).GetScaleValue() / 2;
// ParticleControlOfType currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>(true);
// slider.value += (1 / 6.00f); //Mathf.Clamp( (slider.value + (1 / 6)),0, 1);
// //argue = 90 - slider.value * 180f;
// //pointer.transform.rotation = Quaternion.Euler(0, 0, argue);
// if (currentparticle != null)
// {
// currentparticle.SetScaleValue(slider.value * 2);
// }
// if (SelectSparyObj.GetComponent<TruckBindWaterSource>())
// {
// SelectSparyObj.GetComponent<TruckBindWaterSource>().ParticleSize = slider.value * 2;
// }
// if (SelectSparyObj.GetComponent<FireManControl>())
// {
// SelectSparyObj.GetComponent<FireManControl>().ParticleSize = slider.value * 2;
// }
// //出水信息同步
// SpraySyncData spraysync = new SpraySyncData();
// spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
// //spraysync.spraytype = NowSprayType;
// spraysync.IsOn = true;
// spraysync.size = currentparticle.GetScaleValue();
// spraysync.gameObjID = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjID;
// spraysync.UserID = SelectSparyObj.GetComponent<BaseGameObjInfo>().UserID;
// spraysync.gameObjType = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjType;
// NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
//}
#endregion
void SliderChange(float value)
{
ParticleControlOfType currentparticle = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>();
if (currentparticle==null)
{
return;
}
SprayParameter spray = GetSprayParameter(SelectSparyObj);
// slider.value = value; //Mathf.Clamp( (slider.value + (1 / 6)),0, 1);
float size = GetSize(spray, value);
float power = GetPower(spray, value);
float flow = GetFlow(spray, value);
if (SelectSparyObj.GetComponent<FireManControl>())
{
if (currentparticle.particleType == SprayParticleType.WaterFlower )
{
size = size * 10;
}
if (currentparticle.particleType == SprayParticleType.WaterFog)
{
size = 1.4f+size * 0.6f;
}
if (currentparticle.particleType == SprayParticleType.Froth)
{
size = 0.8f + 0.3f * value;
}
//if (currentparticle.particleType == SprayParticleType.WaterFlower || currentparticle.particleType == SprayParticleType.WaterFog)
//{
// //直流与开花喷雾的换算
// size = value * 2;
//}
}
//argue = 90 - slider.value * 180f;
//pointer.transform.rotation = Quaternion.Euler(0, 0, argue);
if (SelectSparyObj.GetComponent<TruckBindWaterSource>())
{
if (currentparticle.particleType == SprayParticleType.Froth)
{
size = 0.8f + 0.6f * value;
}
SelectSparyObj.GetComponent<TruckBindWaterSource>().ParticleSize = size;
}
if (SelectSparyObj.GetComponent<FireManControl>())
{
SelectSparyObj.GetComponent<FireManControl>().ParticleSize = size;
}
if (SelectSparyObj.GetComponent<WaterConnonController>())
{
if (currentparticle.particleType == SprayParticleType.Froth)
{
size = 0.8f + 0.6f * value;
}
SelectSparyObj.GetComponent<WaterConnonController>().ParticleSize = size;
}
if (SelectSparyObj.GetComponent<SnowConnonController>())
{
if (currentparticle.particleType == SprayParticleType.Froth)
{
size = 0.8f + 0.6f * value;
}
SelectSparyObj.GetComponent<SnowConnonController>().ParticleSize = size;
}
if (SelectSparyObj.GetComponent<FireRobotController>())
{
if (currentparticle.particleType == SprayParticleType.Froth)
{
size = 0.8f + 0.3f * value;
}
SelectSparyObj.GetComponent<FireRobotController>().ParticleSize = size;
}
if (currentparticle != null)
{
currentparticle.SetScaleValue(size);
}
//喷水物体流量设置
SetSelectFlow(SelectSparyObj, GetFlow(spray, slider.value));
//修改连接水源的总流量
//var data = new FlowValueChangeData()
//{
// gameobj=SelectSparyObj,
// flow=flow,
//};
//MessageDispatcher.SendMessage("FLOW_CHANGE", data);
//出水信息同步
SpraySyncData spraysync = new SpraySyncData();
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
spraysync.spraytype = SelectSparyObj.GetComponentInChildren<ParticleControlOfType>().particleType; //NowSprayType;
spraysync.IsOn = true;
spraysync.size = currentparticle.GetScaleValue();
spraysync.gameObjID = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjID;
// spraysync.UserID = SelectSparyObj.GetComponent<BaseGameObjInfo>().UserID;
//spraysync.gameObjType = SelectSparyObj.GetComponent<BaseGameObjInfo>().gameObjType;
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
//固定水泡单独做了同步,所以不再同步
if (SelectSparyObj.GetComponent<GuDingShuiPaoControl>())
{
SelectSparyObj.GetComponent<GuDingShuiPaoControl>().ChangeSize(size);
SelectSparyObj.GetComponent<GuDingShuiPaoControl>().Flow = flow;
}
//流量压力显示
PowerText.text = power.ToString();
FlowText.text = flow.ToString();
}
void UpClick()
{
if (SelectSparyObj.GetComponent<WaterConnonController>())
{//移动水泡
SelectSparyObj.GetComponent<WaterConnonController>().Up();
}
if (SelectSparyObj.GetComponent<FireManControl>())
{//消防员
SelectSparyObj.GetComponent<FireManControl>().Up();
}
if (SelectSparyObj.GetComponent<GuDingShuiPaoControl>())
{//固定水泡
SelectSparyObj.GetComponent<GuDingShuiPaoControl>().Up();
}
// 车辆水炮
if (SelectSparyObj.GetComponent<WaterGunRotate>())
{
SelectSparyObj.GetComponent<WaterGunRotate>().Up();
}
if (SelectSparyObj.GetComponent<SnowConnonController>())
{//暴风雪炮
SelectSparyObj.GetComponent<SnowConnonController>().Up();
}
if (SelectSparyObj.GetComponent<FireRobotController>())
{//暴风雪炮
SelectSparyObj.GetComponent<FireRobotController>().Up();
}
}
void DownClick()
{
if (SelectSparyObj.GetComponent<WaterConnonController>())
{//移动水泡
SelectSparyObj.GetComponent<WaterConnonController>().Down();
}
if (SelectSparyObj.GetComponent<FireManControl>())
{//消防员
SelectSparyObj.GetComponent<FireManControl>().Down();
}
if (SelectSparyObj.GetComponent<GuDingShuiPaoControl>())
{//固定水泡
SelectSparyObj.GetComponent<GuDingShuiPaoControl>().Down();
}
// 车辆水炮
if (SelectSparyObj.GetComponent<WaterGunRotate>())
{
SelectSparyObj.GetComponent<WaterGunRotate>().Down();
}
if (SelectSparyObj.GetComponent<SnowConnonController>())
{//暴风雪炮
SelectSparyObj.GetComponent<SnowConnonController>().Down();
}
if (SelectSparyObj.GetComponent<FireRobotController>())
{//暴风雪炮
SelectSparyObj.GetComponent<FireRobotController>().Down();
}
}
void LeftClick()
{
if (SelectSparyObj.GetComponent<WaterConnonController>())
{//移动水泡
SelectSparyObj.GetComponent<WaterConnonController>().Left();
}
if (SelectSparyObj.GetComponent<FireManControl>())
{//消防员
SelectSparyObj.GetComponent<FireManControl>().Left();
}
if (SelectSparyObj.GetComponent<GuDingShuiPaoControl>())
{//固定水泡
SelectSparyObj.GetComponent<GuDingShuiPaoControl>().Left();
}
// 车辆水炮
if (SelectSparyObj.GetComponent<WaterGunRotate>())
{
SelectSparyObj.GetComponent<WaterGunRotate>().Left();
}
if (SelectSparyObj.GetComponent<SnowConnonController>())
{//暴风雪炮
SelectSparyObj.GetComponent<SnowConnonController>().Left();
}
if (SelectSparyObj.GetComponent<FireRobotController>())
{//暴风雪炮
SelectSparyObj.GetComponent<FireRobotController>().Left();
}
}
void RightClick()
{
if (SelectSparyObj.GetComponent<WaterConnonController>())
{//移动水泡
SelectSparyObj.GetComponent<WaterConnonController>().Right();
}
if (SelectSparyObj.GetComponent<FireManControl>())
{//消防员
SelectSparyObj.GetComponent<FireManControl>().Right();
}
if (SelectSparyObj.GetComponent<GuDingShuiPaoControl>())
{//固定水泡
SelectSparyObj.GetComponent<GuDingShuiPaoControl>().Right();
}
// 车辆水炮
if (SelectSparyObj.GetComponent<WaterGunRotate>())
{
SelectSparyObj.GetComponent<WaterGunRotate>().Right();
}
if (SelectSparyObj.GetComponent<SnowConnonController>())
{//暴风雪炮
SelectSparyObj.GetComponent<SnowConnonController>().Right();
}
if (SelectSparyObj.GetComponent<FireRobotController>())
{//暴风雪炮
SelectSparyObj.GetComponent<FireRobotController>().Right();
}
}
/// <summary>
/// 消防员直流自动寻找火
/// </summary>
void StraightFindFireAuto()
{
}
/// <summary>
/// 根据喷水物体获取喷水压力流量参数
/// </summary>
/// <param name="select"></param>
/// <returns></returns>
SprayParameter GetSprayParameter(GameObject select)
{
SprayParameter spray = new SprayParameter();
if (select.GetComponent<TruckBindWaterSource>())
{
if (select.GetComponent<TruckBindWaterSource>().spraymode == SprayMode.PS30)
{
spray = SprayParameter.GetInfo(SprayMode.PS30);
}
else
{
spray = SprayParameter.GetInfo(SprayMode.PS20);
}
}
if (select.GetComponent<FireManControl>())
{
spray = SprayParameter.GetInfo(SprayMode.WaterGun19);
}
if (select.GetComponent<WaterConnonController>())
{
spray = SprayParameter.GetInfo(SprayMode.PS30);
}
if (select.GetComponent<GuDingShuiPaoControl>())
{
spray = SprayParameter.GetInfo(SprayMode.PS30);
}
if (select.GetComponent<SnowConnonController>())
{
spray = SprayParameter.GetInfo(SprayMode.PS30);
}
if (select.GetComponent<FireRobotController>())
{
spray = SprayParameter.GetInfo(SprayMode.WaterGun19);
}
return spray;
}
/// <summary>
/// 根据最大最小粒子参数获取滑动滚动条跟粒子大小的关系
/// </summary>
/// <param name="sp"></param>
/// <param name="value"></param>
/// <returns></returns>
float GetSize(SprayParameter sp, float value)
{
float size = 0;
size = (sp.maxsize - sp.minsize) * value + sp.minsize;
return size;
}
/// <summary>
/// 获取压力
/// </summary>
/// <param name="sp"></param>
/// <param name="value"></param>
/// <returns></returns>
float GetPower(SprayParameter sp, float value)
{
float power = 0;
power = (sp.maxpower - sp.minpower) * value + sp.minpower;
return power;
}
float GetFlow(SprayParameter sp, float value)
{
float flow = 0;
flow = (sp.maxflow - sp.minpower) * value + sp.minflow;
return flow;
}
/// <summary>
/// 根据粒子大小设置滚动条显示
/// </summary>
/// <param name="spray"></param>
/// <param name="size"></param>
/// <returns></returns>
float GetSlideValue(SprayParameter spray, float size)
{
float value = 0;
value = (size - spray.minsize) / (spray.maxsize - spray.minsize);
return value;
}
/// <summary>
/// 设置选中喷水物体的流量
/// </summary>
void SetSelectFlow(GameObject select, float flow)
{
if (select.GetComponentInChildren<ParticleControlOfType>()&&select.GetComponentInChildren<ParticleControlOfType>().particleType==SprayParticleType.Froth)
{
flow =flow* 0.97f;
}
if (select.GetComponent<FireManControl>())
{
select.GetComponent<FireManControl>().Flow = flow;
}
else if (select.GetComponent<TruckMessage>())
{
select.GetComponent<TruckBindWaterSource>().Flow = flow;
}
else if (select.GetComponent<WaterConnonController>())
{
select.GetComponent<WaterConnonController>().Flow = flow;
}
else if (select.GetComponent<GuDingShuiPaoControl>())
{
select.GetComponent<GuDingShuiPaoControl>().Flow = flow;
}
else if (select.GetComponent<SnowConnonController>())
{
select.GetComponent<SnowConnonController>().Flow = flow;
}
else if (select.GetComponent<FireRobotController>())
{
select.GetComponent<FireRobotController>().Flow = flow;
}
}
KeyValuePair<int, float> GetTimeAndWater(GameObject select)
{
var timewater = new KeyValuePair<int, float>();
if (select.GetComponent<FireManControl>())
{
timewater = new KeyValuePair<int, float>(
select.GetComponent<FireManControl>().RemainTime, select.GetComponent<FireManControl>().RemainWater);
}
if (select.GetComponent<WaterConnonController>())
{
timewater = new KeyValuePair<int, float>(
select.GetComponent<WaterConnonController>().RemainTime, select.GetComponent<WaterConnonController>().RemainWater);
}
if (select.GetComponent<TruckBindWaterSource>())
{
timewater = new KeyValuePair<int, float>(
select.GetComponent<TruckBindWaterSource>().RemainTime, select.GetComponent<TruckBindWaterSource>().RemainWater);
}
if (select.GetComponent<GuDingShuiPaoControl>())
{
timewater = new KeyValuePair<int, float>(-100, -100);
}
if (select.GetComponent<SnowConnonController>())
{
timewater = new KeyValuePair<int, float>(
select.GetComponent<SnowConnonController>().RemainTime, select.GetComponent<SnowConnonController>().RemainWater);
}
if (select.GetComponent<FireRobotController>())
{
timewater = new KeyValuePair<int, float>(
select.GetComponent<FireRobotController>().RemainTime, select.GetComponent<FireRobotController>().RemainWater);
}
return timewater;
}
string SecondToHMS(int second)
{
if (second == -100)
{
return "99:00:00";
}
else
{
int h = (int)(second / 3600);
int m = (int)(second - h * 3600) / 60;
int s = (int)(second - h * 3600 - m * 60);
return string.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);
}
}
}