35 lines
635 B
C#
35 lines
635 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.Hp-=AttackDamage;
|
|
Debug.Log("Opponent Hp = " + Enemy.Hp);
|
|
|
|
//Kill if no hp
|
|
if(Enemy.Hp <= 0) {
|
|
Destroy(Enemy);
|
|
}
|
|
|
|
AttackSpeedWait = 0f;
|
|
}
|
|
|
|
AttackSpeedWait += Time.deltaTime;
|
|
}
|
|
|
|
}
|