コード例 #1
0
ファイル: Target.cs プロジェクト: talecrafter/LudumDare32
        // ================================================================================
        //  constructor
        // --------------------------------------------------------------------------------

        public Target(Actor protagonist, Transform protagonistTransform)
        {
            _protagonist          = protagonist;
            _protagonistTransform = protagonistTransform;

            _ticker = Random.Range(0, _maxTicker);

            _path = new Vector2Path(80);
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        // ================================================================================
        //  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;
        }
コード例 #4
0
        // ================================================================================
        //  constructor
        // --------------------------------------------------------------------------------

        public ActorTarget(Actor2D protagonist, Transform protagonistTransform)
        {
            _protagonist = protagonist;
            _protagonistTransform = protagonistTransform;

            _ticker = Random.Range(0, _maxTicker);

            _path = new Vector2Path(80);
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
        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;
        }