|
|
@ -23,21 +23,25 @@ public class Catapult : MonoBehaviour |
|
|
|
private BGCcCursorObjectTranslate splineObjectTranslate; |
|
|
|
private Vector3 originalScale; |
|
|
|
private MeshRenderer meshRenderer; |
|
|
|
private ParticleSystem particleSystem; |
|
|
|
private Collider boulderCollider; |
|
|
|
private ParticleSystem boulderParticleSystem; |
|
|
|
|
|
|
|
void Start () |
|
|
|
{ |
|
|
|
splineCursor = splineCurve.GetComponent<BGCcCursor>(); |
|
|
|
splineObjectTranslate = splineCurve.GetComponent<BGCcCursorObjectTranslate>(); |
|
|
|
meshRenderer = splineObjectTranslate.ObjectToManipulate.GetComponent<MeshRenderer>(); |
|
|
|
particleSystem = splineObjectTranslate.ObjectToManipulate.GetComponentInChildren<ParticleSystem>(); |
|
|
|
boulderCollider = splineObjectTranslate.ObjectToManipulate.GetComponent<Collider>(); |
|
|
|
boulderParticleSystem = splineObjectTranslate.ObjectToManipulate.GetComponentInChildren<ParticleSystem>(); |
|
|
|
meshRenderer.enabled = false; |
|
|
|
particleSystem.Stop(); |
|
|
|
boulderCollider.enabled = false; |
|
|
|
boulderParticleSystem.Stop(); |
|
|
|
|
|
|
|
originalScale = splineCurve.transform.parent.localScale; |
|
|
|
|
|
|
|
NotificationServer.register("statechange Searchlight", searchlightStateChanged); |
|
|
|
NotificationServer.register("BoulderHit", boulderHit); |
|
|
|
NotificationServer.register("restart scene", boulderHit); |
|
|
|
} |
|
|
|
|
|
|
|
void Update() |
|
|
@ -72,26 +76,31 @@ public class Catapult : MonoBehaviour |
|
|
|
isLaunching = false; |
|
|
|
return; |
|
|
|
} |
|
|
|
particleSystem.Stop(); |
|
|
|
meshRenderer.enabled = true; |
|
|
|
boulderParticleSystem.Stop(); |
|
|
|
splineCursor.DistanceRatio = 0f; |
|
|
|
splineCurve.transform.parent.position = player.position |
|
|
|
+ Vector3.right * Random.Range(-randomFactor, randomFactor) |
|
|
|
+ Vector3.forward * Random.Range(-randomFactor, randomFactor); |
|
|
|
splineCurve.transform.parent.localEulerAngles = Vector3.up * Random.Range(0f, 360f); |
|
|
|
splineCurve.transform.parent.localScale = new Vector3(Random.Range(minScale * originalScale.x, maxScale * originalScale.x), originalScale.y, originalScale.z); |
|
|
|
particleSystem.Play(); |
|
|
|
LeanTween.value(splineObjectTranslate.ObjectToManipulate.gameObject, 0f, 1f, splineCursor.Math.GetDistance() / speed) |
|
|
|
.setEase(animationCurve) |
|
|
|
.setOnUpdate((float val)=>{ |
|
|
|
splineCursor.DistanceRatio = val; |
|
|
|
}).setOnComplete(()=>{ |
|
|
|
particleSystem.Stop(); |
|
|
|
// splineCursor.DistanceRatio = 0f;
|
|
|
|
isLaunching = false; |
|
|
|
meshRenderer.enabled = false; |
|
|
|
launchBoulder(); |
|
|
|
}); |
|
|
|
LeanTween.delayedCall(splineObjectTranslate.ObjectToManipulate.gameObject, 0.1f, ()=>{ |
|
|
|
boulderParticleSystem.Play(); |
|
|
|
meshRenderer.enabled = true; |
|
|
|
boulderCollider.enabled = true; |
|
|
|
LeanTween.value(splineObjectTranslate.ObjectToManipulate.gameObject, 0f, 1f, splineCursor.Math.GetDistance() / speed) |
|
|
|
.setEase(animationCurve) |
|
|
|
.setOnUpdate((float val)=>{ |
|
|
|
splineCursor.DistanceRatio = val; |
|
|
|
}).setOnComplete(()=>{ |
|
|
|
boulderParticleSystem.Stop(); |
|
|
|
isLaunching = false; |
|
|
|
meshRenderer.enabled = false; |
|
|
|
LeanTween.delayedCall(splineObjectTranslate.ObjectToManipulate.gameObject, 0.5f, ()=>{ |
|
|
|
boulderCollider.enabled = false; |
|
|
|
launchBoulder(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |