s
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 插入点(DataInsertPoint) 转换 点(DataPoint)
|
||||
/// </summary>
|
||||
public class BuilderInsertPointToPoint : ModuleBuilder<DataInsertPoint, DataPoint> {
|
||||
|
||||
protected override void Awake() => ModuleCore.InsertPointToPoint = this;
|
||||
|
||||
public override DataPoint To(DataInsertPoint insertPoint) {
|
||||
DataPlate plate = insertPoint.plate;
|
||||
Vector3 position = insertPoint.position;
|
||||
//创建新的点
|
||||
DataPoint point = new DataPoint(insertPoint.plate);
|
||||
point.position = position;
|
||||
//改变关联的边B点,重置贝塞尔曲线
|
||||
insertPoint.side.bPoint = point;
|
||||
insertPoint.side.OneRankBezier();
|
||||
//创建新的边
|
||||
DataSide side = CreateDataSide(plate, point, insertPoint.bPoint);
|
||||
//插入边
|
||||
int sideIndex = plate.sides.IndexOf(insertPoint.side);
|
||||
plate.sides.Insert(sideIndex + 1, side);
|
||||
//插入点
|
||||
int pointIndex = plate.points.IndexOf(insertPoint.aPoint);
|
||||
plate.points.Insert(pointIndex + 1, point);
|
||||
//更新数据
|
||||
plate.UpdateVisual();
|
||||
return point;
|
||||
}
|
||||
|
||||
private DataSide CreateDataSide(DataPlate plate, DataPoint a, DataPoint b) {
|
||||
DataSide side = new DataSide(plate);
|
||||
side.aPoint = a;
|
||||
side.bPoint = b;
|
||||
side.OneRankBezier();
|
||||
return side;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 992dfa55aae34c040a024d7743bb1a8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 板片预设数据(DataPlatePresets) 转换 板片数据(DataPlate)
|
||||
/// </summary>
|
||||
public class BuilderPlatePresetsToPlate : ModuleBuilder<DataPlatePresets, DataPlate> {
|
||||
|
||||
protected override void Awake() => ModuleCore.PlatePresetsToPlate = this;
|
||||
|
||||
public override DataPlate To(DataPlatePresets origin) {
|
||||
DataPlate dataPlate = new DataPlate();
|
||||
dataPlate.points = ToDataPoint(dataPlate, origin.designPoints);
|
||||
dataPlate.sides = ToDataSide(dataPlate, dataPlate.points);
|
||||
return dataPlate;
|
||||
}
|
||||
|
||||
private List<DataPoint> ToDataPoint(DataPlate dataPlate, List<Vector3> list) {
|
||||
List<DataPoint> points = new List<DataPoint>();
|
||||
for (int i = 0; i < list.Count; i++) {
|
||||
DataPoint point = new DataPoint(dataPlate);
|
||||
point.position = list[i];
|
||||
points.Add(point);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
private List<DataSide> ToDataSide(DataPlate dataPlate, List<DataPoint> list) {
|
||||
List<DataSide> sides = new List<DataSide>();
|
||||
for (int i = 0; i < list.Count; i++) {
|
||||
DataSide side = new DataSide(dataPlate);
|
||||
side.aPoint = list.LoopIndex(i + 0);
|
||||
side.bPoint = list.LoopIndex(i + 1);
|
||||
side.OneRankBezier();
|
||||
sides.Add(side);
|
||||
}
|
||||
return sides;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 476a9d6720db7284fae46d62e046095d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 构造器
|
||||
/// 根据原型构造数据
|
||||
/// </summary>
|
||||
/// <typeparam name="Origin"></typeparam>
|
||||
/// <typeparam name="Data"></typeparam>
|
||||
public abstract class ModuleBuilder<Origin, Data> : MonoBehaviour {
|
||||
/// <summary> 必须要初始化 </summary>
|
||||
protected abstract void Awake();
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
|
||||
/// <summary> 根据原型构造数据 </summary>
|
||||
public abstract Data To(Origin origin);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37fd3673cacd6294f8a1de0ddc48768a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user