Compare commits
No commits in common. "20d21f6c0a984e8a5e2368a9655fe777393c9555" and "c5e4fb72e9fed3db6b7b79d14628c705af263c54" have entirely different histories.
20d21f6c0a
...
c5e4fb72e9
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e8bda15086c08a34799dd52fdedadeca
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b8d4664f5fbc53a42894922de3bc7f8c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -1,21 +0,0 @@
|
|||
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,4 +1,3 @@
|
|||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -23,6 +22,7 @@ public enum CurrentLevel
|
|||
public class Bootstrap : MonoSingleton<Bootstrap>
|
||||
{
|
||||
public LandMarksAndInfoController landMarkAndInfoCotroller;
|
||||
//public CurrentLevel currentLevel = CurrentLevel.ProvincialCapital;
|
||||
/// <summary>
|
||||
/// 0 省会 1 城市 2 区县
|
||||
/// </summary>
|
||||
|
|
@ -51,37 +51,29 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
/// <summary>
|
||||
/// 省会
|
||||
/// </summary>
|
||||
public Transform provincialCapital;
|
||||
public GameObject provincialCapital;
|
||||
/// <summary>
|
||||
/// 城市
|
||||
/// </summary>
|
||||
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>();
|
||||
|
||||
public GameObject[] citys;
|
||||
public List<Transform> logicViewList = new List<Transform>();
|
||||
// Start is called before the first frame update
|
||||
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.OnLimitScroll += SwitchLand;
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 展示地标
|
||||
/// </summary>
|
||||
|
|
@ -89,12 +81,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>
|
||||
/// 关闭地标
|
||||
|
|
@ -104,161 +96,90 @@ 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 SwitchLand(int _currentLevel)
|
||||
public void Amplify()
|
||||
{
|
||||
if (currentLand == null) return;
|
||||
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
||||
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)
|
||||
{
|
||||
case 2:
|
||||
Debug.Log("省会");
|
||||
for (int i = 0; i < cityParents.childCount; i++)
|
||||
case 0:
|
||||
Transform viewTarget = logicViewList.Find(x => x.name == "Ê¡»áÊÓ½Ç");
|
||||
cameraRt.SetTarget(viewTarget, 50, 120, 65);
|
||||
for (int i = 0; i < citys.Length; i++)
|
||||
{
|
||||
cityParents.GetChild(i).gameObject.SetActive(false);
|
||||
citys[i].SetActive(false);
|
||||
}
|
||||
lastCity = null;
|
||||
SwitchMatShow(provincialCapital);
|
||||
FadeOrUnFade(false);
|
||||
break;
|
||||
case 1:
|
||||
Debug.Log("城市");
|
||||
if (lastCity)
|
||||
cameraRt.SetTarget(currentLand.transform, 20, 100, 90);
|
||||
for (int i = 0; i < citys.Length; i++)
|
||||
{
|
||||
if (currentArea != null)
|
||||
currentArea.SetActive(false);
|
||||
SwitchMatShow(lastCity);
|
||||
lastCity = null;
|
||||
citys[i].SetActive(false);
|
||||
if (citys[i].name.Equals(currentLand.name))
|
||||
citys[i].SetActive(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);
|
||||
FadeOrUnFade(true);
|
||||
break;
|
||||
case 2:
|
||||
cameraRt.SetMaxMinDistance(70f, 120f);
|
||||
break;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 SetMaxMinDistance(float min, float max)
|
||||
public void SetTarget(Transform _target, float min, float max, float defaultDis)
|
||||
{
|
||||
//distance = defaultDis;
|
||||
distance = defaultDis;
|
||||
maxDistance = max;
|
||||
minDistance = min;
|
||||
//target.position = _target.position;
|
||||
target.position = _target.position;
|
||||
}
|
||||
|
||||
public void SetTarget(Transform _target)
|
||||
|
|
@ -221,33 +221,46 @@ 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);
|
||||
xSpeed_move = distance / maxDistance * tempSpeed;
|
||||
ySpeed_move = distance / maxDistance * tempSpeed;
|
||||
////判断缩放实现自动进入下一级和上一级
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
if (isMinOnece)
|
||||
{
|
||||
if (distance <= levels[i])
|
||||
if (distance == minDistance)
|
||||
{
|
||||
currentLevelIndex = i;
|
||||
break;
|
||||
onMin?.Invoke();
|
||||
Debug.Log("到达最小缩放");
|
||||
isMinOnece = false;
|
||||
isMaxOnece = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("最小缩放不相等");
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLevelIndex != lastLevelIndex)
|
||||
if (isMaxOnece)
|
||||
{
|
||||
//Debug.Log($"currentLevelIndex=={currentLevelIndex}");
|
||||
OnLimitScroll?.Invoke(currentLevelIndex);
|
||||
lastLevelIndex = currentLevelIndex;
|
||||
if (distance == maxDistance)
|
||||
{
|
||||
onMax?.Invoke();
|
||||
Debug.Log("到达最大缩放");
|
||||
isMaxOnece = false;
|
||||
isMinOnece = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("最大缩放不相等");
|
||||
}
|
||||
}
|
||||
|
||||
xSpeed_move = distance / maxDistance * tempSpeed;
|
||||
ySpeed_move = distance / maxDistance * tempSpeed;
|
||||
}
|
||||
|
||||
// 对数值进行限制
|
||||
|
|
|
|||
|
|
@ -6,30 +6,27 @@ public class FadeController : MonoBehaviour
|
|||
{
|
||||
public Material[] selfMaters;
|
||||
public bool isFade = false;
|
||||
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 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 void OnFadeUnFade(bool _isFade)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ public class ThreeDController : MonoBehaviour
|
|||
}
|
||||
private void OnMouseExit()
|
||||
{
|
||||
if (!GetComponent<MeshCollider>().enabled) return;
|
||||
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