鼠标左键待优化

This commit is contained in:
YangHua 2024-06-28 01:15:53 +08:00
parent 6370664333
commit adff1ae9b0
9 changed files with 383542 additions and 36999 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,12 @@ using Adam;
using System;
using System.IO;
using Newtonsoft.Json;
[Serializable]
public class DependencyLevel
{
public int level;
public GameObject[] objs;
}
public class Bootstrap : MonoSingleton<Bootstrap>
{
@ -69,7 +75,8 @@ public class Bootstrap : MonoSingleton<Bootstrap>
[HideInInspector]
public RayHitTester rayHitTester;
public GameObject lastLand;
public GameObject shadowMap;
[Header("ÒÀ¸½Äĸö²ã¼¶ÉϵÄÎïÌå")]
public List<DependencyLevel> dependencyLevel = new List<DependencyLevel>();
public int clickCurrentLevel = 2;
[ContextMenu("1")]
@ -118,11 +125,11 @@ public class Bootstrap : MonoSingleton<Bootstrap>
if (hit.collider != null)
{
Debug.Log("clickCurrentLevel==" + clickCurrentLevel);
if (cameraRt.currentLevelIndex == 1) return;
if (cameraRt.currentLevelIndex == 0) return;
clickCurrentLevel--;
if (clickCurrentLevel <= 1)
if (clickCurrentLevel <= 0)
{
clickCurrentLevel = 1;
clickCurrentLevel = 0;
}
cameraRt.currentLevelIndex = clickCurrentLevel;
//currentLevel = clickCurrentLevel;
@ -158,13 +165,12 @@ public class Bootstrap : MonoSingleton<Bootstrap>
public async void ShowLandMark()
{
if (currentLand == null) return;
currentDistCode = currentLand.GetComponent<CityInfo>().distCode;
currentLand.GetComponent<MeshRenderer>().materials = select;
Vector3 worldToScreenPoint = Camera.main.WorldToScreenPoint(new Vector3(currentLand.transform.position.x, currentLand.transform.position.y, currentLand.transform.position.z));
lastLand = currentLand;
SwitchLevel(-1);
AreaData areaData = await AsyncWebReq.Get<AreaData>($"{urlDic["ľŘÍźľŻłöżň"]}{currentDistCode}", webAdapter.head, webAdapter.token);
if (!bool.Parse(areaData.success)) return;
AreaData areaData = currentLand.GetComponent<CityInfo>().areaData;
if (areaData != null && !bool.Parse(areaData.success)) return;
for (int i = 0; i < areaData.data.items.Count; i++)
{
string info = $"{areaData.data.items[i].label}:{areaData.data.items[i].value}{areaData.data.items[i].unit}";
@ -200,7 +206,6 @@ public class Bootstrap : MonoSingleton<Bootstrap>
landMarkAndInfoCotroller.gameObject.SetActive(false);
currentLevel = _currentLevel;
clickCurrentLevel = _currentLevel;
shadowMap.gameObject.SetActive(false);
switch (currentLevel)
{
case 2:
@ -210,7 +215,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
cityParents.GetChild(i).gameObject.SetActive(false);
}
lastCity = null;
shadowMap.gameObject.SetActive(true);
SwitchMatShow(provincialCapital);
break;
case 1:
@ -233,21 +238,27 @@ public class Bootstrap : MonoSingleton<Bootstrap>
}
break;
case 0:
//lastCity = currentLand.transform.parent;
//SwitchMatHide(lastCity);
//for (int i = 0; i < areaParents.childCount; i++)
//{
// var child = areaParents.GetChild(i).gameObject;
// child.SetActive(child.name == currentLand.name);
// if (child.activeSelf)
// {
// currentArea = child;
// }
//}
lastCity = currentLand.transform.parent;
SwitchMatHide(lastCity);
for (int i = 0; i < areaParents.childCount; i++)
{
var child = areaParents.GetChild(i).gameObject;
child.SetActive(child.name == currentLand.name);
if (child.activeSelf)
{
currentArea = child;
}
}
Debug.Log("ÇøÏØ");
break;
}
for (int i = 0; i < dependencyLevel.Count; i++)
{
for (int j = 0; j < dependencyLevel[i].objs.Length; j++)
{
dependencyLevel[i].objs[j].SetActive(dependencyLevel[i].level == currentLevel);
}
}
}
@ -259,7 +270,6 @@ public class Bootstrap : MonoSingleton<Bootstrap>
tween.Kill(true);
_fadeTweens.Remove(parent);
}
//bool isChange = true;
var renderers = GetMeshRenderers(parent);
List<Material> currentMaters = new List<Material>();
for (int i = 0; i < renderers.Count; i++)
@ -287,7 +297,8 @@ public class Bootstrap : MonoSingleton<Bootstrap>
{
for (int j = 0; j < renderers[i].transform.childCount; j++)
{
renderers[i].transform.GetChild(j).gameObject.SetActive(true);
bool isShow = renderers[i].transform.GetChild(j).GetComponent<AggregateStation>().isHaveValue;
renderers[i].transform.GetChild(j).gameObject.SetActive(isShow);
}
}
}
@ -309,9 +320,9 @@ public class Bootstrap : MonoSingleton<Bootstrap>
{
renderers[i].GetComponent<Collider>().enabled = false;
renderers[i].materials = opacity;
if(renderers[i].transform.childCount > 0)
if (renderers[i].transform.childCount > 0)
{
for(int j = 0; j< renderers[i].transform.childCount; j++)
for (int j = 0; j < renderers[i].transform.childCount; j++)
{
renderers[i].transform.GetChild(j).gameObject.SetActive(false);
}
@ -358,7 +369,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
switch (currentLevel)
{
case -1:
cameraRt.SetMaxMinDistance(30f, 120f);
cameraRt.SetMaxMinDistance(10f, 120f);
break;
case 0:
cameraRt.SetMaxMinDistance(10f, 20f);

View File

@ -8,6 +8,7 @@ public class AggregateStation : MonoBehaviour
public SpriteRenderer instruct;
public TMP_Text instructInfo;
public bool isHaveValue;
public void SetInfo(Sprite stationIcon, string num)
{
instruct.sprite = stationIcon;
@ -17,5 +18,6 @@ public class AggregateStation : MonoBehaviour
{
instructInfo.text = num;
gameObject.SetActive(num != "0");
isHaveValue = num != "0" ? true : false;
}
}

View File

@ -8,6 +8,7 @@ public class CityInfo : MonoBehaviour
public string cityName;
public ScreenTopStatistics sts = new ScreenTopStatistics();
public AreaData areaData = new AreaData();
public int Level = 0;
private void Start()
{
if (!GetComponent<Collider>())
@ -22,10 +23,38 @@ public class CityInfo : MonoBehaviour
public async void OnSetStationInfo()
{
if (distCode.Length == 6)
if (!string.IsNullOrEmpty(distCode) && distCode.Length == 6 && Level != 3)
{
DataController.Instance.loadingScreenTopStatisticsTasks.Add(DataController.Instance.GetProvincialLevelStationInfo(distCode, cityName));
sts = await DataController.Instance.GetProvincialLevelStationInfo(distCode, cityName);
else
}
else if (!string.IsNullOrEmpty(distCode) && distCode.Length == 4 && Level != 3)
sts = DataController.Instance.GetProvincialLevelStationDataByDistCode(distCode);
else
{
}
SetScreenTopStatistices(sts);
if (!string.IsNullOrEmpty(distCode) && distCode.Length == 6 && transform.parent.gameObject.activeSelf && Level != 3)
transform.parent.gameObject.SetActive(false);
if (Level == 3)
gameObject.SetActive(false);
}
public async void GetAreaData()
{
if (Level != 3)
{
if (!string.IsNullOrEmpty(distCode))
{
DataController.Instance.loadingAreaDataTasks.Add(DataController.Instance.GetAreaDataByDistCode(distCode));
areaData = await DataController.Instance.GetAreaDataByDistCode(distCode);
}
}
}
public void SetScreenTopStatistices(ScreenTopStatistics sts)
{
if (sts != null)
{
transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(sts.agentCons);
@ -42,14 +71,24 @@ public class CityInfo : MonoBehaviour
transform.GetChild(i).gameObject.SetActive(false);
}
}
if (distCode.Length == 6 && transform.parent.gameObject.activeSelf)
transform.parent.gameObject.SetActive(false);
}
public async void GetAreaData()
public void SetAreaData(AreaData a)
{
if (!string.IsNullOrEmpty(distCode))
areaData = await DataController.Instance.GetAreaDataByDistCode(distCode);
if (Level == 3)
{
areaData = a;
}
}
public void SetStationData(ScreenTopStatistics s)
{
if (Level == 3)
{
sts = s;
SetScreenTopStatistices(s);
}
}
}

View File

@ -8,15 +8,16 @@ using UnityEngine;
//@description:
//============================================================
public class DistanceAdjuster : MonoBehaviour
{
public float minDistance = 100;
public float maxDistance = 300;
public float minScale = 1;
public class DistanceAdjuster : MonoBehaviour
{
public float minDistance = 10;
public float maxDistance = 120;
private float minScale = 0.3f;
public float maxScale = 1;
private Camera _camera;
// Use this for initialization
private void Start () {
private void Start()
{
_camera = Camera.main;
}
@ -24,8 +25,8 @@ using UnityEngine;
{
var d = Vector3.Distance(transform.position, _camera.transform.position);
var s = Remap(d, minDistance, maxDistance, minScale, maxScale);
s= Mathf.Max(s, minScale);
s= Mathf.Min(s, maxScale);
s = Mathf.Max(s, minScale);
s = Mathf.Min(s, maxScale);
transform.localScale = Vector3.one * s;
}
@ -33,4 +34,4 @@ using UnityEngine;
{
return (value - inMin) / (inMax - inMin) * (outMax - outMin) + outMin;
}
}
}

View File

@ -6,21 +6,44 @@ using UnityEngine;
public class DataController : MonoSingleton<DataController>
{
public string distCode;
public AreaStationData areaStationData = new AreaStationData();
public CityInfo[] cityInfos;
private AreaStationData areaStationData = new AreaStationData();
private CityInfo[] cityInfos;
[HideInInspector]
public List<UniTask<AreaData>> loadingAreaDataTasks = new List<UniTask<AreaData>>();
[HideInInspector]
public List<UniTask<ScreenTopStatistics>> loadingScreenTopStatisticsTasks = new List<UniTask<ScreenTopStatistics>>();
private AreaData[] areaDatas;
private ScreenTopStatistics[] screenTopStatistics;
private async void Start()
{
await UniTask.Delay(1);
areaStationData = await GetProvincialLevelStationData("37");
cityInfos = transform.GetComponentsInChildren<CityInfo>();
for (int i = 0; i < cityInfos.Length; i++)
{
cityInfos[i].Init();
}
areaDatas = await UniTask.WhenAll(loadingAreaDataTasks);
for (int i = 0; i < cityInfos.Length; i++)
{
string distCodeTemp = cityInfos[i].distCode;
cityInfos[i].SetAreaData(GetAreaDateByDistCode(distCodeTemp));
}
screenTopStatistics = await UniTask.WhenAll(loadingScreenTopStatisticsTasks);
for (int i = 0; i < cityInfos.Length; i++)
{
string distCodeTemp = cityInfos[i].distCode;
cityInfos[i].SetStationData(GetAreLevelStationDataByDistCode(distCodeTemp));
}
}
/// <summary>
/// 针对区县
/// 针对市级
/// </summary>
/// <param name="_distCode"></param>
/// <param name="_disName"></param>
@ -36,10 +59,26 @@ public class DataController : MonoSingleton<DataController>
return null;
return sts.screenTopStatistics;
}
/// <summary>
/// 通过市级视角去获取数据 针对区县
/// </summary>
/// <param name="_distCode"></param>
/// <returns></returns>
public ScreenTopStatistics GetAreLevelStationDataByDistCode(string _distCode)
{
for (int i = 0; i < screenTopStatistics.Length; i++)
{
if (screenTopStatistics[i] != null && screenTopStatistics[i].distCode == _distCode)
{
return screenTopStatistics[i];
}
}
return null;
}
/// <summary>
/// 针对省级区域
/// 针对级区域
/// </summary>
/// <param name="_distCode"></param>
/// <returns></returns>
@ -62,13 +101,25 @@ public class DataController : MonoSingleton<DataController>
/// <returns></returns>
public async UniTask<AreaData> GetAreaDataByDistCode(string _distCode)
{
await UniTask.Delay(100);
await UniTask.Delay(2);
string url = Bootstrap.Instance.urlDic["華芞粟堤遺"];
AreaData areaData = await AsyncWebReq.Get<AreaData>($"{url}{_distCode}", Bootstrap.Instance.webAdapter.head, Bootstrap.Instance.webAdapter.token);
if (!bool.Parse(areaData.success)) return null;
if ( !bool.Parse(areaData.success)) return null;
return areaData;
}
public AreaData GetAreaDateByDistCode(string _distCode)
{
for (int i = 0; i < areaDatas.Length; i++)
{
if (areaDatas[i].data.distCode == _distCode)
{
return areaDatas[i];
}
}
return null;
}
/// <summary>
/// 鳳龰華芞颯軞
/// </summary>

View File

@ -11,7 +11,6 @@ GameObject:
- component: {fileID: 8450930769468669304}
- component: {fileID: 4813033407047159934}
- component: {fileID: 6902716355753532296}
- component: {fileID: 686787467225068926}
m_Layer: 0
m_Name: map
m_TagString: Untagged
@ -84,25 +83,3 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!64 &686787467225068926
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8874296918683621621}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 5
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}