Utilize interfaces to create new Enemy class inheriting them and further developing on them also encapsulating more enemy type functions
34 lines
916 B
C#
34 lines
916 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
|
|
public class Attacker {
|
|
public int BaseDamage = 0;
|
|
public bool CanAttack => Time.time < AttackCooldown;
|
|
public float AttackCooldown { get; protected set; } = 0f;
|
|
public float AttackCooldownLeft => Math.Max(0, AttackCooldown - Time.time);
|
|
public float AttackCooldownDuration { get; protected set; } = 1f;
|
|
public void StartAttackCooldown() => AttackCooldown = Time.time;
|
|
}
|
|
|
|
|
|
public interface IAttacker {
|
|
int BaseDamage { get; }
|
|
bool CanAttack => Time.time < AttackCooldown;
|
|
|
|
void StartAttackPreparation();
|
|
float AttackPreparationTime { get; }
|
|
float AttackPreparationTimeLeft { get; }
|
|
bool AttackIsReady { get; }
|
|
|
|
void StartAttackCooldown();
|
|
float AttackCooldown { get; }
|
|
float AttackCooldownLeft { get; }
|
|
float AttackCooldownDuration { get; }
|
|
}
|
|
|