|
@@ -10,6 +10,7 @@ using UnityEngine.Networking;
|
|
|
using UnityEngine.UI;
|
|
|
using UnityAsync;
|
|
|
using WaitUntil = UnityAsync.WaitUntil;
|
|
|
+using Best.HTTP.Caching;
|
|
|
|
|
|
[System.Serializable]
|
|
|
public class YZTLayerData
|
|
@@ -91,8 +92,11 @@ public class YZTLayer : YZTRootLayer
|
|
|
public RectTransform layerInfo;
|
|
|
public Button layerInfoExitBtn;
|
|
|
|
|
|
+ public List<int> cancelLayer = new List<int>();
|
|
|
+
|
|
|
public Sprite[] sprites;
|
|
|
|
|
|
+
|
|
|
// Start is called before the first frame update
|
|
|
async void Awake()
|
|
|
{
|
|
@@ -122,6 +126,19 @@ public class YZTLayer : YZTRootLayer
|
|
|
}
|
|
|
|
|
|
void InitLayerInfo() {
|
|
|
+
|
|
|
+ Button[] btns = layerInfo.GetComponentsInChildren<Button>();
|
|
|
+ for (int i = 0; i < btns.Length - 2; i++) {
|
|
|
+ int temp = i;
|
|
|
+ btns[i].onClick.AddListener(() =>
|
|
|
+ {
|
|
|
+ bool active = btns[temp].GetComponent<CanvasGroup>().alpha > 0.5f;
|
|
|
+ btns[temp].GetComponent<CanvasGroup>().alpha = active ? 0.5f : 1.0f;
|
|
|
+ bool newActive = !active;
|
|
|
+ ChangeRuntimeLayer(temp, newActive);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
layerButton.onClick.AddListener(() => {
|
|
|
layerInfo.gameObject.SetActive(true);
|
|
|
});
|
|
@@ -216,7 +233,7 @@ public class YZTLayer : YZTRootLayer
|
|
|
}
|
|
|
layerBtns[index].SetUseful(true);
|
|
|
layerBtns[index].secContent.gameObject.SetActive(true);
|
|
|
- ChangeRuntimeLayer(index);
|
|
|
+ //ChangeRuntimeLayer(index);
|
|
|
});
|
|
|
|
|
|
layerBtn.SetLayerBtnData(layerSprite[layerDatas[i].layerID], layerDatas[i].layerName, num.ToString());
|
|
@@ -259,7 +276,32 @@ public class YZTLayer : YZTRootLayer
|
|
|
GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
|
|
|
for (int i = 0; i < GlobalData.hotPointDatas.Count; i++)
|
|
|
{
|
|
|
+
|
|
|
HotPointData temp = GlobalData.hotPointDatas[i];
|
|
|
+ Vector3 tempLocalPosition = CoordinateConverter.GeoToUGUISmall(temp.longitude, temp.latitude);
|
|
|
+ bool have = false;
|
|
|
+ for (int j = 0; j < runtimePointLib.Count; j++)
|
|
|
+ {
|
|
|
+ if (Vector3.Distance(tempLocalPosition, runtimePointLib[j].bingObj.transform.localPosition) < 0.1)
|
|
|
+ {
|
|
|
+ if (runtimePointLib[j].layerIDs.Contains((int)temp.type))
|
|
|
+ {
|
|
|
+ have = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ have = true;
|
|
|
+ runtimePointLib[j].Refresh(hotPointSprite[8]);
|
|
|
+ runtimePointLib[j].layerIDs.Add((int)temp.type);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (have) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
RuntimePoint newPoint = Instantiate(pointPrefab, Vector3.zero, Quaternion.identity);
|
|
|
int tempI = i;
|
|
|
newPoint.GetComponent<RectTransform>().SetParent(pointParent);
|
|
@@ -269,24 +311,46 @@ public class YZTLayer : YZTRootLayer
|
|
|
newPoint.bingObj.transform.SetParent(shaPan.transform.GetChild(6));
|
|
|
newPoint.bingObj.transform.localEulerAngles = Vector3.zero;
|
|
|
newPoint.bingObj.transform.localScale = Vector3.one;
|
|
|
- newPoint.bingObj.transform.localPosition = CoordinateConverter.GeoToUGUISmall(temp.longitude, temp.latitude);
|
|
|
+ newPoint.bingObj.transform.localPosition = tempLocalPosition;
|
|
|
newPoint.bingObj.name = temp.name;
|
|
|
+
|
|
|
+
|
|
|
newPoint.btn.onClick.AddListener(() =>
|
|
|
{
|
|
|
- CameraManager.SwitchCamera(0);
|
|
|
- viewMode = ViewMode.normal;
|
|
|
- if((int)temp.type >= 6)
|
|
|
+
|
|
|
+
|
|
|
+ if ((int)temp.type >= 6)
|
|
|
+ {
|
|
|
+ CameraManager.SwitchCamera(0);
|
|
|
+ viewMode = ViewMode.normal;
|
|
|
StaticLod.instance.OnFoucusStatic(newPoint.staticImp);
|
|
|
- yZT.gameObject.SetActive(true);
|
|
|
- ChangeRightContent(tempI);
|
|
|
- middleContent.gameObject.SetActive(false);
|
|
|
- rightContent.gameObject.SetActive(false);
|
|
|
- LeftBtnClick(1, false);
|
|
|
+ yZT.gameObject.SetActive(true);
|
|
|
+ int index = FindIndexByLayerUnitName(temp.name);
|
|
|
+ ChangeRightContent(index);
|
|
|
+ middleContent.gameObject.SetActive(false);
|
|
|
+ rightContent.gameObject.SetActive(false);
|
|
|
+ LeftBtnClick(1, false);
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
runtimePointLib.Add(newPoint);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ int FindIndexByLayerUnitName(string name) {
|
|
|
+ for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++) {
|
|
|
+ if (GlobalData.layerUnitDatas[i].name == name.Trim()) {
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //void OnNewPointClick(HotPointData temp,) {
|
|
|
+
|
|
|
+ //}
|
|
|
+
|
|
|
async Task InitData() {
|
|
|
await new WaitUntil(() => {
|
|
|
return GlobalData.layerUnitDatas.Count > 0;
|
|
@@ -317,11 +381,41 @@ public class YZTLayer : YZTRootLayer
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- void ChangeRuntimeLayer(int layer) {
|
|
|
+ void ChangeRuntimeLayer(int layer,bool show) {
|
|
|
+ if (show)
|
|
|
+ {
|
|
|
+ if (cancelLayer.Contains(layer))
|
|
|
+ {
|
|
|
+ cancelLayer.Remove(layer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (!cancelLayer.Contains(layer))
|
|
|
+ {
|
|
|
+ cancelLayer.Add(layer);
|
|
|
+ }
|
|
|
+ }
|
|
|
for (int i = 0; i < runtimePointLib.Count; i++) {
|
|
|
- runtimePointLib[i].gameObject.SetActive(false);
|
|
|
if (runtimePointLib[i].layerIDs.Contains(layer)) {
|
|
|
- runtimePointLib[i].gameObject.SetActive(true);
|
|
|
+ if (runtimePointLib[i].layerIDs.Count < 2)
|
|
|
+ {
|
|
|
+ runtimePointLib[i].gameObject.SetActive(show);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ List<int> tempLayers = new List<int>(runtimePointLib[i].layerIDs);
|
|
|
+ for (int j = 0; j < cancelLayer.Count; j++) {
|
|
|
+ if (tempLayers.Contains(cancelLayer[j])) {
|
|
|
+ tempLayers.Remove(cancelLayer[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tempLayers.Count < 1)
|
|
|
+ {
|
|
|
+ runtimePointLib[i].gameObject.SetActive(false);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ runtimePointLib[i].gameObject.SetActive(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|