2222
This commit is contained in:
parent
9060c603eb
commit
c00de29a5f
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e8bda15086c08a34799dd52fdedadeca
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b8d4664f5fbc53a42894922de3bc7f8c
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
|
|
@ -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:
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,3 +1,4 @@
|
||||||
|
using DG.Tweening;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -22,7 +23,6 @@ public enum CurrentLevel
|
||||||
public class Bootstrap : MonoSingleton<Bootstrap>
|
public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
{
|
{
|
||||||
public LandMarksAndInfoController landMarkAndInfoCotroller;
|
public LandMarksAndInfoController landMarkAndInfoCotroller;
|
||||||
//public CurrentLevel currentLevel = CurrentLevel.ProvincialCapital;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 0 省会 1 城市 2 区县
|
/// 0 省会 1 城市 2 区县
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -51,29 +51,37 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 省会
|
/// 省会
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GameObject provincialCapital;
|
public Transform provincialCapital;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 城市
|
/// 城市
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GameObject[] citys;
|
public Transform cityParents;
|
||||||
public List<Transform> logicViewList = new List<Transform>();
|
/// <summary>
|
||||||
// Start is called before the first frame update
|
/// 县级区域
|
||||||
|
/// </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()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
landMarks = new List<string> { "网络负荷:49.84 kw", "上网负荷:49.84 kw", "削峰负荷:49.84 kw", "填谷负荷:49.84 kw", "发电负荷:49.84 kw" };
|
landMarks = new List<string> { "网络负荷:49.84 kw", "上网负荷:49.84 kw", "削峰负荷:49.84 kw", "填谷负荷:49.84 kw", "发电负荷:49.84 kw" };
|
||||||
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
||||||
cameraRt.onMax += Reduce;
|
cameraRt.OnLimitScroll += SwitchLand;
|
||||||
cameraRt.onMin += Amplify;
|
|
||||||
SwitchLand();
|
|
||||||
}
|
|
||||||
public void GotoView(string viewName, float _distance)
|
|
||||||
{
|
|
||||||
Transform viewTarget = logicViewList.Find(x => x.name == viewName);
|
|
||||||
|
|
||||||
cameraRt.SetTarget(viewTarget, _distance);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 展示地标
|
/// 展示地标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -81,12 +89,12 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
public void ShowLandMark(GameObject land)
|
public void ShowLandMark(GameObject land)
|
||||||
{
|
{
|
||||||
currentLand = land;
|
currentLand = land;
|
||||||
//currentLand.GetComponent<MeshRenderer>().materials[1].SetColor("_BaseCol", select.GetColor("_BaseCol"));
|
|
||||||
currentLand.GetComponent<MeshRenderer>().materials = select;
|
currentLand.GetComponent<MeshRenderer>().materials = select;
|
||||||
landMarkAndInfoCotroller.gameObject.SetActive(true);
|
landMarkAndInfoCotroller.gameObject.SetActive(true);
|
||||||
Vector3 worldToScreenPoint = Camera.main.WorldToScreenPoint(new Vector3(currentLand.transform.position.x, currentLand.transform.position.y, currentLand.transform.position.z));
|
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.GetComponent<RectTransform>().position = new Vector3(worldToScreenPoint.x, worldToScreenPoint.y, 0);
|
||||||
landMarkAndInfoCotroller.SetMarksInfo(currentLand.name, landMarks);
|
landMarkAndInfoCotroller.SetMarksInfo(currentLand.name, landMarks);
|
||||||
|
SwitchLevel(-1);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关闭地标
|
/// 关闭地标
|
||||||
|
|
@ -96,90 +104,160 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
||||||
if (currentLand != null)
|
if (currentLand != null)
|
||||||
{
|
{
|
||||||
//currentLand.GetComponent<MeshRenderer>().materials[1].SetColor("_BaseCol", mat.GetColor("_BaseCol"));
|
|
||||||
currentLand.GetComponent<MeshRenderer>().materials = mat;
|
currentLand.GetComponent<MeshRenderer>().materials = mat;
|
||||||
currentLand = null;
|
currentLand = null;
|
||||||
}
|
}
|
||||||
|
SwitchLevel(currentLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ·Å´ó
|
/// 2 省会 1 城市 0 区县
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Amplify()
|
public void SwitchLand(int _currentLevel)
|
||||||
{
|
{
|
||||||
if (currentLand == null) return;
|
if (currentLand == null) return;
|
||||||
currentLevel++;
|
currentLevel = _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()
|
|
||||||
{
|
|
||||||
|
|
||||||
switch (currentLevel)
|
switch (currentLevel)
|
||||||
{
|
{
|
||||||
case 0:
|
case 2:
|
||||||
Transform viewTarget = logicViewList.Find(x => x.name == "Ê¡»áÊÓ½Ç");
|
Debug.Log("省会");
|
||||||
cameraRt.SetTarget(viewTarget, 50, 120, 65);
|
for (int i = 0; i < cityParents.childCount; i++)
|
||||||
for (int i = 0; i < citys.Length; i++)
|
|
||||||
{
|
{
|
||||||
citys[i].SetActive(false);
|
cityParents.GetChild(i).gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
FadeOrUnFade(false);
|
lastCity = null;
|
||||||
|
SwitchMatShow(provincialCapital);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
cameraRt.SetTarget(currentLand.transform, 20, 100, 90);
|
Debug.Log("城市");
|
||||||
for (int i = 0; i < citys.Length; i++)
|
if (lastCity)
|
||||||
{
|
{
|
||||||
citys[i].SetActive(false);
|
if (currentArea != null)
|
||||||
if (citys[i].name.Equals(currentLand.name))
|
currentArea.SetActive(false);
|
||||||
citys[i].SetActive(true);
|
SwitchMatShow(lastCity);
|
||||||
}
|
lastCity = null;
|
||||||
FadeOrUnFade(true);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
mesh.GetComponent<Collider>().enabled = false;
|
for (int i = 0; i < cityParents.childCount; i++)
|
||||||
mesh.materials = opacity;
|
{
|
||||||
mesh.GetComponent<FadeController>().OnFadeUnFade(true);
|
var child = cityParents.GetChild(i).gameObject;
|
||||||
provincialCapital.SetActive(true);
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class CameraRT : MonoBehaviour
|
||||||
bool isAutoRotating = false;
|
bool isAutoRotating = false;
|
||||||
|
|
||||||
public bool isMove = true;
|
public bool isMove = true;
|
||||||
|
public int[] levels;
|
||||||
//动态调节相机缩放的灵敏度
|
//动态调节相机缩放的灵敏度
|
||||||
float tempSpeed;
|
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;
|
maxDistance = max;
|
||||||
minDistance = min;
|
minDistance = min;
|
||||||
target.position = _target.position;
|
//target.position = _target.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTarget(Transform _target)
|
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()
|
void Scroll()
|
||||||
{
|
{
|
||||||
distance -= Input.GetAxis("Mouse ScrollWheel") * mSpeed_scale;
|
distance -= Input.GetAxis("Mouse ScrollWheel") * mSpeed_scale;
|
||||||
distance = Mathf.Clamp(distance, minDistance, maxDistance);
|
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;
|
xSpeed_move = distance / maxDistance * tempSpeed;
|
||||||
ySpeed_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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对数值进行限制
|
// 对数值进行限制
|
||||||
|
|
|
||||||
|
|
@ -6,27 +6,30 @@ public class FadeController : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Material[] selfMaters;
|
public Material[] selfMaters;
|
||||||
public bool isFade = false;
|
public bool isFade = false;
|
||||||
public float speed = 1;
|
public float speed = 2;
|
||||||
void Update()
|
//public bool isGo = false;
|
||||||
{
|
//public float time = 0;
|
||||||
if (isFade)
|
//void Update()
|
||||||
{
|
//{
|
||||||
if (selfMaters != null)
|
// if (isFade)
|
||||||
{
|
// {
|
||||||
for (int i = 0; i < selfMaters.Length; i++)
|
// if (selfMaters != null)
|
||||||
{
|
// {
|
||||||
float current_Opacity = selfMaters[i].GetFloat("_Opacity");
|
// for (int i = 0; i < selfMaters.Length; i++)
|
||||||
float t = Mathf.Lerp(current_Opacity, 1, Time.deltaTime * speed);
|
// {
|
||||||
Debug.Log("Surface_mat_opacity==" + t);
|
// float current_Opacity = selfMaters[i].GetFloat("_Opacity");
|
||||||
if (t > 0.9f)
|
// float t = Mathf.Lerp(current_Opacity, 1, Time.deltaTime * speed);
|
||||||
{
|
// if (t > 0.9f)
|
||||||
t = 1;
|
// {
|
||||||
}
|
// t = 1;
|
||||||
selfMaters[i].SetFloat("_Opacity", t);
|
// }
|
||||||
}
|
// selfMaters[i].SetFloat("_Opacity", t);
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
public void OnFadeUnFade(bool _isFade)
|
public void OnFadeUnFade(bool _isFade)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ public class ThreeDController : MonoBehaviour
|
||||||
}
|
}
|
||||||
private void OnMouseExit()
|
private void OnMouseExit()
|
||||||
{
|
{
|
||||||
|
if (!GetComponent<MeshCollider>().enabled) return;
|
||||||
Bootstrap.Instance.CloseLandMark();
|
Bootstrap.Instance.CloseLandMark();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue