void handleBroom() { if (AtlasInputManager.getKeyPressed("Broom") || AtlasInputManager.getKeyPressed("Down") || (!AtlasInputManager.getKey("Broom") && AtlasInputManager.Instance.holdBroom)) { endBroom(); return; } if (AtlasInputManager.getKeyPressed("Jump") && canDoubleJump && resourceManager.Instance.getPlayerMana() >= 1) { endBroom(); if (hasDoubleJump) { doubleJump(); } return; } if ((facing == -1) ? controller.collisions.left : controller.collisions.right) { startBonk(); return; } float vdir = 0 * AtlasInputManager.getAxisState("Dpad").y; velocity.y = moveSpeed / 2.0f * vdir; velocity.x = moveSpeed * 2 * facing; }
void handleHolding() { if (!anim.GetBool("isHolding")) { return; } if (!heldObject) { anim.SetBool("isHolding", false); return; } heldObject.transform.localScale = new Vector3(facing, 1, 1); if ((state != State.Movement && state != State.WaitMoveable) || AtlasInputManager.getKeyPressed("Down")) { anim.SetBool("isHolding", false); dropHolding(); } else if (AtlasInputManager.getKeyPressed("Up") || AtlasInputManager.getKeyPressed("Jump")) { anim.SetBool("isHolding", false); anim.SetTrigger("Throw"); freezeForSeconds(0.4f, true); Invoke("throwHolding", 0.15f); } }
void handleAttack() { anim.SetFloat("animTime", anim.GetCurrentAnimatorStateInfo(0).normalizedTime); deformer.RemoveDeform("fastfall"); if (AtlasInputManager.getKeyPressed("Attack")) { state = State.Attack; anim.SetTrigger("Attack"); } if (!isGrounded()) { arialAttacking = true; } else { if (arialAttacking) { if (fastFalling) { anim.SetTrigger("fastFall"); } anim.SetTrigger("attackLand"); anim.SetBool("Attacking", false); particleMaker.createDust(); } arialAttacking = false; } }
private void Update() { if (AtlasInputManager.getKeyPressed("Escape")) { if (SceneManager.GetActiveScene().name == "Main Menu") { Application.Quit(); } else { switch (state) { case MenuState.Closed: togglePauseMenu(true); break; case MenuState.Pause: togglePauseMenu(false); break; case MenuState.Controls: togglePauseMenu(true); break; case MenuState.Cheats: togglePauseMenu(true); break; } } } }
void allowDoor() { if (currentDoor != null && AtlasInputManager.getKeyPressed("Interact")) { cutScenePrep(); StartCoroutine(doDoor()); } }
public void handleScout() { if (AtlasInputManager.getKeyPressed("Scout")) { //pauseUntilCondition(); gameManager.Instance.pause_manager.addPause(pauseManager.PauseType.Scouter); GameObject scouter = gameManager.createInstance("UI/ScouterTarget", transform.position); Camera.main.GetComponent <cameraController>().target = scouter.transform; } }
private void OnTriggerStay2D(Collider2D other) { if (other.gameObject.layer == LayerMask.NameToLayer("BroomTrigger") && state == State.Broom) { other.SendMessage("OnBroomCollide"); } if (other.CompareTag("Liftable") && AtlasInputManager.getKeyPressed("Up", true)) { liftObject(other.gameObject); } if (other.CompareTag("ResetDamaging")) { if (graceFrames > 0) { graceFrames--; } else { resetPosition = true; } } ; if (other.CompareTag("ResetDrown")) { drown(); } if (intangibleStates.Contains(state)) { return; } if (other.gameObject.layer == LayerMask.NameToLayer("Danger") && (!invulnerable || other.CompareTag("ResetDamaging"))) { if (other.CompareTag("ResetDamaging") && graceFrames > 0) { return; } if (other.CompareTag("Projectile")) { projectile p = other.GetComponent <projectile>(); if (p.hurtPlayer) { p.hit(); } } startBonk(1, resetPosition); return; } }
void canPickUp() { if (AtlasInputManager.getKeyPressed("Down") && isGrounded()) { RaycastHit2D pickup = Physics2D.Raycast(transform.position, -Vector2.up, 0.5f, 1 << LayerMask.NameToLayer("Pickupable")); if (pickup.collider != null) { pickup.transform.SendMessage("pickUp"); } } }
void handleAttackInput() { if (AtlasInputManager.getKeyPressed("Attack")) { if (state == State.Broom) { endBroom(); } state = State.Attack; anim.SetTrigger("SelectAttack"); } }
// Update is called once per frame void Update() { if (!AtlasInputManager.getKey("Scout")) { Destroy(gameObject); } if (selectedPc && AtlasInputManager.getKeyPressed("Jump")) { textPanel.SetActive(true); textPanel.GetComponentInChildren <TextMeshProUGUI>().text = selectedPc.scoutMessage.Replace("\\n", "\n"); } Vector2 velocity = AtlasInputManager.getAxisState("Dpad"); transform.Translate(velocity * speed * Time.deltaTime); }
IEnumerator WallJumpCoroutine() { state = State.WallJump; GameObject explosion = gameManager.createInstance("Effects/Explosions/wallBlast", transform.position + new Vector3(-0.80f * facing, 0.23f, 0)); explosion.transform.localScale = sprite.localScale; if (screenShake) { Camera.main.GetComponent <cameraController>().StartShake(0.2f, 0.15f); } SoundManager.Instance.playClip("wallBlast"); anim.SetBool("isJumping", false); anim.SetBool("isFalling", false); anim.SetBool("wallSlide", false); anim.SetBool("wallBlast", true); yield return(new WaitForSeconds(wallBlastDelay)); anim.SetBool("isJumping", true); anim.SetBool("wallBlast", false); flipHorizontal(); velocity.y = wallJumpVelocity; float startTime = Time.time; while (Time.time - startTime < 0.1f) { velocity.x = wallJumpVelocity * facing; velocity.y += gravity * Time.deltaTime; if (AtlasInputManager.getKeyPressed("Broom") && canBroom) { triggerBroomStart(); yield break; } yield return(new WaitForFixedUpdate()); } anim.SetBool("wallBlast", false); returnToMovement(); }
void handleTornado() { canTornado = false; canBroom = true; canDoubleJump = true; anim.SetBool("inTornado", true); velocity = Vector3.zero; transform.position = Vector3.SmoothDamp(transform.position, currentTornado.position, ref velocitySmoothing, 0.05f); if (AtlasInputManager.getKeyPressed("Jump")) { firstJump(); anim.SetBool("inTornado", false); returnToMovement(); Deformer nadoDeformer = currentTornado.GetComponent <Deformer>(); if (nadoDeformer) { nadoDeformer.startDeform(new Vector3(0.75f, 2.0f, 1.0f), 0.1f); SoundManager.Instance.playClip("LevelObjects/EnterTornado", 1); } currentTornado = null; } if (AtlasInputManager.getKeyPressed("Down")) { movingPlatform mp = currentTornado.GetComponent <movingPlatform>(); if (mp) { velocity.x = mp.getVelocity().x; } Deformer nadoDeformer = currentTornado.GetComponent <Deformer>(); if (nadoDeformer) { nadoDeformer.startDeform(new Vector3(2.0f, 0.25f, 1.0f), 0.1f); } anim.SetBool("inTornado", false); returnToMovement(); currentTornado = null; SoundManager.Instance.playClip("LevelObjects/EnterTornado", -1); } }
void handleMovement(float msMod = 1.0f, bool canJump = true, bool canTurnAround = true) { if (heldObject != null) { msMod *= 0.5f; canJump = false; } Vector2 input = new Vector2(0, 0); if (!(state == State.WaitMoveable && isGrounded())) { input = new Vector2(AtlasInputManager.getAxisState("Dpad").x, AtlasInputManager.getAxisState("Dpad").y); } if (isGrounded() || coyoteTime > 0) { if (AtlasInputManager.getKeyPressed("Jump") && canJump) { firstJump(); } if (AtlasInputManager.getKeyPressed("Broom")) { triggerBroomStart(); } if (isGrounded()) { if (!canBroom && state == State.Movement) { canBroom = true; } canDoubleJump = true; resourceManager.Instance.restoreMana(); } } else { if (canBroom && AtlasInputManager.getKeyPressed("Broom")) { if (wallRiding) { flipHorizontal(); triggerBroomStart(fastBroom, facing); } else { triggerBroomStart(fastBroom); } return; } if (hasWallJump && wallRiding && AtlasInputManager.getKeyPressed("Jump") && resourceManager.Instance.getPlayerMana() >= 2) { state = State.WallJumpInit; return; } if (hasDoubleJump && AtlasInputManager.getKeyPressed("Jump") && canJump && canDoubleJump && resourceManager.Instance.getPlayerMana() >= 1) { doubleJump(); } } float currentMoveSpeed = moveSpeed; if (isCrouching()) { currentMoveSpeed = 1.5f; } float targetVelocityX = input.x * currentMoveSpeed * msMod; anim.SetBool("isRunning", isGrounded() && (targetVelocityX != 0)); anim.SetBool("isJumping", !isGrounded() && (velocity.y > 0) && canDoubleJump); anim.SetBool("isFalling", !isGrounded() && (velocity.y < -0.5f) && !controller.collisions.descendingSlope && !heldObject); anim.SetBool("wallSlide", wallRiding); if (wallRiding) { deformer.RemoveDeform("jump"); deformer.RemoveDeform("fastfall"); } if (canTurnAround) { setFacing(velocity.x); } velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below) ? groundAccelerationTime : airAccelerationTime); velocity.y += gravity * Time.deltaTime * ((wallRiding && velocity.y <= 0) ? 0.5f : 1.0f); if (wallRiding && velocity.y < maxWallSlideVel) { velocity.y = maxWallSlideVel; } float termVel; if (fastFalling) { if (AtlasInputManager.getAxisState("Dpad").y >= 0 || isGrounded() || velocity.y > 0) { fastFalling = false; } termVel = fastFallVel; velocity.y += gravity * Time.deltaTime; } else { termVel = maxFallVel; deformer.RemoveDeform("fastfall"); if (AtlasInputManager.getKeyPressed("Down") && !isGrounded() && (velocity.y <= 0.5f || !AtlasInputManager.getKey("Jump"))) { fastFalling = true; deformer.startDeform(new Vector3(0.85f, 1.4f, 1.0f), 0.2f, -1.0f, -1.0f, "fastfall", true); } } if (velocity.y < termVel) { velocity.y = termVel; } if (velocity.y <= 0 && controller.isSafePosition()) { lastSafePosition = transform.position; } }
void Update() { if (AtlasInputManager.getKeyPressed("Cheat")) { hasDoubleJump = true; hasWallJump = true; SoundManager.Instance.playClip("jump2"); } playerShouldWait(); handleParticles(); if (state != State.Wait && state != State.WaitMoveable) { handleUncrouch(); handleHolding(); handleScout(); } switch (state) { case State.Movement: handleMovement(); handleAttackInput(); canPickUp(); allowDoor(); allowCrouch(); break; case State.BroomStart: handleBroomStart(); break; case State.Broom: handleBroom(); handleAttackInput(); break; case State.Attack: handleAttack(); handleMovement(isGrounded() ? 0f : 1.0f, false, false); break; //Hurt and Bonk look the same to the player, but have different effects case State.Bonk: case State.Hurt: bonk(); break; case State.Reset: handleReset(); break; case State.WaitMoveable: handleMovement(1, false, false); break; case State.WallJumpInit: wallJumpInit(); break; case State.WallJump: handleWallJump(); break; case State.Tornado: handleTornado(); break; default: break; } //Debug.DrawLine(lastSafePosition, lastSafePosition + Vector3.up, Color.blue); }
private void OnTriggerStay2D(Collider2D collision) { if (!(transform.parent && transform.parent.name == "seed") && collision.CompareTag("Player") && canPick && AtlasInputManager.getKeyPressed("Up", true)) { if (gameManager.Instance.playerCtrl.canLift()) { GameObject berry = gameManager.createInstance(liftObject, center); gameManager.Instance.playerCtrl.liftObject(berry.transform.Find("handle").gameObject); StartCoroutine(Picked(false)); } } }