//jesli kula zada obrazenia to ona tez znika; //jesli nie to nic sie nie stanie, kula przeniknie przez cel //jesli cel nie jest wrogi to tez nic sie nie stanie public void Kill(IDamagable target) { if (target.DealDamage(this.owner)) { //kula trafila przeciwnika this.deleteThis = true; } }
private void OnCollisionEnter2D(Collision2D collision) { IDamagable damageable = collision.gameObject.GetComponent <IDamagable>(); if (damageable != null) { damageable.DealDamage(damage); } gameObject.SetActive(false); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.name != "Player") { collider.radius = explodeRadius; IDamagable damageable = other.gameObject.GetComponent <IDamagable>(); if (damageable != null) { damageable.DealDamage(spellDmg); } Destroy(gameObject, 0.1f); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Enemy") { IDamagable damageable = other.gameObject.GetComponent <IDamagable>(); if (damageable != null) { Piercing(); damageable.DealDamage(spellDmg); } transform.LookAt(other.transform); } }
private void OnTriggerEnter(Collider other) { IDamagable damageable = other.gameObject.GetComponent <IDamagable>(); if (damageable != null) { damageable.DealDamage(spellDmg); Destroy(gameObject); } if (other.gameObject.name != "Player") { Destroy(gameObject); } }
private void OnTriggerEnter(Collider other) { IDamagable damageable = other.gameObject.GetComponent <IDamagable>(); if (other.CompareTag("Enemy") && other.GetType() == typeof(CapsuleCollider)) { damageable.DealDamage(gunDmg); Destroy(gameObject); } if (other.gameObject.name != "Player" && other.GetType() != typeof(SphereCollider)) { Destroy(gameObject); } }
private IEnumerator Explode(Collider other) { collider.radius = 5; rb.useGravity = false; pos = transform.position; IDamagable damageable = other.gameObject.GetComponent <IDamagable>(); if (damageable != null) { for (int i = 0; i < amountOfTicks; i++) { Debug.Log("TICK"); damageable.DealDamage(spellTickDmg); yield return(new WaitForSeconds(waitBetweenTick)); } Destroy(gameObject); } yield return(new WaitForSeconds(0)); }
private void CheckForShooting() { if (Input.GetKeyDown(playerController.primaryFireKey)) { RaycastHit whatIsHit; //Sends a raycast in the forward direction forever, until it hits an object. if (Physics.Raycast(cameraTransform.position, transform.forward, out whatIsHit, Mathf.Infinity)) { //The raycast checks if the object has the IDamagable interface applied to it. IDamagable damagable = whatIsHit.collider.GetComponent <IDamagable>(); //If the object does have the IDamageable interface, then it will deal damage. If it does not, nothing will happen. if (damagable != null) { damagable.DealDamage(currentWeapon.maximumDamage); } //Print name of object that raycast has hit. Debug.Log(whatIsHit.collider.name); } } }
protected void Fire(Transform cameraPos) { if (AmmunitionManager.instance.ConsumeAmmo(ammunitionType)) //if player has ammo then shoot { RaycastHit whatIHit; if (Physics.Raycast(cameraPos.position, cameraPos.transform.forward, out whatIHit, Mathf.Infinity)) { Debug.Log(whatIHit.collider.name); IDamagable damagable = whatIHit.collider.GetComponent <IDamagable>(); if (damagable != null) { //checks the distance of the fired shot float normalisedDistance = whatIHit.distance / maximumRange; //if the distance is more than 1 that means that it is above the max range if (normalisedDistance <= 1) { //make damage drop off as range goes up damagable.DealDamage(Mathf.RoundToInt(Mathf.Lerp(maximumDamage, minimumDamage, normalisedDistance))); } } } } }