private void OnTriggerEnter2D(Collider2D collision) { //Damage player when hit, turn on the scream sound, turn big and opague for 1s if (collision.gameObject.tag == "Player") { Debug.Log("hit player"); screamAudioControl.Play(); player.loseHP(damage); transform.localScale *= jumpOutScale; spr.color = new Color(spr.color.r, spr.color.g, spr.color.b, 1.0f); transform.DOScale(oldScale, 1.0f).Play(); spr.DOFade(0f, 1.0f).Play(); //seq.Restart(); } }
private void Update() { if (player.hp <= 0) { Die(); } rigi.velocity = Vector2.zero; direction = Vector2.zero; //Movement Control if (!fl.getFlashLight()) { direction = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); anim.SetFloat("x", Input.GetAxis("Horizontal")); anim.SetFloat("y", Input.GetAxis("Vertical")); rigi.velocity = direction * speed * playerSpeedScale; } //Turn on off the flash light if (Input.GetButton("Light")) { TurnOnFlashLight(); } else if (Input.GetButtonUp("Light")) { TurnOffFlashLight(); } //Leave blood mark if (Input.GetButtonDown("Mark")) { if (player.hp > 1) { Instantiate(mark, transform.position, Quaternion.identity); player.loseHP(1); } } if (!isCooling) { if (Input.GetButton("Sprint")) { if (player.stamina > 0) { playerSpeedScale = speedUpScale; consumeStamina(); } else { playerSpeedScale = 1; isCooling = true; StartCoroutine(CoolingTime()); } } else { if (player.stamina < 1) { playerSpeedScale = 1; recoverStamina(); } else { playerSpeedScale = 1; } } } else { playerSpeedScale = 1; } }