视角切换&小地图模糊问题解决

This commit is contained in:
lishuo committed 2021-05-07 18:41:37 +08:00
1 parent 9bc3864790
commit e4d4333357
30 files changed
+3746 -2965

No files matched your search

+30 -12
View File
@@ -10,6 +10,7 @@ using System.Collections.Generic;
using UnityEngine.EventSystems;
using ChartAndGraph;
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
namespace Assets.Scenes.Ride.Scripts
{
@@ -60,7 +61,7 @@ namespace Assets.Scenes.Ride.Scripts
Button closeQuitButton;//退出panel关闭按钮
RawImage head;//海拔图头像
RawImage miniMap;//小地图
GameObject miniMap;//小地图
RawImage altitudeGraph;//海拔图
Image leftImage;
Image rightImage;
@@ -97,6 +98,8 @@ namespace Assets.Scenes.Ride.Scripts
Image nextSlopeImage;
Image currentSlopeImage;
Image miniMapProcess;
Text miniMapProcessText;
void Awake()
{
@@ -131,7 +134,7 @@ namespace Assets.Scenes.Ride.Scripts
head = transform.Find("Panel/GraphChart/HeadPanel/Head").GetComponent<RawImage>();
headPanel = transform.Find("Panel/GraphChart/HeadPanel").gameObject;
t = transform.Find("Panel/GraphChart/Button");
miniMap = transform.Find("Panel/MiniMap").GetComponent<RawImage>();
miniMap = transform.Find("Panel/MiniMap").gameObject;
alertPanel = transform.Find("Panel/Alert").gameObject;
@@ -176,6 +179,9 @@ namespace Assets.Scenes.Ride.Scripts
straightSmall = Resources.Load<Sprite>("Images/Ride/straight-small");
target = transform.parent.Find("Target").gameObject;
//小地图进度
miniMapProcess = transform.Find("Panel/MiniMap/Process").GetComponent<Image>();
miniMapProcessText = transform.Find("Panel/MiniMap/Process/Text").GetComponent<Text>();
UIManager.AddEvent(startBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, StartRide);
UIManager.AddEvent(simpleBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ClearPanel);
@@ -239,21 +245,24 @@ namespace Assets.Scenes.Ride.Scripts
fps.text = (1 / Time.deltaTime).ToString();
time = 1;
}
CountDown();
MoveCamera();
CountDown();
}
private float cameraX = 0;
private float cameraY = 0;
private float cameraZ = 0;
Transform player;
MapRoute routeInstance;
private void Init()
{
playerController = FindObjectOfType<PlayerController>();
mainController = FindObjectOfType<CyclingController>();
player = transform.parent.Find("Player");
var route = mainController.GetRoute();
mapName.text = route.RouteInstance.Name;
var camera = route.RouteInstance.Camera;
routeInstance = route.RouteInstance;
mapName.text = routeInstance.Name;
var camera = routeInstance.Camera;
if (!string.IsNullOrEmpty(camera))
{
var cameraArr = camera.Split(',');
@@ -311,20 +320,25 @@ namespace Assets.Scenes.Ride.Scripts
nearByPanel.SetActive(true);
}
}
Vector3 m = new Vector3(0.1f, 0.1f, 0.1f);
//移动摄像头和箭头位置
private void MoveCamera()
{
if (target != null)
{
target.transform.position = playerController.transform.position; //new Vector3((float)Math.Round(player.transform.position.x,1), 0, (float)Math.Round(player.transform.position.z,1));
target.transform.position = playerController.currentPos; //player.transform.position;// new Vector3((float)Math.Round(player.transform.position.x,1), 0, (float)Math.Round(player.transform.position.z,1));
if (!mainController.Is3dView)
{ //target.transform.rotation = playerController.transform.rotation;//new Quaternion(playerController.transform.rotation.x, playerController.transform.rotation.y +1f, playerController.transform.rotation.z, playerController.transform.rotation.w);
target.transform.eulerAngles = new Vector3(0, playerController.transform.eulerAngles.y + 160f, 0);
mainController.player.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
{
Vector3 v = Vector3.zero;
v.y += playerController.currentRotation.eulerAngles.y + 160f; //target.transform.rotation = playerController.transform.rotation;//new Quaternion(playerController.transform.rotation.x, playerController.transform.rotation.y +1f, playerController.transform.rotation.z, playerController.transform.rotation.w);
target.transform.eulerAngles = v; //.Set(0, playerController.currentRotation.eulerAngles.y + 160f, 0);// = new Vector3(0, playerController.transform.eulerAngles.y + 160f, 0);
//mainController.player.transform.localScale.Set(0.1f, 0.1f, 0.1f);
player.transform.localScale = m;
}
else
{
target.transform.eulerAngles = new Vector3(cameraX, cameraY, cameraZ);
target.transform.eulerAngles.Set(cameraX, cameraY, cameraZ);// = new Vector3(cameraX, cameraY, cameraZ);
}
//控制照片移动
((RectTransform)arrow.transform).position = Camera.main.WorldToScreenPoint(target.transform.position);
@@ -383,6 +397,10 @@ namespace Assets.Scenes.Ride.Scripts
currentSlopeText.text = Math.Round(playerController.CurrentSlope, 1).ToString() + "%";
currentSlopeDistanceText.GetComponent<NumberDotween>().AnimateNum((float)playerController.CurrentSlopeDistance, Math.Round(playerController.CurrentDistance, 0), playerController.CurrentIndex, 0, "{0}M");
totalClimb.text = Math.Round(playerController.TotalClimb, 0).ToString();
//小地图进度
var process = (float)(playerController.TotalDistance / routeInstance.Distance);
miniMapProcess.fillAmount = process;
miniMapProcessText.text = $"{process*100:f0}%";
//动态改变坡度图片
if (playerController.CurrentSlope >= 1)
{