1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/Entities/Attack/MeleeAttack.cs
Saibotk f03c0f4469 Attack package
2 simple attack types 
IAttack interface
2018-04-22 23:49:43 +02:00

35 lines
889 B
C#

using System;
using UnityEngine;
namespace Assets.Scripts.Entities.Attack {
[Serializable]
class MeleeAttack : IAttack {
int damage = 12;
float cooldown = 1;
float range = 1.5f;
GameObject owner;
public MeleeAttack(GameObject owner) {
this.owner = owner;
}
public void Attack() {
RaycastHit2D hit = Physics2D.Raycast(owner.transform.position, owner.transform.localRotation * Vector3.up, range);
Mob m = hit.collider.gameObject.GetComponent(typeof(Mob)) as Mob;
if ( m != null && m.tag != owner.tag) {
m.InflictDamage(damage);
}
// Todo animation?
}
public float GetCooldownTime() {
return cooldown;
}
public float GetRange() {
return range;
}
}
}