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
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ protected override void UpdateImpl(float deltaTime, float time)
// Insert you code here
///////////////////////////////////////

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

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

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

float currentTemperature = GetTemperature();
if (currentTemperature >= overheatTemperature) { return; }

for (float i = -1; i < currentTemperature; i++)
{
///////////////////////////////////////
// Homework 1.3 (1st block, 3rd module)
///////////////////////////////////////
var projectile = CreateProjectile(forTarget);
AddProjectileToList(projectile, intoList);
///////////////////////////////////////
}
IncreaseTemperature();
}

public override Vector2Int GetNextStep()
Expand All @@ -35,10 +43,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)
return result;

Vector2Int closestTarget = result[0];
float closestDistance = DistanceToOwnBase(closestTarget);

foreach (var target in result)
{
result.RemoveAt(result.Count - 1);
float distance = DistanceToOwnBase(target);
if (distance < closestDistance)
{
closestDistance = distance;
closestTarget = target;
}
}

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