summaryrefslogtreecommitdiff
path: root/GameCode/TracerRound.cs
diff options
context:
space:
mode:
Diffstat (limited to 'GameCode/TracerRound.cs')
-rw-r--r--GameCode/TracerRound.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/GameCode/TracerRound.cs b/GameCode/TracerRound.cs
new file mode 100644
index 0000000..201a5f7
--- /dev/null
+++ b/GameCode/TracerRound.cs
@@ -0,0 +1,48 @@
+using UnityEngine;
+
+public class TracerRound : MonoBehaviour
+{
+ public GameObject bullet;
+
+ public GameObject bulletSpawnPos;
+
+ private TracerTarget target;
+
+ private MoveTransform move;
+
+ private bool done;
+
+ private void Start()
+ {
+ move = GetComponent<MoveTransform>();
+ bullet = Object.Instantiate(bullet, bulletSpawnPos.transform.position, bulletSpawnPos.transform.rotation);
+ bullet.GetComponent<ProjectileHit>().damage *= base.transform.localScale.x;
+ GetComponentInParent<SpawnedAttack>().CopySpawnedAttackTo(bullet);
+ target = bullet.GetComponent<TracerTarget>();
+ GetComponentInParent<ProjectileHit>().AddHitActionWithData(Hit);
+ bullet.GetComponentInParent<ProjectileHit>().AddHitActionWithData(Hit);
+ }
+
+ public void Hit(HitInfo hit)
+ {
+ if ((bool)hit.transform.root.GetComponent<Player>())
+ {
+ base.transform.SetParent(null);
+ base.gameObject.AddComponent<RemoveAfterSeconds>().seconds = 10f;
+ base.gameObject.AddComponent<FollowTransform>().target = hit.transform;
+ }
+ }
+
+ private void Update()
+ {
+ if (target != null)
+ {
+ target.SetPos(base.transform.position, Vector3.Cross(Vector3.forward, base.transform.forward), move);
+ }
+ if (bullet == null && !done)
+ {
+ done = true;
+ GetComponentInChildren<ParticleSystem>().Stop();
+ }
+ }
+}