diff options
Diffstat (limited to 'AlienSurvival/Assets/Test/Scripts')
34 files changed, 895 insertions, 0 deletions
diff --git a/AlienSurvival/Assets/Test/Scripts/TestBeamBullet.cs b/AlienSurvival/Assets/Test/Scripts/TestBeamBullet.cs new file mode 100644 index 0000000..17d0005 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestBeamBullet.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestBeamBullet : MonoBehaviour +{ + public Vector3 direction; + public float speed; + + // Start is called before the first frame update + void Start() + { + Invoke("Dead", 3); + } + + void Dead() + { + if (this.gameObject) + { + GameObject.Destroy(this.gameObject); + } + } + + // Update is called once per frame + void Update() + { + Vector3 position = transform.position; + position += direction * speed * Time.deltaTime; + transform.position = position; + } + + private void OnTriggerEnter2D(Collider2D collision) + { + GameObject go = collision.gameObject; + + if (!go.CompareTag("enemy")) + { + return; + } + + GameObject.Destroy( collision.gameObject); + + //this.gameObject.SetActive(false); + + if (this.gameObject) + { + GameObject.Destroy(this.gameObject); + } + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestBeamBullet.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestBeamBullet.cs.meta new file mode 100644 index 0000000..b1551a7 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestBeamBullet.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca62ef044d3b4104eac135eea37e0c03 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestBeamGun.cs b/AlienSurvival/Assets/Test/Scripts/TestBeamGun.cs new file mode 100644 index 0000000..69225b6 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestBeamGun.cs @@ -0,0 +1,79 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestBeamGun : MonoBehaviour +{ + public TestBeamBullet bullet; + + public Transform start; + + public float speed = 1; + + SpriteRenderer sprite; + + // Start is called before the first frame update + void Start() + { + sprite = GetComponent<SpriteRenderer>(); + + // StartCoroutine(coFire()); + } + + // Update is called once per frame + void Update() + { + + Vector3 screenPos = Input.mousePosition; + + Vector2 target = Camera.main.ScreenToWorldPoint(screenPos); + + Vector2 dir = Vector2.ClampMagnitude(target - (Vector2)transform.position, 1); + Vector3 move = dir * speed * Time.deltaTime; + + float x = move.x; + if (x > 0) + { + sprite.flipY = false; + } + else if (x < 0) + { + sprite.flipY = true; + } + + transform.rotation = Quaternion.Euler(0, 0, Mathf.Rad2Deg * Mathf.Atan2(dir.y, dir.x)); + + Shot(); + } + + void Shot() + { + if (Input.GetButtonDown("Fire1")) + { + //Debug.Log("Shoot"); + + TestBeamBullet b = TestBeamBullet.Instantiate(bullet); + b.gameObject.SetActive(true); + + b.transform.position = start.position; + + b.direction = transform.right; + } + } + + IEnumerator coFire() + { + while (true) + { + TestBeamBullet b = TestBeamBullet.Instantiate(bullet); + b.gameObject.SetActive(true); + + b.transform.position = start.position; + + b.direction = transform.right; + + yield return new WaitForSeconds(0.5f); + } + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestBeamGun.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestBeamGun.cs.meta new file mode 100644 index 0000000..cfeb8f2 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestBeamGun.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 058a2b89691b2f94d912ff341719edd9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestCameraSortByY.cs b/AlienSurvival/Assets/Test/Scripts/TestCameraSortByY.cs new file mode 100644 index 0000000..585f2c3 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestCameraSortByY.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[RequireComponent(typeof(Camera))] +public class TestCameraSortByY : MonoBehaviour +{ + private Camera camera; + + // Start is called before the first frame update + void Start() + { + camera = GetComponent<Camera>(); + camera.transparencySortMode = TransparencySortMode.CustomAxis; + camera.transparencySortAxis = Vector3.up; + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestCameraSortByY.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestCameraSortByY.cs.meta new file mode 100644 index 0000000..210a02e --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestCameraSortByY.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b692e7619b71ada41b02f616b9a6134d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestCannon.cs b/AlienSurvival/Assets/Test/Scripts/TestCannon.cs new file mode 100644 index 0000000..22b168b --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestCannon.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestCannon : MonoBehaviour +{ + public TestBeamBullet bullet; + + public Transform start; + + public float speed = 1; + + SpriteRenderer sprite; + + // Start is called before the first frame update + void Start() + { + sprite = GetComponent<SpriteRenderer>(); + + StartCoroutine(coFire(1f)); + } + + // Update is called once per frame + void Update() + { + + } + + IEnumerator coFire(float interval) + { + while (true) + { + TestBeamBullet b = TestBeamBullet.Instantiate(bullet); + b.gameObject.SetActive(true); + + b.transform.position = start.position; + + b.direction = -transform.right; + + yield return new WaitForSeconds(interval); + } + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestCannon.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestCannon.cs.meta new file mode 100644 index 0000000..52c902c --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestCannon.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 14e80cec1a94a5449b2081ac81bea639 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestCharacterMovement.cs b/AlienSurvival/Assets/Test/Scripts/TestCharacterMovement.cs new file mode 100644 index 0000000..8911ea9 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestCharacterMovement.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestCharacterMovement : MonoBehaviour +{ + public SpriteRenderer sprite; + + public float speed; + + // Start is called before the first frame update + void Start() + { + sprite = GetComponent<SpriteRenderer>(); + + } + + // Update is called once per frame + void Update() + { + float x = Input.GetAxis("Horizontal"); + float y = Input.GetAxis("Vertical"); + + Vector3 position = transform.position; + position.x += x * speed * Time.deltaTime; + position.y += y * speed * Time.deltaTime; + + transform.position = position; + + if (x > 0) + { + sprite.flipX = false; + } + else if(x < 0) + { + sprite.flipX = true; + } + + } +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestCharacterMovement.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestCharacterMovement.cs.meta new file mode 100644 index 0000000..606b4cc --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestCharacterMovement.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a2fd7e5c6f466b7448001599a97c5b58 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestEnforceTransform0.cs b/AlienSurvival/Assets/Test/Scripts/TestEnforceTransform0.cs new file mode 100644 index 0000000..57b777d --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestEnforceTransform0.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestEnforceTransform0 : MonoBehaviour +{ + void Update() + { +// transform.localToWorldMatrix = Matrix4x4.identity; + } +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestEnforceTransform0.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestEnforceTransform0.cs.meta new file mode 100644 index 0000000..3371029 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestEnforceTransform0.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 666db70fcce7c7e4a94cc321eb68e307 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestFakeCube.cs b/AlienSurvival/Assets/Test/Scripts/TestFakeCube.cs new file mode 100644 index 0000000..5d8f2c5 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestFakeCube.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestFakeCube : MonoBehaviour +{ + public float z; // fake height + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + + + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestFakeCube.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestFakeCube.cs.meta new file mode 100644 index 0000000..83c3602 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestFakeCube.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 84033172d3ac67f4eb3eb8586b6ecb11 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestGrenade.cs b/AlienSurvival/Assets/Test/Scripts/TestGrenade.cs new file mode 100644 index 0000000..a1434d8 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestGrenade.cs @@ -0,0 +1,107 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestPseudoVec3 +{ + public float x; + public float y; + public float h; + public TestPseudoVec3(float x, float y, float h) + { + this.x = x; + this.y = y; + this.h = h; + } +} + +public class TestGrenade : MonoBehaviour +{ + public bool useGravity; + + public float gravity = -9.8f; + + public TestPseudoVec3 velocity; + public TestPseudoVec3 pseudoPos; + + public Transform shadow; + + private bool m_IsGround + { + get + { + return pseudoPos.h <= 0; + } + } + + // Start is called before the first frame update + void Start() + { + //Invoke("Dead", 3); + } + + void Dead() + { + if (this.gameObject) + { + GameObject.Destroy(this.gameObject); + } + } + + // Update is called once per frame + void Update() + { + if(useGravity && !m_IsGround) + { + velocity.h += gravity * Time.deltaTime; + } + + pseudoPos.x += velocity.x * Time.deltaTime; + pseudoPos.y += velocity.y * Time.deltaTime; + pseudoPos.h += velocity.h * Time.deltaTime; + + if(m_IsGround) + { + velocity.h = -velocity.h; + pseudoPos.h = 0; + } + + Vector3 position = transform.position; + + position.x = pseudoPos.x; + position.y = pseudoPos.y + pseudoPos.h; + + transform.position = position; + + if (shadow) + { + // shadow position + shadow.rotation = Quaternion.identity; + Vector3 shadowPos = Vector3.zero; + shadowPos.x = pseudoPos.x; + shadowPos.y = pseudoPos.y; + shadowPos.z = 0; + shadow.position = shadowPos; + } + } + + private void OnTriggerEnter2D(Collider2D collision) + { + //GameObject go = collision.gameObject; + + //if (!go.CompareTag("enemy")) + //{ + // return; + //} + + //GameObject.Destroy(collision.gameObject); + + ////this.gameObject.SetActive(false); + + //if (this.gameObject) + //{ + // GameObject.Destroy(this.gameObject); + //} + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestGrenade.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestGrenade.cs.meta new file mode 100644 index 0000000..f5d87e9 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestGrenade.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 76da92161ea22274996c5bc1d0bdea94 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestLauncher.cs b/AlienSurvival/Assets/Test/Scripts/TestLauncher.cs new file mode 100644 index 0000000..f053854 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestLauncher.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestLauncher : MonoBehaviour +{ + public TestGrenade bullet; + + public Transform shadow; + + public Transform start; + + public float speed = 1; + + SpriteRenderer sprite; + + // Start is called before the first frame update + void Start() + { + sprite = GetComponent<SpriteRenderer>(); + } + + // Update is called once per frame + void Update() + { + + Vector3 screenPos = Input.mousePosition; + + Vector2 target = Camera.main.ScreenToWorldPoint(screenPos); + + Vector2 dir = Vector2.ClampMagnitude(target - (Vector2)transform.position, 1); + Vector3 move = dir * speed * Time.deltaTime; + + float x = move.x; + if (x > 0) + { + sprite.flipY = false; + } + else if (x < 0) + { + sprite.flipY = true; + } + + transform.rotation = Quaternion.Euler(0, 0, Mathf.Rad2Deg * Mathf.Atan2(dir.y, dir.x)); + + Shot(); + } + + void Shot() + { + if (Input.GetButtonDown("Fire1")) + { + //Debug.Log("Shoot"); + + TestGrenade b = TestGrenade.Instantiate(bullet); + b.gameObject.SetActive(true); + + b.transform.position = start.position; + + b.pseudoPos = new TestPseudoVec3(start.position.x, start.position.y, 0.1f); + + float speed = 5; + b.velocity = new TestPseudoVec3(transform.right.x * speed, transform.right.y * speed, 3f); + } + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestLauncher.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestLauncher.cs.meta new file mode 100644 index 0000000..8688fc3 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestLauncher.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 45111da1fa00b2a4192afc01c5be0873 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestMirror.cs b/AlienSurvival/Assets/Test/Scripts/TestMirror.cs new file mode 100644 index 0000000..832c785 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestMirror.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestMirror : MonoBehaviour +{ + HashSet<GameObject> m_Mirrored = new HashSet<GameObject>(); + + private void OnTriggerEnter2D(Collider2D collision) + { + GameObject go = collision.gameObject; + if (go && go.CompareTag("bullet") && !m_Mirrored.Contains(go)) + { + //Debug.Log("mirror"); + + go.GetComponent<TestBeamBullet>().direction.x = -go.GetComponent<TestBeamBullet>().direction.x; + + m_Mirrored.Add(go); + } + } + + private void OnTriggerExit2D(Collider2D collision) + { + GameObject go = collision.gameObject; + if (go && go.CompareTag("bullet") && m_Mirrored.Contains(go)) + { + m_Mirrored.Remove(go); + } + } +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestMirror.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestMirror.cs.meta new file mode 100644 index 0000000..6fdba29 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestMirror.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bfd61ceb1fbec0944a66ace63dcd8e02 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestMoveToTarget.cs b/AlienSurvival/Assets/Test/Scripts/TestMoveToTarget.cs new file mode 100644 index 0000000..4b5f637 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestMoveToTarget.cs @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestMoveToTarget : MonoBehaviour +{ + public float speed = 1; + + Vector2 target; + + SpriteRenderer sprite; + + private void Start() + { + sprite = GetComponent<SpriteRenderer>(); + + } + + private void Update() + { + if (Input.GetButtonDown("Fire2")) + { + Vector3 screenPos = Input.mousePosition; + + target = Camera.main.ScreenToWorldPoint(screenPos); + //Debug.Log(target); + } + + Vector2 dir = Vector2.ClampMagnitude(target - (Vector2)transform.position, 1); + Vector3 move = dir * speed * Time.deltaTime; + transform.position = transform.position + move; + + float x = move.x; + if (x > 0) + { + sprite.flipX = false; + } + else if (x < 0) + { + sprite.flipX = true; + } + + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestMoveToTarget.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestMoveToTarget.cs.meta new file mode 100644 index 0000000..6f68458 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestMoveToTarget.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2283c114a7cfbd1429d3e2a0d5e6a957 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestPhysicsHelper.cs b/AlienSurvival/Assets/Test/Scripts/TestPhysicsHelper.cs new file mode 100644 index 0000000..a1606f2 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestPhysicsHelper.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestPhysicsHelper : TestSingleton<TestPhysicsHelper> +{ + public TestPhysicsHelper() + { + } + + + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestPhysicsHelper.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestPhysicsHelper.cs.meta new file mode 100644 index 0000000..47ba3fc --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestPhysicsHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8031513d870e5e54e942664031efe406 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestRobot1.cs b/AlienSurvival/Assets/Test/Scripts/TestRobot1.cs new file mode 100644 index 0000000..b8f8366 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestRobot1.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestRobot1 : MonoBehaviour +{ + public Transform shadow; + + public float z; // fake height + + public AnimationCurve curve; + + private void Update() + { + + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestRobot1.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestRobot1.cs.meta new file mode 100644 index 0000000..554affe --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestRobot1.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 04de5fad9d56a774498cac6d58b2f231 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestSeperator.cs b/AlienSurvival/Assets/Test/Scripts/TestSeperator.cs new file mode 100644 index 0000000..d1819c0 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestSeperator.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestSeperator : MonoBehaviour +{ + HashSet<GameObject> m_Seperated = new HashSet<GameObject>(); + + private void OnTriggerEnter2D(Collider2D collision) + { + GameObject go = collision.gameObject; + if (go && go.CompareTag("bullet") && !m_Seperated.Contains(go)) + { + //Debug.Log("seperate"); + + TestBeamBullet bullet1 = TestBeamBullet.Instantiate(go.GetComponent<TestBeamBullet>()); + bullet1.direction = Quaternion.Euler(0,0, 30) * bullet1.direction; + bullet1.enabled = true; + bullet1.gameObject.SetActive(true); + + TestBeamBullet bullet2 = TestBeamBullet.Instantiate(go.GetComponent<TestBeamBullet>()); + bullet2.direction = Quaternion.Euler(0, 0, -30) * bullet2.direction; + bullet2.enabled = true; + bullet2.gameObject.SetActive(true); + + m_Seperated.Add(go); + m_Seperated.Add(bullet1.gameObject); + m_Seperated.Add(bullet2.gameObject); + } + } + + private void OnTriggerExit2D(Collider2D collision) + { + GameObject go = collision.gameObject; + if (go.CompareTag("bullet") && m_Seperated.Contains(go)) + { + m_Seperated.Remove(go); + } + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestSeperator.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestSeperator.cs.meta new file mode 100644 index 0000000..58f5ccb --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestSeperator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ec780be79a9ec774b80c4ba5593c3a39 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestSingleton.cs b/AlienSurvival/Assets/Test/Scripts/TestSingleton.cs new file mode 100644 index 0000000..d522653 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestSingleton.cs @@ -0,0 +1,20 @@ +public class TestSingleton<T> where T : class, new() +{ + private static T _instance; + private static readonly object syslock = new object(); + + public static T getInstance() + { + if (_instance == null) + { + lock (syslock) + { + if (_instance == null) + { + _instance = new T(); + } + } + } + return _instance; + } +}
\ No newline at end of file diff --git a/AlienSurvival/Assets/Test/Scripts/TestSingleton.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestSingleton.cs.meta new file mode 100644 index 0000000..8035c63 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestSingleton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0e4486fb2a577bb4fa367c939cd96141 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestSortingByY.cs b/AlienSurvival/Assets/Test/Scripts/TestSortingByY.cs new file mode 100644 index 0000000..59f44b7 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestSortingByY.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestSortingByY : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestSortingByY.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestSortingByY.cs.meta new file mode 100644 index 0000000..5074c7f --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestSortingByY.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a346df7f7a231e46bfeb3dbc1a63116 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AlienSurvival/Assets/Test/Scripts/TestTopDown2DTransform.cs b/AlienSurvival/Assets/Test/Scripts/TestTopDown2DTransform.cs new file mode 100644 index 0000000..acfac68 --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestTopDown2DTransform.cs @@ -0,0 +1,78 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TestTopDown2DTransform : MonoBehaviour +{ + public bool useGravity = false; + + public Vector3 position // x, y, h + { + get + { + Vector3 topdownPos = transform.position; + topdownPos.y -= h; + topdownPos.z = h; + return topdownPos; + } + set + { + h = value.z; + Vector3 realPos = transform.position; + realPos.y = value.y + h; + transform.position = realPos; + } + } + + public float x + { + get + { + return position.x; + } + } + + public float y + { + get + { + return position.y; + } + } + + public float h = 0; + + public float z + { + get + { + return transform.position.z; + } + } + + public float depth + { + get + { + return this.z; + } + } + + private float vy = 0; + + private void Update() + { + if (useGravity) + { + Vector3 pos = position; + vy += -9.8f * Time.deltaTime; + pos.z = Mathf.Max(pos.z + vy * Time.deltaTime, 0f); + if(pos.z == 0) + { + vy = 0; + } + position = pos; + } + } + +} diff --git a/AlienSurvival/Assets/Test/Scripts/TestTopDown2DTransform.cs.meta b/AlienSurvival/Assets/Test/Scripts/TestTopDown2DTransform.cs.meta new file mode 100644 index 0000000..b8279be --- /dev/null +++ b/AlienSurvival/Assets/Test/Scripts/TestTopDown2DTransform.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65a986ca41323a44c910b7d7660abf9c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |