feat: added connections
This commit is contained in:
parent
7a1a0465a0
commit
49799b8dbd
6 changed files with 206 additions and 0 deletions
|
|
@ -633,6 +633,61 @@ Transform:
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1249182055}
|
m_Father: {fileID: 1249182055}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &952215032
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 952215034}
|
||||||
|
- component: {fileID: 952215033}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &952215033
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 952215032}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d9a8ed1dbf611654e914bd61e5a99aac, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
maxConnectionLength: 6
|
||||||
|
nodes:
|
||||||
|
- {fileID: 8318396349631803076}
|
||||||
|
- {fileID: 2030518901}
|
||||||
|
- {fileID: 1781135855}
|
||||||
|
- {fileID: 1929610336}
|
||||||
|
- {fileID: 1380013025}
|
||||||
|
connections:
|
||||||
|
- nodeA: {fileID: 2030518901}
|
||||||
|
nodeB: {fileID: 1380013025}
|
||||||
|
allowed: 0
|
||||||
|
--- !u!4 &952215034
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 952215032}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -0.54042053, y: 0.5476823, z: -0.84545517}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1001 &1038807940
|
--- !u!1001 &1038807940
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -803,6 +858,28 @@ Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
m_PrefabInstance: {fileID: 1380013023}
|
m_PrefabInstance: {fileID: 1380013023}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &1380013025 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6619618649642168463, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1380013023}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!114 &1781135855 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6619618649642168463, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1038807940}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1858015877
|
--- !u!1 &1858015877
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -986,6 +1063,17 @@ Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
m_PrefabInstance: {fileID: 1929610334}
|
m_PrefabInstance: {fileID: 1929610334}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &1929610336 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6619618649642168463, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1929610334}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1001 &2030518899
|
--- !u!1001 &2030518899
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1048,6 +1136,17 @@ Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
m_PrefabInstance: {fileID: 2030518899}
|
m_PrefabInstance: {fileID: 2030518899}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &2030518901 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6619618649642168463, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2030518899}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!114 &114306062090195993
|
--- !u!114 &114306062090195993
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1134,10 +1233,22 @@ Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
m_CorrespondingSourceObject: {fileID: 7965170655419664431, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
m_PrefabInstance: {fileID: 8318396349631803074}
|
m_PrefabInstance: {fileID: 8318396349631803074}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &8318396349631803076 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6619618649642168463, guid: 6fa1678ce2080e44ca5b11723d197651, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 8318396349631803074}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1660057539 &9223372036854775807
|
--- !u!1660057539 &9223372036854775807
|
||||||
SceneRoots:
|
SceneRoots:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_Roots:
|
m_Roots:
|
||||||
|
- {fileID: 952215034}
|
||||||
- {fileID: 1858015879}
|
- {fileID: 1858015879}
|
||||||
- {fileID: 1249182055}
|
- {fileID: 1249182055}
|
||||||
- {fileID: 510780377}
|
- {fileID: 510780377}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ GameObject:
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 7965170655419664431}
|
- component: {fileID: 7965170655419664431}
|
||||||
|
- component: {fileID: 6619618649642168463}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Point
|
m_Name: Point
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -31,3 +32,15 @@ Transform:
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &6619618649642168463
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6039747573752144155}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
|
|
||||||
62
Assets/Scripts/GameManager.cs
Normal file
62
Assets/Scripts/GameManager.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class GameManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
[HideInInspector]
|
||||||
|
public static GameManager instance;
|
||||||
|
|
||||||
|
|
||||||
|
[Header("Parameters")]
|
||||||
|
[Range(0, 100)]
|
||||||
|
public float maxConnectionLength;
|
||||||
|
|
||||||
|
|
||||||
|
public List<Node> nodes = new List<Node>();
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
public List<Connection> connections = new List<Connection>();
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public struct Connection
|
||||||
|
{
|
||||||
|
public Node nodeA, nodeB;
|
||||||
|
public bool allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
foreach (Node nodeA in nodes)
|
||||||
|
{
|
||||||
|
foreach (Node nodeB in nodes)
|
||||||
|
{
|
||||||
|
bool conExists = false;
|
||||||
|
if (nodeA == nodeB || Vector3.Distance(nodeA.transform.position, nodeB.transform.position) > maxConnectionLength)
|
||||||
|
break;
|
||||||
|
|
||||||
|
foreach (Connection con in connections)
|
||||||
|
{
|
||||||
|
if ((con.nodeA == nodeA && con.nodeB == nodeB) || (con.nodeA == nodeB && con.nodeB == nodeA))
|
||||||
|
{
|
||||||
|
conExists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!conExists)
|
||||||
|
connections.Add(new Connection { nodeA = nodeA, nodeB = nodeB});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
foreach (Connection con in connections)
|
||||||
|
{
|
||||||
|
Debug.DrawLine(con.nodeA.transform.position, con.nodeB.transform.position, con.allowed ? Color.green : Color.red);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/GameManager.cs.meta
Normal file
2
Assets/Scripts/GameManager.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d9a8ed1dbf611654e914bd61e5a99aac
|
||||||
16
Assets/Scripts/Node.cs
Normal file
16
Assets/Scripts/Node.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Node : MonoBehaviour
|
||||||
|
{
|
||||||
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Node.cs.meta
Normal file
2
Assets/Scripts/Node.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 041c65d606731c44cb794dc7d95e72dd
|
||||||
Loading…
Add table
Reference in a new issue