/// <summary> /// Raises the attack event. /// </summary> public override void OnAttack(WeaponHitbox hitbox) { var hb = hitbox as Arrow; if (hb != null) { hb.Direction = hb.Direction.RotateY(hb.transform.localRotation.eulerAngles.y); } }
private void OnTriggerEnter(Collider other) { WeaponHitbox enemy = other.gameObject.GetComponent <WeaponHitbox>(); if ((other.gameObject.tag == "Weapon") && (hitStun <= 0.05) && (enemy != null)) { health -= enemy.damage; hitStun = enemy.attackSpeed; } }
/// <summary> /// Raises the attack event. /// </summary> public override void OnAttack(WeaponHitbox hitbox) { if (_cameraTrack == null || _playerController == null) { _playerController = Parent.GetComponent <PlayerMovement>(); _cameraTrack = Parent.GetComponent <CameraTrack>(); } _hitbox = hitbox as BoomerangHitbox; _hitbox.StartFlight(_cameraTrack, _playerController); }
public virtual void startAttacking(Transform playerTransform, PlayerHands hands) { //spawn weapon at location GameObject currentlySpawnedWeapon = Instantiate(weaponPrefab, playerTransform); currentlySpawnedWeapon.AddComponent <SpriteRenderer>(); currentlySpawnedWeapon.GetComponent <SpriteRenderer>().sprite = itemGraphic; currentlySpawnedWeapon.AddComponent <PolygonCollider2D>(); WeaponHitbox hitbox = currentlySpawnedWeapon.AddComponent <WeaponHitbox>(); hitbox.init(this); currentlySpawnedWeapon.layer = 8; hands.spawnedItem = currentlySpawnedWeapon; }
/// <summary> /// Raises the attack event. /// </summary> public override void OnAttack(WeaponHitbox hitbox) { _canAttack = false; }
/// <summary> /// Called when the attack button is pressed. /// </summary> public abstract void OnAttack(WeaponHitbox hitbox);