using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Leak1Data { public long ID; public bool CatchFire; public Vector3 BottomScale; public BoxCollider BoxC; public float NowScale; public Transform BodyTransform; public float ShapRadius; } public class Leak1Controller : MonoBehaviour { public long OilTankId; public bool CatchFire; private float timmer = 1; private Leak1Data myData; private KeyValuePair Mydata; void Start() { myData = new Leak1Data(); Mydata = new KeyValuePair(); FireScaleValue.GetAllFireScales += addMyFireScale; } void Update() { timmer -= Time.deltaTime; if (timmer <= 0) { if (!CheckFireArround()) { timmer = 1; } } //if (Input.GetKeyDown(KeyCode.T)) //{ // Mydata = PushData(); // Debug.Log("ttttt"); // Debug.Log(Mydata.Value); //} //if (Input.GetKeyDown(KeyCode.S)) //{ // PullData(Mydata); // Debug.Log("ttttt1"); //} } void OnDestroy() { FireScaleValue.GetAllFireScales -= addMyFireScale; } private bool CheckFireArround() { bool hasFire = false; return hasFire; } public void Initialize(Vector3 hitPoint, OilTankMessage TankMsg) { float dis = 0; RaycastHit[] AllHit = Physics.RaycastAll(hitPoint, Vector3.down, 100f, LayerMask.NameToLayer("SoliderRoad")); foreach (RaycastHit hit in AllHit) { Debug.Log(hit.transform.name + "down"); //if (hit.transform.name.Contains("DiMian")) if (!hit.transform.parent.GetComponent() && hit.transform.name.Contains("Floor")) { dis = Vector3.Distance(hit.point, hitPoint); Debug.Log(dis); } } TankMsg.HasLeakeSet = true; ///如果是导调组或者灾情管理员 if ((CurrentUserInfo.room!=null&&CurrentUserInfo.mySelf.Id==CurrentUserInfo.room.Owner.UserInfo.Id) ||GameSettings.othersSettings.mode==Mode.DisasterManagement) { if (OilSetManager.GetInstance.gameObject.activeSelf) OilSetManager.GetInstance.ChuLiangSlider.GetComponent().interactable = false; } transform.localScale = new Vector3(1, dis / 9, 1); transform.Translate(Vector3.down * (dis / 2 - 0.4f)); Vector3 hitobjVec = TankMsg.transform.position; transform.LookAt(new Vector3(hitobjVec.x, transform.position.y, hitobjVec.z)); } /// /// 泄露火,统计过火面积 /// /// /// private FloatData addMyFireScale(FloatData data) { int tempMaxFireArea = Mathf.RoundToInt(GetComponent().size.x) * Mathf.RoundToInt(GetComponent().size.z); data.value += tempMaxFireArea; return data; } //public override KeyValuePair PushData() //{ // myData.ID = GetComponent().gameObjID; // myData.BodyTransform = transform; // myData.BoxC = GetComponent(); // myData.BottomScale = transform.Find("BottomOil").transform.localScale; // myData.BodyTransform = transform; // myData.NowScale = myData.BottomScale.x; // myData.ShapRadius = transform.Find("FireBottom").GetComponent().NowShape; // return new KeyValuePair(myData.ID, myData); //} //public override void PullData(KeyValuePair data) //{ // if (data.Key != GetComponent().gameObjID) // return; // myData = (Leak1Data)data.Value; // transform.localPosition = myData.BodyTransform.localPosition; // transform.localScale = myData.BodyTransform.localScale; // transform.localEulerAngles = myData.BodyTransform.localEulerAngles; // transform.localRotation = myData.BodyTransform.localRotation; // GetComponent().size = myData.BoxC.size; // transform.Find("BottomOil").transform.localScale = myData.BottomScale; // transform.Find("BottomOil").GetComponent().ranyouScale = myData.NowScale; // transform.Find("FireBottom/fire (8)").GetComponent().NowShape = myData.ShapRadius; // transform.Find("FireBottom").GetComponent().NowShape = myData.ShapRadius; //} }