Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Platformer/Platformer/Assets/Scripts/Player&Enemy/BossWeapon.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (44 sloc)
1.42 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class BossWeapon : MonoBehaviour | |
{ | |
//same as user weapon really, enraged attack just makes faster | |
public int attackDamage = 20; | |
public int enragedAttackDamage = 40; | |
public Vector3 attackOffset; | |
public float attackRange = 1f; | |
public LayerMask attackMask; | |
public void Attack() | |
{ | |
//attack circle | |
Vector3 pos = transform.position; | |
pos += transform.right * attackOffset.x; | |
pos += transform.up * attackOffset.y; | |
Collider2D colInfo = Physics2D.OverlapCircle(pos, attackRange, attackMask); | |
if (colInfo != null) | |
{ | |
colInfo.GetComponent<Player>().TakeDamage(20); | |
} | |
} | |
//same as attack up their but animated more often | |
public void EnragedAttack() | |
{ | |
Vector3 pos = transform.position; | |
pos += transform.right * attackOffset.x; | |
pos += transform.up * attackOffset.y; | |
Collider2D colInfo = Physics2D.OverlapCircle(pos, attackRange, attackMask); | |
if (colInfo != null) | |
{ | |
colInfo.GetComponent<Player>().TakeDamage(30); | |
} | |
} | |
//draw circle in scene view | |
void OnDrawGizmosSelected() | |
{ | |
Vector3 pos = transform.position; | |
pos += transform.right * attackOffset.x; | |
pos += transform.up * attackOffset.y; | |
Gizmos.DrawWireSphere(pos, attackRange); | |
} | |
} |