Beispiel #1
0
    /// <summary>
    ///     Calculates the correct transform from
    ///     the path, so that way this is always
    ///     correctly positioned at the start at
    ///     the path.
    /// </summary>
    public void CalculateCorrectTransform()
    {
        var firstEnemyPathNode = pathManager.GetActivePath().GetExtrapolator().GetMinimalRepresentation().First();

        gameObject.transform.position = GridSpaceGlobalSpaceConverter.FromLocation(firstEnemyPathNode.Location, 3);
        // make sure that this thing isn't null.
        Debug.Assert(firstEnemyPathNode.OutgoingDirection != null, "firstEnemyPathNode.OutgoingDirection != null");
        gameObject.transform.rotation =
            Quaternion.Euler(CardinalDirectionToEuler(firstEnemyPathNode.OutgoingDirection.Value));
    }
Beispiel #2
0
        private void JumpToStartOfPath()
        {
            path.MoveNext();
            var startingPathNode = path.Current;

            if (startingPathNode == null)
            {
                throw new NullReferenceException("The passed path has a null starting point. This is forbidden.");
            }
            transform.position = GridSpaceGlobalSpaceConverter.FromLocation(startingPathNode.Location, yOffset);
            AdvanceToNextNode();
        }
Beispiel #3
0
        private bool AdvanceToNextNode()
        {
            if (path == null)
            {
                return(true);
            }
            var isMoved = path.MoveNext();

            if (isMoved && path.Current != null)
            {
                targetedPosition = GridSpaceGlobalSpaceConverter.FromLocation(path.Current.Location, yOffset);
                transform.LookAt(targetedPosition);
            }

            return(isMoved);
        }
Beispiel #4
0
 public PathGridItem CreateInstance(PrefabGrid <PathGridItem> grid, GridLocation location)
 {
     return(Object.Instantiate(grid.Prefab, GridSpaceGlobalSpaceConverter.FromLocation(location, 0.45f),
                               Quaternion.identity));
 }