Merge branch 'bugfix/dialog' into 'develop'

dialog问题修改

See merge request aibis-dream/aibis-dream!276
This commit is contained in:
2025-02-22 19:06:38 +00:00
11 changed files with 300 additions and 2591 deletions
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 560a88da2bbc70140bed167f0ba7fe37
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fb01be13d6e88ca488dda82150319bfc
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 117dcc671050f5247bd8743b91ecaab7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because one or more lines are too long
+13 -9
View File
@@ -1053,15 +1053,19 @@ MonoBehaviour:
m_PostInfinity: 2
m_RotationOrder: 4
_filter:
- 0.007228916
- 0.043749984
- 0.12409639
- 0.20444278
- 0.24096388
- 0.20444278
- 0.12409639
- 0.043749984
- 0.007228916
- 0.0048309183
- 0.016401261
- 0.04532712
- 0.08293076
- 0.12053438
- 0.14946026
- 0.1610306
- 0.14946026
- 0.12053438
- 0.08293076
- 0.04532712
- 0.016401261
- 0.0048309183
--- !u!114 &-6086986437317696584
MonoBehaviour:
m_ObjectHideFlags: 3
Binary file not shown.
@@ -3,6 +3,7 @@ tags:
colorID: 8
position: -449,-3574
---
<<hide_dialog>>
<<play_clinic_cut>>
<<fade_in 1>>
<<switch_fix_system_to "BodyModule">>
+3 -113
View File
@@ -8254,9 +8254,9 @@ MonoBehaviour:
- {fileID: 11400000, guid: 8d8b11f0c2fbc4d4cb8c2857d98383c9, type: 2}
- {fileID: 11400000, guid: afc5b01ef301cc74db7cae741acad427, type: 2}
- {fileID: 11400000, guid: ac5ca9a66ff22ab4b9cd5adbdade6b8c, type: 2}
runMode: 0
runMode: 1
firstTalkSo: {fileID: 11400000, guid: ac5ca9a66ff22ab4b9cd5adbdade6b8c, type: 2}
testTalkSo: {fileID: 11400000, guid: 68a9c1b8c5230454bb9498fd2ab5714b, type: 2}
testTalkSo: {fileID: 11400000, guid: afc5b01ef301cc74db7cae741acad427, type: 2}
saveFileName: "PeipeiDay1_\u7ED3\u675F\u5BF9\u8BDD"
--- !u!4 &719228339
Transform:
@@ -13407,42 +13407,10 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 1604842429}
m_Modifications:
- target: {fileID: 4734035430968629439, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4734035430968629439, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4734035430968629439, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4734035430968629439, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4734035430968629439, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4734035430968629439, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5969022388722944562, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6059188073131988442, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_Name
value: Dialog Box
objectReference: {fileID: 0}
- target: {fileID: 6059188073131988442, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7131956091114956203, guid: e2211373480d40243a377721316dd8f7, type: 3}
propertyPath: m_Pivot.x
value: 0.5
@@ -13525,10 +13493,7 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 7131956091114956203, guid: e2211373480d40243a377721316dd8f7, type: 3}
insertIndex: 0
addedObject: {fileID: 4481270323425242496}
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e2211373480d40243a377721316dd8f7, type: 3}
--- !u!224 &1302630844 stripped
@@ -24009,32 +23974,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5620133977514361937}
m_CullTransparentMesh: 0
--- !u!222 &635920725062021162
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 639485488558054897}
m_CullTransparentMesh: 1
--- !u!1 &639485488558054897
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4481270323425242496}
- component: {fileID: 635920725062021162}
- component: {fileID: 3750012938176552409}
m_Layer: 5
m_Name: Dialog Box (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &641375504935977363
GameObject:
m_ObjectHideFlags: 0
@@ -35111,36 +35050,6 @@ RectTransform:
m_AnchoredPosition: {x: -272, y: 0}
m_SizeDelta: {x: 40, y: 40}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &3750012938176552409
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 639485488558054897}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: -683341770, guid: c8409501d0e34af47b749d1d13131442, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &3759593572619545997
GameObject:
m_ObjectHideFlags: 0
@@ -38062,25 +37971,6 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!224 &4481270323425242496
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 639485488558054897}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1302630844}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 150}
m_SizeDelta: {x: 1200, y: 300}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &4491849107062785388
RectTransform:
m_ObjectHideFlags: 0
+237 -224
View File
@@ -7,6 +7,7 @@ using AibisDream;
using System.Linq;
using DG.Tweening;
using AibisDream.FixSystem;
[System.Serializable]
public class LineSegmentInfo
{
@@ -14,11 +15,11 @@ public class LineSegmentInfo
public Transform StartTransform;
public Transform EndTransform;
}
public class LineManager : MonoBehaviour
{
public InteractiveLineSegment interactiveLineSegmentPrefab; // InteractiveLineSegment 的预制体
[SerializeField]
private List<LineSegmentInfo> lineSegmentInfos; // 线段信息的列表
public InteractiveLineSegment interactiveLineSegmentPrefab; // InteractiveLineSegment 的预制体
[SerializeField] private List<LineSegmentInfo> lineSegmentInfos; // 线段信息的列表
// 线段字典,用于快速查找
@@ -30,10 +31,7 @@ public class LineManager : MonoBehaviour
public bool IsScissorsMode
{
get
{
return isScissorsMode;
}
get { return isScissorsMode; }
set
{
isScissorsMode = value;
@@ -48,20 +46,23 @@ public class LineManager : MonoBehaviour
}
}
}
private Dictionary<string, InteractiveLineSegment> lineSegmentDictionary = new Dictionary<string, InteractiveLineSegment>();
private Dictionary<string, InteractiveLineSegment> lineSegmentDictionary =
new Dictionary<string, InteractiveLineSegment>();
private bool isTryLineCut = false;
private bool isLineCut = false;
public IEnumerable<string> GetLineSegmentNames()
{
return lineSegmentDictionary.Keys;
}
private InteractiveLineSegment currentLineSegment; // 当前要被剪断的线段
{
return lineSegmentDictionary.Keys;
}
private const float LONG_PRESS_THRESHOLD = 0.01f; // 长按阈值,可以根据需要调整
private float longPressTime = 0.0f; // 长按时间
private float detectionRadius=0.25f;
private InteractiveLineSegment currentLineSegment; // 当前要被剪断的线段
private const float LONG_PRESS_THRESHOLD = 0.01f; // 长按阈值,可以根据需要调整
private float longPressTime = 0.0f; // 长按时间
private float detectionRadius = 0.25f;
// [YarnCommand("wait_for_LineCut")]
// public IEnumerator WaitForClose()
@@ -79,7 +80,7 @@ private float detectionRadius=0.25f;
// }
// //ToolManager.Instance.ShowToolBoxAfterTask();
// }
private void Awake()
private void Awake()
{
Init();
}
@@ -89,176 +90,188 @@ private void Awake()
{
FixSystemCenter.SystemDic.Register(this);
}
private void SaveCutLine(string lineName)
{
PlayerPrefs.SetString(lineName, "cut");
PlayerPrefs.Save();
}
private bool IsLineCut(string lineName)
{
return PlayerPrefs.HasKey(lineName);
}
public void CutLine(InteractiveLineSegment originalLineSegment, Vector3 splitPoint)
{
// 如果线段不可剪断,就直接返回,不进行剪断操作
if (!originalLineSegment.IsCuttable)
private void SaveCutLine(string lineName)
{
return;
PlayerPrefs.SetString(lineName, "cut");
PlayerPrefs.Save();
}
AudioManager.RandomPlayInteraction("wire_cut");
// Create the first new line segment
GameObject firstLineSegmentObject = Instantiate(physicLineSegmentPrefab, transform);
PhysicLineSegment firstLineSegment = firstLineSegmentObject.GetComponent<PhysicLineSegment>();
firstLineSegment.Initialize(originalLineSegment.StartTransform.position, splitPoint);
firstLineSegment.lineRenderer.startColor=originalLineSegment.lineRenderer.startColor;
firstLineSegment.lineRenderer.endColor=originalLineSegment.lineRenderer.endColor;
private bool IsLineCut(string lineName)
{
return PlayerPrefs.HasKey(lineName);
}
// Create the second new line segment
GameObject secondLineSegmentObject = Instantiate(physicLineSegmentPrefab, transform);
PhysicLineSegment secondLineSegment = secondLineSegmentObject.GetComponent<PhysicLineSegment>();
secondLineSegment.Initialize(originalLineSegment.EndTransform.position,splitPoint);
secondLineSegment.lineRenderer.startColor=originalLineSegment.lineRenderer.startColor;
secondLineSegment.lineRenderer.endColor=originalLineSegment.lineRenderer.endColor;
// Immediately destroy the original line segment
Destroy(originalLineSegment.gameObject);
Debug.Log("线销毁了");
StartCoroutine(ScreenEffectManager.Instance.FlashRed(0.3f));
StartCoroutine(ScreenEffectManager.Instance.ShakeScreen());
SaveCutLine(originalLineSegment.name);
public void CutLine(InteractiveLineSegment originalLineSegment, Vector3 splitPoint)
{
// 如果线段不可剪断,就直接返回,不进行剪断操作
if (!originalLineSegment.IsCuttable)
{
return;
}
// Start the coroutine to destroy the new line segments after fade in and out
StartCoroutine(DestroyNewSegmentsAfterFade(firstLineSegmentObject, secondLineSegmentObject,originalLineSegment));
}
AudioManager.RandomPlayInteraction("wire_cut");
private IEnumerator DestroyNewSegmentsAfterFade(GameObject firstLineSegmentObject, GameObject secondLineSegmentObject,InteractiveLineSegment originalLineSegment)
{
yield return new WaitForSeconds(1.5f);
ToolManager.Instance.ShowToolBoxAfterTask();
yield return StartCoroutine(ScreenEffectManager.Instance.FadeIn(1));
Destroy(firstLineSegmentObject);
Destroy(secondLineSegmentObject);
yield return StartCoroutine(ScreenEffectManager.Instance.FadeOut(1));
isLineCut=true;
DialogController.Instance.SetVariable("$isLineCut",true);
DialogController.Instance.StartDialogNode("CutLine");
// Create the first new line segment
GameObject firstLineSegmentObject = Instantiate(physicLineSegmentPrefab, transform);
PhysicLineSegment firstLineSegment = firstLineSegmentObject.GetComponent<PhysicLineSegment>();
firstLineSegment.Initialize(originalLineSegment.StartTransform.position, splitPoint);
firstLineSegment.lineRenderer.startColor = originalLineSegment.lineRenderer.startColor;
firstLineSegment.lineRenderer.endColor = originalLineSegment.lineRenderer.endColor;
//originalLineSegment.Option.SelectOption();
}
// Create the second new line segment
GameObject secondLineSegmentObject = Instantiate(physicLineSegmentPrefab, transform);
PhysicLineSegment secondLineSegment = secondLineSegmentObject.GetComponent<PhysicLineSegment>();
secondLineSegment.Initialize(originalLineSegment.EndTransform.position, splitPoint);
secondLineSegment.lineRenderer.startColor = originalLineSegment.lineRenderer.startColor;
secondLineSegment.lineRenderer.endColor = originalLineSegment.lineRenderer.endColor;
// Immediately destroy the original line segment
Destroy(originalLineSegment.gameObject);
Debug.Log("线销毁了");
StartCoroutine(ScreenEffectManager.Instance.FlashRed(0.3f));
StartCoroutine(ScreenEffectManager.Instance.ShakeScreen());
SaveCutLine(originalLineSegment.name);
// Start the coroutine to destroy the new line segments after fade in and out
StartCoroutine(
DestroyNewSegmentsAfterFade(firstLineSegmentObject, secondLineSegmentObject, originalLineSegment));
}
private IEnumerator DestroyNewSegmentsAfterFade(GameObject firstLineSegmentObject,
GameObject secondLineSegmentObject, InteractiveLineSegment originalLineSegment)
{
yield return new WaitForSeconds(1.5f);
ToolManager.Instance.ShowToolBoxAfterTask();
yield return StartCoroutine(ScreenEffectManager.Instance.FadeIn(1));
Destroy(firstLineSegmentObject);
Destroy(secondLineSegmentObject);
yield return StartCoroutine(ScreenEffectManager.Instance.FadeOut(1));
isLineCut = true;
DialogController.Instance.SetVariable("$isLineCut", true);
DialogController.Instance.StartDialogNode("CutLine");
//originalLineSegment.Option.SelectOption();
}
private void AddPhysicsComponents(GameObject lineSegmentObject)
private void AddPhysicsComponents(GameObject lineSegmentObject)
{
// Add Rigidbody2D
Rigidbody2D rb = lineSegmentObject.AddComponent<Rigidbody2D>();
rb.gravityScale = 1; // Enable gravity
rb.gravityScale = 1; // Enable gravity
// Add HingeJoint2D
HingeJoint2D hinge = lineSegmentObject.AddComponent<HingeJoint2D>();
hinge.anchor = Vector2.zero; // Set the anchor at one end of the line segment
hinge.anchor = Vector2.zero; // Set the anchor at one end of the line segment
}
public void BindOptionToLineSegment(string lineSegmentName, YarnOption option)
{
InteractiveLineSegment lineSegment = GetLineSegmentByName(lineSegmentName);
if (lineSegment != null)
public void BindOptionToLineSegment(string lineSegmentName, YarnOption option)
{
if (option != null)
InteractiveLineSegment lineSegment = GetLineSegmentByName(lineSegmentName);
if (lineSegment != null)
{
lineSegment.Option = option;
Debug.Log("Binded option to " + lineSegmentName);
}
else
{
Debug.LogError("Option is null for " + lineSegmentName);
if (option != null)
{
lineSegment.Option = option;
Debug.Log("Binded option to " + lineSegmentName);
}
else
{
Debug.LogError("Option is null for " + lineSegmentName);
}
}
}
}
private void EnterLineSegment(InteractiveLineSegment lineSegment)
{
if (currentLineSegment != null)
{
lineSegment.OnHoverExit();
}
lineSegment.OnHover();
currentLineSegment = lineSegment;
}
private void LongPressLineSegment(InteractiveLineSegment lineSegment)
{
if(!lineSegment.IsCuttable)
{
DialogController.Instance.SetVariable("$isLineCut",false);
DialogController.Instance.StartDialogNode("CutLine");
Debug.Log("not cuttable");
//lineSegment.Option.SelectOption();
return;
}
longPressTime += Time.deltaTime;
Vector3 midpoint = (lineSegment.StartPoint + lineSegment.EndPoint) / 2;
float distance = Vector3.Distance(midpoint, lineSegment.StartPoint);
private void EnterLineSegment(InteractiveLineSegment lineSegment)
{
if (currentLineSegment != null)
{
lineSegment.OnHoverExit();
}
// Make the scissors shake and the line segment turn red
// if (longPressTime < LONG_PRESS_THRESHOLD)
// {
// customCursor.Shake(longPressTime * 5.0f, 10.0f); // 抖动强度随时间增加
// float progress = longPressTime / LONG_PRESS_THRESHOLD;
// // Calculate the new position of the color gradient
// float newPosition = progress * distance;
// }
// else
// {
lineSegment.OnHover();
currentLineSegment = lineSegment;
}
private void LongPressLineSegment(InteractiveLineSegment lineSegment)
{
if (!lineSegment.IsCuttable)
{
DialogController.Instance.SetVariable("$isLineCut", false);
DialogController.Instance.StartDialogNode("CutLine");
Debug.Log("not cuttable");
//lineSegment.Option.SelectOption();
return;
}
longPressTime += Time.deltaTime;
Vector3 midpoint = (lineSegment.StartPoint + lineSegment.EndPoint) / 2;
float distance = Vector3.Distance(midpoint, lineSegment.StartPoint);
// Make the scissors shake and the line segment turn red
// if (longPressTime < LONG_PRESS_THRESHOLD)
// {
// customCursor.Shake(longPressTime * 5.0f, 10.0f); // 抖动强度随时间增加
// float progress = longPressTime / LONG_PRESS_THRESHOLD;
// // Calculate the new position of the color gradient
// float newPosition = progress * distance;
// }
// else
// {
// Cut the line segment
CutLine(lineSegment,midpoint);
IsScissorsMode=false;
CutLine(lineSegment, midpoint);
IsScissorsMode = false;
Debug.Log("线剪断触发了");
// }
}
private void ExitLineSegment()
{
if (currentLineSegment != null)
{
currentLineSegment.OnHoverExit();
// }
}
currentLineSegment = null;
}
private void ExitLineSegment()
{
if (currentLineSegment != null)
{
currentLineSegment.OnHoverExit();
}
currentLineSegment = null;
}
private void Update()
{
if (isScissorsMode)
{
// Get the position of the mouse in world coordinates
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
// Check if there is a line segment in the scissors' detection range
Collider2D hitCollider = Physics2D.OverlapCircle(mousePosition, detectionRadius);
InteractiveLineSegment hitLineSegment = hitCollider != null ? hitCollider.GetComponent<InteractiveLineSegment>() : null;
if (hitLineSegment != null)
if (isScissorsMode)
{
EnterLineSegment(hitLineSegment);
// Get the position of the mouse in world coordinates
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
// Check if there is a line segment in the scissors' detection range
Collider2D hitCollider = Physics2D.OverlapCircle(mousePosition, detectionRadius);
InteractiveLineSegment hitLineSegment =
hitCollider != null ? hitCollider.GetComponent<InteractiveLineSegment>() : null;
if (hitLineSegment != null)
{
longPressTime = 0.0f;
EnterLineSegment(hitLineSegment);
if (Input.GetMouseButtonDown(0))
{
longPressTime = 0.0f;
}
else if (Input.GetMouseButton(0))
{
LongPressLineSegment(hitLineSegment);
}
else if (Input.GetMouseButtonUp(0))
{
longPressTime = 0.0f;
//customCursor.ResetRotation(); // 假设你有一个方法来重置剪刀的旋转
//currentLineSegment.ResetColor(); // 假设你有一个方法来重置线段的颜色
}
}
else if (Input.GetMouseButton(0))
else
{
LongPressLineSegment(hitLineSegment);
ExitLineSegment();
}
else if (Input.GetMouseButtonUp(0))
{
longPressTime = 0.0f;
//customCursor.ResetRotation(); // 假设你有一个方法来重置剪刀的旋转
//currentLineSegment.ResetColor(); // 假设你有一个方法来重置线段的颜色
}
}
else
{
ExitLineSegment();
}
}
}
// private void SetScissorsCursor()
// {
// // 启用自定义光标
@@ -272,86 +285,88 @@ private void ExitLineSegment()
// }
[YarnCommand("reconnected_line")]
public void Reconnected(string input)
{
// Use GetLineSegmentName method to find the recognized name
string recognizedName = GetLineSegmentName(input);
if (recognizedName == null)
[YarnCommand("reconnected_line")]
public void Reconnected(string input)
{
Debug.LogError("Invalid LineSegmentInfo name: " + input);
return;
}
// Use GetLineSegmentName method to find the recognized name
string recognizedName = GetLineSegmentName(input);
// Find the LineSegmentInfo with the recognized name
LineSegmentInfo lineSegmentInfo = lineSegmentInfos.Find(info => info.Name == recognizedName);
if (lineSegmentInfo == null)
{
Debug.LogError("Invalid LineSegmentInfo name: " + recognizedName);
return;
}
// If the line is already cut, skip it
// if (!IsLineCut(lineSegmentInfo.Name))
// {
// return;
// }
// Instantiate a new line segment with the given info
InteractiveLineSegment newSegment = Instantiate(interactiveLineSegmentPrefab, transform);
newSegment.StartTransform = lineSegmentInfo.StartTransform;
newSegment.EndTransform = lineSegmentInfo.EndTransform;
newSegment.Initialize();
}
[YarnCommand("delete_line")]
public void DeleteLine(string input)
{
// Use GetLineSegmentName method to find the recognized name
string recognizedName = GetLineSegmentName(input);
if (recognizedName == null)
{
Debug.LogError("Invalid LineSegmentInfo name: " + input);
return;
}
if (lineSegmentDictionary.ContainsKey(recognizedName))
{
InteractiveLineSegment lineSegmentToRemove = lineSegmentDictionary[recognizedName];
if (lineSegmentToRemove == null || lineSegmentToRemove.gameObject == null)
if (recognizedName == null)
{
Debug.LogWarning("Line segment already removed: " + recognizedName);
Debug.LogError("Invalid LineSegmentInfo name: " + input);
return;
}
// Destroy the line segment GameObject
Destroy(lineSegmentToRemove.gameObject);
Debug.Log("Line segment removed: " + recognizedName);
}
else
{
Debug.LogError("Line segment not found in dictionary: " + recognizedName);
}
}
// Find the LineSegmentInfo with the recognized name
LineSegmentInfo lineSegmentInfo = lineSegmentInfos.Find(info => info.Name == recognizedName);
private void Start()
{
foreach (LineSegmentInfo lineSegmentInfo in lineSegmentInfos)
if (lineSegmentInfo == null)
{
if (IsLineCut(lineSegmentInfo.Name))
{
continue;
Debug.LogError("Invalid LineSegmentInfo name: " + recognizedName);
return;
}
// If the line is already cut, skip it
// if (!IsLineCut(lineSegmentInfo.Name))
// {
// return;
// }
// Instantiate a new line segment with the given info
InteractiveLineSegment newSegment = Instantiate(interactiveLineSegmentPrefab, transform);
newSegment.StartTransform = lineSegmentInfo.StartTransform;
newSegment.EndTransform = lineSegmentInfo.EndTransform;
newSegment.Initialize();
}
[YarnCommand("delete_line")]
public void DeleteLine(string input)
{
// Use GetLineSegmentName method to find the recognized name
string recognizedName = GetLineSegmentName(input);
if (recognizedName == null)
{
Debug.LogError("Invalid LineSegmentInfo name: " + input);
return;
}
if (lineSegmentDictionary.ContainsKey(recognizedName))
{
InteractiveLineSegment lineSegmentToRemove = lineSegmentDictionary[recognizedName];
if (lineSegmentToRemove == null || lineSegmentToRemove.gameObject == null)
{
Debug.LogWarning("Line segment already removed: " + recognizedName);
return;
}
// Destroy the line segment GameObject
Destroy(lineSegmentToRemove.gameObject);
Debug.Log("Line segment removed: " + recognizedName);
}
else
{
Debug.LogError("Line segment not found in dictionary: " + recognizedName);
}
}
private void Start()
{
foreach (LineSegmentInfo lineSegmentInfo in lineSegmentInfos)
{
if (IsLineCut(lineSegmentInfo.Name))
{
continue;
}
InteractiveLineSegment newSegment = Instantiate(interactiveLineSegmentPrefab, transform);
newSegment.StartTransform = lineSegmentInfo.StartTransform;
newSegment.EndTransform = lineSegmentInfo.EndTransform;
newSegment.Initialize();
lineSegmentDictionary.Add(lineSegmentInfo.Name, newSegment);
}
}
}
public InteractiveLineSegment GetLineSegmentByName(string lineSegmentName)
{
@@ -365,6 +380,7 @@ private void Start()
return null;
}
}
public string GetLineSegmentName(string input)
{
// 转换为小写并移除所有的下划线
@@ -376,7 +392,8 @@ private void Start()
string[] lineSegmentWords = lineSegmentName.ToLower().Split('_');
// 检查是否包含相同的单词
if (inputWords.All(word => lineSegmentWords.Contains(word)) && lineSegmentWords.All(word => inputWords.Contains(word)))
if (inputWords.All(word => lineSegmentWords.Contains(word)) &&
lineSegmentWords.All(word => inputWords.Contains(word)))
{
return lineSegmentName;
}
@@ -384,6 +401,7 @@ private void Start()
return null;
}
// Yarn 命令,设置线段的可剪断性
[YarnCommand("set_line_cuttable")]
public void SetLineCuttable(string lineSegmentName, bool isCuttable)
@@ -402,16 +420,11 @@ private void Start()
Debug.LogError("Invalid line segment name: " + lineSegmentName);
}
}
// Yarn 命令,设置剪刀模式
// Yarn 命令,设置剪刀模式
[YarnCommand("set_scissors_mode")]
public void SetScissorsMode(bool isEnabled)
{
IsScissorsMode = isEnabled;
}
}
}
@@ -27,7 +27,7 @@ namespace AibisDream
{
InitQuickTalkButton();
InitEvent();
// 默认对话框直接加载
var box = transform.Find("Dialog Box").GetComponent<IDialogView>();
RegisterDialogView(DialogViewType.OldBox, box);
@@ -129,7 +129,7 @@ namespace AibisDream
{
_lastShowView?.HideDialog();
}
_lastShowView = _curView;
// 没有指定对话框,就用当前激活的
_curView.ShowLine(dialogLine, character, nextStep, onTextShowed, isAutoSkip);
@@ -140,7 +140,7 @@ namespace AibisDream
{
_lastShowView?.HideDialog();
}
_lastShowView = view;
// 对于指定了对话框的,就在指定对话框显示
view.ShowLine(dialogLine, character, nextStep, onTextShowed, isAutoSkip);
@@ -161,7 +161,7 @@ namespace AibisDream
}
else
{
_dialogViewDict[viewType].ShowOptions(dialogueOptions);
_dialogViewDict[viewType].ShowOptions(dialogueOptions);
}
}
@@ -172,12 +172,12 @@ namespace AibisDream
public bool TrySkipLine()
{
return _lastShowView.TrySkipLine();
return _lastShowView != null && _lastShowView.TrySkipLine();
}
public void NextStep()
{
_lastShowView.NextStep();
_lastShowView?.NextStep();
}
public void SwitchDialogView(DialogViewType dialogViewType)
@@ -185,6 +185,7 @@ namespace AibisDream
if (_dialogViewDict.TryGetValue(dialogViewType, out var view))
{
_curView.HideDialog();
_lastShowView?.HideDialog();
_lastShowView = null;
_curView = view;
}
@@ -32,7 +32,10 @@ namespace AibisDream
// 注册泡泡
DialogCanvasManager.Instance.RegisterDialogView(DialogViewType.Bubble, this);
DialogCanvasManager.Instance.SwitchDialogView(DialogViewType.Bubble);
}
private void Start()
{
HideDialog();
}
@@ -118,9 +121,9 @@ namespace AibisDream
EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
var next = _nextStep;
_nextStep = null;
_bubbleDict[_curRole].Hide();
next.Invoke();
}