|
@ -9,6 +9,8 @@ public class MissileController : MonoBehaviour { |
|
|
public float initVelocity = 5; |
|
|
public float initVelocity = 5; |
|
|
public float boostCoolDown = 0.3f; |
|
|
public float boostCoolDown = 0.3f; |
|
|
public float difficulty = 0.0f; |
|
|
public float difficulty = 0.0f; |
|
|
|
|
|
public int totalBoosts = 2; |
|
|
|
|
|
|
|
|
public ParticleSystem boostEffect; |
|
|
public ParticleSystem boostEffect; |
|
|
public GameObject Explosion; |
|
|
public GameObject Explosion; |
|
|
|
|
|
|
|
@ -42,20 +44,20 @@ public class MissileController : MonoBehaviour { |
|
|
|
|
|
|
|
|
rigid = GetComponent<Rigidbody2D>(); |
|
|
rigid = GetComponent<Rigidbody2D>(); |
|
|
rigid.velocity = startVelocity * initVelocity; |
|
|
rigid.velocity = startVelocity * initVelocity; |
|
|
Destroy(gameObject, 1.5f); |
|
|
|
|
|
|
|
|
Destroy(gameObject, boostCoolDown * totalBoosts + 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
// Update is called once per frame
|
|
|
void FixedUpdate () { |
|
|
void FixedUpdate () { |
|
|
|
|
|
|
|
|
if (Time.time - startTime >= boostCoolDown && reCalibrate < 2) { |
|
|
|
|
|
|
|
|
if (Time.time - startTime >= boostCoolDown && reCalibrate < totalBoosts) { |
|
|
if (reCalibrate == 0) { |
|
|
if (reCalibrate == 0) { |
|
|
targetPos = target.transform.position; |
|
|
|
|
|
|
|
|
if (target != null) { |
|
|
|
|
|
targetPos = target.transform.position; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (target != null) { |
|
|
if (target != null) { |
|
|
moveTorwards(target); |
|
|
moveTorwards(target); |
|
|
} else { |
|
|
|
|
|
moveTorwards(targetPos); |
|
|
|
|
|
} |
|
|
} |
|
|
reCalibrate++; |
|
|
reCalibrate++; |
|
|
startTime = Time.time; |
|
|
startTime = Time.time; |
|
@ -79,6 +81,9 @@ public class MissileController : MonoBehaviour { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void moveTorwards(GameObject target) { |
|
|
private void moveTorwards(GameObject target) { |
|
|
|
|
|
if (target == null) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
if (targetRigid != null && reCalibrate == 1) { |
|
|
if (targetRigid != null && reCalibrate == 1) { |
|
|
Debug.DrawLine(targetPos, target.transform.position, Color.blue, 0.3f); |
|
|
Debug.DrawLine(targetPos, target.transform.position, Color.blue, 0.3f); |
|
|
Vector2 pos = Vector3.Lerp( targetPos,target.transform.position,difficulty); |
|
|
Vector2 pos = Vector3.Lerp( targetPos,target.transform.position,difficulty); |
|
|