This commit is contained in:
2025-05-19 21:27:58 +08:00
parent 34aa1b7bf4
commit cfe8f8e5c1
14 changed files with 4761 additions and 1300 deletions
@@ -56,7 +56,7 @@ namespace AibisDream.FixSystem
{
if (_cutting && Input.GetMouseButton(0))
{
OnCut();
//OnCut();
}
}
@@ -112,66 +112,71 @@ namespace AibisDream.FixSystem
#endregion
#region
public void EnableCut()
public SpriteRenderer GetSpriteRenderer()
{
// 打开或获取CutLine
ShowCutLine();
_cutLine.OnCuttingDown += OnCuttingDown;
_cutting = true;
return _targetSpriteRenderer;
}
// public void EnableCut()
// {
// // 打开或获取CutLine
// ShowCutLine();
// _cutLine.OnCuttingDown += OnCuttingDown;
// _cutting = true;
EnumEventSystem.Global.Send(EventEnum.CutStart);
}
// EnumEventSystem.Global.Send(EventEnum.CutStart);
// }
private void OnCut()
{
Vector2 mousePos = CommonUtil.GetMouseWorldPos(Input.mousePosition);
_cutLine.DetectLineClick(mousePos, clickRadius);
}
// private void OnCut()
// {
// Vector2 mousePos = CommonUtil.GetMouseWorldPos(Input.mousePosition);
// _cutLine.DetectLineClick(mousePos, clickRadius);
// }
private void OnCuttingDown()
{
_cutLine.OnCuttingDown -= OnCuttingDown;
_cutting = false;
// 模块脱落
_cutLine.HideLine();
_bodyModuleSystem.RemoveModule(this);
ActionKit.Sequence()
.Delay(0.8f)
.DOTween(() => transform.DOMoveY(ConstRef.TweenEndY,
(transform.position.y - ConstRef.TweenEndY) / (ConstRef.FallSpeed * 0.6f))
.SetEase(Ease.InQuad))
.Callback(() => DialogController.Instance?.StartDialogNode($"{data.moduleName}CutDown"))
.Callback(() => EnumEventSystem.Global.Send(EventEnum.CutEnd))
.Start(this, () => Destroy(gameObject));
}
// private void OnCuttingDown()
// {
// _cutLine.OnCuttingDown -= OnCuttingDown;
// _cutting = false;
// // 模块脱落
// _cutLine.HideLine();
// _bodyModuleSystem.RemoveModule(this);
// ActionKit.Sequence()
// .Delay(0.8f)
// .DOTween(() => transform.DOMoveY(ConstRef.TweenEndY,
// (transform.position.y - ConstRef.TweenEndY) / (ConstRef.FallSpeed * 0.6f))
// .SetEase(Ease.InQuad))
// .Callback(() => DialogController.Instance?.StartDialogNode($"{data.moduleName}CutDown"))
// .Callback(() => EnumEventSystem.Global.Send(EventEnum.CutEnd))
// .Start(this, () => Destroy(gameObject));
// }
private void ShowCutLine()
{
// 切割线不存在,就新建一个
if (!_cutLine)
{
var prefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.CutLinePrefabName);
var cutLineObj = Instantiate(prefab, transform);
_cutLine = cutLineObj.GetComponent<CutLine>();
}
// private void ShowCutLine()
// {
// // 切割线不存在,就新建一个
// if (!_cutLine)
// {
// var prefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.CutLinePrefabName);
// var cutLineObj = Instantiate(prefab, transform);
// _cutLine = cutLineObj.GetComponent<CutLine>();
// }
// 对切割线进行初始化
var shapePoints = new List<Vector2>();
_targetSpriteRenderer.sprite.GetPhysicsShape(0, shapePoints);
if (shapePoints.Count <= 0)
{
Debug.LogWarning($"{name} has no shape");
return;
}
// // 对切割线进行初始化
// var shapePoints = new List<Vector2>();
// _targetSpriteRenderer.sprite.GetPhysicsShape(0, shapePoints);
// if (shapePoints.Count <= 0)
// {
// Debug.LogWarning($"{name} has no shape");
// return;
// }
// 本地坐标转世界坐标
var shapePointsV3 = shapePoints
.Select(item => _targetSpriteRenderer.transform.TransformPoint(item))
.ToList();
// // 本地坐标转世界坐标
// var shapePointsV3 = shapePoints
// .Select(item => _targetSpriteRenderer.transform.TransformPoint(item))
// .ToList();
_cutLine.Init(shapePointsV3, clickRadius);
}
// _cutLine.Init(shapePointsV3, clickRadius);
// }
#endregion
}