Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
m039 committed Dec 15, 2019
1 parent 6ee1cea commit d744297
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Assets/Scripts/Parallax/ParallaxLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public class ParallaxLayer : MonoBehaviour
{
#region Inspector

[Tooltip("An order of the ParllaxLayer in Z direction.")]
public int depthOrder = 0;

[Tooltip("Скорость с которой движется объект, на котурую влияет еще общая скорость параллакса.")]
[Tooltip("Speed used to parallax the background which is also affected by ReferenceSpeed")]
public float horizontalSpeed = 0f;

[Tooltip("Repeat the background sprite horizontally.")]
public bool repeatBackground = true;

#endregion
Expand Down
21 changes: 20 additions & 1 deletion Assets/Scripts/Parallax/ParallaxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,33 @@ namespace m039.Parallax
{
public interface IParallaxManager
{
/// <summary>
/// Align all ParallaxLayers with the target.
/// </summary>
/// <param name="target">is the object which position will be used by ParallaxLayers.</param>
void Follow(Transform target);

/// <summary>
/// Align all ParallaxLayers with this position.
/// </summary>
/// <param name="position">this position will be used by ParallaxLayers</param>
void Follow(Vector2 position);

/// <summary>
/// The default speed which is used by all ParallaxLayers.
/// </summary>
float ReferenceSpeed { get; }

/// <summary>
/// The position to align with.
/// </summary>
Vector2 GetFollowPosition();

/// <summary>
/// Get Z position for ParallaxLayer.
/// </summary>
/// <param name="depthOrder">the order of a layer by which will be calculated Z position</param>
/// <returns>calculated Z position</returns>
float GetDepth(int depthOrder);
}

Expand Down Expand Up @@ -72,7 +91,7 @@ public static IParallaxManager Instance

#region Inspector

[Tooltip("Общая скорость для всех объектов, использующие параллакс.")]
[Tooltip("Common speed for all ParallaxLayers.")]
public float referenceSpeed = 2;

#endregion
Expand Down

0 comments on commit d744297

Please sign in to comment.