ababa
This commit is contained in:
parent
8f3b17aad9
commit
9e622d31c9
3 changed files with 22 additions and 10 deletions
|
|
@ -117,8 +117,8 @@ Material:
|
|||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.46226418, g: 0.46226418, b: 0.46226418, a: 1}
|
||||
- _Color: {r: 0.46226412, g: 0.46226412, b: 0.46226412, a: 1}
|
||||
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
|
|
@ -42,5 +42,4 @@ public class Connection : MonoBehaviour
|
|||
|
||||
hovered = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ public class Node : MonoBehaviour
|
|||
|
||||
public bool hovered;
|
||||
|
||||
private int Nachos = 0;
|
||||
|
||||
public static Node pressedNode = null;
|
||||
|
||||
void Awake()
|
||||
|
|
@ -31,6 +33,17 @@ public class Node : MonoBehaviour
|
|||
{
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
CalculateNachos();
|
||||
}
|
||||
|
||||
|
||||
void CalculateNachos()
|
||||
{
|
||||
Nachos = CycleFinder.FindLargestCycleAmongNeighbors(this).Count;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
|
@ -38,13 +51,11 @@ public class Node : MonoBehaviour
|
|||
|
||||
if (Input.GetMouseButtonDown(0) && hovered)
|
||||
{
|
||||
var count = CycleFinder.FindLargestCycleAmongNeighbors(this);
|
||||
|
||||
Debug.Log($"Largest Nacho: {count.Count}");
|
||||
Debug.Log($"Largest Nacho: {Nachos}");
|
||||
}
|
||||
|
||||
unitText.enabled = hovered;
|
||||
unitText.text = Units.ToString();
|
||||
unitText.text = Nachos.ToString();
|
||||
unitText.transform.forward = Camera.main.transform.forward;
|
||||
UpdateColor();
|
||||
UpdateTransform();
|
||||
|
|
@ -106,17 +117,19 @@ public class CycleFinder
|
|||
private HashSet<Node> allowedNodes;
|
||||
private List<Node> bestCycle;
|
||||
private Node centerNode;
|
||||
private int Owner;
|
||||
|
||||
public CycleFinder(Node center)
|
||||
public CycleFinder(Node center, int owner)
|
||||
{
|
||||
centerNode = center;
|
||||
allowedNodes = new HashSet<Node>(center.connected);
|
||||
allowedNodes = new HashSet<Node>(center.connected.Where(obj => obj.Owner == owner));
|
||||
bestCycle = new List<Node>();
|
||||
Owner = owner;
|
||||
}
|
||||
|
||||
public static List<Node> FindLargestCycleAmongNeighbors(Node center)
|
||||
{
|
||||
var finder = new CycleFinder(center);
|
||||
var finder = new CycleFinder(center, center.Owner);
|
||||
return finder.FindBestCycle();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue