Browse Source

Refactored comments and layout

master
Christopher 9 years ago
parent
commit
e4451a54a0
  1. 5
      Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs
  2. 5
      Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs
  3. 5
      Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs
  4. 5
      Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs
  5. 5
      Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs
  6. 5
      Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs
  7. 4
      Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs
  8. 4
      Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs
  9. 4
      Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs
  10. 40
      Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs
  11. 4
      Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs
  12. 4
      Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs
  13. 4
      Assets/Fungus/Audio/Scripts/Commands/StopMusic.cs
  14. 8
      Assets/Fungus/Camera/Editor/ViewEditor.cs
  15. 38
      Assets/Fungus/Camera/Scripts/CameraController.cs
  16. 6
      Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs
  17. 6
      Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs
  18. 5
      Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs
  19. 8
      Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs
  20. 4
      Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs
  21. 5
      Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs
  22. 5
      Assets/Fungus/Camera/Scripts/Commands/StopSwipe.cs
  23. 39
      Assets/Fungus/Camera/Scripts/View.cs

5
Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs

@ -4,11 +4,12 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Plays a state of an animator according to the state name.
/// </summary>
[CommandInfo("Animation",
"Play Anim State",
"Plays a state of an animator according to the state name")]

5
Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs

@ -5,11 +5,12 @@
using UnityEngine;
using UnityEngine.Serialization;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Resets a trigger parameter on an Animator component.
/// </summary>
[CommandInfo("Animation",
"Reset Anim Trigger",
"Resets a trigger parameter on an Animator component.")]

5
Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs

@ -5,11 +5,12 @@
using UnityEngine;
using UnityEngine.Serialization;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Sets a boolean parameter on an Animator component to control a Unity animation"
/// </summary>
[CommandInfo("Animation",
"Set Anim Bool",
"Sets a boolean parameter on an Animator component to control a Unity animation")]

5
Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs

@ -5,11 +5,12 @@
using UnityEngine;
using UnityEngine.Serialization;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Sets a float parameter on an Animator component to control a Unity animation.
/// </summary>
[CommandInfo("Animation",
"Set Anim Float",
"Sets a float parameter on an Animator component to control a Unity animation")]

5
Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs

@ -5,11 +5,12 @@
using UnityEngine;
using UnityEngine.Serialization;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Sets an integer parameter on an Animator component to control a Unity animation.
/// </summary>
[CommandInfo("Animation",
"Set Anim Integer",
"Sets an integer parameter on an Animator component to control a Unity animation")]

5
Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs

@ -5,11 +5,12 @@
using UnityEngine;
using UnityEngine.Serialization;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Sets a trigger parameter on an Animator component to control a Unity animation.
/// </summary>
[CommandInfo("Animation",
"Set Anim Trigger",
"Sets a trigger parameter on an Animator component to control a Unity animation")]

4
Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs

@ -9,6 +9,9 @@ using System.Collections;
namespace Fungus
{
/// <summary>
/// Plays, loops, or stops an audiosource. Any AudioSources with the same tag as the target Audio Source will automatically be stoped.
/// </summary>
[CommandInfo("Audio",
"Control Audio",
"Plays, loops, or stops an audiosource. Any AudioSources with the same tag as the target Audio Source will automatically be stoped.")]
@ -26,7 +29,6 @@ namespace Fungus
[Tooltip("What to do to audio")]
[SerializeField] protected controlType control;
public controlType Control { get { return control; } }
[Tooltip("Audio clip to play")]

4
Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs

@ -4,10 +4,12 @@
*/
using UnityEngine;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Plays looping game music. If any game music is already playing, it is stopped. Game music will continue playing across scene loads.
/// </summary>
[CommandInfo("Audio",
"Play Music",
"Plays looping game music. If any game music is already playing, it is stopped. Game music will continue playing across scene loads.")]

4
Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs

@ -4,10 +4,12 @@
*/
using UnityEngine;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Plays a once-off sound effect. Multiple sound effects can be played at the same time.
/// </summary>
[CommandInfo("Audio",
"Play Sound",
"Plays a once-off sound effect. Multiple sound effects can be played at the same time.")]

40
Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs

@ -3,11 +3,15 @@
* It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
*/
namespace Fungus {
using System;
using UnityEngine;
using UnityEngine.Serialization;
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace Fungus
{
/// <summary>
/// Plays a usfxr synth sound. Use the usfxr editor [Tools > Fungus > Utilities > Generate usfxr Sound Effects] to create the SettingsString. Set a ParentTransform if using positional sound. See https://github.com/zeh/usfxr for more information about usfxr.
/// </summary>
[CommandInfo("Audio",
"Play Usfxr Sound",
"Plays a usfxr synth sound. Use the usfxr editor [Tools > Fungus > Utilities > Generate usfxr Sound Effects] to create the SettingsString. Set a ParentTransform if using positional sound. See https://github.com/zeh/usfxr for more information about usfxr.")]
@ -15,8 +19,6 @@
[ExecuteInEditMode]
public class PlayUsfxrSound : Command
{
protected SfxrSynth _synth = new SfxrSynth();
[Tooltip("Transform to use for positional audio")]
[SerializeField] protected Transform ParentTransform = null;
@ -26,20 +28,26 @@
[Tooltip("Time to wait before executing the next command")]
[SerializeField] protected float waitDuration = 0;
protected SfxrSynth _synth = new SfxrSynth();
//Call this if the settings have changed
protected void UpdateCache() {
if (_SettingsString.Value != null) {
protected void UpdateCache()
{
if (_SettingsString.Value != null)
{
_synth.parameters.SetSettingsString(_SettingsString.Value);
_synth.CacheSound();
}
}
public void Awake() {
public void Awake()
{
//Always build the cache on awake
UpdateCache();
}
public override void OnEnter() {
public override void OnEnter()
{
_synth.SetParentTransform(ParentTransform);
_synth.Play();
if (waitDuration == 0f)
@ -57,17 +65,21 @@
Continue();
}
public override string GetSummary() {
if (String.IsNullOrEmpty(_SettingsString.Value)) {
public override string GetSummary()
{
if (String.IsNullOrEmpty(_SettingsString.Value))
{
return "Settings String hasn't been set!";
}
if (ParentTransform != null) {
if (ParentTransform != null)
{
return "" + ParentTransform.name + ": " + _SettingsString.Value;
}
return "Camera.main: " + _SettingsString.Value;
}
public override Color GetButtonColor() {
public override Color GetButtonColor()
{
return new Color32(128, 200, 200, 255);
}

4
Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs

@ -4,10 +4,12 @@
*/
using UnityEngine;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Sets the global pitch level for audio played with Play Music and Play Sound commands.
/// </summary>
[CommandInfo("Audio",
"Set Audio Pitch",
"Sets the global pitch level for audio played with Play Music and Play Sound commands.")]

4
Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs

@ -4,10 +4,12 @@
*/
using UnityEngine;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Sets the global volume level for audio played with Play Music and Play Sound commands.
/// </summary>
[CommandInfo("Audio",
"Set Audio Volume",
"Sets the global volume level for audio played with Play Music and Play Sound commands.")]

4
Assets/Fungus/Audio/Scripts/Commands/StopMusic.cs

@ -4,10 +4,12 @@
*/
using UnityEngine;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Stops the currently playing game music.
/// </summary>
[CommandInfo("Audio",
"Stop Music",
"Stops the currently playing game music.")]

8
Assets/Fungus/Camera/Editor/ViewEditor.cs

@ -154,7 +154,7 @@ namespace Fungus
if (newPos != handles[i])
{
Undo.RecordObject(view, "Set View Size");
view.viewSize = (newPos - pos).magnitude;
view.ViewSize = (newPos - pos).magnitude;
EditorUtility.SetDirty(view);
break;
}
@ -164,8 +164,8 @@ namespace Fungus
public static void DrawView(View view, bool drawInterior)
{
float height = CalculateLocalViewSize(view);
float widthA = height * (view.primaryAspectRatio.x / view.primaryAspectRatio.y);
float widthB = height * (view.secondaryAspectRatio.x / view.secondaryAspectRatio.y);
float widthA = height * (view.PrimaryAspectRatio.x / view.PrimaryAspectRatio.y);
float widthB = height * (view.SecondaryAspectRatio.x / view.SecondaryAspectRatio.y);
Color transparent = new Color(1,1,1,0f);
Color fill = viewColor;
@ -260,7 +260,7 @@ namespace Fungus
// Kinda expensive, but accurate and only called in editor.
static float CalculateLocalViewSize(View view)
{
return view.transform.InverseTransformPoint(view.transform.position + new Vector3(0, view.viewSize, 0)).magnitude;
return view.transform.InverseTransformPoint(view.transform.position + new Vector3(0, view.ViewSize, 0)).magnitude;
}
}

38
Assets/Fungus/Camera/Scripts/CameraController.cs

@ -11,40 +11,28 @@ using Fungus;
namespace Fungus
{
/**
* Controller for main camera.
* Supports several types of camera transition including snap, pan & fade.
*/
/// <summary>
/// Controller for main camera.Supports several types of camera transition including snap, pan & fade.
/// </summary>
public class CameraController : MonoBehaviour
{
/**
* Full screen texture used for screen fade effect.
*/
[Tooltip("Full screen texture used for screen fade effect.")]
[SerializeField] protected Texture2D screenFadeTexture;
public Texture2D ScreenFadeTexture { set { screenFadeTexture = value; } }
/**
* Icon to display when swipe pan mode is active.
*/
[Tooltip("Icon to display when swipe pan mode is active.")]
[SerializeField] protected Texture2D swipePanIcon;
/**
* Position of continue and swipe icons in normalized screen space coords.
* (0,0) = top left, (1,1) = bottom right
*/
[Tooltip("Position of continue and swipe icons in normalized screen space coords. (0,0) = top left, (1,1) = bottom right")]
[SerializeField] protected Vector2 swipeIconPosition = new Vector2(1,0);
/**
* Set the camera z coordinate to a fixed value every frame.
*/
[Tooltip("Set the camera z coordinate to a fixed value every frame.")]
[SerializeField] protected bool setCameraZ = true;
/**
* Fixed Z coordinate of main camera.
*/
[Tooltip("Fixed Z coordinate of main camera.")]
[SerializeField] protected float cameraZ = -10f;
[Tooltip("Camera to use when in swipe mode")]
[SerializeField] protected Camera swipeCamera;
protected float fadeAlpha = 0f;
@ -165,7 +153,7 @@ namespace Fungus
Fade(1f, outDuration, delegate {
// Snap to new view
PanToPosition(camera, view.transform.position, view.transform.rotation, view.viewSize, 0f, null);
PanToPosition(camera, view.transform.position, view.transform.rotation, view.ViewSize, 0f, null);
// Fade in
Fade(0f, inDuration, delegate {
@ -242,7 +230,7 @@ namespace Fungus
public virtual void PanToView(Camera camera, View view, float duration, Action arriveAction)
{
PanToPosition(camera, view.transform.position, view.transform.rotation, view.viewSize, duration, arriveAction);
PanToPosition(camera, view.transform.position, view.transform.rotation, view.ViewSize, duration, arriveAction);
}
/**
@ -422,7 +410,7 @@ namespace Fungus
Vector3 viewPos = new Vector3(view.transform.position.x,
view.transform.position.y,
view.viewSize);
view.ViewSize);
pathList.Add(viewPos);
}
@ -597,7 +585,7 @@ namespace Fungus
float t = Vector3.Dot(toViewB, localPos);
t = Mathf.Clamp01(t); // Not really necessary but no harm
float cameraSize = Mathf.Lerp(viewA.viewSize, viewB.viewSize, t);
float cameraSize = Mathf.Lerp(viewA.ViewSize, viewB.ViewSize, t);
return cameraSize;
}

6
Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs

@ -4,11 +4,13 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Draws a fullscreen texture over the scene to give a fade effect. Setting Target Alpha to 1 will obscure the screen, alpha 0 will reveal the screen.
/// If no Fade Texture is provided then a default flat color texture is used.
/// </summary>
[CommandInfo("Camera",
"Fade Screen",
"Draws a fullscreen texture over the scene to give a fade effect. Setting Target Alpha to 1 will obscure the screen, alpha 0 will reveal the screen. " +

6
Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs

@ -4,11 +4,12 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Fades the camera out and in again at a position specified by a View object.
/// </summary>
[CommandInfo("Camera",
"Fade To View",
"Fades the camera out and in again at a position specified by a View object.")]
@ -23,7 +24,6 @@ namespace Fungus
[Tooltip("View to transition to when Fade is complete")]
[SerializeField] protected View targetView;
public View TargetView { get { return targetView; } }
[Tooltip("Wait until the fade has finished before executing next command")]

5
Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs

@ -4,11 +4,12 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Sets the application to fullscreen, windowed or toggles the current state.
/// </summary>
[CommandInfo("Camera",
"Fullscreen",
"Sets the application to fullscreen, windowed or toggles the current state.")]

8
Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs

@ -4,11 +4,12 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Moves the camera to a location specified by a View object.
/// </summary>
[CommandInfo("Camera",
"Move To View",
"Moves the camera to a location specified by a View object.")]
@ -20,7 +21,6 @@ namespace Fungus
[Tooltip("View to transition to when move is complete")]
[SerializeField] protected View targetView;
public View TargetView { get { return targetView; } }
[Tooltip("Wait until the fade has finished before executing next command")]
@ -62,7 +62,7 @@ namespace Fungus
Vector3 targetPosition = targetView.transform.position;
Quaternion targetRotation = targetView.transform.rotation;
float targetSize = targetView.viewSize;
float targetSize = targetView.ViewSize;
cameraController.PanToPosition(targetCamera, targetPosition, targetRotation, targetSize, duration, delegate {
if (waitUntilFinished)

4
Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs

@ -4,11 +4,13 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Applies a camera shake effect to the main camera.
/// </summary>
[CommandInfo("Camera",
"Shake Camera",
"Applies a camera shake effect to the main camera.")]

5
Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs

@ -4,11 +4,12 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Activates swipe panning mode where the player can pan the camera within the area between viewA & viewB.
/// </summary>
[CommandInfo("Camera",
"Start Swipe",
"Activates swipe panning mode where the player can pan the camera within the area between viewA & viewB.")]

5
Assets/Fungus/Camera/Scripts/Commands/StopSwipe.cs

@ -4,11 +4,12 @@
*/
using UnityEngine;
using System;
using System.Collections;
namespace Fungus
{
/// <summary>
/// Deactivates swipe panning mode.
/// </summary>
[CommandInfo("Camera",
"Stop Swipe",
"Deactivates swipe panning mode.")]

39
Assets/Fungus/Camera/Scripts/View.cs

@ -4,37 +4,36 @@
*/
using UnityEngine;
using System.Collections;
namespace Fungus
{
/**
* Defines a camera view point.
* The position and rotation are specified using the game object's transform, so this class
* only needs to specify the ortographic view size.
*/
/// <summary>
/// Defines a camera view point.
/// The position and rotation are specified using the game object's transform, so this class only needs to specify the ortographic view size.
/// </summary>
[ExecuteInEditMode]
public class View : MonoBehaviour
{
/**
* Orthographic size of the camera view in world units.
*/
/// <summary>
/// Orthographic size of the camera view in world units.
/// </summary>
[Tooltip("Orthographic size of the camera view in world units.")]
public float viewSize = 0.5f;
[SerializeField] protected float viewSize = 0.5f;
public float ViewSize { get { return viewSize; } set { viewSize = value; } }
/**
* Aspect ratio of the primary view rectangle.
* e.g. a 4:3 aspect ratio = 1.333
*/
/// <summary>
/// Aspect ratio of the primary view rectangle. e.g. a 4:3 aspect ratio = 1.333.
/// </summary>
[Tooltip("Aspect ratio of the primary view rectangle. (e.g. 4:3 aspect ratio = 1.333)")]
public Vector2 primaryAspectRatio = new Vector2(4, 3);
[SerializeField] protected Vector2 primaryAspectRatio = new Vector2(4, 3);
public Vector2 PrimaryAspectRatio { get { return primaryAspectRatio; } set { primaryAspectRatio = value; } }
/**
* Aspect ratio of the secondary view rectangle.
* e.g. a 2:1 aspect ratio = 2/1 = 2.0
*/
/// <summary>
/// Aspect ratio of the secondary view rectangle. e.g. a 2:1 aspect ratio = 2/1 = 2.0.
/// </summary>
[Tooltip("Aspect ratio of the secondary view rectangle. (e.g. 2:1 aspect ratio = 2.0)")]
public Vector2 secondaryAspectRatio = new Vector2(2, 1);
[SerializeField] protected Vector2 secondaryAspectRatio = new Vector2(2, 1);
public Vector2 SecondaryAspectRatio { get { return secondaryAspectRatio; } set { secondaryAspectRatio = value; } }
protected virtual void Update()
{

Loading…
Cancel
Save