summaryrefslogtreecommitdiff
path: root/AlienSurvival/Assets/Scripts/Test/TestSpaceBeam.cs
diff options
context:
space:
mode:
Diffstat (limited to 'AlienSurvival/Assets/Scripts/Test/TestSpaceBeam.cs')
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestSpaceBeam.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/AlienSurvival/Assets/Scripts/Test/TestSpaceBeam.cs b/AlienSurvival/Assets/Scripts/Test/TestSpaceBeam.cs
new file mode 100644
index 0000000..b8ce07b
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/TestSpaceBeam.cs
@@ -0,0 +1,70 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+/// <summary>
+/// Ì«¿ÕÉäÏß
+/// </summary>
+public class TestSpaceBeam : MonoBehaviour
+{
+ [SerializeField] private GameObject m_Beam;
+
+ TopDownTransform m_Coord;
+
+ List<GameObject> m_Beams = new List<GameObject>();
+
+ float m_RotateSpeed = 5f;
+
+ float m_Radius = 1f;
+
+ int count = 8;
+
+ float m_CurrentAngle = 0;
+
+ private void Awake()
+ {
+ m_Coord = GetComponent<TopDownTransform>();
+ }
+
+ public void Set(Vector3 posTDS)
+ {
+ m_Coord.position = posTDS;
+
+ Vector3 groundPos = m_Coord.positionOnGround;
+
+ for(int i = 0; i < count; ++i)
+ {
+ float angle = Mathf.PI * 2f / (float)count * i;
+ Vector3 pos = /*groundPos +*/ new Vector3(m_Radius * Mathf.Cos(angle), m_Radius * Mathf.Sin(angle), 0f);
+ GameObject beam = Instantiate<GameObject>(m_Beam, this.transform);
+ beam.GetComponent<TopDownTransform>().localPosition = pos;
+ beam.SetActive(true);
+ m_Beams.Add(beam);
+ }
+ }
+
+ void Update()
+ {
+ m_CurrentAngle += m_RotateSpeed * Time.deltaTime;
+
+ RotateBeams(m_CurrentAngle);
+ }
+
+ /// <summary>
+ /// Ðýת
+ /// </summary>
+ /// <param name="angle">»¡¶È</param>
+ void RotateBeams(float angle)
+ {
+ Vector3 groundPos = m_Coord.positionOnGround;
+
+ for (int i = 0; i < m_Beams.Count; ++i)
+ {
+ float rad = angle + Mathf.PI * 2f / (float)count * i;
+ Vector3 pos = /*groundPos + */new Vector3(m_Radius * Mathf.Cos(rad), m_Radius * Mathf.Sin(rad), 0f);
+ m_Beams[i].GetComponent<TopDownTransform>().localPosition = pos;
+ }
+
+ }
+
+}