Add node interactions

This commit is contained in:
Jan Groß
2021-06-12 14:18:38 +02:00
parent 927b1f2882
commit 4ad82fe684
4 changed files with 25 additions and 5 deletions

View File

@@ -8,4 +8,11 @@ public class DirectionPaddle : MonoBehaviour
{
gameObject.SetActive(!gameObject.activeSelf);
}
public void InteractNode()
{
this.GetComponent<Collider>().enabled = !this.GetComponent<Collider>().enabled;
this.GetComponent<MeshRenderer>().enabled = !this.GetComponent<MeshRenderer>().enabled;
}
}

View File

@@ -1057,6 +1057,10 @@ PrefabInstance:
propertyPath: connections.Array.data[1]
value:
objectReference: {fileID: 1143571366}
- target: {fileID: 6314262857863842719, guid: cd2709ce625391747b56d49b13717da0, type: 3}
propertyPath: connections.Array.data[3]
value:
objectReference: {fileID: 1643453143}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: cd2709ce625391747b56d49b13717da0, type: 3}
--- !u!4 &852901939 stripped
@@ -1995,7 +1999,7 @@ GameObject:
- component: {fileID: 1643453144}
- component: {fileID: 1643453148}
m_Layer: 0
m_Name: Conveyer (6)
m_Name: Conveyor Paddle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

View File

@@ -34,8 +34,17 @@ public class Node : MonoBehaviour
public void MoveToDirection(Direction dir)
{
connections[(int)dir].GetComponent<Node>().SetActiveNode();
Node nodeComp = connections[(int)dir].GetComponent<Node>();
if (nodeComp)
{
nodeComp.SetActiveNode();
UI.SetActive(false);
isActive = false;
} else
{
connections[(int)dir].SendMessage("InteractNode");
}
}
}

View File

@@ -33,7 +33,7 @@ public class Switch : MonoBehaviour
if (Keyboard.current.eKey.wasPressedThisFrame)
{
gameManager.SetActiveCamera(1);
debugNode.SetActiveNode();
debugNode.SendMessage("SetActiveNode", debugNode.GetComponent<Node>());
}
}
}