using System.Collections; using System.Collections.Generic; using UnityEngine; /* -------------------------------------- Project: Programing assessment Standard: 91906 (AS3.7) v.1 School: Tauranga Boys' College Author: Rauputu Noah Phizacklea Date: August 2024 Unity: 2021.3.18f --------------------------------------- */ public class BossWeapon : MonoBehaviour { public int attackDamage = 20; // Damage dealt by the boss in normal attack public int enragedAttackDamage = 40; // Damage dealt by the boss in enraged attack public Vector3 attackOffset; // Offset position for attack calculations public float attackRange = 1f; // Range of the attack public LayerMask attackMask; // Layer mask to filter which objects are affected by the attack // Method to perform a normal attack public void Attack() { // Calculate the position where the attack will be checked Vector3 pos = transform.position; pos += transform.right * attackOffset.x; pos += transform.up * attackOffset.y; // Check for any colliders within the attack range at the calculated position Collider2D colInfo = Physics2D.OverlapCircle(pos, attackRange, attackMask); if (colInfo != null) { // If an object with PlayerHealth component is hit, apply damage colInfo.GetComponent().TakeDamage(attackDamage); } } // Method to perform an enraged attack public void EnragedAttack() { // Calculate the position where the attack will be checked Vector3 pos = transform.position; pos += transform.right * attackOffset.x; pos += transform.up * attackOffset.y; // Check for any colliders within the attack range at the calculated position Collider2D colInfo = Physics2D.OverlapCircle(pos, attackRange, attackMask); if (colInfo != null) { // If an object with PlayerHealth component is hit, apply enraged damage colInfo.GetComponent().TakeDamage(enragedAttackDamage); } } // Method to visualize attack range in the editor void OnDrawGizmosSelected() { // Calculate the position where the attack range will be visualized Vector3 pos = transform.position; pos += transform.right * attackOffset.x; pos += transform.up * attackOffset.y; // Draw a wire sphere to show the attack range Gizmos.DrawWireSphere(pos, attackRange); } }