// ================================================================================ // constructor // -------------------------------------------------------------------------------- public Target(Actor protagonist, Transform protagonistTransform) { _protagonist = protagonist; _protagonistTransform = protagonistTransform; _ticker = Random.Range(0, _maxTicker); _path = new Vector2Path(80); }
private void Test() { _testPath = new Vector2Path((_columnCount + _rowCount) * 5); // warmup, just in case Utilities.TestMethod(TestPathClosed, "ClosedPath", 50, false); float completeTime = 0; completeTime += Utilities.TestMethod(TestPathNear, "NearPath"); completeTime += Utilities.TestMethod(TestPathOpen, "OpenPath"); completeTime += Utilities.TestMethod(TestPathTypical, "TypicalPath"); completeTime += Utilities.TestMethod(TestPathOpenReversed, "OpenPathReversed"); completeTime += Utilities.TestMethod(TestPathMediumLength, "MediumLength"); completeTime += Utilities.TestMethod(TestPathClosed, "ClosedPath"); Debug.Log(completeTime.ToString("F5")); }
// ================================================================================ // public methods // -------------------------------------------------------------------------------- public virtual void GetPath(Vector2 startPos, Vector2 endPos, Vector2Path vectorPath) { _lastTarget = endPos; GridPosition startGridPosition = GetGridPositionFromLevelPosition(startPos); GridPosition endGridPosition = GetGridPositionFromLevelPosition(endPos); _pathController.FindPath(startGridPosition, endGridPosition, MovementPossibleCheck, true, maxCheckNodesWithoutProgress); vectorPath.Clear(); if (_pathController.gridPath.count > 0) { for (int i = 0; i < _pathController.gridPath.count; i++) { Vector2 p = GetLevelPositionFromGridPosition(_pathController.gridPath[i]); vectorPath.AddPosition(p.x, p.y); } } _testPath = vectorPath; }
// ================================================================================ // constructor // -------------------------------------------------------------------------------- public ActorTarget(Actor2D protagonist, Transform protagonistTransform) { _protagonist = protagonist; _protagonistTransform = protagonistTransform; _ticker = Random.Range(0, _maxTicker); _path = new Vector2Path(80); }
public virtual void GetPath(Vector2 startPos, Vector2 endPos, Vector2Path vectorPath) { _lastTarget = endPos; GridPosition startGridPosition = GetGridPositionFromLevelPosition(startPos); GridPosition endGridPosition = GetGridPositionFromLevelPosition(endPos); _pathController.FindPath(startGridPosition, endGridPosition, MovementPossibleCheck, true, maxCheckNodesWithoutProgress); vectorPath.Clear(); if (_pathController.gridPath.count > 0) { for (int i = 0; i < _pathController.gridPath.count; i++) { Vector2 p = GetLevelPositionFromGridPosition(_pathController.gridPath[i]); vectorPath.AddPosition(p.x, p.y); } } _testPath = vectorPath; }