Browse Source

Can now run other commands in parallel to PanToView()

master
chrisgregan 11 years ago
parent
commit
da314746c3
  1. 3
      Assets/Fungus/Scripts/CameraController.cs
  2. 30
      Assets/Fungus/Scripts/Commands/CameraCommands.cs
  3. 10
      Assets/Fungus/Scripts/GameController.cs
  4. 3
      Assets/FungusExample/Scripts/ViewRoom.cs

3
Assets/Fungus/Scripts/CameraController.cs

@ -171,6 +171,9 @@ namespace Fungus
*/
public void PanToPosition(Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction)
{
// Stop any pan that is currently active
StopAllCoroutines();
swipePanActive = false;
if (duration == 0f)

30
Assets/Fungus/Scripts/Commands/CameraCommands.cs

@ -49,30 +49,44 @@ namespace Fungus
Quaternion targetRotation;
float targetSize;
float duration;
bool wait;
public PanToPosition(Vector3 _targetPosition, Quaternion _targetRotation, float _targetSize, float _duration)
public PanToPosition(Vector3 _targetPosition, Quaternion _targetRotation, float _targetSize, float _duration, bool _wait)
{
targetPosition = _targetPosition;
targetRotation = _targetRotation;
targetSize = _targetSize;
duration = _duration;
wait = _wait;
}
public override void Execute(CommandQueue commandQueue, Action onComplete)
{
Game game = Game.GetInstance();
game.waiting = true;
if (wait)
{
game.waiting = true;
}
game.cameraController.PanToPosition(targetPosition, targetRotation, targetSize, duration, delegate {
game.waiting = false;
if (wait)
{
game.waiting = false;
if (onComplete != null)
{
onComplete();
}
}
});
if (!wait)
{
if (onComplete != null)
{
onComplete();
}
});
}
}
}

10
Assets/Fungus/Scripts/GameController.cs

@ -138,10 +138,11 @@ namespace Fungus
* This method returns immediately but it queues an asynchronous command for later execution.
* @param targetView The View to pan the camera to.
* @param duration The length of time in seconds needed to complete the pan.
* @param wait Wait for pan to finish before executing next command.
*/
public static void PanToView(View targetView, float duration)
public static void PanToView(View targetView, float duration, bool wait = true)
{
PanToPosition(targetView.transform.position, targetView.transform.rotation, targetView.viewSize, duration);
PanToPosition(targetView.transform.position, targetView.transform.rotation, targetView.viewSize, duration, wait);
}
/**
@ -153,11 +154,12 @@ namespace Fungus
* @param targetRotation The rotation to pan the camera to.
* @param targetSize The orthographic size to pan the camera to.
* @param duration The length of time in seconds needed to complete the pan.
* @param wait Wait for pan to finish before executing next command.
*/
public static void PanToPosition(Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration)
public static void PanToPosition(Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, bool wait)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.PanToPosition(targetPosition, targetRotation, targetSize, duration));
commandQueue.AddCommand(new Command.PanToPosition(targetPosition, targetRotation, targetSize, duration, wait));
}
/**

3
Assets/FungusExample/Scripts/ViewRoom.cs

@ -31,7 +31,8 @@ namespace Fungus.Example
{
PanToView(logoView, 2f);
Wait(2);
PanToView(mainView, 2f);
PanToView(mainView, 2f, false); // Don't wait for pan to finish before executing next command
Say("Wow - nice logo!");
Call(OnEnter);
}

Loading…
Cancel
Save