Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Assets/Scripts/Model/Runtime/Projectiles/ArchToTileProjectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ArchToTileProjectile : BaseProjectile
private readonly Vector2Int _target;
private readonly float _timeToTarget;
private readonly float _totalDistance;

public ArchToTileProjectile(Unit unit, Vector2Int target, int damage, Vector2Int startPoint) : base(damage, startPoint)
{
_target = target;
Expand All @@ -20,21 +20,23 @@ protected override void UpdateImpl(float deltaTime, float time)
{
float timeSinceStart = time - StartTime;
float t = timeSinceStart / _timeToTarget;

Pos = Vector2.Lerp(StartPoint, _target, t);

float localHeight = 0f;
float totalDistance = _totalDistance;

///////////////////////////////////////
// Insert you code here
///////////////////////////////////////

float maxHeight = totalDistance * 0.6f;
localHeight = maxHeight * (-(t * 2 - 1) * (t * 2 - 1) + 1);

///////////////////////////////////////
// End of the code to insert
///////////////////////////////////////

Height = localHeight;
if (time > StartTime + _timeToTarget)
Hit(_target);
Expand Down
38 changes: 33 additions & 5 deletions Assets/Scripts/UnitBrains/Player/SecondUnitBrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@ protected override void GenerateProjectiles(Vector2Int forTarget, List<BaseProje
float overheatTemperature = OverheatTemperature;
///////////////////////////////////////
// Homework 1.3 (1st block, 3rd module)
///////////////////////////////////////
var projectile = CreateProjectile(forTarget);
AddProjectileToList(projectile, intoList);
///////////////////////////////////////

int temperature = GetTemperature();
if (temperature >= overheatTemperature)
{
return;
}

int projectileAmount = temperature + 1;
for (int i = 0; i < projectileAmount; i++)
{
var projectile = CreateProjectile(forTarget);
AddProjectileToList(projectile, intoList);
}

IncreaseTemperature();
///////////////////////////////////////
}

Expand All @@ -35,9 +48,24 @@ protected override List<Vector2Int> SelectTargets()
// Homework 1.4 (1st block, 4rd module)
///////////////////////////////////////
List<Vector2Int> result = GetReachableTargets();
while (result.Count > 1)
if (result.Count > 0)
{
result.RemoveAt(result.Count - 1);

float minDistance = float.MaxValue;
Vector2Int finalTarget = result[0];

foreach (var target in result)
{
float targetDist = DistanceToOwnBase(target);
if (targetDist < minDistance)
{
minDistance = targetDist;
finalTarget = target;
}
}

result.Clear();
result.Add(finalTarget);
}
return result;
///////////////////////////////////////
Expand Down