|
@@ -1,184 +1,184 @@
|
|
|
-using System.Collections;
|
|
|
-using System.Collections.Generic;
|
|
|
-using UnityEngine;
|
|
|
-
|
|
|
-public class PlayerTrigger : MonoBehaviour
|
|
|
-{
|
|
|
- private Vector3 m_LastPos;
|
|
|
-
|
|
|
- private bool m_IsDown;
|
|
|
- private string m_Dir;
|
|
|
- [Range(0.1f, 10f)]
|
|
|
- public float Speed = 0.4f;
|
|
|
- public List<Vector3> MovePoints
|
|
|
- {
|
|
|
- get; set;
|
|
|
- }
|
|
|
- private int m_MoveIndex;
|
|
|
-
|
|
|
- private void Start()
|
|
|
- {
|
|
|
- m_LastPos = Vector3.zero;
|
|
|
-
|
|
|
-
|
|
|
- m_IsDown = false;
|
|
|
-
|
|
|
- m_MoveIndex = 0;
|
|
|
- MovePoints = new List<Vector3>();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void LateUpdate()
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+public class PlayerTrigger : MonoBehaviour
|
|
|
+{
|
|
|
+ private Vector3 m_LastPos;
|
|
|
+
|
|
|
+ private bool m_IsDown;
|
|
|
+ private string m_Dir;
|
|
|
+ [Range(0.1f, 10f)]
|
|
|
+ public float Speed = 0.4f;
|
|
|
+ public List<Vector3> MovePoints
|
|
|
{
|
|
|
-
|
|
|
- if (API_GSXR_Slam.GSXR_Get_Head() != null)
|
|
|
- {
|
|
|
- transform.position = new Vector3(API_GSXR_Slam.GSXR_Get_Head().position.x, transform.position.y, API_GSXR_Slam.GSXR_Get_Head().position.z);
|
|
|
- transform.eulerAngles = new Vector3(0, API_GSXR_Slam.GSXR_Get_Head().eulerAngles.y, 0);
|
|
|
- if (GameManager.Instance.IsRuning)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (Vector3.Distance(m_LastPos, transform.position) < 0.1f)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- m_LastPos = transform.position;
|
|
|
- float x = transform.localPosition.x / GameManager.Instance.MapSize.x * GameManager.Instance.WebMapSize.x;
|
|
|
- float y = transform.localPosition.z / GameManager.Instance.MapSize.y * GameManager.Instance.WebMapSize.y;
|
|
|
- var pos = new Vector3(x, -y, 0);
|
|
|
-
|
|
|
- HttpSocket.Instance.SendIpToPointPos(pos, (message) =>
|
|
|
- {
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ get; set;
|
|
|
+ }
|
|
|
+ private int m_MoveIndex;
|
|
|
+
|
|
|
+ private void Start()
|
|
|
+ {
|
|
|
+ m_LastPos = Vector3.zero;
|
|
|
+
|
|
|
+
|
|
|
+ m_IsDown = false;
|
|
|
+
|
|
|
+ m_MoveIndex = 0;
|
|
|
+ MovePoints = new List<Vector3>();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void LateUpdate()
|
|
|
+ {
|
|
|
+
|
|
|
+ if (API_GSXR_Slam.GSXR_Get_Head() != null)
|
|
|
+ {
|
|
|
+ transform.position = new Vector3(API_GSXR_Slam.GSXR_Get_Head().position.x, transform.position.y, API_GSXR_Slam.GSXR_Get_Head().position.z);
|
|
|
+ transform.eulerAngles = new Vector3(0, API_GSXR_Slam.GSXR_Get_Head().eulerAngles.y, 0);
|
|
|
+ if (GameManager.Instance.IsRuning)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (Vector3.Distance(m_LastPos, transform.position) < 0.1f)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_LastPos = transform.position;
|
|
|
+ float x = transform.localPosition.x / GameManager.Instance.MapSize.x * GameManager.Instance.WebMapSize.x;
|
|
|
+ float y = transform.localPosition.z / GameManager.Instance.MapSize.y * GameManager.Instance.WebMapSize.y;
|
|
|
+ var pos = new Vector3(x, -y, 0);
|
|
|
+
|
|
|
+ HttpSocket.Instance.SendIpToPointPos(pos, (message) =>
|
|
|
+ {
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
*/
|
|
|
- if (OpenXRCamera.Instance.head != null)
|
|
|
- {
|
|
|
- transform.position = new Vector3(OpenXRCamera.Instance.head.position.x, OpenXRCamera.Instance.head.position.y, OpenXRCamera.Instance.head.position.z);
|
|
|
- transform.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
|
|
|
- if (GameManager.Instance.IsRuning)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (Vector3.Distance(m_LastPos, transform.position) < 0.1f)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- m_LastPos = transform.position;
|
|
|
- float x = transform.localPosition.x / GameManager.Instance.MapSize.x * GameManager.Instance.WebMapSize.x;
|
|
|
- float y = transform.localPosition.z / GameManager.Instance.MapSize.y * GameManager.Instance.WebMapSize.y;
|
|
|
- var pos = new Vector3(x, -y, 0);
|
|
|
-
|
|
|
- HttpSocket.Instance.SendIpToPointPos(pos, (message) =>
|
|
|
- {
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void OnTriggerEnter(Collider other)
|
|
|
- {
|
|
|
- if (other.gameObject.tag == "TriggerBox")
|
|
|
- {
|
|
|
- GameManager.Instance.OnColliderTriggerEnter(other);
|
|
|
- Debug.Log("OnTriggerEnter " + other.name);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void OnTriggerExit(Collider other)
|
|
|
- {
|
|
|
- if (other.gameObject.tag == "TriggerBox")
|
|
|
- {
|
|
|
- GameManager.Instance.OnColliderTriggerExit(other);
|
|
|
- Debug.Log("OnTriggerExit " + other.name);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- #region Player Move
|
|
|
-
|
|
|
- public void PlayerMove(string dir)
|
|
|
- {
|
|
|
- m_IsDown = true;
|
|
|
- m_Dir = dir;
|
|
|
- StartCoroutine(CalMove());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public void StopMove()
|
|
|
- {
|
|
|
- m_IsDown = false;
|
|
|
-
|
|
|
- StopAllCoroutines();
|
|
|
- m_Dir = null;
|
|
|
- }
|
|
|
-
|
|
|
- IEnumerator CalMove()
|
|
|
- {
|
|
|
- while (m_IsDown)
|
|
|
- {
|
|
|
-
|
|
|
- yield return new WaitForFixedUpdate();
|
|
|
- Vector3 pos = Vector3.zero;
|
|
|
- switch (m_Dir)
|
|
|
- {
|
|
|
- case "Front":
|
|
|
-
|
|
|
- pos = transform.forward * Time.deltaTime * Speed;
|
|
|
- break;
|
|
|
- case "After":
|
|
|
-
|
|
|
- pos = -transform.forward * Time.deltaTime * Speed;
|
|
|
- break;
|
|
|
- case "Left":
|
|
|
-
|
|
|
- pos = -transform.right * Time.deltaTime * Speed;
|
|
|
- break;
|
|
|
- case "Right":
|
|
|
-
|
|
|
- pos = transform.right * Time.deltaTime * Speed;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- var position = transform.localPosition + pos;
|
|
|
- position = transform.parent.TransformPoint(position);
|
|
|
- Debug.Log(position);
|
|
|
-#if UNITY_EDITOR
|
|
|
- API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
-#elif UNITY_ANDROID
|
|
|
- API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
-#endif
|
|
|
- Debug.Log("m_Dir:" + m_Dir.ToString() + "=====" + API_GSXR_Slam.GSXR_Get_Head().localPosition.ToString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void MoveNextPoint()
|
|
|
- {
|
|
|
- if (MovePoints.Count > 0)
|
|
|
- {
|
|
|
- m_MoveIndex++;
|
|
|
-
|
|
|
- m_MoveIndex = m_MoveIndex < MovePoints.Count ? m_MoveIndex : 0;
|
|
|
- var position = transform.parent.TransformPoint(new Vector3(MovePoints[m_MoveIndex].x, transform.localPosition.y, MovePoints[m_MoveIndex].z));
|
|
|
-#if UNITY_EDITOR
|
|
|
- API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
-#elif UNITY_ANDROID
|
|
|
- API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
-#endif
|
|
|
- }
|
|
|
- Debug.Log("m_MoveIndex:" + m_MoveIndex.ToString() + "=====" + API_GSXR_Slam.GSXR_Get_Head().localPosition.ToString());
|
|
|
- Debug.Log(transform.position);
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
-}
|
|
|
+ if (OpenXRCamera.Instance.head != null)
|
|
|
+ {
|
|
|
+ transform.position = new Vector3(OpenXRCamera.Instance.head.position.x, OpenXRCamera.Instance.head.position.y, OpenXRCamera.Instance.head.position.z);
|
|
|
+ transform.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
|
|
|
+ if (GameManager.Instance.IsRuning)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (Vector3.Distance(m_LastPos, transform.position) < 0.1f)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_LastPos = transform.position;
|
|
|
+ float x = transform.localPosition.x / GameManager.Instance.MapSize.x * GameManager.Instance.WebMapSize.x;
|
|
|
+ float y = transform.localPosition.z / GameManager.Instance.MapSize.y * GameManager.Instance.WebMapSize.y;
|
|
|
+ var pos = new Vector3(x, -y, 0);
|
|
|
+
|
|
|
+ HttpSocket.Instance.SendIpToPointPos(pos, (message) =>
|
|
|
+ {
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void OnTriggerEnter(Collider other)
|
|
|
+ {
|
|
|
+ if (other.gameObject.tag == "TriggerBox")
|
|
|
+ {
|
|
|
+ GameManager.Instance.OnColliderTriggerEnter(other);
|
|
|
+ Debug.Log("OnTriggerEnter " + other.name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void OnTriggerExit(Collider other)
|
|
|
+ {
|
|
|
+ if (other.gameObject.tag == "TriggerBox")
|
|
|
+ {
|
|
|
+ GameManager.Instance.OnColliderTriggerExit(other);
|
|
|
+ Debug.Log("OnTriggerExit " + other.name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ #region Player Move
|
|
|
+
|
|
|
+ public void PlayerMove(string dir)
|
|
|
+ {
|
|
|
+ m_IsDown = true;
|
|
|
+ m_Dir = dir;
|
|
|
+ StartCoroutine(CalMove());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void StopMove()
|
|
|
+ {
|
|
|
+ m_IsDown = false;
|
|
|
+
|
|
|
+ StopAllCoroutines();
|
|
|
+ m_Dir = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ IEnumerator CalMove()
|
|
|
+ {
|
|
|
+ while (m_IsDown)
|
|
|
+ {
|
|
|
+
|
|
|
+ yield return new WaitForFixedUpdate();
|
|
|
+ Vector3 pos = Vector3.zero;
|
|
|
+ switch (m_Dir)
|
|
|
+ {
|
|
|
+ case "Front":
|
|
|
+
|
|
|
+ pos = transform.forward * Time.deltaTime * Speed;
|
|
|
+ break;
|
|
|
+ case "After":
|
|
|
+
|
|
|
+ pos = -transform.forward * Time.deltaTime * Speed;
|
|
|
+ break;
|
|
|
+ case "Left":
|
|
|
+
|
|
|
+ pos = -transform.right * Time.deltaTime * Speed;
|
|
|
+ break;
|
|
|
+ case "Right":
|
|
|
+
|
|
|
+ pos = transform.right * Time.deltaTime * Speed;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ var position = transform.localPosition + pos;
|
|
|
+ position = transform.parent.TransformPoint(position);
|
|
|
+ Debug.Log(position);
|
|
|
+#if UNITY_EDITOR
|
|
|
+ API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
+#elif UNITY_ANDROID
|
|
|
+ API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
+#endif
|
|
|
+ Debug.Log("m_Dir:" + m_Dir.ToString() + "=====" + API_GSXR_Slam.GSXR_Get_Head().localPosition.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void MoveNextPoint()
|
|
|
+ {
|
|
|
+ if (MovePoints.Count > 0)
|
|
|
+ {
|
|
|
+ m_MoveIndex++;
|
|
|
+
|
|
|
+ m_MoveIndex = m_MoveIndex < MovePoints.Count ? m_MoveIndex : 0;
|
|
|
+ var position = transform.parent.TransformPoint(new Vector3(MovePoints[m_MoveIndex].x, transform.localPosition.y, MovePoints[m_MoveIndex].z));
|
|
|
+#if UNITY_EDITOR
|
|
|
+ API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
+#elif UNITY_ANDROID
|
|
|
+ API_GSXR_Slam.GSXR_Get_Head().position = position;
|
|
|
+#endif
|
|
|
+ }
|
|
|
+ Debug.Log("m_MoveIndex:" + m_MoveIndex.ToString() + "=====" + API_GSXR_Slam.GSXR_Get_Head().localPosition.ToString());
|
|
|
+ Debug.Log(transform.position);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+}
|