Exemplo n.º 1
0
        public Vector3 GetPointAlongPath(Vector3 currentPos, float distance)
        {
            path.BlockUntilCalculated();
            var point = path.vectorPath[1];

            point = Vector3.MoveTowards(currentPos, point, distance);

            return(point);
        }
Exemplo n.º 2
0
        private void ApplyNow(Path path)
        {
            if (_destroyed)
            {
                return;
            }

            if (path.path != null)
            {
                if (_randomizeAllPenalties)
                {
                    foreach (var node in path.path)
                    {
                        node.Penalty = (uint)Random.Range(0, penalty);
                        if (_randomizeAdjacentPenalties)
                        {
                            node.GetConnections(otherNode =>
                            {
                                otherNode.Penalty = (uint)Random.Range(0, penalty);
                            });
                        }
                    }
                }
                else
                {
                    int rndStart = _random.Next(randomStep);
                    for (int i = rndStart; i < path.path.Count; i += _random.Next(1, randomStep))
                    {
                        path.path[i].Penalty += (uint)penalty;
                        if (_randomizeAdjacentPenalties)
                        {
                            path.path[i].GetConnections(otherNode =>
                            {
                                otherNode.Penalty = (uint)Random.Range(0, penalty);
                            });
                        }
                    }
                }

                if (_RecalculatePathAfterRandomise)
                {
                    path.BlockUntilCalculated();
                }
            }
        }