An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.5 KiB

using UnityEngine;
using System;
using System.Collections;
namespace Fungus.Script
{
public class View : FungusCommand
{
public enum Transition
{
Move,
Fade
}
public Transition transition;
public float duration;
public Fungus.View targetView;
public bool waitUntilFinished = true;
public override void OnEnter()
{
Game game = Game.GetInstance();
if (waitUntilFinished)
{
game.waiting = true;
}
if (transition == Transition.Fade)
{
game.cameraController.FadeToView(targetView, duration, delegate {
if (waitUntilFinished)
{
game.waiting = false;
Continue();
}
});
}
else if (transition == Transition.Move)
{
Vector3 targetPosition = targetView.transform.position;
Quaternion targetRotation = targetView.transform.rotation;
float targetSize = targetView.viewSize;
game.cameraController.PanToPosition(targetPosition, targetRotation, targetSize, duration, delegate {
if (waitUntilFinished)
{
game.waiting = false;
Continue();
}
});
}
if (!waitUntilFinished)
{
Continue();
}
}
public override string GetDescription()
{
string description = "";
switch (transition)
{
case Transition.Move:
description = "Move to ";
break;
case Transition.Fade:
description = "Fade to ";
break;
}
if (targetView == null)
{
description = "<no view selected>";
}
else
{
description += targetView.name;
}
return description;
}
}
}