diff --git a/Assets/Resources/PlayerUnits/PlayerUnit3.prefab b/Assets/Resources/PlayerUnits/PlayerUnit3.prefab index 234d5b6a1..5254a33e9 100644 --- a/Assets/Resources/PlayerUnits/PlayerUnit3.prefab +++ b/Assets/Resources/PlayerUnits/PlayerUnit3.prefab @@ -48,6 +48,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: _healthBar: {fileID: 178258570018206233} + _debugPathOutput: {fileID: 0} --- !u!114 &3664015912038799981 MonoBehaviour: m_ObjectHideFlags: 0 @@ -67,10 +68,8 @@ MonoBehaviour: _maxHealth: 400 _brainUpdateDelay: 0.25 _moveDelay: 0.25 - _attackDelay: 0.75 + _attackDelay: 0.15 _attackRange: 3.5 - _shotsPerTarget: 1 - _targetsInVolley: 1 _projectileType: 0 _damage: 15 --- !u!1 &526913648782850647 diff --git a/Assets/Scripts/UnitBrains/Player/NewBehaviourScript.cs b/Assets/Scripts/UnitBrains/Player/NewBehaviourScript.cs new file mode 100644 index 000000000..a8d6f3920 --- /dev/null +++ b/Assets/Scripts/UnitBrains/Player/NewBehaviourScript.cs @@ -0,0 +1,63 @@ +using Model; +using Model.Runtime.Projectiles; +using System.Collections; +using System.Collections.Generic; +using UnitBrains.Player; +using UnityEngine; + +public class ThirdUnitBrain : DefaultPlayerUnitBrain +{ + public enum LastAction + { + Step, + Fire + } + + public override string TargetUnitName => "Ironclad Behemoth"; + private LastAction lastAction = LastAction.Step; + private float _actionCooldownTime = 0; + + protected override void GenerateProjectiles(Vector2Int forTarget, List intoList) + { + if (lastAction == LastAction.Step && _actionCooldownTime == 0) + { + _actionCooldownTime = 1; + lastAction = LastAction.Fire; + } + + if (_actionCooldownTime <= 0) + { + var projectile = CreateProjectile(forTarget); + AddProjectileToList(projectile, intoList); + lastAction = LastAction.Fire; + } + else { + _actionCooldownTime -= Time.deltaTime; + if (_actionCooldownTime < 0) { _actionCooldownTime = 0; } + } + } + + public override Vector2Int GetNextStep() + { + if (HasTargetsInRange()) + return unit.Pos; + + if (lastAction == LastAction.Fire && _actionCooldownTime == 0) + { + _actionCooldownTime = 1; + lastAction = LastAction.Step; + } + + if (_actionCooldownTime <= 0) + { + lastAction = LastAction.Step; + return base.GetNextStep(); + } + else + { + _actionCooldownTime -= Time.deltaTime; + if (_actionCooldownTime < 0) { _actionCooldownTime = 0; } + return unit.Pos; + } + } +}