54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Ally : Entity
|
|
{
|
|
public override float DamageMultiplier => GlobalConfig.Instance.Current.allyDamageMultiplier;
|
|
public override float AttackSpeedMultiplier => GlobalConfig.Instance.Current.allyAttackSpeedMultiplier;
|
|
public override float HpMultiplier => GlobalConfig.Instance.Current.allyLifeMultiplier;
|
|
public override Vector2 RangeMultiplier => GlobalConfig.Instance.Current.allyRangeMultiplier;
|
|
public override float SpeedMultiplier => GlobalConfig.Instance.Current.allySpeedMultiplier;
|
|
public float PopulationCost => GlobalConfig.Instance.Current.populationCostPerUnit;
|
|
|
|
public override void Update()
|
|
{
|
|
base.Update();
|
|
if (IsEnemyDetected)
|
|
{
|
|
AttackEnemy();
|
|
}
|
|
|
|
}
|
|
|
|
void AttackEnemy()
|
|
{
|
|
//Attack Cooldown
|
|
if (AttackSpeedWait > AttackInterval)
|
|
{
|
|
|
|
Animation.PlayAttackAnim();
|
|
|
|
AttackSpeedWait = 0f;
|
|
}
|
|
|
|
AttackSpeedWait += Time.deltaTime;
|
|
}
|
|
|
|
public Vector3 GetPosition()
|
|
{
|
|
return transform.position;
|
|
}
|
|
|
|
public override void LevelStart()
|
|
{
|
|
base.LevelStart();
|
|
if (this is not Building) ResourceManager.Instance.CurrentPopulation += PopulationCost;
|
|
}
|
|
public override void LevelDestroy()
|
|
{
|
|
base.LevelDestroy();
|
|
if (this is not Building) ResourceManager.Instance.CurrentPopulation -= PopulationCost;
|
|
}
|
|
}
|