private void OnTriggerEnter(Collider other) { if (other.tag == "Enemy") { int thisWeaponDamgae = this.GetComponent <WeaponStats> ().weaponDamage; EnemyHealth healthEnemy = other.gameObject.GetComponent <EnemyHealth>(); if (healthEnemy != null) { healthEnemy.DamageTaken(thisWeaponDamgae); } player = GameObject.FindGameObjectWithTag("Player"); if (player.GetComponent <PlayerWeapons> ().activItem != null) { contactedActivItem = player.GetComponent <PlayerWeapons> ().activItem; contactedActivItem.GetComponent <ActivDamageMetter> ().damageNow += thisWeaponDamgae; } Destroy(gameObject); } if (other.tag == "Room") { Destroy(gameObject); } }
private void OnTriggerEnter(Collider other) { // Referenced https://learn.unity.com/tutorial/collecting-scoring-and-building-the-game?projectId=5c51479fedbc2a001fd5bb9f#5c7f8529edbc2a002053b78b // for how to inflict damage on an enemy when it comes into contact with a potion explosion // If the game object is a potion, deal damage to the enemy if (other.gameObject.CompareTag("Potion")) { // Increase the damage taken by the enemy if the amount of damage the potion inflicts has been increased if (GC.damageIncreased) { enemyHealth.DamageTaken(50); } else { enemyHealth.DamageTaken(25); } // Reset the damage increase for the next potion GC.damageIncreased = false; } }
void DrawBounseLine(Vector3 position, Vector3 direction, int reflectionsRemaining) { RaycastHit hit; if (Physics.Raycast(position, direction, out hit)) { if ((hit.collider) && (hit.collider.tag != "Trigger")) { // lr.SetPosition(1, Vector3.Lerp(hit.point, gameObject.transform.position,0)); //new Vector3(hit.point.x+Random.Range(-5f,5f), hit.point.y, hit.point.z + Random.Range(-5f, 5f))); lr.SetPosition(currentBouse, hit.point); // lr.numPositions = 4; direction = Vector3.Reflect(direction, hit.normal); position = hit.point; currentBouse++; if (reflectionsRemaining == 1) { return; } lr.positionCount++; DrawBounseLine(position, direction, reflectionsRemaining - 1); if (((hit.collider.tag == "Enemy") || (hit.collider.tag == "Projective")) && (Time.time > nextFire)) { Debug.Log("laser hit enemyaw"); //Relaod Time nextFire = Time.time + (this.GetComponent <WeaponStats>().weaponReloadTime - (this.GetComponent <WeaponStats>().weaponReloadTime *player.GetComponent <PlayerWeapons>().atackSPeedBuff / 100)); EnemyHealth healthEnemy = hit.collider.gameObject.GetComponent <EnemyHealth>(); //Deal Damage if (healthEnemy != null) { float DamageBuffAdd = player.GetComponent <PlayerWeapons>().damageBuff; float DamageTOAdd = this.GetComponent <WeaponStats>().weaponDamage + (this.GetComponent <WeaponStats>().weaponDamage *DamageBuffAdd / 100); healthEnemy.DamageTaken(DamageTOAdd); } } } else { position += direction * 300; //laserLight.transform.position = hit.transform.position; lr.SetPosition(currentBouse, direction * 2000); } } laserLight.SetActive(true); laserLight.transform.position = new Vector3(lr.GetPosition(currentBouse - 1).x, 1f, lr.GetPosition(currentBouse - 1).z); }
void DrawLine(Vector3 position, Vector3 direction) { RaycastHit hit; LayerMask layerMask = 2; layerMask = ~layerMask; if (Physics.Raycast(position, direction, out hit, Mathf.Infinity)) { if ((hit.collider) && (hit.collider.tag != "Trigger")) { // Debug.Log("layer " + hit.transform.gameObject.layer); // lr.SetPosition(1, Vector3.Lerp(hit.point, gameObject.transform.position,0)); //new Vector3(hit.point.x+Random.Range(-5f,5f), hit.point.y, hit.point.z + Random.Range(-5f, 5f))); lr.SetPosition(1, hit.point); // lr.numPositions = 4; if (((hit.collider.tag == "Enemy") || (hit.collider.tag == "Projective")) && (Time.time > nextFire)) { //Relaod Time nextFire = Time.time + (this.GetComponent <WeaponStats>().weaponReloadTime - (this.GetComponent <WeaponStats>().weaponReloadTime *player.GetComponent <PlayerWeapons>().atackSPeedBuff / 100)); EnemyHealth healthEnemy = hit.collider.gameObject.GetComponent <EnemyHealth>(); //Deal Damage if (healthEnemy != null) { float DamageBuffAdd = player.GetComponent <PlayerWeapons>().damageBuff; float DamageTOAdd = this.GetComponent <WeaponStats>().weaponDamage + (this.GetComponent <WeaponStats>().weaponDamage *DamageBuffAdd / 100); healthEnemy.DamageTaken(DamageTOAdd); } } } else { // position += direction * 300; //laserLight.transform.position = hit.transform.position; lr.SetPosition(1, direction * 2000); } } laserLight.SetActive(true); laserLight.transform.position = new Vector3(lr.GetPosition(1).x, 1f, lr.GetPosition(1).z); }