36 lines
680 B
C#
36 lines
680 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Ally : Entity
|
|
{
|
|
|
|
void Update() {
|
|
|
|
if(IsEnemyDetected) {
|
|
AttackEnemy();
|
|
}
|
|
|
|
}
|
|
|
|
void AttackEnemy() {
|
|
//Attack Cooldown
|
|
if(AttackSpeed < AttackSpeedWait) {
|
|
|
|
Enemy.hit(AttackDamage);
|
|
Debug.Log("Opponent Hp = " + Enemy.Hp);
|
|
|
|
//Kill if no hp
|
|
if(Enemy.Hp <= 0) {
|
|
IsEnemyDetected = false;
|
|
Enemy.death();
|
|
}
|
|
|
|
AttackSpeedWait = 0f;
|
|
}
|
|
|
|
AttackSpeedWait += Time.deltaTime;
|
|
}
|
|
|
|
}
|