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
1 change: 1 addition & 0 deletions .vs/Assembly-CSharp-Editor.csproj.dtbcache.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .vs/Assembly-CSharp.csproj.dtbcache.json

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/CSharpMainProjectMyFork/v17/.suo
Binary file not shown.
282 changes: 282 additions & 0 deletions .vs/CSharpMainProjectMyFork/v17/DocumentLayout.backup.json

Large diffs are not rendered by default.

281 changes: 281 additions & 0 deletions .vs/CSharpMainProjectMyFork/v17/DocumentLayout.json

Large diffs are not rendered by default.

Binary file not shown.
Binary file added .vs/CSharpMainProjectMyFork/v18/.suo
Binary file not shown.
367 changes: 367 additions & 0 deletions .vs/CSharpMainProjectMyFork/v18/DocumentLayout.backup.json

Large diffs are not rendered by default.

367 changes: 367 additions & 0 deletions .vs/CSharpMainProjectMyFork/v18/DocumentLayout.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .vs/Root.csproj.dtbcache.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .vs/Tests.csproj.dtbcache.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .vs/Tests1.csproj.dtbcache.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Assets/Resources/PlayerUnits/PlayerUnit3.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_healthBar: {fileID: 178258570018206233}
_debugPathOutput: {fileID: 0}
--- !u!114 &3664015912038799981
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scenes/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Controller/BotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using Model.Config;
using UnityEngine;
using Utilities;
//hello
//hello!
//How are you?
//i'm fine
//I'm fine
namespace Controller
{
public class BotController
Expand Down Expand Up @@ -74,3 +74,5 @@ private void ChooseUnit()
}
}
}


8 changes: 8 additions & 0 deletions Assets/Scripts/Editor/Editor.Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Assets/Scripts/Editor/Editor.Tests/Dz2Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Model.Runtime.Projectiles;
using NUnit.Framework;
using UnityEngine;

public class Dz2Test : MonoBehaviour
{
private const int SamplesOverTrajectory = 100;

private const float ProjectileSpeed = 7f;

[Test]
public void TestProjectileTrajectory()
{
TestProjectileTrajectory(Vector2Int.zero, new Vector2Int(100, 0));
TestProjectileTrajectory(Vector2Int.zero, new Vector2Int(0, 100));
TestProjectileTrajectory(Vector2Int.zero, new Vector2Int(100, 100));
TestProjectileTrajectory(new Vector2Int(50, 50), new Vector2Int(100, 100));
}

public void TestProjectileTrajectory(Vector2Int start, Vector2Int target)
{
var proj = new ArchToTileProjectile(null, target, 0, start);

var totalDistance = Vector2.Distance(start, target);
var timeToTarget = totalDistance / ProjectileSpeed;
var maxHeight = 0.6f * totalDistance;

var step = 1f / SamplesOverTrajectory;
var timeStep = timeToTarget / SamplesOverTrajectory;
var totalPassedTime = 0f;
for (float t = 0; t <= 1; t += step)
{
totalPassedTime += timeStep;
proj.Update(timeStep, totalPassedTime);
var height = proj.Height;
var refHeight = maxHeight * (-(t * 2 - 1) * (t * 2 - 1) + 1);

Assert.AreEqual(refHeight, height, 0.1f, "Height is not as expected at t=" + t);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Editor/Editor.Tests/Dz2Test.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/Scripts/Editor/Editor.Tests/Tests.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Tests1",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"Root"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Assets/Scripts/Editor/Editor.Tests/Tests.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Assets/Scripts/EnterPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public class EnterPoint : MonoBehaviour
{
[SerializeField] private Settings _settings;
[SerializeField] private Canvas _targetCanvas;
private float _timeScale = 1;
private float _timeScale = 5;

//������, ����� ���� �!
void Start()
{
Time.timeScale = _timeScale;
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Model/Runtime/MainBase.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Model.Runtime.ReadOnly;
using UnityEngine;

namespace Model.Runtime
{
public class MainBase : IReadOnlyBase
{
public int Health { get; private set; }

public MainBase(int health)
{
Health = health;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@ protected override void UpdateImpl(float deltaTime, float time)
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
8 changes: 8 additions & 0 deletions Assets/Scripts/Model/Runtime/Projectiles/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Projectiles.Test",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 88 additions & 0 deletions Assets/Scripts/Model/Runtime/UnitManaget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Linq;
using Model;
using Model.Runtime.ReadOnly;
using UnityEngine;
using Utilities;

namespace Assets.Scripts.Model.Runtime
{
public class UnitManager
{
private static UnitManager _instance;
public static UnitManager Instance
{
get
{
if (_instance == null)
_instance = new UnitManager();
return _instance;
}
}

private readonly IReadOnlyRuntimeModel _runtimeModel;
private readonly TimeUtil _timeUtil;

public IReadOnlyUnit RecommendedTarget { get; private set; }
public Vector2Int RecommendedPosition { get; private set; }

private UnitManager()
{
_runtimeModel = ServiceLocator.Get<IReadOnlyRuntimeModel>();
_timeUtil = ServiceLocator.Get<TimeUtil>();

_timeUtil.AddUpdateAction(OnUpdate);
}

private void OnUpdate(float deltaTime)
{
UpdateLogic();
}

private void UpdateLogic()
{
var enemies = _runtimeModel.RoBotUnits.ToList();

if (enemies.Count == 0)
{
RecommendedTarget = null;
return;
}

var basePos = _runtimeModel.RoMap.Bases[RuntimeModel.PlayerId];

var enemiesNearBase = enemies
.Where(e => Vector2Int.Distance(e.Pos, basePos) < 5)
.ToList();

if (enemiesNearBase.Count > 0)
{
RecommendedTarget = enemiesNearBase
.OrderBy(e => Vector2Int.Distance(e.Pos, basePos))
.First();

var dir = RecommendedTarget.Pos - basePos;
dir = new Vector2Int(
Mathf.Clamp(dir.x, -1, 1),
Mathf.Clamp(dir.y, -1, 1)
);

RecommendedPosition = basePos + dir;
}
else
{
RecommendedTarget = enemies
.OrderBy(e => e.Health)
.First();

var dir = RecommendedTarget.Pos - basePos;
dir = new Vector2Int(
Mathf.Clamp(dir.x, -1, 1),
Mathf.Clamp(dir.y, -1, 1)
);

int attackRange = 2;
RecommendedPosition = RecommendedTarget.Pos - dir * attackRange;
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Model/Runtime/UnitManaget.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Scripts/Model/RuntimeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class RuntimeModel : IReadOnlyRuntimeModel
{
public const int PlayerId = 0;
public const int BotPlayerId = 1;

public IReadOnlyMap RoMap => Map;
public IReadOnlyDictionary<int, int> RoMoney => Money;

Expand Down
17 changes: 10 additions & 7 deletions Assets/Scripts/UnitBrains/BaseUnitBrain.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using Model;
using Model;
using Model.Runtime.Projectiles;
using Model.Runtime.ReadOnly;
using System.Collections.Generic;
using System.Linq;
using UnitBrains.Pathfinding;
using UnityEngine;
using Utilities;
using static UnityEngine.GraphicsBuffer;
using Unit = Model.Runtime.Unit;

namespace UnitBrains
Expand All @@ -14,11 +15,11 @@ public abstract class BaseUnitBrain
{
public virtual string TargetUnitName => string.Empty;
public virtual bool IsPlayerUnitBrain => true;
public virtual BaseUnitPath ActivePath => _activePath;
public virtual BaseUnitPath ActivePath { get; protected set; }

protected Unit unit { get; private set; }
protected IReadOnlyRuntimeModel runtimeModel => ServiceLocator.Get<IReadOnlyRuntimeModel>();
private BaseUnitPath _activePath = null;
protected BaseUnitPath _activePath = null;

private readonly Vector2[] _projectileShifts = new Vector2[]
{
Expand All @@ -33,13 +34,15 @@ public abstract class BaseUnitBrain

public virtual Vector2Int GetNextStep()
{

if (HasTargetsInRange())
return unit.Pos;

var target = runtimeModel.RoMap.Bases[
IsPlayerUnitBrain ? RuntimeModel.BotPlayerId : RuntimeModel.PlayerId];

_activePath = new DummyUnitPath(runtimeModel, unit.Pos, target);

_activePath = new SmartPath(runtimeModel, unit.Pos, target);
return _activePath.GetNextStepFrom(unit.Pos);
}

Expand Down
Loading