summaryrefslogtreecommitdiff
path: root/AlienSurvival/Assets/Test/Scripts/TestB2.cs
diff options
context:
space:
mode:
Diffstat (limited to 'AlienSurvival/Assets/Test/Scripts/TestB2.cs')
-rw-r--r--AlienSurvival/Assets/Test/Scripts/TestB2.cs79
1 files changed, 0 insertions, 79 deletions
diff --git a/AlienSurvival/Assets/Test/Scripts/TestB2.cs b/AlienSurvival/Assets/Test/Scripts/TestB2.cs
deleted file mode 100644
index 532c254..0000000
--- a/AlienSurvival/Assets/Test/Scripts/TestB2.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class TestB2 : MonoBehaviour
-{
- [SerializeField] private TestBomb m_Bomb;
- [SerializeField] private float m_Speed;
-
- private Vector3 m_From;
- private Vector3 m_To;
-
- private Coroutine m_CoBomb;
-
- Vector3 direction
- {
- get
- {
- return (m_To - m_From).normalized;
- }
- }
-
- /// <summary>
- /// from to ÔÚ3d¿Õ¼ä
- /// </summary>
- /// <param name="from"></param>
- /// <param name="to"></param>
- public void Set(Vector3 from, Vector3 to, float speed, float lifeTime)
- {
- m_From = from;
- m_To = to;
- m_Speed = speed;
-
- transform.position = from;
-
- this.gameObject.SetActive(true);
-
- m_CoBomb = StartCoroutine(coBomb(0.1f));
-
- Invoke("DestroySelf", lifeTime);
- }
-
- void DestroySelf()
- {
- if (m_CoBomb != null)
- {
- StopCoroutine(m_CoBomb);
- m_CoBomb = null;
- }
- this.gameObject.SetActive(false);
- Destroy(this.gameObject);
- }
-
- private void Update()
- {
- Vector3 pos = transform.position;
- pos += direction * m_Speed * Time.deltaTime;
-
- transform.position = pos;
- }
-
- IEnumerator coBomb(float interval)
- {
- while (true)
- {
- Vector3 pos = transform.position;
- for(int i = 0; i < 1; ++i)
- {
- TestBomb grenade = Instantiate<TestBomb>(m_Bomb);
- Vector3 position = new Vector3(pos.x + Random.Range(-3, 3), pos.y + Random.Range(-5f, 5f), 7f);
- grenade.Set(position, new Vector3(0, 0, -1f), Random.Range(8f, 10f));
- grenade.gameObject.SetActive(true);
- }
-
- yield return new WaitForSeconds(interval);
- }
- }
-
-}