//private void Update() //{ // if (Input.GetKeyDown(KeyCode.K) && isLocalPlayer) // TakeDamage(30, "Magic"); // if (Input.GetKeyDown(KeyCode.V) && isLocalPlayer) // Win(); // if (Input.GetKeyDown(KeyCode.C) && isLocalPlayer) // ratio = "Shit :("; //} public void TakeDamage(int damage, string type) { if (isDead) { return; } if (type == "Magic") { camShake.ShakeCam(fireBallShakePosMag, fireBallShakeRotMag); } else { camShake.ShakeCam(shakeDelay); } if (type == "Sword") { //blood particle audioManager.PlaySFX("Sword Hit"); GameObject particle = Instantiate(swordHitParticle, hitHolder); Destroy(particle, 1f); } else if (type == "Fist") { //hit effect audioManager.PlaySFX("Fist Hit"); GameObject particle = Instantiate(fistHitParticle, hitHolder); Destroy(particle, 1f); } audioManager.PlaySFX("Pain"); currentHealth -= damage; if (currentHealth < 0) { currentHealth = 0; } SetHealthBar(currentHealth); if (isLocalPlayer) { if (currentHealth == 0) { Die(); } animator.SetInteger("HitNO", Random.Range(1, 4)); animator.SetTrigger("GotHit"); } if (currentHealth == 0 && !isLocalPlayer) { manager.localPlayer.GetComponent <Player>().Win(); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Environment")) { Collider2D[] objectsToDamage = Physics2D.OverlapCircleAll(transform.position, areaOfEffect, whatIsDestructible); for (int i = 0; i < objectsToDamage.Length; i++) { objectsToDamage[i].GetComponent <DestructibleEnvi>().health -= damage; shake.ShakeCam(); } GameObject terEffect = Instantiate(effect, transform.position, Quaternion.identity); Destroy(gameObject); Destroy(terEffect, 0.5f); } }
void Update() { if (timer <= 0) { Collider2D[] objectsToDamage = Physics2D.OverlapCircleAll(transform.position, areaOfEffect, whatIsDestructible); for (int i = 0; i < objectsToDamage.Length; i++) { objectsToDamage[i].GetComponent <DestructibleEnvi>().health -= damage; shake.ShakeCam(); } GameObject effectD = Instantiate(bombEffect, transform.position, Quaternion.identity); Destroy(gameObject); Destroy(effectD, 1f); } else { timer -= Time.deltaTime; } }
private void OnTriggerEnter(Collider other) { if (other.transform.root.name == transform.root.name) { return; } GetComponent <Rigidbody>().velocity = Vector3.zero; GameObject tempExplosion = Instantiate(explosion, transform.position, Quaternion.identity); Destroy(this.gameObject, destroyDelay); if (other.tag != "Player") { camShake.ShakeCam(explosionShakeMag, explosionRotMag); return; } if (transform.root.name == "local player") { actionControl.Damage(other.GetComponent <NetworkIdentity>().netId.ToString(), damage, "Magic"); } }