summaryrefslogtreecommitdiff
path: root/Other/NavMeshTest/Assets/Scripts/Prop
diff options
context:
space:
mode:
Diffstat (limited to 'Other/NavMeshTest/Assets/Scripts/Prop')
-rw-r--r--Other/NavMeshTest/Assets/Scripts/Prop/Door.cs15
-rw-r--r--Other/NavMeshTest/Assets/Scripts/Prop/Door.cs.meta11
-rw-r--r--Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs18
-rw-r--r--Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs.meta11
-rw-r--r--Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs63
-rw-r--r--Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs.meta11
6 files changed, 129 insertions, 0 deletions
diff --git a/Other/NavMeshTest/Assets/Scripts/Prop/Door.cs b/Other/NavMeshTest/Assets/Scripts/Prop/Door.cs
new file mode 100644
index 0000000..d222797
--- /dev/null
+++ b/Other/NavMeshTest/Assets/Scripts/Prop/Door.cs
@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.AI;
+
+public class Door : Switchable
+{
+ public Transform plank;
+
+ public override void OnSwitch(bool on)
+ {
+ plank.GetComponent<MeshRenderer>().enabled = !on;
+ plank.GetComponent<NavMeshObstacle>().enabled = !on;
+ }
+}
diff --git a/Other/NavMeshTest/Assets/Scripts/Prop/Door.cs.meta b/Other/NavMeshTest/Assets/Scripts/Prop/Door.cs.meta
new file mode 100644
index 0000000..5190cf8
--- /dev/null
+++ b/Other/NavMeshTest/Assets/Scripts/Prop/Door.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c22c62dfca55ff144bf01ebccebb49bc
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs b/Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs
new file mode 100644
index 0000000..3104b32
--- /dev/null
+++ b/Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs
@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Gate : MonoBehaviour
+{
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs.meta b/Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs.meta
new file mode 100644
index 0000000..de2ee0b
--- /dev/null
+++ b/Other/NavMeshTest/Assets/Scripts/Prop/Gate.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: eb933ba9cfde80c4fbe1ef5a467fb99d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs b/Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs
new file mode 100644
index 0000000..1312616
--- /dev/null
+++ b/Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs
@@ -0,0 +1,63 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public abstract class Switchable : MonoBehaviour
+{
+ public virtual void OnSwitch(bool on)
+ { }
+}
+
+
+public class Switch : MonoBehaviour
+{
+ public Switchable target;
+
+ public Transform bar;
+
+ public Vector2 rotationRange;
+
+ private bool m_IsOn;
+
+ private void Start()
+ {
+ m_IsOn = false;
+ OnPressed();
+ }
+
+ private void Update()
+ {
+ if(Input.GetMouseButtonDown(0))
+ {
+ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
+ RaycastHit info;
+ if (Physics.Raycast(ray, out info))
+ {
+ if(info.collider.gameObject == gameObject)
+ {
+ m_IsOn = !m_IsOn;
+
+ OnPressed();
+
+ if (target != null)
+ {
+ target.OnSwitch(m_IsOn);
+ }
+ }
+ }
+ }
+ }
+
+ void OnPressed()
+ {
+ if(m_IsOn)
+ {
+ bar.localRotation = Quaternion.Euler(0, 0, rotationRange.x);
+ }
+ else
+ {
+ bar.localRotation = Quaternion.Euler(0, 0, rotationRange.y);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs.meta b/Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs.meta
new file mode 100644
index 0000000..757a879
--- /dev/null
+++ b/Other/NavMeshTest/Assets/Scripts/Prop/Switch.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0e50f703823877b4c93c62af16e9e011
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: