summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/Walls
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/Walls
+scripts
Diffstat (limited to 'Client/Assets/Scripts/Walls')
-rw-r--r--Client/Assets/Scripts/Walls/XCameraWall.cs50
-rw-r--r--Client/Assets/Scripts/Walls/XCameraWall.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XCutsceneWall.cs16
-rw-r--r--Client/Assets/Scripts/Walls/XCutsceneWall.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XCylinderTrigger.cs22
-rw-r--r--Client/Assets/Scripts/Walls/XCylinderTrigger.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XHorseWall.cs12
-rw-r--r--Client/Assets/Scripts/Walls/XHorseWall.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XSpawnWall.cs22
-rw-r--r--Client/Assets/Scripts/Walls/XSpawnWall.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XTerminalWall.cs17
-rw-r--r--Client/Assets/Scripts/Walls/XTerminalWall.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XTransferWall.cs33
-rw-r--r--Client/Assets/Scripts/Walls/XTransferWall.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XTrigger.cs42
-rw-r--r--Client/Assets/Scripts/Walls/XTrigger.cs.meta8
-rw-r--r--Client/Assets/Scripts/Walls/XWall.cs54
-rw-r--r--Client/Assets/Scripts/Walls/XWall.cs.meta8
18 files changed, 340 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/Walls/XCameraWall.cs b/Client/Assets/Scripts/Walls/XCameraWall.cs
new file mode 100644
index 00000000..75485b68
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XCameraWall.cs
@@ -0,0 +1,50 @@
+using UnityEngine;
+using XUtliPoolLib;
+
+[ExecuteInEditMode]
+public class XCameraWall : XWall
+{
+ public XCameraWall Associated = null;
+ public XCurve Curve = null;
+
+ public bool BeginWith = false;
+ public float Angle = 0;
+ public bool VerticalOnly = false;
+ public float VerticalShiftAngle = 0;
+
+ protected override void OnTriggered()
+ {
+ float sector = Vector3.Angle(transform.forward, Associated.transform.forward);
+ Vector3 rotate = transform.rotation.eulerAngles; rotate.y = 0;
+ Vector3 dir = Quaternion.AngleAxis(rotate.z, transform.forward) * XCommon.singleton.HorizontalRotateVetor3(transform.forward, 90, true);
+
+ if (_forward_collision)
+ {
+ if (!VerticalOnly)
+ {
+ if (BeginWith)
+ {
+ _interface.CameraWallEnter(Curve.Curve, transform.parent.transform.position, dir, sector, Angle, Associated.Angle, BeginWith);
+ }
+ else
+ _interface.CameraWallExit(Angle);
+ }
+
+ _interface.CameraWallVertical(VerticalShiftAngle);
+ }
+ else
+ {
+ if (!VerticalOnly)
+ {
+ if (BeginWith)
+ _interface.CameraWallExit(Angle);
+ else
+ {
+ _interface.CameraWallEnter(Curve.Curve, transform.parent.transform.position, dir, sector, Angle, Associated.Angle, BeginWith);
+ }
+ }
+
+ _interface.CameraWallVertical(-VerticalShiftAngle);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/Walls/XCameraWall.cs.meta b/Client/Assets/Scripts/Walls/XCameraWall.cs.meta
new file mode 100644
index 00000000..b1f02b86
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XCameraWall.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: ce06ee0225b91484a827bab6d7fd7efa
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XCutsceneWall.cs b/Client/Assets/Scripts/Walls/XCutsceneWall.cs
new file mode 100644
index 00000000..efd104e6
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XCutsceneWall.cs
@@ -0,0 +1,16 @@
+using UnityEngine;
+using XUtliPoolLib;
+
+public class XCutsceneWall : XWall
+{
+ public string CutScene;
+ private bool _played = false;
+
+ protected override void OnTriggered()
+ {
+ if (_played) return;
+
+ _interface.PlayCutScene(CutScene);
+ _played = true;
+ }
+}
diff --git a/Client/Assets/Scripts/Walls/XCutsceneWall.cs.meta b/Client/Assets/Scripts/Walls/XCutsceneWall.cs.meta
new file mode 100644
index 00000000..2a4ab231
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XCutsceneWall.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3704ace3ca5afff43a82e6dc7e4fcd21
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XCylinderTrigger.cs b/Client/Assets/Scripts/Walls/XCylinderTrigger.cs
new file mode 100644
index 00000000..4c39cdaf
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XCylinderTrigger.cs
@@ -0,0 +1,22 @@
+using UnityEngine;
+using XUtliPoolLib;
+
+public class XCylinderTrigger : XTrigger
+{
+ public string exString;
+ public etrigger_type TriggerType;
+
+ public enum etrigger_type
+ {
+ once,
+ always
+ }
+
+ protected override void OnTriggered()
+ {
+ if (exString != null && exString.Length > 0)
+ {
+ _interface.SetExternalString(exString, (TriggerType == etrigger_type.once));
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/Walls/XCylinderTrigger.cs.meta b/Client/Assets/Scripts/Walls/XCylinderTrigger.cs.meta
new file mode 100644
index 00000000..27bb8f06
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XCylinderTrigger.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 0ae4d123a3496fb4099b11f1c9abe92b
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XHorseWall.cs b/Client/Assets/Scripts/Walls/XHorseWall.cs
new file mode 100644
index 00000000..2c406c14
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XHorseWall.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+using System.Collections;
+
+public class XHorseWall : XWall
+{
+ public int index;
+
+ protected override void OnTriggered()
+ {
+
+ }
+} \ No newline at end of file
diff --git a/Client/Assets/Scripts/Walls/XHorseWall.cs.meta b/Client/Assets/Scripts/Walls/XHorseWall.cs.meta
new file mode 100644
index 00000000..f9b2249b
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XHorseWall.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7b70f50528aca9a41ba4440d7c3f86aa
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XSpawnWall.cs b/Client/Assets/Scripts/Walls/XSpawnWall.cs
new file mode 100644
index 00000000..0a247c7b
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XSpawnWall.cs
@@ -0,0 +1,22 @@
+using UnityEngine;
+using XUtliPoolLib;
+
+public class XSpawnWall : XWall
+{
+ public string exString;
+ public etrigger_type TriggerType;
+
+ public enum etrigger_type
+ {
+ once,
+ always
+ }
+
+ protected override void OnTriggered()
+ {
+ if (exString != null && exString.Length > 0)
+ {
+ _interface.SetExternalString(exString, (TriggerType == etrigger_type.once));
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/Walls/XSpawnWall.cs.meta b/Client/Assets/Scripts/Walls/XSpawnWall.cs.meta
new file mode 100644
index 00000000..2cab53f8
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XSpawnWall.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 8514cd5e69e42dc468414d3f842a9d4d
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XTerminalWall.cs b/Client/Assets/Scripts/Walls/XTerminalWall.cs
new file mode 100644
index 00000000..4a1a83f3
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XTerminalWall.cs
@@ -0,0 +1,17 @@
+using UnityEngine;
+using System.Collections;
+
+public class XTerminalWall : XWall
+{
+ public string exString;
+ private bool reported = false;
+
+ protected override void OnTriggered()
+ {
+ if (!reported && exString != null && exString.Length > 0)
+ {
+ _interface.SetExternalString(exString, true);
+ reported = true;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/Walls/XTerminalWall.cs.meta b/Client/Assets/Scripts/Walls/XTerminalWall.cs.meta
new file mode 100644
index 00000000..3d807c72
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XTerminalWall.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 76c23e647f1e04e4787c2a7c66936025
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XTransferWall.cs b/Client/Assets/Scripts/Walls/XTransferWall.cs
new file mode 100644
index 00000000..d0e9042a
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XTransferWall.cs
@@ -0,0 +1,33 @@
+using UnityEngine;
+using XUtliPoolLib;
+
+public class XTransferWall : XWall
+{
+ public enum transfer_type
+ {
+ current_scene,
+ other_scene,
+ }
+
+ public transfer_type targetScene;
+ public int sceneID;
+ public GameObject targetPos;
+
+ protected override void OnTriggered()
+ {
+ if (targetScene == transfer_type.current_scene)
+ {
+ if (targetPos != null)
+ {
+ _interface.TransferToSceneLocation(targetPos.transform.position, targetPos.transform.forward);
+ }
+ }
+ else if (targetScene == transfer_type.other_scene)
+ {
+ if (sceneID > 0)
+ {
+ _interface.TransferToNewScene((uint)sceneID);
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/Walls/XTransferWall.cs.meta b/Client/Assets/Scripts/Walls/XTransferWall.cs.meta
new file mode 100644
index 00000000..0ff18032
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XTransferWall.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f6f164f1b2d28a9459e7d0926d8385fa
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 5
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XTrigger.cs b/Client/Assets/Scripts/Walls/XTrigger.cs
new file mode 100644
index 00000000..cea27e25
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XTrigger.cs
@@ -0,0 +1,42 @@
+using UnityEngine;
+using XUtliPoolLib;
+
+public abstract class XTrigger : MonoBehaviour
+{
+ protected IXPlayerAction _interface;
+ private CapsuleCollider _cap = null;
+
+ // Use this for initialization
+ void Awake()
+ {
+ _cap = GetComponent<CapsuleCollider>();
+ _cap.enabled = false;
+ }
+
+ void Update()
+ {
+ if (_interface == null || _interface.Deprecated) _interface = XInterfaceMgr.singleton.GetInterface<IXPlayerAction>(1);
+
+ if (_interface != null && _interface.IsValid)
+ {
+ Vector3 pos = _interface.PlayerPosition(true);
+ Vector3 last_pos = _interface.PlayerLastPosition(true);
+
+ if ((last_pos - pos).sqrMagnitude > 0)
+ {
+ CollisionDetected(pos);
+ }
+ }
+ }
+
+ private void CollisionDetected(Vector3 pos)
+ {
+ Vector3 delta = (pos - (_cap.transform.position + _cap.center)); delta.y = 0;
+ if (delta.sqrMagnitude < _cap.radius * _cap.radius)
+ {
+ OnTriggered();
+ }
+ }
+
+ protected abstract void OnTriggered();
+}
diff --git a/Client/Assets/Scripts/Walls/XTrigger.cs.meta b/Client/Assets/Scripts/Walls/XTrigger.cs.meta
new file mode 100644
index 00000000..e37536d5
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XTrigger.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c3f173c7f0bce9e46b902d3e849f1ae6
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/Client/Assets/Scripts/Walls/XWall.cs b/Client/Assets/Scripts/Walls/XWall.cs
new file mode 100644
index 00000000..ab1cfea0
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XWall.cs
@@ -0,0 +1,54 @@
+using UnityEngine;
+using XUtliPoolLib;
+
+public abstract class XWall : MonoBehaviour
+{
+ protected bool _forward_collision;
+ protected IXPlayerAction _interface;
+
+ private BoxCollider _box = null;
+
+ private Vector3 _left;
+ private Vector3 _right;
+
+ // Use this for initialization
+ void Awake ()
+ {
+ _box = GetComponent<BoxCollider>();
+ _box.enabled = false;
+
+ Vector3 half = Vector3.Cross(Vector3.up, transform.forward) * _box.size.x * _box.transform.localScale.x * 0.5f;
+
+ _left = _box.center + _box.transform.position - half;
+ _right = _box.center + _box.transform.position + half;
+ }
+
+ void Update()
+ {
+ if (_interface == null || _interface.Deprecated) _interface = XInterfaceMgr.singleton.GetInterface<IXPlayerAction>(1);
+
+ if (_interface != null && _interface.IsValid)
+ {
+ Vector3 pos = _interface.PlayerPosition(!(this is XCameraWall));
+ Vector3 last_pos = _interface.PlayerLastPosition(!(this is XCameraWall));
+
+ if ((last_pos - pos).sqrMagnitude > 0)
+ {
+ CollisionDetected(pos, last_pos);
+ }
+ }
+ }
+
+ private void CollisionDetected(Vector3 pos, Vector3 last)
+ {
+ if (XCommon.singleton.IsLineSegmentCross(last, pos, _left, _right))
+ {
+ Vector3 dir = pos - last;
+
+ _forward_collision = Vector3.Dot(dir, transform.forward) > 0;
+ OnTriggered();
+ }
+ }
+
+ protected abstract void OnTriggered();
+}
diff --git a/Client/Assets/Scripts/Walls/XWall.cs.meta b/Client/Assets/Scripts/Walls/XWall.cs.meta
new file mode 100644
index 00000000..9a7bf727
--- /dev/null
+++ b/Client/Assets/Scripts/Walls/XWall.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f4c2c4737501e30428839068ffbd9cf5
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData: