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
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 = 1f;

void Start()
{
Expand Down
10 changes: 2 additions & 8 deletions Assets/Scripts/Model/Runtime/Projectiles/ArchToTileProjectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ protected override void UpdateImpl(float deltaTime, float time)

float localHeight = 0f;
float totalDistance = _totalDistance;
float maxHeight = totalDistance * 0.6f;

///////////////////////////////////////
// Insert you code here
///////////////////////////////////////
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
72 changes: 53 additions & 19 deletions Assets/Scripts/UnitBrains/Player/SecondUnitBrain.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System.Collections.Generic;
using Model;
using Model.Runtime.Projectiles;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UIElements;
using Utilities;

namespace UnitBrains.Player
{
Expand All @@ -12,43 +16,74 @@ public class SecondUnitBrain : DefaultPlayerUnitBrain
private float _temperature = 0f;
private float _cooldownTime = 0f;
private bool _overheated;

private List<Vector2Int> UnreachableTargets = new List<Vector2Int>();

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);
///////////////////////////////////////

if (GetTemperature() >= overheatTemperature) //Checking for overheating
{
return;
}

int projectileCount = (int)( _temperature + 1); //Calculating the number of shells

for (int i = 0; i < projectileCount; i++) //Creating projectiles in a cycle
{
var projectile = CreateProjectile(forTarget);
AddProjectileToList(projectile, intoList);
}

IncreaseTemperature(); //Temperature rise
}

public override Vector2Int GetNextStep()
{
return base.GetNextStep();
if (UnreachableTargets.Count == 0 || GetReachableTargets().Contains(UnreachableTargets[0]))
return unit.Pos;
else
return unit.Pos.CalcNextStepTowards(UnreachableTargets[0]);
}

protected override List<Vector2Int> SelectTargets()
{
///////////////////////////////////////
// Homework 1.4 (1st block, 4rd module)
///////////////////////////////////////
List<Vector2Int> result = GetReachableTargets();
while (result.Count > 1)
UnreachableTargets.Clear();
List<Vector2Int> result = GetAllTargets().ToList();
if (result.Count > 1)
{
result.RemoveAt(result.Count - 1);
float min = float.MaxValue;
Vector2Int minResult = new Vector2Int();
foreach (Vector2Int res in result)
{
if (DistanceToOwnBase(res) < min)
{
min = DistanceToOwnBase(res);
minResult = res;
}

}
result.Clear();
UnreachableTargets.Add(minResult);
if (GetReachableTargets().Contains(minResult))
result.Add(minResult);
}
else
{
result.Clear();
var enemyBase = runtimeModel.RoMap.Bases[IsPlayerUnitBrain ? RuntimeModel.BotPlayerId : RuntimeModel.PlayerId];
UnreachableTargets.Add(enemyBase);
result.Add(enemyBase);
}
return result;
///////////////////////////////////////
}

public override void Update(float deltaTime, float time)
{
if (_overheated)
{
{
_cooldownTime += Time.deltaTime;
float t = _cooldownTime / (OverheatCooldown/10);
float t = _cooldownTime / (OverheatCooldown / 10);
_temperature = Mathf.Lerp(OverheatTemperature, 0, t);
if (t >= 1)
{
Expand All @@ -57,7 +92,6 @@ public override void Update(float deltaTime, float time)
}
}
}

private int GetTemperature()
{
if(_overheated) return (int) OverheatTemperature;
Expand Down