Merge branch 'develop' into 6.14优化

This commit is contained in:
2025-06-14 21:13:41 +08:00
74 changed files with 10122 additions and 3192 deletions
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using DG.Tweening;
using JetBrains.Annotations;
using Newtonsoft.Json;
using UnityEngine;
using System.Collections;
using DG.Tweening;
namespace AibisDream.FixSystem
{
@@ -18,7 +13,10 @@ namespace AibisDream.FixSystem
private const string SocketObjName = "Socket";
public Transform socketPos;
private Transform _socketPos;
private Transform _socketLeft;
private Transform _socketRight;
private Tween _socketTween;
private BodyModuleSystem _bodyModuleSystem;
private Material _highlightMaterial;
@@ -44,6 +42,7 @@ namespace AibisDream.FixSystem
[SerializeField] public BodyModuleData data;
public bool available = true;
private bool _cutting;
private bool _isOpen;
private void Awake()
{
@@ -53,7 +52,10 @@ namespace AibisDream.FixSystem
private void InitReference()
{
socketPos = transform.Find(SocketObjName);
_socketPos = transform.Find(SocketObjName);
_socketLeft = _socketPos.Find("Left");
_socketRight = _socketPos.Find("Right");
_bodyModuleSystem = transform.parent.parent.GetComponent<BodyModuleSystem>();
_targetSpriteRenderer = transform.Find("Module Pic").GetComponent<SpriteRenderer>();
@@ -71,14 +73,6 @@ namespace AibisDream.FixSystem
_alarmMaterial = Resources.Load<Material>("Materials/AlarmMaterial");
}
private void Update()
{
if (_cutting && Input.GetMouseButton(0))
{
//OnCut();
}
}
#region
public bool IsAvailable()
@@ -104,7 +98,35 @@ namespace AibisDream.FixSystem
public Vector3 GetSocketPos()
{
return socketPos.position;
return _socketPos.position;
}
public void OpenPlugSlot()
{
if (!_socketLeft) return;
if (_isOpen) return;
_isOpen = true;
// 打开插槽
if (_socketTween is { active: true } && _socketTween.IsPlaying()) _socketTween.Kill(true);
var sequence = DOTween.Sequence();
sequence.Join(_socketLeft.DOScale(new Vector3(0, 1, 1), 0.1f).SetEase(Ease.InSine));
sequence.Join(_socketRight.DOScale(new Vector3(0, 1, 1), 0.1f).SetEase(Ease.InSine));
_socketTween = sequence;
}
public void ClosePlugSlot()
{
if (!_socketLeft) return;
if (!_isOpen) return;
_isOpen = false;
// 关闭插槽
if (_socketTween != null && _socketTween.IsPlaying()) _socketTween.Kill(true);
var sequence = DOTween.Sequence();
sequence.Join(_socketLeft.DOScale(new Vector3(1, 1, 1), 0.1f).SetEase(Ease.OutSine));
sequence.Join(_socketRight.DOScale(new Vector3(1, 1, 1), 0.1f).SetEase(Ease.OutSine));
_socketTween = sequence;
}
#endregion
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using AibisDream.Framework;
using Cinemachine;
using JetBrains.Annotations;
using UnityEngine;
namespace AibisDream.FixSystem
@@ -104,6 +105,12 @@ namespace AibisDream.FixSystem
var closestDistance = Mathf.Infinity;
BodyModule closestModule = null;
if (BodyModules is not { Count: > 0 })
{
targetModule = null;
return false;
}
// 寻找最接近的BodyModule
foreach (var bodyModule in BodyModules)
{
@@ -121,16 +128,35 @@ namespace AibisDream.FixSystem
}
}
bool res;
// 判断距离是否在目标范围内,在的话就返回,不在的话返回个空的
if (closestDistance < plugSnappingRange && closestModule)
{
targetModule = closestModule;
return true;
res = true;
}
else
{
targetModule = null;
return false;
res = false;
}
HandleModuleSlotState(targetModule);
return res;
}
private void HandleModuleSlotState([CanBeNull]BodyModule closestModule)
{
foreach (var bodyModule in BodyModules)
{
if (closestModule && bodyModule == closestModule)
{
bodyModule.OpenPlugSlot();
}
else
{
bodyModule.ClosePlugSlot();
}
}
}
@@ -275,6 +301,7 @@ namespace AibisDream.FixSystem
_headModuleGroup.transform.localPosition = _headModuleOriginalPos + new Vector3(0, yOffset, 0);
yield return null;
}
// ReSharper disable once IteratorNeverReturns
}
public void TriggerPainShake()
@@ -357,6 +384,7 @@ namespace AibisDream.FixSystem
_headModuleGroup.transform.localPosition = originalPos;
yield return new WaitForSeconds(0.5f);
}
// ReSharper disable once IteratorNeverReturns
}
}
@@ -26,12 +26,12 @@ namespace AibisDream.FixSystem
public bool isInDialog;
public bool isActive = true;
public bool isCableRetracted = true; // 线缆是否收起
public bool isCableRetracted = true; // 线缆是否收起
[SerializeField] private Transform retractedPos; // 收起位置
[SerializeField] private float dropDownDuration = 0.5f; // 放下动画时长
[SerializeField] private float swingDuration = 0.3f; // 摆动动画时长
[SerializeField] private float swingAngle = 15f; // 摆动角度
[SerializeField] private Transform retractedPos; // 收起位置
[SerializeField] private float dropDownDuration = 0.5f; // 放下动画时长
[SerializeField] private float swingDuration = 0.3f; // 摆动动画时长
[SerializeField] private float swingAngle = 15f; // 摆动角度
[HideInInspector] public ISocket curSocket;
[HideInInspector] public BodyModule curBodyModule;
@@ -108,7 +108,7 @@ namespace AibisDream.FixSystem
private void SaveCableState()
{
Debug.Log("Save cableRetractedstate"+isCableRetracted);
Debug.Log("Save cableRetractedstate" + isCableRetracted);
StorageSystem.Instance.SetValue(CABLE_RETRACTED_KEY, isCableRetracted);
}
@@ -123,7 +123,6 @@ namespace AibisDream.FixSystem
public void ResetPlug()
{
Debug.Log("ResetPlug");
// 不在初始插孔里,就从当前插孔拔出来,插回初始插孔
PlugRef.PullUpSocket();
PlugRef.ReturnToStartPosition();
@@ -180,7 +179,8 @@ namespace AibisDream.FixSystem
Disable_plugInput();
ResetPlug();
PlugRef.SetPhysicCableActive(false);
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName = CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName =
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
PlugRef.transform.DOMove(retractedPos.position, 0.1f).OnComplete(() =>
{
@@ -189,6 +189,7 @@ namespace AibisDream.FixSystem
SaveCableState();
});
}
public void DropDownCable()
{
if (!isCableRetracted) return;
@@ -217,7 +218,8 @@ namespace AibisDream.FixSystem
// 设置Plug位置和层级
PlugRef.transform.position = retractedPos.position;
PlugRef.transform.rotation = retractedPos.rotation;
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName = CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName =
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
isCableRetracted = true;
//SaveCableState();
+16 -15
View File
@@ -12,7 +12,7 @@ namespace AibisDream.FixSystem
public class Plug : MonoBehaviour, IInteraction
{
private static readonly int ShineFade = Shader.PropertyToID("_ShineFade");
#region
private Vector3 _startPos;
@@ -39,9 +39,10 @@ namespace AibisDream.FixSystem
private void Awake()
{
InitComponentRef();
EventRegister();
EventRegister();
_RetractedPos = transform.position;
_startPos = new Vector3(transform.position.x+0.3f, transform.position.y - 2f, transform.position.z); // 初始化时记录初始位置
_startPos = new Vector3(transform.position.x + 0.3f, transform.position.y - 2f,
transform.position.z); // 初始化时记录初始位置
}
private void InitComponentRef()
@@ -50,7 +51,7 @@ namespace AibisDream.FixSystem
_sprite = GetComponent<SpriteRenderer>();
_plugRootPos = transform.Find("Plug Root Pos");
_trigger = GetComponent<EventTriggerEx>();
// 处理插头高亮
_sprite.material.SetFloat(ShineFade, GlobalVariableKit.IsPlugHighLight ? 1 : 0);
}
@@ -62,7 +63,7 @@ namespace AibisDream.FixSystem
_trigger.Register(EventTriggerType.PointerUp, OnPointerUp);
}
/// <summary>
/// 插入某个socket
/// </summary>
@@ -138,8 +139,8 @@ namespace AibisDream.FixSystem
GetComponent<SpriteRenderer>().sortingOrder = 48;
// 系统被锁定就返回
if (!_cableSystem.IsPlugAvailable()) return;
// 首次拖拽后关闭高亮
if (GlobalVariableKit.IsPlugHighLight)
{
@@ -184,9 +185,10 @@ namespace AibisDream.FixSystem
public void ReturnToStartPosition()
{
PlugPosBack();
transform.DOMove(_startPos, 0.1f).OnComplete(() => {
transform.DOMove(_startPos, 0.1f).OnComplete(() =>
{
_cableSystem.CableReelRef.ResetRotation();
SwitchToPhysicCableState();
SwitchToPhysicCableState();
});
}
@@ -209,18 +211,21 @@ namespace AibisDream.FixSystem
_cableSystem.PhysicCableRef.GetComponent<LineRenderer>().enabled = true;
_isPhysicCableActive = true;
}
public void SetPhysicCableActive(bool active)
{
_isPhysicCableActive = active;
}
private void Update()
{
if (_isPhysicCableActive && !_cableSystem.isCableRetracted)
{
_cableSystem.PhysicCableRef.physicLine.UpdatePlug(this.transform);
_cableSystem.PhysicCableRef.physicLine.UpdatePlug(transform);
}
// 如果未锁定,就一直查询是否靠近最近的插孔
if (!_cableSystem.IsPlugAvailable()) return;
_cableSystem.TryFindClosestModule(transform.position, out _);
}
void OnDrawGizmosSelected()
@@ -238,10 +243,6 @@ namespace AibisDream.FixSystem
return gameObject;
}
public void SetStartPos(Vector3 pos)
{
_startPos = pos;
}
public Vector3 GetStartPos()
{
return _startPos;
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -14,7 +15,7 @@ namespace AibisDream
private Transform _taskListParent;
private GameObject _taskItemPrefab;
private readonly Dictionary<string, LocalizedText> _taskDict = new();
private readonly Dictionary<string, GameObject> _taskDict = new();
#endregion
@@ -26,15 +27,30 @@ namespace AibisDream
#region
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false)
// TODO 随时切换回头再加,先直接赋值
// public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false)
// {
// var taskItem = Instantiate(_taskItemPrefab, _taskListParent);
// // 设置本地化数据
//
// var localize = taskItem.GetComponent<LocalizedText>();
// localize.SetLocalizedText(DialogController.Instance.GetCurLocalizedTableName(), lineId);
// _taskDict[lineId] = localize;
//
// EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
// EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
// nextStep.Invoke();
// LayoutRebuilder.ForceRebuildLayoutImmediate(_taskListParent.GetComponent<RectTransform>());
// }
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId,
bool isAutoSkip = false)
{
var taskItem = Instantiate(_taskItemPrefab, _taskListParent);
// 设置本地化数据
var localize = taskItem.GetComponent<LocalizedText>();
localize.SetLocalizedText(DialogController.Instance.GetCurLocalizedTableName(), lineId);
_taskDict[lineId] = localize;
var task = taskItem.GetComponent<TMP_Text>();
task.text = $"\u25cf {dialogLine}";
_taskDict[lineId] = taskItem;
EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
nextStep.Invoke();
@@ -73,7 +89,7 @@ namespace AibisDream
{
if (_taskDict.Remove(lineId, out var taskItem))
{
Destroy(taskItem.gameObject);
Destroy(taskItem);
}
}
@@ -81,7 +97,7 @@ namespace AibisDream
{
foreach (var task in _taskDict)
{
Destroy(task.Value.gameObject);
Destroy(task.Value);
}
_taskDict.Clear();
}
@@ -118,7 +118,7 @@ public class TimelineManager : MonoBehaviour
/// 暂停指定的Timeline
/// </summary>
/// <param name="name">Timeline的名称</param>
[YarnCommand("pause_timeline")]
// [YarnCommand("pause_timeline")]
public void PauseTimeline(string name)
{
if (directors.TryGetValue(name, out var director))
+1
View File
@@ -108,6 +108,7 @@ namespace AibisDream
private IEnumerator LoadFirstScene()
{
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
yield return SceneLoader.Instance.LoadSceneAsync(_currentTalkSceneSo.Value.firstSceneName);
DialogController.Instance.StartDialog(_currentTalkSceneSo.Value.yarnProject);
}
+1
View File
@@ -93,6 +93,7 @@ namespace AibisDream
public IEnumerator Load()
{
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync();
yield return SceneLoader.Instance.LoadSceneAsync(sceneName);
}
}
@@ -4,6 +4,7 @@ using AibisDream.Framework;
using AibisDream.Kit;
using Cinemachine;
using UnityEngine;
using UnityEngine.Playables;
using Yarn.Unity;
namespace AibisDream
@@ -18,6 +19,8 @@ namespace AibisDream
public CinemachineVirtualCamera subwayCam;
public CinemachineVirtualCamera tvCam;
public PlayableDirector arriveStation;
public static StateMachine<OutSideState> StateMachine { get; private set; }
#endregion
@@ -49,6 +52,12 @@ namespace AibisDream
res.SetArgs(arg);
return res;
}
public IEnumerator ArriveAtStation()
{
arriveStation.Play();
yield return new WaitForSeconds((float) arriveStation.playableAsset.duration);
}
}
public struct SubwayState : IState<OutSideState>
@@ -92,5 +101,11 @@ namespace AibisDream
yield return SubwayCenter.StateMachine.SwitchState(targetState);
}
[YarnCommand("arrive_at_station")]
public static IEnumerator ArriveAtStation()
{
return SubwayCenter.Instance.ArriveAtStation();
}
}
}
@@ -35,5 +35,10 @@ namespace AibisDream
_localizeEvent.SetTable(table);
_localizeEvent.SetEntry(entry);
}
public void SetVariables()
{
}
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ namespace AibisDream.Utility
public const string CutLinePrefabName = "CutLine";
public const string TaskItemName = "Task Item";
public const string TaskItemName = "Task Item Temp";
public const string GearFollowerPrefabName = "GearFollower";