关卡中相机边距从配置表读取
parent
5e6bb4613f
commit
383e807b6c
|
|
@ -2,8 +2,8 @@ using System;
|
|||
using DG.Tweening;
|
||||
using Framework;
|
||||
using PhxhSDK;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
[ExecuteAlways]
|
||||
|
|
@ -530,7 +530,8 @@ public class CameraController : MonoBehaviour
|
|||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
public void InitializeCameraPosition(Vector3 targetPosition, MapData.CameraInfo cameraInfo = null)
|
||||
public void InitializeCameraPosition(Vector3 targetPosition, MapData.CameraInfo cameraInfo = null,
|
||||
float rightM = 0f, float leftM = 0f, float topM = 0f, float bottomM = 0f)
|
||||
{
|
||||
var useOrthographic = Application.isPlaying && CameraServiceLocator.CameraService.UseOrthographicMode;
|
||||
mainCamera.transform.position = CalculateCell2CameraPosition(targetPosition);
|
||||
|
|
@ -538,16 +539,16 @@ public class CameraController : MonoBehaviour
|
|||
// 进入关卡初始化相机边距
|
||||
if (cameraInfo != null)
|
||||
{
|
||||
rightMargin = cameraInfo.rightMarginInPre;
|
||||
leftMargin = cameraInfo.leftMarginInPre;
|
||||
topMargin = cameraInfo.topMarginInInPre;
|
||||
bottomMargin = cameraInfo.bottomMarginInPre;
|
||||
SetCameraFOVSize(cameraInfo.initialFOV);
|
||||
}
|
||||
rightMargin = rightM;
|
||||
leftMargin = leftM;
|
||||
topMargin = topM;
|
||||
bottomMargin = bottomM;
|
||||
|
||||
var rotEuler = useOrthographic ? cameraStartRotationO : cameraStartRotationP;
|
||||
mainCamera.transform.rotation = Quaternion.Euler(rotEuler);
|
||||
|
||||
|
||||
var currentPos = transform.position;
|
||||
transform.position = new Vector3(currentPos.x, CameraPositionStartY, currentPos.z);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class MapData
|
|||
[Serializable]
|
||||
public class CameraInfo
|
||||
{
|
||||
public float leftMarginInFight = 1.5f;
|
||||
/*public float leftMarginInFight = 1.5f;
|
||||
public float rightMarginInFight = 1.5f;
|
||||
public float topMarginInFight = 0.9f;
|
||||
public float bottomMarginInFight = 0.9f;
|
||||
|
|
@ -69,7 +69,7 @@ public class MapData
|
|||
public float leftMarginInPre = 1.5f;
|
||||
public float rightMarginInPre = 1.5f;
|
||||
public float topMarginInInPre = 0.9f;
|
||||
public float bottomMarginInPre = 0.9f;
|
||||
public float bottomMarginInPre = 0.9f;*/
|
||||
|
||||
public float initialFOV = 30f;
|
||||
public float initialOrthographicSize = 12f;
|
||||
|
|
|
|||
|
|
@ -90,8 +90,6 @@ public class MapManager : MonoBehaviour
|
|||
if (_map == null && MapData != null)
|
||||
{
|
||||
_map = MapUtils.LoadMap(TGS, MapData, isLegionMap);
|
||||
if (_map != null && CameraController)
|
||||
MapUtils.BindCameraController(CameraController.GetComponent<Camera>(), _map);
|
||||
}
|
||||
|
||||
return _map;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public static class MapUtils
|
|||
map?.Destroy();
|
||||
}
|
||||
|
||||
public static void BindCameraController(Camera camera, Map map)
|
||||
public static void BindCameraController(Camera camera, Map map, float rightMargin, float leftMargin, float topMargin, float bottomMargin)
|
||||
{
|
||||
var cameraController = camera.gameObject.GetComponent<CameraController>();
|
||||
if (!cameraController)
|
||||
|
|
@ -92,7 +92,7 @@ public static class MapUtils
|
|||
|
||||
cameraController.InitializeCameraPosition(
|
||||
map.BlockPosition2WorldPosition(map.MapData.initialCameraPosition),
|
||||
map.MapData.cameraMarginInfo);
|
||||
map.MapData.cameraMarginInfo,rightMargin, leftMargin, topMargin, bottomMargin);
|
||||
}
|
||||
|
||||
public static int Distance(Map map, int cellIndex1, int cellIndex2)
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public class MapManagerInspector : OdinEditor
|
|||
MapGridWindow.OpenWindow(Target, Target.isLegionMap);
|
||||
}
|
||||
|
||||
DrawCameraInfo();
|
||||
// DrawCameraInfo();
|
||||
if (GUILayout.Button("保存"))
|
||||
{
|
||||
Target.SaveMapData();
|
||||
|
|
@ -193,7 +193,7 @@ public class MapManagerInspector : OdinEditor
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawCameraInfo()
|
||||
/*private void DrawCameraInfo()
|
||||
{
|
||||
_isEditingCameraInfo = EditorGUILayout.Toggle("编辑相机间距", _isEditingCameraInfo);
|
||||
if (_isEditingCameraInfo)
|
||||
|
|
@ -216,7 +216,7 @@ public class MapManagerInspector : OdinEditor
|
|||
MapData.cameraMarginInfo.bottomMarginInPre =
|
||||
EditorGUILayout.FloatField("准备前相机下间距", MapData.cameraMarginInfo.bottomMarginInPre);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
private void DrawCheckCamera()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue