Merge branch '佩佩视觉模块优化' into 'develop'
佩佩视觉模块优化 See merge request aibis-dream/aibis-dream!113
This commit is contained in:
@@ -63,7 +63,7 @@ public void Initialize()
|
||||
|
||||
public void OnEnter()
|
||||
{
|
||||
SetInitialTargetState(targets[1]);
|
||||
//SetInitialTargetState(targets[1]);
|
||||
mouseFollowAndZoom.SetIsActive(true);
|
||||
mouseFollowAndZoom.SetIsLock(false);
|
||||
// 进入视图时的逻辑
|
||||
@@ -106,20 +106,6 @@ public void Initialize()
|
||||
eyeStateEffect?.InitializeEffect(target,cameraManager);
|
||||
}
|
||||
|
||||
// private void InitializeTargets()
|
||||
// {
|
||||
// // 查找所有带有EyeTarget标签的物体
|
||||
// GameObject[] eyeTargets = GameObject.FindGameObjectsWithTag("EyeTarget");
|
||||
// foreach (GameObject go in eyeTargets)
|
||||
// {
|
||||
// EyeTarget eyeTarget = go.GetComponent<EyeTarget>();
|
||||
// if (eyeTarget != null)
|
||||
// {
|
||||
// targets.Add(eyeTarget);
|
||||
// Debug.Log(eyeTarget.name+" add");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public EyeTarget FindEyeTargetByName(string name)
|
||||
{
|
||||
return Targets.FirstOrDefault(target => target.gameObject.name == name);
|
||||
@@ -146,6 +132,7 @@ public void Initialize()
|
||||
|
||||
if (currentTarget == target)
|
||||
{
|
||||
// DialogController.Instance.SetVariable("$currentEyeTarget",target.name);
|
||||
yield break;
|
||||
}
|
||||
DialogController.Instance.SetVariable("$currentEyeTarget",target.name);
|
||||
|
||||
@@ -267,7 +267,7 @@ Material:
|
||||
- _FrozenHighlightDensity: 1
|
||||
- _FrozenSnowContrast: 1
|
||||
- _FrozenSnowDensity: 0.25
|
||||
- _FullAlphaDissolveFade: 1
|
||||
- _FullAlphaDissolveFade: 0
|
||||
- _FullAlphaDissolveWidth: 0.5
|
||||
- _FullDistortionFade: 1
|
||||
- _FullGlowDissolveFade: 0.5
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bc541441973264418cfb40a9f7aec30
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
title: Start
|
||||
tags:
|
||||
---
|
||||
<<declare $StartNode="">>
|
||||
<<declare $EndNode="">>
|
||||
<<indoor>>
|
||||
<<ClearAllNode CanvasClueBoard>>
|
||||
<<OpenClueBoard ClueBoard>>
|
||||
|
||||
<<SetNodeState CanvasClueBoard Memory病床 true true>>
|
||||
|
||||
<<SetNodeState CanvasClueBoard EyeSky true>>
|
||||
|
||||
<<SetNodeState CanvasClueBoard EyePlant true>>
|
||||
|
||||
<<SetNodeState CanvasClueBoard EyePoster true>>
|
||||
|
||||
<<EnableQuestion CanvasClueBoard Memory病床>>
|
||||
|
||||
|
||||
|
||||
|
||||
===
|
||||
title: 检查ClueBoard
|
||||
tags:
|
||||
---
|
||||
<<if $StartNode=="Memory病床"&&$EndNode=="EyeSky">>
|
||||
<<ScrollToNode CanvasClueBoard EyeSky>>
|
||||
<<wait 1>>
|
||||
<<ScrollToNode CanvasClueBoard Memory病床>>
|
||||
<<endif>>
|
||||
===
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d135a3a01057914398e9dc018e6c883
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 94073015eacc34c1d8fc6786e43d60ca, type: 3}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"projectFileVersion": 2,
|
||||
"sourceFiles": [
|
||||
"*.yarn"
|
||||
],
|
||||
"excludeFiles": [
|
||||
"**/*~/*"
|
||||
],
|
||||
"localisation": {},
|
||||
"baseLanguage": "zh-CHS",
|
||||
"compilerOptions": {}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aebd92aaf26b32843866111558da0eb0
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 053561912b1654d80a424bb0696a74ae, type: 3}
|
||||
useAddressableAssets: 0
|
||||
UseUnityLocalisationSystem: 0
|
||||
unityLocalisationStringTableCollection: {instanceID: 0}
|
||||
@@ -16,18 +16,7 @@ public class ClueBaordNew : MonoBehaviour
|
||||
|
||||
private GraphManager gm;
|
||||
public List<GameObject> nodeLists;
|
||||
|
||||
// public List<Node> Day1InitnodeLists;
|
||||
|
||||
// public List<Node> Day2InitnodeLists;
|
||||
|
||||
// public List<Node> Day1AllnodeLists;
|
||||
|
||||
// public List<Node> Day2AllnodeLists;
|
||||
|
||||
public Notification ClueBoardNotification;
|
||||
//private Dictionary<string, Vector3> nodePositions = new Dictionary<string, Vector3>();
|
||||
|
||||
private Connection currentConnection;
|
||||
|
||||
private List<Connection> connectionList;
|
||||
@@ -53,6 +42,12 @@ public class ClueBaordNew : MonoBehaviour
|
||||
[YarnCommand("ScrollToNode")]
|
||||
public IEnumerator ScrollToNode(string nodeName)
|
||||
{
|
||||
if (scrollRect == null || contentRectTransform == null)
|
||||
{
|
||||
Debug.LogError("ScrollRect or ContentRectTransform is not assigned!");
|
||||
yield break;
|
||||
}
|
||||
|
||||
// 获取目标节点
|
||||
Transform targetNode = GetNodeGameObject(nodeName)?.transform;
|
||||
if (targetNode == null)
|
||||
@@ -68,41 +63,37 @@ public IEnumerator ScrollToNode(string nodeName)
|
||||
yield break;
|
||||
}
|
||||
|
||||
// **核心逻辑:计算目标 Content 位置**
|
||||
// 获取目标节点相对于 Content 的本地位置
|
||||
Vector2 nodeLocalPos = targetRectTransform.localPosition;
|
||||
// **计算目标 Content 位置**
|
||||
Vector3[] viewportCorners = new Vector3[4];
|
||||
scrollRect.viewport.GetWorldCorners(viewportCorners);
|
||||
|
||||
// Content 的目标位置 = 目标节点相对于 Content 的位置 - Viewport 的中心偏移
|
||||
Vector2 viewportCenterOffset = new Vector2(
|
||||
scrollRect.viewport.rect.width / 2,
|
||||
-scrollRect.viewport.rect.height / 2
|
||||
);
|
||||
Vector2 targetContentPos = -nodeLocalPos + viewportCenterOffset;
|
||||
Vector3[] contentCorners = new Vector3[4];
|
||||
contentRectTransform.GetWorldCorners(contentCorners);
|
||||
|
||||
// 限制 Content 的移动范围,防止超出边界
|
||||
// float minX = 0; // Content 左侧对齐
|
||||
// float minY = -contentRectTransform.rect.height + scrollRect.viewport.rect.height; // Content 底部对齐
|
||||
// float maxX = 0; // Content 不水平滚动
|
||||
// float maxY = 0; // Content 顶部对齐
|
||||
// targetContentPos = new Vector2(
|
||||
// Mathf.Clamp(targetContentPos.x, minX, maxX),
|
||||
// Mathf.Clamp(targetContentPos.y, minY, maxY)
|
||||
// );
|
||||
Vector3 targetWorldPosition = targetRectTransform.position;
|
||||
Vector2 viewportCenter = (viewportCorners[0] + viewportCorners[2]) / 2f;
|
||||
Vector2 offset = (Vector2)targetWorldPosition - viewportCenter;
|
||||
|
||||
// 平滑移动 Content 到目标位置
|
||||
contentRectTransform.DOAnchorPos(targetContentPos, scrollDuration).SetEase(Ease.InOutQuad);
|
||||
Vector2 targetContentPos = contentRectTransform.anchoredPosition - offset;
|
||||
|
||||
// 缩放目标节点
|
||||
targetRectTransform.DOScale(Vector3.one * 1.5f, scaleDuration).SetEase(Ease.OutBack);
|
||||
// **动画处理**
|
||||
float zoomScale = 1.5f; // 放大倍数
|
||||
Sequence scrollSequence = DOTween.Sequence();
|
||||
|
||||
// 等待动画完成
|
||||
yield return new WaitForSeconds(scrollDuration);
|
||||
// 平滑移动 Content
|
||||
scrollSequence.Append(contentRectTransform.DOAnchorPos(targetContentPos, scrollDuration).SetEase(Ease.InOutQuad));
|
||||
|
||||
// 同时缩放目标节点
|
||||
scrollSequence.Join(targetRectTransform.DOScale(Vector3.one * zoomScale, scaleDuration).SetEase(Ease.OutBack));
|
||||
|
||||
// 恢复目标节点缩放
|
||||
targetRectTransform.DOScale(Vector3.one, scaleDuration).SetEase(Ease.OutBack);
|
||||
// 动画完成后恢复缩放
|
||||
scrollSequence.Append(targetRectTransform.DOScale(Vector3.one, scaleDuration).SetEase(Ease.OutBack));
|
||||
|
||||
yield return scrollSequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
[YarnCommand("SetNodeState")]
|
||||
public IEnumerator ActiveNodeToBoard(string nodeID,bool isactive)
|
||||
public IEnumerator ActiveNodeToBoard(string nodeID,bool isactive,bool skipAnimation=false)
|
||||
{
|
||||
GameObject targetNode=nodeLists.Find(node => node.name == nodeID);
|
||||
if (targetNode == null)
|
||||
@@ -111,6 +102,11 @@ public IEnumerator ActiveNodeToBoard(string nodeID,bool isactive)
|
||||
yield break;
|
||||
}
|
||||
targetNode.gameObject.SetActive(isactive);
|
||||
|
||||
if(skipAnimation)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
RectTransform targetRectTransform = targetNode.GetComponent<RectTransform>();
|
||||
if (targetRectTransform == null)
|
||||
{
|
||||
@@ -124,7 +120,6 @@ public IEnumerator ActiveNodeToBoard(string nodeID,bool isactive)
|
||||
|
||||
// 恢复目标节点缩放
|
||||
targetRectTransform.DOScale(Vector3.one, scaleDuration).SetEase(Ease.OutBack);
|
||||
|
||||
}
|
||||
[YarnCommand("NodeInit")]
|
||||
public void NodeInit(string nodeID,bool isactive)
|
||||
@@ -165,39 +160,6 @@ public void NodeInit(string nodeID,bool isactive)
|
||||
{
|
||||
DialogController.Instance.StartDialogNode("退出ClueBoard");
|
||||
}
|
||||
// {
|
||||
// public void NodeInit(int day)
|
||||
// {
|
||||
// if(day==1)
|
||||
// {
|
||||
// gm.localConnections.Clear();
|
||||
// foreach(Node node in Day2AllnodeLists)
|
||||
// {
|
||||
// node.gameObject.SetActive(false);
|
||||
// }
|
||||
// foreach(Node node in Day1InitnodeLists)
|
||||
// {
|
||||
// node.gameObject.SetActive(true);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
// if(day==2)
|
||||
// {
|
||||
|
||||
// gm.localConnections.Clear();
|
||||
// foreach(Node node in Day1AllnodeLists)
|
||||
// {
|
||||
// node.gameObject.SetActive(false);
|
||||
// }
|
||||
// foreach(Node node in Day2InitnodeLists)
|
||||
// {
|
||||
// node.gameObject.SetActive(true);
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
public Node GetNode(string nodeID)
|
||||
{
|
||||
@@ -237,9 +199,6 @@ public void NodeInit(string nodeID,bool isactive)
|
||||
Targetconnection.line.animation.DrawLineAnimation(gm.lineRenderer,Targetconnection.line);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//[YarnCommand("CheckClueBoard")]
|
||||
public void CheckConnection(Connection connection)
|
||||
{
|
||||
currentConnection=connection;
|
||||
@@ -250,29 +209,6 @@ public void NodeInit(string nodeID,bool isactive)
|
||||
DialogController.Instance.StartDialogNode("检查ClueBoard");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if (connection.port0.node.ID == "UFImage" && connection.port1.node.ID == "MemoryGrass")
|
||||
// {
|
||||
// connection.DisableClick=false;
|
||||
// connection.EnableDrag=false;
|
||||
// DialogController.Instance.StartDialogNode("UF图像问题回答正确");
|
||||
// // GetNode("MemoryGrass").transform.GetChild(1).gameObject.SetActive(true);
|
||||
|
||||
// }
|
||||
// if (connection.port0.node.ID == "MemoryGrass" && connection.port1.node.ID == "EyePlant")
|
||||
// {
|
||||
// connection.DisableClick=false;
|
||||
// connection.EnableDrag=false;
|
||||
// DialogController.Instance.StartDialogNode("记忆问题回答正确");
|
||||
// }
|
||||
// if (connection.port0.node.ID == "手术" && connection.port1.node.ID == "solution")
|
||||
// {
|
||||
// connection.DisableClick=false;
|
||||
// connection.EnableDrag=false;
|
||||
// DialogController.Instance.StartDialogNode("执行手术");
|
||||
// }
|
||||
}
|
||||
[YarnCommand("ConnectionCantBreak")]
|
||||
public void SetConnectionProperties()
|
||||
@@ -287,36 +223,22 @@ public void NodeInit(string nodeID,bool isactive)
|
||||
currentConnection.EnableDrag=false;
|
||||
currentConnection.EnableHover=false;
|
||||
currentConnection.line.color=Color.red;
|
||||
//currentConnection.port0.node.
|
||||
//currentConnection=null;
|
||||
|
||||
}
|
||||
[YarnCommand("AddNodeConnection")]
|
||||
public void CreateConnection(string starNode,int startPort,string endNode,int endPort)
|
||||
{
|
||||
Node start= GetNode(starNode);
|
||||
Node end= GetNode(endNode);
|
||||
Connection newConnection=start.ports[startPort].ConnectTo(end.ports[endPort]);
|
||||
newConnection.DisableClick=false;
|
||||
newConnection.EnableDrag=false;
|
||||
gm.UnselectAllElements();
|
||||
newConnection.DisableClick=false;
|
||||
newConnection.EnableDrag=false;
|
||||
newConnection.EnableHover=false;
|
||||
newConnection.line.color=Color.green;
|
||||
//currentConnection=null;
|
||||
}
|
||||
|
||||
// [YarnCommand("AddNode")]
|
||||
// public void CreateNode(string NodeID)
|
||||
// [YarnCommand("AddNodeConnection")]
|
||||
// public void CreateConnection(string starNode,int startPort,string endNode,int endPort)
|
||||
// {
|
||||
// Node targetNode = nodeLists.Find(node => node.ID == NodeID);
|
||||
// if (targetNode == null)
|
||||
// {
|
||||
// Debug.LogWarning($"Node with ID {NodeID} not found.");
|
||||
// return;
|
||||
// }
|
||||
// targetNode.gameObject.SetActive(true);
|
||||
// Node start= GetNode(starNode);
|
||||
// Node end= GetNode(endNode);
|
||||
// Connection newConnection=start.ports[startPort].ConnectTo(end.ports[endPort]);
|
||||
// newConnection.DisableClick=false;
|
||||
// newConnection.EnableDrag=false;
|
||||
// gm.UnselectAllElements();
|
||||
// newConnection.DisableClick=false;
|
||||
// newConnection.EnableDrag=false;
|
||||
// newConnection.EnableHover=false;
|
||||
// newConnection.line.color=Color.green;
|
||||
// //currentConnection=null;
|
||||
// }
|
||||
[YarnCommand("EnableQuestion")]
|
||||
public void EnableQuestion(string nodeID)
|
||||
@@ -324,12 +246,6 @@ public void NodeInit(string nodeID,bool isactive)
|
||||
GetNode(nodeID).transform.GetChild(2).gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user