92 lines
1.9 KiB
C#
92 lines
1.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class ToolNewVector
|
|
{
|
|
[HideInInspector]
|
|
public Vector3 cursorPos;
|
|
[HideInInspector]
|
|
public List<Vector3> vector = new List<Vector3>();
|
|
|
|
public void Reset()
|
|
{
|
|
// for resetting the tool (when swapping around, initializing, etc)
|
|
vector.Clear();
|
|
}
|
|
|
|
public void Frame(Input input, Pixelgon pixelgon)
|
|
{
|
|
cursorPos = input.twistCursor;
|
|
|
|
int length = 0;
|
|
for (int i = 0; i < pixelgon.vectors.Count; i++)
|
|
{
|
|
if (pixelgon.vectors[i] == Vector3.zero)
|
|
{
|
|
length = 0;
|
|
}
|
|
else
|
|
{
|
|
if (length > 0)
|
|
{
|
|
// how to switch between edge snap and direction snap
|
|
// can you have them both happening at the same time?
|
|
// is it a priority based system?
|
|
cursorPos = StaticMethods.EdgeSnap(
|
|
pixelgon.vectors[i - 1],
|
|
pixelgon.vectors[i],
|
|
input.twistCursor
|
|
);
|
|
if (cursorPos != input.twistCursor)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
length++;
|
|
}
|
|
}
|
|
|
|
if (input.mainCon.trigger.down)
|
|
{
|
|
vector.Add(cursorPos);
|
|
vector.Add(cursorPos); // -> vector
|
|
}
|
|
|
|
if (vector.Count > 0)
|
|
{
|
|
if (input.mainCon.trigger.held)
|
|
{
|
|
if (input.mainCon.one.down)
|
|
{
|
|
vector.Add(cursorPos);
|
|
}
|
|
|
|
if (input.mainCon.two.down)
|
|
{
|
|
if (vector.Count > 2)
|
|
{
|
|
vector.RemoveAt(vector.Count - 1);
|
|
}
|
|
else
|
|
{
|
|
vector.Clear();
|
|
}
|
|
}
|
|
|
|
vector[vector.Count - 1] = cursorPos;
|
|
}
|
|
|
|
if (input.mainCon.trigger.up)
|
|
{
|
|
vector.Insert(0, Vector3.zero);
|
|
vector.Add(Vector3.zero);
|
|
pixelgon.vectors.AddRange(vector);
|
|
vector.Clear();
|
|
}
|
|
}
|
|
}
|
|
}
|