// Update is called once per frame void Update() { BaseUpdate(); if (myCollider.IsTouching(lemonCollider)) { Debug.LogWarning("touching!"); LoadNextScene(); } if (CommandsHeldThisFrame.ContainsKey(Command.Up)) { UpdateFloat(MoveDirection.Up); } else if (CommandsHeldThisFrame.ContainsKey(Command.Down)) { UpdateFloat(MoveDirection.Down); } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { UpdateFloat(MoveDirection.Left); } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { UpdateFloat(MoveDirection.Right); } }
public void Update() { timeSinceLastJump += Time.deltaTime; BaseUpdate(); if (!visible) { return; } float distanceToTarget = Vector3.Distance(this.transform.position, Target.transform.position); if (distanceToTarget < lemonDistance || Target.IsTouching(this.lemonGrabCollider)) { snatchSFX.Play(); LoadNextScene(); } bool didSomething = false; if (CommandsHeldThisFrame.ContainsKey(Command.Up) || CommandsHeldThisFrame.ContainsKey(Command.Fire)) { didSomething = true; UpdateJump(); } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Left); } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Right); } if (!didSomething) { UpdateIdle(); } }
// Update is called once per frame public void Update() { BaseUpdate(); UpdateGravity(); UpdateHunger(); timeSinceLastJump += Time.deltaTime; if (!hangry) { bool didSomething = false; if (CommandsHeldThisFrame.ContainsKey(Command.Up) || CommandsHeldThisFrame.ContainsKey(Command.Fire)) { didSomething = true; UpdateJump(); } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Left); } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Right); } if (!didSomething) { UpdateIdle(); } } else { UpdateHangry(); } }
void UpdatePreClench() { if (CommandsHeldThisFrame.ContainsKey(Command.Up)) { arm.transform.localPosition = new Vector3( arm.transform.localPosition.x, arm.transform.localPosition.y + Time.deltaTime * armSpeed, arm.transform.localPosition.z ); } if (CommandsHeldThisFrame.ContainsKey(Command.Down)) { arm.transform.localPosition = new Vector3( arm.transform.localPosition.x, arm.transform.localPosition.y - Time.deltaTime * armSpeed, arm.transform.localPosition.z ); } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { arm.transform.localPosition = new Vector3( arm.transform.localPosition.x - Time.deltaTime * armSpeed, arm.transform.localPosition.y, arm.transform.localPosition.z ); } if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { arm.transform.localPosition = new Vector3( arm.transform.localPosition.x + Time.deltaTime * armSpeed, arm.transform.localPosition.y, arm.transform.localPosition.z ); } if (arm.transform.position.y > maxHeight) { clickSound.Play(); arm.SetActive(false); clenchedArm.SetActive(true); clenchedArm.transform.position = new Vector3( arm.transform.position.x, maxHeight, arm.transform.position.z ); clenched = true; jitter *= jitterIntensityIncreaseAfterClench; jitterPeriod /= jitterIntensityIncreaseAfterClench; } }
private void UpdateSwingMotion() { if (currentTime < Period) { currentTime += 1 * Time.deltaTime; Container.transform.localRotation = new Quaternion(Container.transform.localRotation.x, Container.transform.localRotation.y, maxAngle - 2f * (maxAngle * Curve.Evaluate(Mathf.Abs(currentTime) / Period)), 1 * Container.transform.localRotation.w ); } else { currentTime = -Period; } bool helpingSwing = false; bool hurtingSwing = false; if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { Head.transform.localPosition = new Vector3(headStartPosition.x - HeadOffset, headStartPosition.y, headStartPosition.z); if (currentTime > 0) { helpingSwing = true; } else { hurtingSwing = true; } } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { Head.transform.localPosition = new Vector3(headStartPosition.x + HeadOffset, headStartPosition.y, headStartPosition.z); if (currentTime < 0) { helpingSwing = true; } else { hurtingSwing = true; } } else { Head.transform.localPosition = new Vector3(headStartPosition.x + 0f, headStartPosition.y, headStartPosition.z); } if (helpingSwing) { DebugText.text = "helping"; maxAngle += MaxAngleIncreasePerSecond * Time.deltaTime; Period -= PeriodDecreasePerSecond * Time.deltaTime; } if (hurtingSwing) { DebugText.text = "hurting"; maxAngle -= MaxAngleIncreasePerSecond * Time.deltaTime; Period += PeriodDecreasePerSecond * Time.deltaTime; } if (maxAngle < MaxAngleMinimum) { maxAngle = MaxAngleMinimum; } }
public void Update() { BaseUpdate(); if (shantyIsSaiyan) { saiyanElapsed += Time.deltaTime; if (saiyanElapsed > gunDestroyTime && laser.IsTouching(SternCollider)) { //todo explosions LoadNextScene(); } if (CommandsHeldThisFrame.ContainsKey(Command.Up)) { UpdateFloat(MoveDirection.Up); } else if (CommandsHeldThisFrame.ContainsKey(Command.Down)) { UpdateFloat(MoveDirection.Down); } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { UpdateFloat(MoveDirection.Left); } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { UpdateFloat(MoveDirection.Right); } } else { invincibilityCooldownElapsed += Time.deltaTime; timeSinceLastJump += Time.deltaTime; timeSinceLastBite += Time.deltaTime; if (!shantyIsSaiyan && timeSinceLastBite > biteTime) { ActivateShantyAnimation(ShantyAnimStateM70.Idle); } bool didSomething = false; if (!shantyIsSaiyan && BiteCollider.IsTouching(SternCollider) && timeSinceLastBite > biteCooldown) { // play shanty's bite animation and bounce backwards BiteStern(); } if (CommandsStartedThisFrame.ContainsKey(Command.Up) || CommandsStartedThisFrame.ContainsKey(Command.Fire)) { didSomething = true; AttemptJump(); } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Left); } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Right); } } }
private void Update() { BaseUpdate(); timeSinceLastJump += Time.deltaTime; elapsed += Time.deltaTime; invincibilityCooldownElapsed += Time.deltaTime; if (elapsed > IslandHittable && !hitIsland && MyCollider.IsTouching(IslandCollider)) { hitIsland = true; CamJitter.JitterForDuration(ExplosionJitterDuration); CrashSfx.Play(); BigSandHitSFX.Play(); Explosion.gameObject.SetActive(true); Stern.gameObject.SetActive(false); } if (!startP2 && elapsed > PartTwoTime) { // zoom out, start spawning sharks startP2 = true; MainCam.gameObject.transform.position = CamPosP2; CamJitter.ResetStartingPosition(); Old.gameObject.SetActive(false); New.gameObject.SetActive(true); this.gameObject.transform.position += LowerAmountP2; SternCollider.gameObject.transform.position += LowerAmountP2; Stern.StartPartTwo(); Lemon.gameObject.transform.localPosition = lemonInitialLocalPosition; } if (!startP3 && hitIsland && elapsed > PartThreeTime) { startP3 = true; LoadNextScene(); } if (this.MyCollider.IsTouching(SternCollider)) { TakeDamage(KnockbackForceSternTouch); } if (this.BodyCollider.IsTouching(SternBodyCollider)) { var rLaugh = Random.Range(0, SternLaughs.Length); SternLaughs[rLaugh].Play(); TakeDamage(KnockbackForceSternTouch); } BaseUpdate(); var didSomething = false; if (!hitIsland) { if (CommandsHeldThisFrame.ContainsKey(Command.Up) || CommandsHeldThisFrame.ContainsKey(Command.Fire)) { didSomething = true; UpdateJump(); } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Left); } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Right); } } if (startP2) { // do specific new updates for things like the sharks } }
public void Update() { timeSinceLastJump += Time.deltaTime; BaseUpdate(); if (struckSand && !escaped) { wiggleElapsed += Time.deltaTime; if ( CommandsStartedThisFrame.ContainsKey(Command.Fire) || CommandsStartedThisFrame.ContainsKey(Command.Left) || CommandsStartedThisFrame.ContainsKey(Command.Right) || CommandsStartedThisFrame.ContainsKey(Command.Up) || CommandsStartedThisFrame.ContainsKey(Command.Down) ) { if (wiggleElapsed > WiggleCooldown) { //wiggle numWiggles++; SandHitSFX.Play(); wiggleElapsed = 0f; this.transform.localPosition += WiggleOffset; if (numWiggles > EscapeWiggles) { Container.gameObject.SetActive(true); BonkedMoxie.SetActive(false); Sandpile.SetActive(false); AlbaStarsAnimation.gameObject.SetActive(false); currentlyFlippingOut = true; PopOutSfx.Play(); escaped = true; this.myRigidbody.gravityScale = 1; // enable this in a little bit ActivateAnimation(MaoxunAnimState23.Idle); StartCoroutine(EnableMyColliderInABit()); myRigidbody.AddForce(EscapeForce); myRigidbody.AddTorque(EscapeTorque); } } } } else if (currentlyFlippingOut) { // wait until you land then give back control to the player and right moxie if (myCollider.IsTouching(GroundCollider)) { // right her this.transform.rotation = InitialRotation; SetMobile(true); currentlyFlippingOut = false; } } else { scareElapsed += Time.deltaTime; if (!doneScared && scareElapsed > ScareTime) { doneScared = true; ScareSprite.gameObject.SetActive(false); this.Container.gameObject.SetActive(true); this.myRigidbody.gravityScale = 1f; } // if ur airborne and hit space, jumpkick if (doneScared && !currentlyFlippingOut) { var didSomething = false; if (this.myCollider.IsTouching(GroundCollider)) { airborne = false; kicking = false; } else { didSomething = true; airborne = true; } if (kicking && footCollider.IsTouching(island.TreeCollider) && island.IsReady() ) { int nutIndex = island.ShakeTree(); if (nutIndex > 5 && !released) { released = true; Ball.Release(); //LoadNextScene(); } //kicking = false; // push her away a little bit } if (!part3 && part2 && kicking && footCollider.IsTouching(YesCollider)) { StartYes(); } else if (!part3 && part2 && kicking && footCollider.IsTouching(NoCollider)) { StartNo(); } if (CommandsStartedThisFrame.ContainsKey(Command.Up) || CommandsStartedThisFrame.ContainsKey(Command.Fire)) { didSomething = true; if (airborne) { AttemptKick(); } else { AttemptJump(); } } if (CommandsHeldThisFrame.ContainsKey(Command.Left)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Left); } else if (CommandsHeldThisFrame.ContainsKey(Command.Right)) { didSomething = true; UpdateMoveLeftRight(MoveDirection.Right); } if (!didSomething) { UpdateIdle(); } } } }
void Update() { BaseUpdate(); if (nextScene) { return; } var armProgress = arm.transform.position.y / minPosition.y; banjoSound.pitch = minMaxPitch.x + minMaxPitch.y * curve.Evaluate(armProgress); var modifiedArmSpeed = armSpeedCurve.Evaluate(armProgress) * armSpeed; // zoom in as you get closer camera.gameObject.transform.position = new Vector3(camera.gameObject.transform.position.x, camera.gameObject.transform.position.y, minMaxCameraZ.x - (minMaxCameraZ.y * cameraCurve.Evaluate(armProgress)) ); jitterElapsed += Time.deltaTime; if (jitterElapsed > jitterPeriod) { jitterElapsed = 0f; this.gameObject.transform.localPosition += new Vector3( Random.Range(-jitter.x, jitter.x), Random.Range(-jitter.y, jitter.y), Random.Range(-jitter.z, jitter.z)); } if (CommandsHeldThisFrame.ContainsKey(Command.Up) || CommandsHeldThisFrame.ContainsKey(Command.Right)) { arm.transform.localPosition = new Vector3( arm.transform.localPosition.x + Time.deltaTime * modifiedArmSpeed, arm.transform.localPosition.y + Time.deltaTime * modifiedArmSpeed, arm.transform.localPosition.z ); } if (CommandsHeldThisFrame.ContainsKey(Command.Down) || CommandsHeldThisFrame.ContainsKey(Command.Left)) { arm.transform.localPosition = new Vector3( arm.transform.localPosition.x - Time.deltaTime * modifiedArmSpeed, arm.transform.localPosition.y - Time.deltaTime * modifiedArmSpeed, arm.transform.localPosition.z ); } // dont let arm extend farther than we want if (arm.transform.position.x < minPosition.x) { arm.transform.position = new Vector3(minPosition.x, arm.transform.position.y, arm.transform.position.z); } if (arm.transform.position.y < minPosition.y + sceneBreakMargin) { arm.transform.position = new Vector3(arm.transform.position.x, minPosition.y, arm.transform.position.z); stringBreak.Play(); LoadNextScene(); nextScene = true; } }