summaryrefslogtreecommitdiff
path: root/AlienSurvival/Assets/Scripts/Test
diff options
context:
space:
mode:
Diffstat (limited to 'AlienSurvival/Assets/Scripts/Test')
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs52
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestBeamGun.cs79
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestBeamGun.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestCameraSortByY.cs23
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestCameraSortByY.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestCannon.cs44
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestCannon.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestCharacterMovement.cs40
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestCharacterMovement.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestEnforceTransform0.cs11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestEnforceTransform0.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestMirror.cs30
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestMirror.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestMoveToTarget.cs45
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestMoveToTarget.cs.meta11
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestSeperator.cs37
-rw-r--r--AlienSurvival/Assets/Scripts/Test/TestSeperator.cs.meta11
18 files changed, 460 insertions, 0 deletions
diff --git a/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs b/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs
new file mode 100644
index 0000000..d5d0476
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs
@@ -0,0 +1,52 @@
+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()
+ {
+ 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.attachedRigidbody.gameObject;
+
+ if(go.CompareTag("device"))
+ {
+ return;
+ }
+
+ if(go.CompareTag("bullet"))
+ {
+ return;
+ }
+
+ //Debug.Log("hit");
+
+ GameObject.Destroy( collision.attachedRigidbody.gameObject);
+
+ this.gameObject.SetActive(false);
+
+ GameObject.Destroy(this.gameObject);
+ }
+
+}
diff --git a/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestBeamBullet.cs.meta
new file mode 100644
index 0000000..b1551a7
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestBeamGun.cs b/AlienSurvival/Assets/Scripts/Test/TestBeamGun.cs
new file mode 100644
index 0000000..69225b6
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestBeamGun.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestBeamGun.cs.meta
new file mode 100644
index 0000000..cfeb8f2
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestCameraSortByY.cs b/AlienSurvival/Assets/Scripts/Test/TestCameraSortByY.cs
new file mode 100644
index 0000000..585f2c3
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestCameraSortByY.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestCameraSortByY.cs.meta
new file mode 100644
index 0000000..210a02e
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestCannon.cs b/AlienSurvival/Assets/Scripts/Test/TestCannon.cs
new file mode 100644
index 0000000..e68186f
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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());
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+
+ 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/Scripts/Test/TestCannon.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestCannon.cs.meta
new file mode 100644
index 0000000..52c902c
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestCharacterMovement.cs b/AlienSurvival/Assets/Scripts/Test/TestCharacterMovement.cs
new file mode 100644
index 0000000..8911ea9
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestCharacterMovement.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestCharacterMovement.cs.meta
new file mode 100644
index 0000000..606b4cc
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestEnforceTransform0.cs b/AlienSurvival/Assets/Scripts/Test/TestEnforceTransform0.cs
new file mode 100644
index 0000000..57b777d
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestEnforceTransform0.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestEnforceTransform0.cs.meta
new file mode 100644
index 0000000..3371029
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestMirror.cs b/AlienSurvival/Assets/Scripts/Test/TestMirror.cs
new file mode 100644
index 0000000..25ea3db
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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.attachedRigidbody.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.attachedRigidbody.gameObject;
+ if (go && go.CompareTag("bullet") && m_Mirrored.Contains(go))
+ {
+ m_Mirrored.Remove(go);
+ }
+ }
+}
diff --git a/AlienSurvival/Assets/Scripts/Test/TestMirror.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestMirror.cs.meta
new file mode 100644
index 0000000..6fdba29
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestMoveToTarget.cs b/AlienSurvival/Assets/Scripts/Test/TestMoveToTarget.cs
new file mode 100644
index 0000000..4b5f637
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestMoveToTarget.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestMoveToTarget.cs.meta
new file mode 100644
index 0000000..6f68458
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/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/Scripts/Test/TestSeperator.cs b/AlienSurvival/Assets/Scripts/Test/TestSeperator.cs
new file mode 100644
index 0000000..4f96379
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/TestSeperator.cs
@@ -0,0 +1,37 @@
+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.attachedRigidbody.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;
+
+ TestBeamBullet bullet2 = TestBeamBullet.Instantiate(go.GetComponent<TestBeamBullet>());
+ bullet2.direction = Quaternion.Euler(0, 0, -30) * bullet2.direction;
+
+ m_Seperated.Add(go);
+ m_Seperated.Add(bullet1.gameObject);
+ m_Seperated.Add(bullet2.gameObject);
+ }
+ }
+
+ private void OnTriggerExit2D(Collider2D collision)
+ {
+ GameObject go = collision.attachedRigidbody.gameObject;
+ if (go.CompareTag("bullet") && m_Seperated.Contains(go))
+ {
+ m_Seperated.Remove(go);
+ }
+ }
+
+}
diff --git a/AlienSurvival/Assets/Scripts/Test/TestSeperator.cs.meta b/AlienSurvival/Assets/Scripts/Test/TestSeperator.cs.meta
new file mode 100644
index 0000000..58f5ccb
--- /dev/null
+++ b/AlienSurvival/Assets/Scripts/Test/TestSeperator.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ec780be79a9ec774b80c4ba5593c3a39
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: