Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Assets/Scripts/EnterPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class EnterPoint : MonoBehaviour
{
[SerializeField] private Settings _settings;
[SerializeField] private Canvas _targetCanvas;
private float _timeScale = 1;
private float _timeScale = 5;

void Start()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected override void UpdateImpl(float deltaTime, float time)
///////////////////////////////////////
// End of the code to insert
///////////////////////////////////////

Height = localHeight;
if (time > StartTime + _timeToTarget)
Hit(_target);
Expand Down
42 changes: 35 additions & 7 deletions Assets/Scripts/UnitBrains/Player/SecondUnitBrain.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Model.Runtime.Projectiles;
using Model.Runtime.Projectiles;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;

namespace UnitBrains.Player
Expand All @@ -18,9 +19,21 @@ 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;
}
else
{
IncreaseTemperature();
}
for (int i = 1; i <= Temperature+1; i++)
{
var projectile = CreateProjectile(forTarget);
AddProjectileToList(projectile, intoList);
}
///////////////////////////////////////
}

Expand All @@ -35,10 +48,25 @@ protected override List<Vector2Int> SelectTargets()
// Homework 1.4 (1st block, 4rd module)
///////////////////////////////////////
List<Vector2Int> result = GetReachableTargets();
while (result.Count > 1)
float minDistance = float.MaxValue;
Vector2Int nearestTarget = Vector2Int.zero;
bool targetFound = false;

foreach (Vector2Int target in result)
{
result.RemoveAt(result.Count - 1);
float distance = DistanceToOwnBase(target);

if (distance < minDistance)
{
minDistance = distance;
nearestTarget = target;
targetFound = true;
}
}

result.Clear();
if (targetFound) result.Add(nearestTarget);

return result;
///////////////////////////////////////
}
Expand Down