/// <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)); }
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(); }
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); }
public PathGridItem CreateInstance(PrefabGrid <PathGridItem> grid, GridLocation location) { return(Object.Instantiate(grid.Prefab, GridSpaceGlobalSpaceConverter.FromLocation(location, 0.45f), Quaternion.identity)); }