代码合并

This commit is contained in:
MuHua-123
2024-11-08 18:15:06 +08:00
parent 5f169b90bb
commit 497b43a446
146 changed files with 2858 additions and 110 deletions
@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MuHua;
public class PrefabPlateEdge : MonoBehaviour {
public LineRenderer lineRenderer;
public EdgeCollider2D edgeCollider;
[HideInInspector] public int index;
[HideInInspector] public DataPlate value;
public int MaxIndex => value.edgePoints.Count;
public int NextIndex => DataPlateTool.NormalIndex(index + 1, MaxIndex);
public Vector3 CurrentPosition => value.FindEdgePoint(index);
public Vector3 NextPosition => value.FindEdgePoint(NextIndex);
public void SetValue(int index, DataPlate value) {
this.index = index;
this.value = value;
value.OnChangeEdgePoint += UpdateLineRenderer;
UpdateLineRenderer(index);
}
private void OnDestroy() {
value.OnChangeEdgePoint -= UpdateLineRenderer;
}
public void UpdateLineRenderer(int index) {
if (index != this.index && index != NextIndex) { return; }
transform.localPosition = CurrentPosition;
Vector3 direction = NextPosition - CurrentPosition;
lineRenderer.SetPosition(1, direction);
edgeCollider.points = new Vector2[] { Vector2.zero, direction };
}
}