void bigGuyJump()
{
float height = Mathf.PerlinNoise(jumpIter, 0f) * 10f;
height = height * height * 0.3f;
// Debug.Log("height:"+height+" jumpIter:"+jumpIter);
LeanTween.moveY(avatarBig, height, 1f).setEase(LeanTweenType.easeInOutQuad).setOnComplete(() => {
LeanTween.moveY(avatarBig, 0f, 0.27f).setEase(LeanTweenType.easeInQuad).setOnComplete(() => {
LeanTween.cancel(gameObject);
/**************
* Camera Shake
**************/
float shakeAmt = height * 0.2f; // the degrees to shake the camera
float shakePeriodTime = 0.42f; // The period of each shake
float dropOffTime = 1.6f; // How long it takes the shaking to settle down to nothing
LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime)
.setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking
.setLoopClamp()
.setRepeat(-1);
// Slow the camera shake down to zero
LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate(
(float val) => {
shakeTween.setTo(Vector3.right * val);
}
).setEase(LeanTweenType.easeOutQuad);
/********************
* Shake scene objects
********************/
// Make the boxes jump from the big stomping
GameObject[] boxes = GameObject.FindGameObjectsWithTag("Respawn"); // I just arbitrarily tagged the boxes with this since it was available in the scene
foreach (GameObject box in boxes)
{
box.rigidbody.AddForce(Vector3.up * 100 * height);
}
// Make the lamps spin from the big stomping
GameObject[] lamps = GameObject.FindGameObjectsWithTag("GameController"); // I just arbitrarily tagged the lamps with this since it was available in the scene
foreach (GameObject lamp in lamps)
{
float z = lamp.transform.eulerAngles.z;
z = z > 0.0f && z < 180f ? 1 : -1; // push the lamps in whatever direction they are currently swinging
lamp.rigidbody.AddForce(new Vector3(z, 0f, 0f) * 15 * height);
}
// Play BOOM!
playAudio(boomAudioClip, transform.position, height * 0.2f, 0.34f);
// Have the jump happen again 2 seconds from now
LeanTween.delayedCall(2f, bigGuyJump);
});
});
jumpIter += 5.2f;
}