This commit is contained in:
YangHua 2024-06-23 09:39:45 +08:00
parent 9060c603eb
commit c00de29a5f
17 changed files with 179017 additions and 4369 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e8bda15086c08a34799dd52fdedadeca
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b8d4664f5fbc53a42894922de3bc7f8c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 9f12e1b2edda19446b0e0743be668dec
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- SimHei
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,3 +1,4 @@
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@ -22,7 +23,6 @@ public enum CurrentLevel
public class Bootstrap : MonoSingleton<Bootstrap>
{
public LandMarksAndInfoController landMarkAndInfoCotroller;
//public CurrentLevel currentLevel = CurrentLevel.ProvincialCapital;
/// <summary>
/// 0 省会 1 城市 2 区县
/// </summary>
@ -51,29 +51,37 @@ public class Bootstrap : MonoSingleton<Bootstrap>
/// <summary>
/// 省会
/// </summary>
public GameObject provincialCapital;
public Transform provincialCapital;
/// <summary>
/// 城市
/// </summary>
public GameObject[] citys;
public List<Transform> logicViewList = new List<Transform>();
// Start is called before the first frame update
public Transform cityParents;
/// <summary>
/// 县级区域
/// </summary>
public Transform areaParents;
private Transform lastCity;
private GameObject currentArea;
/// <summary>
/// 城市
/// </summary>
//public GameObject[] citys;
private Dictionary<Transform, Tween> _fadeTweens = new Dictionary<Transform, Tween>();
void Start()
{
landMarks = new List<string> { "网络负荷49.84 kw", "上网负荷49.84 kw", "削峰负荷49.84 kw", "填谷负荷49.84 kw", "发电负荷49.84 kw" };
landMarkAndInfoCotroller.gameObject.SetActive(false);
cameraRt.onMax += Reduce;
cameraRt.onMin += Amplify;
SwitchLand();
}
public void GotoView(string viewName, float _distance)
{
Transform viewTarget = logicViewList.Find(x => x.name == viewName);
cameraRt.SetTarget(viewTarget, _distance);
cameraRt.OnLimitScroll += SwitchLand;
}
/// <summary>
/// 展示地标
/// </summary>
@ -81,12 +89,12 @@ public class Bootstrap : MonoSingleton<Bootstrap>
public void ShowLandMark(GameObject land)
{
currentLand = land;
//currentLand.GetComponent<MeshRenderer>().materials[1].SetColor("_BaseCol", select.GetColor("_BaseCol"));
currentLand.GetComponent<MeshRenderer>().materials = select;
landMarkAndInfoCotroller.gameObject.SetActive(true);
Vector3 worldToScreenPoint = Camera.main.WorldToScreenPoint(new Vector3(currentLand.transform.position.x, currentLand.transform.position.y, currentLand.transform.position.z));
landMarkAndInfoCotroller.GetComponent<RectTransform>().position = new Vector3(worldToScreenPoint.x, worldToScreenPoint.y, 0);
landMarkAndInfoCotroller.SetMarksInfo(currentLand.name, landMarks);
SwitchLevel(-1);
}
/// <summary>
/// 关闭地标
@ -96,90 +104,160 @@ public class Bootstrap : MonoSingleton<Bootstrap>
landMarkAndInfoCotroller.gameObject.SetActive(false);
if (currentLand != null)
{
//currentLand.GetComponent<MeshRenderer>().materials[1].SetColor("_BaseCol", mat.GetColor("_BaseCol"));
currentLand.GetComponent<MeshRenderer>().materials = mat;
currentLand = null;
}
SwitchLevel(currentLevel);
}
/// <summary>
/// ·Å´ó
/// 2 省会 1 城市 0 区县
/// </summary>
public void Amplify()
public void SwitchLand(int _currentLevel)
{
if (currentLand == null) return;
currentLevel++;
if (currentLevel > 2)
{
currentLevel = 2;
}
SwitchLand();
}
/// <summary>
/// ËõС
/// </summary>
public void Reduce()
{
//if (currentLand == null) return;
currentLevel--;
if (currentLevel < 0)
{
currentLevel = 0;
}
SwitchLand();
}
public void SwitchLand()
{
currentLevel = _currentLevel;
switch (currentLevel)
{
case 0:
Transform viewTarget = logicViewList.Find(x => x.name == "Ê¡»áÊÓ½Ç");
cameraRt.SetTarget(viewTarget, 50, 120, 65);
for (int i = 0; i < citys.Length; i++)
case 2:
Debug.Log("省会");
for (int i = 0; i < cityParents.childCount; i++)
{
citys[i].SetActive(false);
cityParents.GetChild(i).gameObject.SetActive(false);
}
FadeOrUnFade(false);
lastCity = null;
SwitchMatShow(provincialCapital);
break;
case 1:
cameraRt.SetTarget(currentLand.transform, 20, 100, 90);
for (int i = 0; i < citys.Length; i++)
Debug.Log("城市");
if (lastCity)
{
citys[i].SetActive(false);
if (citys[i].name.Equals(currentLand.name))
citys[i].SetActive(true);
if (currentArea != null)
currentArea.SetActive(false);
SwitchMatShow(lastCity);
lastCity = null;
}
FadeOrUnFade(true);
else
{
for (int i = 0; i < cityParents.childCount; i++)
{
var child = cityParents.GetChild(i).gameObject;
child.SetActive(child.name == currentLand.name);
}
SwitchMatHide(provincialCapital);
}
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;
}
}
Debug.Log("区县");
break;
}
}
public void SwitchMatShow(Transform parent)
{
if (_fadeTweens.TryGetValue(parent, out var tween))
{
tween.Kill(true);
_fadeTweens.Remove(parent);
}
//bool isChange = true;
var renderers = parent.GetComponentsInChildren<MeshRenderer>();
List<Material> currentMaters = new List<Material>();
for (int i = 0; i < renderers.Length; i++)
{
for (int j = 0; j < renderers[i].materials.Length; j++)
{
currentMaters.Add(renderers[i].materials[j]);
}
}
tween = DOVirtual.Float(1, 0, 0.5f, t =>
{
for (int i = 0; i < currentMaters.Count; i++)
{
currentMaters[i].SetFloat("_Opacity", t);
}
}).OnComplete(() =>
{
for (int i = 0; i < renderers.Length; i++)
{
renderers[i].GetComponent<Collider>().enabled = true;
renderers[i].materials = mat;
}
_fadeTweens.Remove(parent);
});
_fadeTweens.Add(parent, tween);
}
private void SwitchMatHide(Transform parent)
{
if (_fadeTweens.TryGetValue(parent, out var tween))
{
tween.Kill(true);
_fadeTweens.Remove(parent);
}
var renderers = parent.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < renderers.Length; i++)
{
renderers[i].GetComponent<Collider>().enabled = false;
renderers[i].materials = opacity;
}
List<Material> currentMaters = new List<Material>();
for (int i = 0; i < renderers.Length; i++)
{
for (int j = 0; j < renderers[i].materials.Length; j++)
{
currentMaters.Add(renderers[i].materials[j]);
}
}
tween = DOVirtual.Float(0, 1, 0.5f, t =>
{
for (int i = 0; i < currentMaters.Count; i++)
{
currentMaters[i].SetFloat("_Opacity", t);
}
}).OnComplete(() =>
{
_fadeTweens.Remove(parent);
});
_fadeTweens.Add(parent, tween);
}
private void SwitchLevel(int currentLevel)
{
switch (currentLevel)
{
case -1:
cameraRt.SetMaxMinDistance(10f, 120f);
break;
case 0:
cameraRt.SetMaxMinDistance(10f, 20f);
break;
case 1:
cameraRt.SetMaxMinDistance(30f, 60f);
break;
case 2:
cameraRt.SetMaxMinDistance(70f, 120f);
break;
}
CloseLandMark();
}
private void FadeOrUnFade(bool isCity)
{
for (int i = 0; i < provincialCapital.transform.childCount; i++)
{
MeshRenderer mesh = provincialCapital.transform.GetChild(i).GetComponent<MeshRenderer>();
if (!isCity)
{
mesh.GetComponent<FadeController>().OnFadeUnFade(false);
mesh.materials = mat;
mesh.GetComponent<Collider>().enabled = true;
//provincialCapital.SetActive(false);
}
else
{
mesh.GetComponent<Collider>().enabled = false;
mesh.materials = opacity;
mesh.GetComponent<FadeController>().OnFadeUnFade(true);
provincialCapital.SetActive(true);
}
}
}
}

View File

@ -63,7 +63,7 @@ public class CameraRT : MonoBehaviour
bool isAutoRotating = false;
public bool isMove = true;
public int[] levels;
//动态调节相机缩放的灵敏度
float tempSpeed;
@ -85,12 +85,12 @@ public class CameraRT : MonoBehaviour
}
public void SetTarget(Transform _target, float min, float max, float defaultDis)
public void SetMaxMinDistance(float min, float max)
{
distance = defaultDis;
//distance = defaultDis;
maxDistance = max;
minDistance = min;
target.position = _target.position;
//target.position = _target.position;
}
public void SetTarget(Transform _target)
@ -221,46 +221,33 @@ public class CameraRT : MonoBehaviour
}
}
public bool isMaxOnece;
public bool isMinOnece;
public Action onMax;
public Action onMin;
public Action<int> OnLimitScroll;
public int currentLevelIndex = 2;
public int lastLevelIndex = 2;
void Scroll()
{
distance -= Input.GetAxis("Mouse ScrollWheel") * mSpeed_scale;
distance = Mathf.Clamp(distance, minDistance, maxDistance);
////判断缩放实现自动进入下一级和上一级
if (isMinOnece)
{
if (distance == minDistance)
{
onMin?.Invoke();
Debug.Log("到达最小缩放");
isMinOnece = false;
isMaxOnece = true;
}
else
{
//Debug.Log("最小缩放不相等");
}
}
if (isMaxOnece)
{
if (distance == maxDistance)
{
onMax?.Invoke();
Debug.Log("到达最大缩放");
isMaxOnece = false;
isMinOnece = true;
}
else
{
//Debug.Log("最大缩放不相等");
}
}
xSpeed_move = distance / maxDistance * tempSpeed;
ySpeed_move = distance / maxDistance * tempSpeed;
////判断缩放实现自动进入下一级和上一级
for (int i = 0; i < levels.Length; i++)
{
if (distance <= levels[i])
{
currentLevelIndex = i;
break;
}
}
if (currentLevelIndex != lastLevelIndex)
{
//Debug.Log($"currentLevelIndex=={currentLevelIndex}");
OnLimitScroll?.Invoke(currentLevelIndex);
lastLevelIndex = currentLevelIndex;
}
}
// 对数值进行限制

View File

@ -6,27 +6,30 @@ public class FadeController : MonoBehaviour
{
public Material[] selfMaters;
public bool isFade = false;
public float speed = 1;
void Update()
{
if (isFade)
{
if (selfMaters != null)
{
for (int i = 0; i < selfMaters.Length; i++)
{
float current_Opacity = selfMaters[i].GetFloat("_Opacity");
float t = Mathf.Lerp(current_Opacity, 1, Time.deltaTime * speed);
Debug.Log("Surface_mat_opacity==" + t);
if (t > 0.9f)
{
t = 1;
}
selfMaters[i].SetFloat("_Opacity", t);
}
}
}
}
public float speed = 2;
//public bool isGo = false;
//public float time = 0;
//void Update()
//{
// if (isFade)
// {
// if (selfMaters != null)
// {
// for (int i = 0; i < selfMaters.Length; i++)
// {
// float current_Opacity = selfMaters[i].GetFloat("_Opacity");
// float t = Mathf.Lerp(current_Opacity, 1, Time.deltaTime * speed);
// if (t > 0.9f)
// {
// t = 1;
// }
// selfMaters[i].SetFloat("_Opacity", t);
// }
// }
// }
//}
public void OnFadeUnFade(bool _isFade)
{

View File

@ -13,6 +13,7 @@ public class ThreeDController : MonoBehaviour
}
private void OnMouseExit()
{
if (!GetComponent<MeshCollider>().enabled) return;
Bootstrap.Instance.CloseLandMark();
}
}