private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "PlayerWeapon") // if hit by player bullet { ObjectPooling.Bullets.Bullet temp = other.gameObject.GetComponent <ObjectPooling.Bullets.Bullet>(); if (temp == null) { this.health -= 2; } else { this.health -= temp.GetDamage(); } } if (other.gameObject.tag == "CaneWeaponHitBox" && other.GetComponent <BoxCollider>() != null) //hit by player cane { other.GetComponent <BoxCollider>().enabled = false; } }
private void Update() { if (Managers.GameState.Instance.CurrentState != Managers.GameState.State.Playing) { return; } if (invunTimer > 0) { if (flashTimer > flashInterval) { isVisible = !isVisible; flashTimer = 0; this.mesh.SetActive(isVisible); } flashTimer += Time.deltaTime; invunTimer -= Time.deltaTime; } else if (!isVisible || isInvulnerable) { isVisible = true; this.mesh.SetActive(true); isInvulnerable = false; } if (this.Health <= 0 && !this.dead) { GameOver.Instance.Show(); this.sfx.PlayPlayerDieSFX(); this.dead = true; } float yRot = cameraControl.UpdateCamera(); if (yRot != 0) { float z = this.transform.rotation.eulerAngles.z; this.transform.Rotate(new Vector3(0f, yRot, 0f)); this.transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, z); } if (this.Moving) { Move(); } this.anim.SetBool(this.moveHash, this.Moving); if (!this.meleeing && CustomInput.BoolFreshPress(CustomInput.UserInput.Melee)) { this.meleeCollider.enabled = true; this.meleeing = true; CaneHitbox.enabled = true; this.anim.SetBool(this.meleeHash, true); this.sfx.PlayPlayerMeleeSFX(); } else if (this.meleeing) { this.rgdb.velocity *= .5f; } if (!reloading && !shooting && CustomInput.BoolFreshPress(CustomInput.UserInput.Shoot)) { GameObject g = BulletPool.Instance.GetBullet(BulletPool.BulletTypes.Player); if (g != null) { this.shooting = true; ObjectPooling.Bullets.Bullet rf = g.GetComponent <ObjectPooling.Bullets.Bullet>(); MeleeWeaponTrail[] fb = rf.trails; if (fb != null) { foreach (MeleeWeaponTrail m in fb) { m.startTrail(); } } g.transform.position = gunPos.position; g.transform.rotation = gunPos.rotation; this.anim.SetBool(this.shootHash, true); this.agro.radius += 1f; this.sfx.PlayPlayerGunfireSFX(); this.reloadUI.Fire(this.bullets); this.bullets--; } } else if (this.shooting) { this.rgdb.velocity *= .75f; } if (!reloading && (bullets < 0 || CustomInput.BoolFreshPress(CustomInput.UserInput.Reload))) { this.reloading = true; this.reloadUI.StartReload(); } else if (this.reloading && !this.reloadUI.IsReloading) { this.bullets = this.maxBullets; this.reloading = false; } if (!this.recharging && CustomInput.BoolFreshPress(CustomInput.UserInput.Screech)) { this.recharging = true; this.agro.radius *= 2f; this.screechUI.StartRecharge(); this.camEffects.Screech(); GameObject s = SonarPool.Instance.GetSonar(1f, 10f); s.transform.position = this.foot.position; s = SonarPool.Instance.GetSonar(8f, 10f); s.transform.position = this.foot.position; this.sfx.PlayPlayerSonarSFX(); } else if (this.recharging && !this.screechUI.IsRecharging) { this.recharging = false; } this.agro.radius = Mathf.Min(this.agro.radius, this.agroCap); if (this.agro.radius > this.originalRadius) { this.agro.radius -= Time.deltaTime * .75f; } }