Browse Source

Reverted ICameraController interface

master
Christopher 8 years ago
parent
commit
31f9d86d7e
  1. 2
      Assets/Fungus/Scripts/Commands/FadeScreen.cs
  2. 2
      Assets/Fungus/Scripts/Commands/FadeToView.cs
  3. 2
      Assets/Fungus/Scripts/Commands/MoveToView.cs
  4. 2
      Assets/Fungus/Scripts/Commands/StartSwipe.cs
  5. 2
      Assets/Fungus/Scripts/Commands/StopSwipe.cs
  6. 33
      Assets/Fungus/Scripts/Components/CameraController.cs
  7. 2
      Assets/Fungus/Scripts/Components/Writer.cs
  8. 49
      Assets/Fungus/Scripts/Interfaces/ICameraController.cs
  9. 12
      Assets/Fungus/Scripts/Interfaces/ICameraController.cs.meta

2
Assets/Fungus/Scripts/Commands/FadeScreen.cs

@ -33,7 +33,7 @@ namespace Fungus.Commands
public override void OnEnter() public override void OnEnter()
{ {
ICameraController cameraController = CameraController.GetInstance(); var cameraController = CameraController.GetInstance();
if (fadeTexture) if (fadeTexture)
{ {

2
Assets/Fungus/Scripts/Commands/FadeToView.cs

@ -65,7 +65,7 @@ namespace Fungus.Commands
return; return;
} }
ICameraController cameraController = CameraController.GetInstance(); var cameraController = CameraController.GetInstance();
if (fadeTexture) if (fadeTexture)
{ {

2
Assets/Fungus/Scripts/Commands/MoveToView.cs

@ -56,7 +56,7 @@ namespace Fungus.Commands
return; return;
} }
ICameraController cameraController = CameraController.GetInstance(); var cameraController = CameraController.GetInstance();
Vector3 targetPosition = targetView.transform.position; Vector3 targetPosition = targetView.transform.position;
Quaternion targetRotation = targetView.transform.rotation; Quaternion targetRotation = targetView.transform.rotation;

2
Assets/Fungus/Scripts/Commands/StartSwipe.cs

@ -51,7 +51,7 @@ namespace Fungus.Commands
return; return;
} }
ICameraController cameraController = CameraController.GetInstance(); var cameraController = CameraController.GetInstance();
cameraController.StartSwipePan(targetCamera, viewA, viewB, duration, speedMultiplier, () => Continue() ); cameraController.StartSwipePan(targetCamera, viewA, viewB, duration, speedMultiplier, () => Continue() );
} }

2
Assets/Fungus/Scripts/Commands/StopSwipe.cs

@ -16,7 +16,7 @@ namespace Fungus.Commands
{ {
public override void OnEnter() public override void OnEnter()
{ {
ICameraController cameraController = CameraController.GetInstance(); var cameraController = CameraController.GetInstance();
cameraController.StopSwipePan(); cameraController.StopSwipePan();

33
Assets/Fungus/Scripts/Components/CameraController.cs

@ -9,7 +9,10 @@ using Fungus;
namespace Fungus namespace Fungus
{ {
public class CameraController : MonoBehaviour, ICameraController /// <summary>
/// Controller for main camera.Supports several types of camera transition including snap, pan & fade.
/// </summary>
public class CameraController : MonoBehaviour
{ {
[Tooltip("Full screen texture used for screen fade effect.")] [Tooltip("Full screen texture used for screen fade effect.")]
[SerializeField] protected Texture2D screenFadeTexture; [SerializeField] protected Texture2D screenFadeTexture;
@ -48,13 +51,13 @@ namespace Fungus
protected Dictionary<string, CameraView> storedViews = new Dictionary<string, CameraView>(); protected Dictionary<string, CameraView> storedViews = new Dictionary<string, CameraView>();
protected static ICameraController instance; protected static CameraController instance;
/// <summary> /// <summary>
/// Returns the CameraController singleton instance. /// Returns the CameraController singleton instance.
/// Will create a CameraController game object if none currently exists. /// Will create a CameraController game object if none currently exists.
/// </summary> /// </summary>
static public ICameraController GetInstance() static public CameraController GetInstance()
{ {
if (instance == null) if (instance == null)
{ {
@ -361,15 +364,25 @@ namespace Fungus
return cameraSize; return cameraSize;
} }
#region ICameraController implementation #region Public methods
/// <summary>
/// Full screen texture used for screen fade effect.
/// </summary>
/// <value>The screen fade texture.</value>
public Texture2D ScreenFadeTexture { set { screenFadeTexture = value; } } public Texture2D ScreenFadeTexture { set { screenFadeTexture = value; } }
/// <summary>
/// Perform a fullscreen fade over a duration.
/// </summary>
public virtual void Fade(float targetAlpha, float fadeDuration, Action fadeAction) public virtual void Fade(float targetAlpha, float fadeDuration, Action fadeAction)
{ {
StartCoroutine(FadeInternal(targetAlpha, fadeDuration, fadeAction)); StartCoroutine(FadeInternal(targetAlpha, fadeDuration, fadeAction));
} }
/// <summary>
/// Fade out, move camera to view and then fade back in.
/// </summary>
public virtual void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, Action fadeAction) public virtual void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, Action fadeAction)
{ {
swipePanActive = false; swipePanActive = false;
@ -405,11 +418,17 @@ namespace Fungus
}); });
} }
/// <summary>
/// Stop all camera tweening.
/// </summary>
public virtual void Stop() public virtual void Stop()
{ {
StopAllCoroutines(); StopAllCoroutines();
} }
/// <summary>
/// Moves camera from current position to a target position over a period of time.
/// </summary>
public virtual void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction) public virtual void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction)
{ {
if (camera == null) if (camera == null)
@ -443,6 +462,9 @@ namespace Fungus
} }
} }
/// <summary>
/// Activates swipe panning mode. The player can pan the camera within the area between viewA & viewB.
/// </summary>
public virtual void StartSwipePan(Camera camera, View viewA, View viewB, float duration, float speedMultiplier, Action arriveAction) public virtual void StartSwipePan(Camera camera, View viewA, View viewB, float duration, float speedMultiplier, Action arriveAction)
{ {
if (camera == null) if (camera == null)
@ -472,6 +494,9 @@ namespace Fungus
}); });
} }
/// <summary>
/// Deactivates swipe panning mode.
/// </summary>
public virtual void StopSwipePan() public virtual void StopSwipePan()
{ {
swipePanActive = false; swipePanActive = false;

2
Assets/Fungus/Scripts/Components/Writer.cs

@ -716,7 +716,7 @@ namespace Fungus
protected virtual void Flash(float duration) protected virtual void Flash(float duration)
{ {
ICameraController cameraController = CameraController.GetInstance(); var cameraController = CameraController.GetInstance();
cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32);
cameraController.Fade(1f, duration, delegate { cameraController.Fade(1f, duration, delegate {
cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32);

49
Assets/Fungus/Scripts/Interfaces/ICameraController.cs

@ -1,49 +0,0 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Controller for main camera.Supports several types of camera transition including snap, pan & fade.
/// </summary>
public interface ICameraController
{
/// <summary>
/// Full screen texture used for screen fade effect.
/// </summary>
/// <value>The screen fade texture.</value>
Texture2D ScreenFadeTexture { set; }
/// <summary>
/// Perform a fullscreen fade over a duration.
/// </summary>
void Fade(float targetAlpha, float fadeDuration, System.Action fadeAction);
/// <summary>
/// Fade out, move camera to view and then fade back in.
/// </summary>
void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, System.Action fadeAction);
/// <summary>
/// Stop all camera tweening.
/// </summary>
void Stop();
/// <summary>
/// Moves camera from current position to a target position over a period of time.
/// </summary>
void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, System.Action arriveAction);
/// <summary>
/// Activates swipe panning mode. The player can pan the camera within the area between viewA & viewB.
/// </summary>
void StartSwipePan(Camera camera, View viewA, View viewB, float duration, float speedMultiplier, System.Action arriveAction);
/// <summary>
/// Deactivates swipe panning mode.
/// </summary>
void StopSwipePan();
}
}

12
Assets/Fungus/Scripts/Interfaces/ICameraController.cs.meta

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 182888cc7e1a0470c81e9ea6966d6fc6
timeCreated: 1473431064
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save