撬棍逻辑
This commit is contained in:
@@ -33,6 +33,7 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
public Socket socket;
|
||||
public InteractiveLineSegment lineSegment; // 线段
|
||||
public ViewState viewState;
|
||||
public Image VisualspriteRender; // 新增字段,用于保存视图的图片
|
||||
|
||||
private bool _isAvailable = false; // 视图是否可用的私有字段
|
||||
|
||||
@@ -63,6 +64,8 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
// 是否正在进行视图过渡
|
||||
private bool isTransitioning = false;
|
||||
|
||||
public Button CloseBookButton;
|
||||
|
||||
// 视图状态枚举
|
||||
public enum ViewState
|
||||
{
|
||||
@@ -178,6 +181,15 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
{
|
||||
var optionDic = options.ToDictionary(item => item.Text, item => item);
|
||||
Debug.Log("Option dictionary keys: " + string.Join(", ", optionDic.Keys));
|
||||
if (optionDic.ContainsKey("CloseBook"))
|
||||
{
|
||||
CloseBookButton.onClick.AddListener(() =>
|
||||
{
|
||||
optionDic["CloseBook"].SelectOption();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
foreach (var viewConfig in viewConfigs)
|
||||
{
|
||||
@@ -341,6 +353,29 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
});
|
||||
}
|
||||
}
|
||||
[YarnCommand("SetViewVisual")]
|
||||
public void ChangeSprite(string viewStateName, string spriteName, bool isActive)
|
||||
{
|
||||
ViewState viewState;
|
||||
if (!Enum.TryParse(viewStateName, out viewState))
|
||||
{
|
||||
Debug.LogError("Invalid ViewState name: " + viewStateName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(viewState, out ViewConfig config)) return;
|
||||
|
||||
// 加载新的图片
|
||||
if (config.VisualspriteRender != null)
|
||||
{
|
||||
config.VisualspriteRender.sprite = Resources.Load<Sprite>(spriteName);
|
||||
|
||||
// 设置VisualspriteRender的激活状态
|
||||
bool activeStatus = isActive;
|
||||
config.VisualspriteRender.gameObject.SetActive(activeStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 从黑屏淡出
|
||||
private void FadeFromBlack(TweenCallback onComplete)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,140 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 239668b9d344929459599f24d5d627c4
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,10 +3,13 @@ tags:
|
||||
---
|
||||
<<indoor>>
|
||||
<<load_scene 佩佩视觉模块>>
|
||||
->打开书
|
||||
|
||||
->打开书并翻到第四页
|
||||
<<OpenBook BookManager>>
|
||||
我: 打开了
|
||||
->翻到第四页
|
||||
<<Flip BookManager 4 >>
|
||||
//页码需要在编辑内找到book去配置
|
||||
[command name=activate_socket_choice /]
|
||||
[options /]
|
||||
->CloseBook
|
||||
我: 嗯,刚刚的内容很有趣
|
||||
===
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f94d9e65ef7734a44af54eb61586965b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"projectFileVersion": 2,
|
||||
"sourceFiles": [
|
||||
"*.yarn"
|
||||
],
|
||||
"excludeFiles": [
|
||||
"**/*~/*"
|
||||
],
|
||||
"localisation": {},
|
||||
"baseLanguage": "zh-CHS",
|
||||
"compilerOptions": {}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 458a4fa326574294fac42576176de61f
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 053561912b1654d80a424bb0696a74ae, type: 3}
|
||||
useAddressableAssets: 0
|
||||
UseUnityLocalisationSystem: 0
|
||||
unityLocalisationStringTableCollection: {instanceID: 0}
|
||||
@@ -0,0 +1,6 @@
|
||||
title: Start
|
||||
tags:
|
||||
---
|
||||
<<indoor>>
|
||||
<<load_scene 佩佩视觉模块>>
|
||||
===
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3873fe34ec85fe64eb55505d5c9555e8
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 94073015eacc34c1d8fc6786e43d60ca, type: 3}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a29396a6175045d488caf12e1d0b1c46
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,144 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.UI;
|
||||
using Yarn.Unity;
|
||||
|
||||
public class Crowbar : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public float rotationSpeed = 10f; // 拖动旋转的速度
|
||||
public float rotationThreshold = 30f; // 触发撬动完成的旋转阈值
|
||||
|
||||
public Transform crowbarVisual;
|
||||
//public Transform crowbarBox;
|
||||
public Transform crowbarInPosition;
|
||||
//public Transform crowbarOutPosition;
|
||||
public Transform crowbarSocket;
|
||||
public bool IsInDialogue { get; set; } = false;
|
||||
|
||||
private Vector3 startPosition;
|
||||
private Quaternion startRotation;
|
||||
private bool isInserted = false;
|
||||
private Vector3 lastMousePosition;
|
||||
private float progress = 0f;
|
||||
private Image image;
|
||||
private bool isPryingCompleted = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
image = GetComponent<Image>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// startPosition = transform.position;
|
||||
// startRotation = transform.rotation;
|
||||
}
|
||||
|
||||
public void MoveIn()
|
||||
{
|
||||
//transform.DOMove(crowbarInPosition.position, 0.5f);
|
||||
}
|
||||
|
||||
public void MoveOut()
|
||||
{
|
||||
//transform.DOMove(crowbarOutPosition.position, 0.5f);
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if (IsInDialogue || isInserted) return;
|
||||
|
||||
image.raycastTarget = false;
|
||||
//crowbarSocket.Activate();
|
||||
|
||||
RectTransform canvasRectTransform = (RectTransform)transform.root;
|
||||
Vector3 worldPoint;
|
||||
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(canvasRectTransform, eventData.position, eventData.pressEventCamera, out worldPoint))
|
||||
{
|
||||
transform.position = worldPoint;
|
||||
}
|
||||
lastMousePosition = Input.mousePosition;
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
if (IsInDialogue || isPryingCompleted) return;
|
||||
|
||||
if (isInserted)
|
||||
{
|
||||
float deltaY = Input.mousePosition.y - lastMousePosition.y;
|
||||
progress = Mathf.Clamp01(progress+deltaY * Time.deltaTime);
|
||||
|
||||
// 计算插入旋转和插入旋转+35度之间的插值
|
||||
float startAngle = crowbarSocket.transform.eulerAngles.z;
|
||||
float endAngle = startAngle - 45f;
|
||||
float currentAngle = Mathf.Lerp(startAngle, endAngle, progress);
|
||||
|
||||
// 更新撬棍的旋转角度
|
||||
crowbarVisual.rotation = Quaternion.Euler(0f, 0f, currentAngle);
|
||||
|
||||
if (progress >= 1f)
|
||||
{
|
||||
// 触发撬动完成的逻辑
|
||||
Debug.Log("Crowbar action completed.");
|
||||
isPryingCompleted = true;
|
||||
//ResetCrowbar();
|
||||
ResetCrowbar();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RectTransform canvasRectTransform = (RectTransform)transform.root;
|
||||
Vector3 worldPoint;
|
||||
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(canvasRectTransform, eventData.position, eventData.pressEventCamera, out worldPoint))
|
||||
{
|
||||
transform.position = worldPoint;
|
||||
}
|
||||
}
|
||||
|
||||
lastMousePosition = Input.mousePosition;
|
||||
}
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
if (IsInDialogue) return;
|
||||
|
||||
if (isInserted)
|
||||
{
|
||||
ResetCrowbarProgress();
|
||||
}
|
||||
else
|
||||
{
|
||||
float snappingRange = 1f; // You might need to adjust this for WorldSpace Canvas
|
||||
if (Vector3.Distance(transform.position, crowbarSocket.transform.position) <= snappingRange)
|
||||
{
|
||||
transform.position = crowbarSocket.transform.position;
|
||||
crowbarVisual.rotation = crowbarSocket.transform.rotation;
|
||||
isInserted = true;
|
||||
//crowbarSocket.Deactivate();
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.DOMove(crowbarInPosition.position, 0.1f).OnComplete(() =>
|
||||
{
|
||||
//crowbarSocket.Deactivate();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetCrowbarProgress()
|
||||
{
|
||||
//isInserted = false;
|
||||
progress = 0f;
|
||||
crowbarVisual.rotation = startRotation;
|
||||
}
|
||||
private void ResetCrowbar()
|
||||
{
|
||||
isInserted=false;
|
||||
progress = 0f;
|
||||
crowbarVisual.rotation = startRotation;
|
||||
isPryingCompleted = false;
|
||||
transform.DOMove(crowbarInPosition.position, 0.1f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f0d3b645b9cb60418d0059fad6b7cc6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user