public void Wake(Vector3 impulse) { manager.Ragdoll(); if (impulse.magnitude >= minCollisionMagnitude) { manager.Damage(Mathf.Clamp(impulse.magnitude * collisionMultiplicator, 0, maxDamage), true); } }
public override void DealDamage(HealthManager manager, GameObject projectile) { if (manager != null) { if (projectile.name != "miniArrow") { manager.Damage(realDmg, null, gameObject); } else { manager.Damage((realDmg / 100) * 75, null, gameObject); } } projectile.SetActive(false); }
private void OnCollisionEnter(Collision col) { if (col.gameObject.transform.CompareTag("Projectile")) { return; } HealthManager hitObjHP = col.gameObject.transform.GetComponent <HealthManager>(); if (hitObjHP != null) { hitObjHP.Damage(damage); } Rigidbody rigidbody = col.gameObject.transform.GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.AddForceAtPosition(transform.forward * (5f) * knockback, transform.position); } if (col != null) { Destroy(ObjectToDestroy); } }
void Explode() { if (detonationSE != null) { AudioSource.PlayClipAtPoint(detonationSE, this.transform.position); } Collider[] aroundObjs = Physics.OverlapSphere(this.transform.position, explodeRange); foreach (Collider subject in aroundObjs) { HealthManager subjectHealth = subject.transform.GetComponent <HealthManager>(); if (subjectHealth != null) { float proximity = (this.transform.position - subject.transform.position).magnitude; float effect = 1 - (proximity / explodeRange); subjectHealth.Damage((int)(damageAtCenter * effect)); } Rigidbody subjectRB = subject.transform.GetComponent <Rigidbody>(); if (subjectRB != null) { subjectRB.AddExplosionForce(knockbackAtCenter, this.transform.position, explodeRange); } } if (detonationEffect != null) { GameObject grenadeFlame = Instantiate(detonationEffect, this.transform); grenadeFlame.transform.SetParent(null); Destroy(grenadeFlame, 2f); } Destroy(objectToDetonate); }
void HitEvent(Collider2D hit) { if (hit.CompareTag("Damagable") || hit.CompareTag("Player")) { HealthManager healthMangCollider = hit.GetComponent <HealthManager>(); if (isDamage) { healthMangCollider.Damage(effectValue); } else { healthMangCollider.Heal(effectValue); } KillSelf(); } else if (hit.CompareTag("Projectiles")) { if (collideWithProjectiles) { Destroy(hit.gameObject); KillSelf(); } } else { KillSelf(); } }
public override void DealDamage(HealthManager manager, GameObject projectile) { if (manager != null) { manager.Damage(realDmg, null, gameObject); } projectile.SetActive(false); }
/* void OnCollisionEnter(Collision collision) * { * if(collision.transform.tag == "Player") * { * Debug.Log("Contacted with player"); * } * }*/ void OnTriggerEnter(Collider other) { if (other.tag == "Player") { HealthManager d = other.GetComponent <HealthManager>(); d.Damage(1); } }
void OnCollisionEnter(Collision collision) { if (collision.rigidbody) { //Could use _punchingBagComponent.HealthInfo.Damage(...) but this is just an example HealthManager.Damage((int)(collision.relativeVelocity.magnitude * .25f), _punchingBagComponent.gameObject, collision.rigidbody.gameObject); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Good")) { health.Damage(); } Destroy(other.gameObject); }
public void HitTest() { if (!health.invincible) { health.Damage(1); //play player got hit sfx MyGame.PlaySFX("Sounds/playerHit.wav", 2f); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Enemy")) { HealthManager hp = other.gameObject.GetComponent <HealthManager>(); if (hp != null) { hp.Damage(dmg * CharacterBehaviour.characterStats.associatedLevel, null, playerObj); } } }
public void Reflect(float i, HealthManager enemyHp, GameObject g = null) { if (enemyHp == null) { return; } float newDmg = i / 100 * percentageReflet; enemyHp.Damage(newDmg, null, gameObject); }
private void EnemyHit(Enemy en) { HealthManager health = en.healthManage; if (health.health > 0) { if (!health.invincible) { health.Damage(damage); } LateDestroy(); } }
protected override void OnPicked(Collider other) { base.OnPicked(other); HealthManager healthManager = other.GetComponent <HealthManager>(); if (!healthManager) { return; } healthManager.Damage(damage); Destroy(gameObject); }
void Fire() { if (fireTimer >= fireRate && reloading >= reloadTime && !isRunning) { currentAmmo--; RaycastHit hit; if (Physics.Raycast(shootPoint.position, shootPoint.transform.forward + Random.onUnitSphere * curScatter, out hit, shootRange)) { // if hit Debug.Log(weaponName + " hit / Remaining ammo: " + currentAmmo + "/" + ammoPerMag); // marking bullets by using prefab GameObject hitHole = Instantiate(hitHolePrefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); hitHole.transform.SetParent(hit.transform); Destroy(hitHole, 5f); // knockback needs hit hole not to have a Mesh Collider // each hit hole needs their own mesh collider removed Rigidbody rigidbody = hit.transform.GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.AddForceAtPosition(transform.forward * 5f * knockbackPerRound, transform.position); } // hit HP reduction does so // each hit hole needs their own mesh collider removed HealthManager hitObjHP = hit.transform.GetComponent <HealthManager>(); if (hitObjHP != null) { hitObjHP.Damage(damagePerRound); } } else { // if miss Debug.Log(weaponName + " miss / Remaining ammo: " + currentAmmo + "/" + ammoPerMag); } anim.CrossFadeInFixedTime("Fire", fireRate); weaponSound.PlayOneShot(fireSE); CasingExitEffect(); IncreaseScatter(); fireTimer = 0.0f; } }
void TestDamage(Collider collider) { if (collider.tag != gameObject.tag) { var damageScript = collider.GetComponent <ApplyDamageBehavior>(); if (damageScript != null && damageScript.enabled == true) { healthManager.Damage(damageScript.damage); if (particleSystem != null) { particleSystem.Emit(20); } soundManager.PlaySound(hitSoundIdentifier); tookDamage = true; } } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.transform.CompareTag("Player")) { Debug.Log("Player Missile Collide"); return; } if (collision.gameObject.transform.CompareTag("Projectile")) { Debug.Log("Projectile Missile Collide"); return; } Debug.Log("Missile Collide"); HealthManager hitHP = collision.gameObject.transform.GetComponent <HealthManager>(); if (hitHP != null) { hitHP.Damage(damage); } Destroy(this.transform.gameObject); }
void Update() { if (timerIsRunning) { if (timeRemaining > 0) { if (!clock.isPlaying) { clock.Play(); } timeRemaining -= Time.deltaTime; DisplayTime(timeRemaining); } else { timerText.SetText("00:00"); clock.Stop(); timerIsRunning = false; timeRemaining = timeLimit; hm.Damage(1); } } }
public override void DealDamage(HealthManager manager, GameObject projectile) { manager.Damage(realDmg, null, gameObject); }
public virtual void Damage(float amount) { healthManager.Damage(amount); }
void Fire() { if (Input.GetKey(InputManager.Fire) && IsFireable()) { // Animation & Sound Effect anim.CrossFadeInFixedTime("Fire", fireRate); weaponSound.PlayOneShot(fireSE); // Shoot point flame GameObject shootFlame = Instantiate(shootFlamePrefab, pointFlameSpot.transform); Destroy(shootFlame, fireRate); GameObject pointFlame = Instantiate(pointFlamePrefab, pointFlameSpot.transform); Destroy(pointFlame, fireRate / 2); // Hit Scan RaycastHit hit; if (Physics.Raycast(shootPoint.transform.position, shootPoint.transform.forward + Random.onUnitSphere * curScatter, out hit, shootRange)) { // if hit //Debug.Log(weaponName + " hit / Remaining ammo: " + currentAmmo + "/" + ammoPerMag); // Muzzle Flash on the hit object GameObject muzzleFlash = Instantiate(muzzleFlashPrefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); muzzleFlash.transform.SetParent(hit.transform); Destroy(muzzleFlash, 1f); // marking bullets by using prefab GameObject hitHole = Instantiate(hitHolePrefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); hitHole.transform.SetParent(hit.transform); Destroy(hitHole, 5f); // knockback needs hit hole not to have a Mesh Collider // each hit hole needs their own mesh collider removed Rigidbody rigidbody = hit.transform.GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.AddForceAtPosition(transform.forward * (-5f) * knockbackPerRound, transform.position); } // hit HP reduction does so // each hit hole needs their own mesh collider removed HealthManager hitObjHP = hit.transform.GetComponent <HealthManager>(); if (hitObjHP != null) { hitObjHP.Damage(damagePerRound); } } else { // if miss //Debug.Log(weaponName + " miss / Remaining ammo: " + currentAmmo + "/" + ammoPerMag); } curScatter += scatterIncreasePerRound; if (curScatter > maxScatter) { curScatter = maxScatter; } // Process fireTimer = 0; currentAmmo--; } }
public override void DealDamage(HealthManager manager, GameObject projectile) { myHealth.Heal(lifesteal * CharacterBehaviour.characterStats.associatedLevel); //lifesteal * playerlevel + lifesteal stats manager.Damage(realDmg, null, gameObject); projectile.SetActive(false); }
public override void DealDamage(HealthManager manager, GameObject projectile) { manager.Damage(realDmg, null, gameObject); manager.gameObject.GetComponent <EnemyMovement>().GiveSlow(slowAmount, slowDuration); projectile.SetActive(false); }
// Update is called once per frame void Update() //por el momento se utiliza toque unico { if (Input.touchCount == 0) { return; } if (Input.touchCount == 2) { // Store both touches. Touch touchZero = Input.GetTouch(0); Touch touchOne = Input.GetTouch(1); // Find the position in the previous frame of each touch. Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition; // Find the magnitude of the vector (the distance) between the touches in each frame. float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude; float touchDeltaMag = (touchZero.position - touchOne.position).magnitude; // Find the difference in the distances between each frame. float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag; if (deltaMagnitudeDiff <= 0) { // HeroPower salud.HeroPowerActivate(); } } Touch toque = Input.GetTouch(0); Vector3 objetivo = Camera.main.ScreenToWorldPoint(toque.position); RaycastHit2D hit = Physics2D.Raycast(objetivo, objetivo); if (hit.collider != null) { //TODO comportamiento de audio GameObject obj = hit.collider.gameObject; if (obj.tag.Equals("Good")) { puntaje.IncreaseScore(); salud.Recover(); } else if (obj.tag.Equals("Bad")) { puntaje.LoseStreak(); salud.Damage(); } Note nota = obj.GetComponent <Note>(); if (nota != null) { int note = nota.note; int vol = nota.volume; int inst = nota.instrument; float duration = nota.duration; StartCoroutine(PlayNote(note, vol, inst, duration)); Destroy(obj); } } }