void Update() { GameManager.playerPosition = gameObject.transform.position; anim.SetBool("gotBalloon", false); if (GameManager.gotBalloons) { anim.SetBool("gotBalloon", true); } // end game check if (GameManager.gotBalloons && GameManager.gotBlanket && GameManager.gotBouquet && GameManager.gotWine && GameManager.gotRadio) { GameManager.gotEverything = true; Debug.Log("hooray u got errethang"); } // movement code moveDirection *= 0.75f; anim.SetBool("biking", false); if (Input.GetKey(rightKey)) { moveDirection += Vector2.right; spriteRenderer.flipX = false; lastKeyLeft = false; anim.SetBool("biking", true); } if (Input.GetKey(leftKey)) { moveDirection += Vector2.left; spriteRenderer.flipX = true; lastKeyLeft = true; anim.SetBool("biking", true); } else if (lastKeyLeft) { spriteRenderer.flipX = true; } // audio code // bike pedal audio if (Input.GetKeyDown(leftKey)) { bikeAudio = SoundController.me.PlaySound(bikePedalingSound); } if (Input.GetKeyUp(leftKey)) { bikeAudio.Stop(); } if (Input.GetKeyDown(rightKey)) { bikeAudio = SoundController.me.PlaySound(bikePedalingSound); } if (Input.GetKeyUp(rightKey)) { bikeAudio.Stop(); } // bell ring audio if (Input.GetKeyDown(bellKey)) { SoundController.me.PlaySoundJitter(bikeRingSound, 1f, 0.2f, 1.3f, 0.5f); } // bird chirp audio currentChirpCountDown -= Time.deltaTime; if (currentChirpCountDown < 0) { chirpCountDown = Random.Range(5, 20); Debug.Log("chirp count down: " + chirpCountDown); SoundController.me.PlaySoundJitter(birdChirpSound, 1f, 0.2f, 1.3f, 0.5f); currentChirpCountDown = chirpCountDown; Debug.Log("bird chirp"); } // dialogue code if (dialogueNPC != null) { if (lastKeyLeft) { leftNotificationPrefab.SetActive(true); rightNotificationPrefab.SetActive(false); } else { rightNotificationPrefab.SetActive(true); leftNotificationPrefab.SetActive(false); } if (Input.GetKeyDown(interactKey)) { Debug.Log("talking"); if (dialogueManager.InConversation) { dialogueManager.AdvanceConversation(); } else { dialogueManager.BeginConversation(dialogueNPC); } } } else { leftNotificationPrefab.SetActive(false); rightNotificationPrefab.SetActive(false); if (dialogueManager.InConversation) { dialogueManager.EndConversation(); } } }
void Update() { currentHealthCoolDownTime -= Time.deltaTime; currentWeaponCoolDown -= Time.deltaTime; if (currentHealthCoolDownTime < 0) { currentHealthCoolDownTime = 0; Debug.Log("not invulnerable"); invulnerable = false; } if (currentWeaponCoolDown < 0) { currentWeaponCoolDown = 0; Debug.Log("weapon ready"); weaponCoolingDown = false; } if (npc != null) { if (Input.GetKeyDown(interactKey)) { if (dialogueManager.InConversation) { // Debug.Log("INTERACTING AT TIME: " + Time.time); dialogueManager.AdvanceConversation(); } else { dialogueManager.BeginConversation(npc); } } } else { if (dialogueManager.InConversation) { dialogueManager.EndConversation(); } } moveDirection *= 0.75f; anim.SetBool("moving", false); if (Input.GetKey(rightKey)) { moveDirection += Vector2.right; lastKeyLeft = false; anim.SetBool("moving", true); spriteRenderer.flipX = false; } else { spriteRenderer.flipX = false; } if (Input.GetKey(leftKey)) { moveDirection += Vector2.left; lastKeyLeft = true; anim.SetBool("moving", true); spriteRenderer.flipX = true; } else if (lastKeyLeft) { spriteRenderer.flipX = true; } if (Input.GetKeyDown(jumpKey) && OnGround) { Debug.Log("jump"); anim.SetTrigger("jumping"); anim.SetBool("moving", false); Sound.me.PlaySoundJitter(jumpSound, 1f, 0.2f, 1.3f, 0.5f); rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse); } if (Input.GetKeyDown(attackKey) && weaponCoolingDown == false) { weaponCoolingDown = true; currentWeaponCoolDown = weaponCoolDown; anim.SetTrigger("attacking"); anim.SetBool("moving", false); GameObject weapon = Instantiate(weaponPrefab); Vector3 newPos = weapon.transform.position; Sound.me.PlaySoundJitter(attackSound, 1f, 0.2f, 1.3f, 0.5f); if (lastKeyLeft) { newPos.x = transform.position.x - 0.8f; } else { newPos.x = transform.position.x + 0.8f; } newPos.y = transform.position.y; weapon.transform.position = newPos; } updateHealthUI(); }