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
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 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.
1 change: 1 addition & 0 deletions .vs/Root.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.

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
16 changes: 9 additions & 7 deletions Assets/Scripts/UnitBrains/BaseUnitBrain.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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;
Expand All @@ -14,11 +14,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 +33,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
4 changes: 3 additions & 1 deletion Assets/Scripts/UnitBrains/Pathfinding/BaseUnitPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public IEnumerable<Vector2Int> GetPath()

public Vector2Int GetNextStepFrom(Vector2Int unitPos)
{

var found = false;
foreach (var cell in GetPath())
{
Expand All @@ -35,7 +36,8 @@ public Vector2Int GetNextStepFrom(Vector2Int unitPos)
found = cell == unitPos;
}

Debug.LogError($"Unit {unitPos} is not on the path");
Debug.LogWarning($"Unit {unitPos} is not on the path");

return unitPos;
}

Expand Down
18 changes: 14 additions & 4 deletions Assets/Scripts/UnitBrains/Pathfinding/DebugPathOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void HighlightPath(BaseUnitPath path)
{
DestroyHighlight(0);
}

if (highlightCoroutine != null)
{
StopCoroutine(highlightCoroutine);
Expand All @@ -32,10 +32,20 @@ public void HighlightPath(BaseUnitPath path)

private IEnumerator HighlightCoroutine(BaseUnitPath path)
{
// TODO Implement me
yield break;
}
var delay = new WaitForSeconds(0.03f);

foreach (var cell in path.GetPath())
{
CreateHighlight(cell);

while (allHighlights.Count > maxHighlights)
{
DestroyHighlight(0);
}

yield return delay;
}
}
private void CreateHighlight(Vector2Int atCell)
{
var pos = Gameplay3dView.ToWorldPosition(atCell, 1f);
Expand Down
35 changes: 35 additions & 0 deletions Assets/Scripts/UnitBrains/Pathfinding/Node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace UnitBrains.Pathfinding
{
public class Node
{
public Vector2Int Pos;
public int Cost = 1;
public int Estimate;
public int Value;
public Node Parent;

public Node(Vector2Int pos)
{
Pos = pos;
}

public override bool Equals(object obj)
{
return obj is Node n && Pos == n.Pos;
}

public override int GetHashCode()
{
return Pos.GetHashCode();
}
}
}

11 changes: 11 additions & 0 deletions Assets/Scripts/UnitBrains/Pathfinding/Node.cs.meta

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

Loading