Browse Source

Added protected and virtual to all remaining classes

master
chrisgregan 11 years ago
parent
commit
e39ac81579
  1. 8
      Assets/Fungus/Audio/Scripts/MusicController.cs
  2. 2
      Assets/Fungus/Camera/Commands/ShakeCamera.cs
  3. 368
      Assets/Fungus/Camera/Editor/ViewEditor.cs
  4. 50
      Assets/Fungus/Camera/Scripts/CameraController.cs
  5. 2
      Assets/Fungus/Camera/Scripts/View.cs
  6. 4
      Assets/Fungus/Dialog/Commands/Choose.cs
  7. 7
      Assets/Fungus/Dialog/Commands/Say.cs
  8. 8
      Assets/Fungus/Dialog/Editor/AddOptionEditor.cs
  9. 16
      Assets/Fungus/Dialog/Editor/CharacterEditor.cs
  10. 10
      Assets/Fungus/Dialog/Editor/ChooseEditor.cs
  11. 10
      Assets/Fungus/Dialog/Editor/SayEditor.cs
  12. 4
      Assets/Fungus/Dialog/Editor/SetChooseDialogEditor.cs
  13. 4
      Assets/Fungus/Dialog/Editor/SetSayDialogEditor.cs
  14. 2
      Assets/Fungus/Dialog/Scripts/Background.cs
  15. 4
      Assets/Fungus/Dialog/Scripts/Character.cs
  16. 12
      Assets/Fungus/Dialog/Scripts/ChooseDialog.cs
  17. 32
      Assets/Fungus/Dialog/Scripts/Dialog.cs
  18. 8
      Assets/Fungus/Dialog/Scripts/SayDialog.cs
  19. 11
      Assets/Fungus/Sprite/Scripts/Parallax.cs
  20. 20
      Assets/Fungus/Sprite/Scripts/SpriteFader.cs

8
Assets/Fungus/Audio/Scripts/MusicController.cs

@ -29,7 +29,7 @@ namespace Fungus
return instance; return instance;
} }
void Start() protected virtual void Start()
{ {
audio.playOnAwake = false; audio.playOnAwake = false;
audio.loop = true; audio.loop = true;
@ -49,7 +49,7 @@ namespace Fungus
/** /**
* Stops playing game music. * Stops playing game music.
*/ */
public void StopMusic() public virtual void StopMusic()
{ {
audio.Stop(); audio.Stop();
} }
@ -59,7 +59,7 @@ namespace Fungus
* @param volume The new music volume value [0..1] * @param volume The new music volume value [0..1]
* @param duration The length of time in seconds needed to complete the volume change. * @param duration The length of time in seconds needed to complete the volume change.
*/ */
public void SetMusicVolume(float volume, float duration) public virtual void SetMusicVolume(float volume, float duration)
{ {
iTween.AudioTo(gameObject, volume, 1f, duration); iTween.AudioTo(gameObject, volume, 1f, duration);
} }
@ -70,7 +70,7 @@ namespace Fungus
* @param soundClip The sound effect clip to play * @param soundClip The sound effect clip to play
* @param volume The volume level of the sound effect * @param volume The volume level of the sound effect
*/ */
public void PlaySound(AudioClip soundClip, float volume) public virtual void PlaySound(AudioClip soundClip, float volume)
{ {
audio.PlayOneShot(soundClip, volume); audio.PlayOneShot(soundClip, volume);
} }

2
Assets/Fungus/Camera/Commands/ShakeCamera.cs

@ -27,7 +27,7 @@ namespace Fungus
} }
} }
void OnWaitComplete() protected virtual void OnWaitComplete()
{ {
Continue(); Continue();
} }

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

@ -2,243 +2,247 @@ using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Fungus;
[CanEditMultipleObjects] namespace Fungus
[CustomEditor (typeof(View))]
public class ViewEditor : Editor
{ {
static Color viewColor = Color.yellow;
SerializedProperty primaryAspectRatioProp; [CanEditMultipleObjects]
SerializedProperty secondaryAspectRatioProp; [CustomEditor (typeof(View))]
public class ViewEditor : Editor
// Draw Views when they're not selected
[DrawGizmo(GizmoType.NotSelected | GizmoType.SelectedOrChild)]
static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType)
{ {
View view = objectTransform.gameObject.GetComponent<View>(); static Color viewColor = Color.yellow;
if (view != null)
{
DrawView(view);
}
}
Vector2 LookupAspectRatio(int index) protected SerializedProperty primaryAspectRatioProp;
{ protected SerializedProperty secondaryAspectRatioProp;
switch (index)
// Draw Views when they're not selected
[DrawGizmo(GizmoType.NotSelected | GizmoType.SelectedOrChild)]
static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType)
{ {
default: View view = objectTransform.gameObject.GetComponent<View>();
case 1: if (view != null)
return new Vector2(4, 3); {
case 2: DrawView(view);
return new Vector2(3, 2); }
case 3:
return new Vector2(16, 10);
case 4:
return new Vector2(17, 10);
case 5:
return new Vector2(16, 9);
case 6:
return new Vector2(2, 1);
case 7:
return new Vector2(3, 4);
case 8:
return new Vector2(2, 3);
case 9:
return new Vector2(10, 16);
case 10:
return new Vector2(10, 17);
case 11:
return new Vector2(9, 16);
case 12:
return new Vector2(1, 2);
} }
}
void OnEnable()
{
primaryAspectRatioProp = serializedObject.FindProperty ("primaryAspectRatio");
secondaryAspectRatioProp = serializedObject.FindProperty ("secondaryAspectRatio");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
string[] ratios = { "<None>", "Landscape / 4:3", "Landscape / 3:2", "Landscape / 16:10", "Landscape / 17:10", "Landscape / 16:9", "Landscape / 2:1", "Portrait / 3:4", "Portrait / 2:3", "Portrait / 10:16", "Portrait / 10:17", "Portrait / 9:16", "Portrait / 1:2" };
EditorGUILayout.PropertyField(primaryAspectRatioProp, new GUIContent("Primary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)")); protected virtual Vector2 LookupAspectRatio(int index)
int primaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios);
if (primaryIndex > 0)
{ {
primaryAspectRatioProp.vector2Value = LookupAspectRatio(primaryIndex); switch (index)
{
default:
case 1:
return new Vector2(4, 3);
case 2:
return new Vector2(3, 2);
case 3:
return new Vector2(16, 10);
case 4:
return new Vector2(17, 10);
case 5:
return new Vector2(16, 9);
case 6:
return new Vector2(2, 1);
case 7:
return new Vector2(3, 4);
case 8:
return new Vector2(2, 3);
case 9:
return new Vector2(10, 16);
case 10:
return new Vector2(10, 17);
case 11:
return new Vector2(9, 16);
case 12:
return new Vector2(1, 2);
}
} }
EditorGUILayout.Separator();
EditorGUILayout.PropertyField(secondaryAspectRatioProp, new GUIContent("Secondary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)")); protected virtual void OnEnable()
int secondaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios);
if (secondaryIndex > 0)
{ {
secondaryAspectRatioProp.vector2Value = LookupAspectRatio(secondaryIndex); primaryAspectRatioProp = serializedObject.FindProperty ("primaryAspectRatio");
secondaryAspectRatioProp = serializedObject.FindProperty ("secondaryAspectRatio");
} }
EditorGUILayout.Separator();
if (EditorGUI.EndChangeCheck()) public override void OnInspectorGUI()
{ {
// Avoid divide by zero errors serializedObject.Update();
if (primaryAspectRatioProp.vector2Value.y == 0)
EditorGUI.BeginChangeCheck();
string[] ratios = { "<None>", "Landscape / 4:3", "Landscape / 3:2", "Landscape / 16:10", "Landscape / 17:10", "Landscape / 16:9", "Landscape / 2:1", "Portrait / 3:4", "Portrait / 2:3", "Portrait / 10:16", "Portrait / 10:17", "Portrait / 9:16", "Portrait / 1:2" };
EditorGUILayout.PropertyField(primaryAspectRatioProp, new GUIContent("Primary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)"));
int primaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios);
if (primaryIndex > 0)
{ {
primaryAspectRatioProp.vector2Value = new Vector2(primaryAspectRatioProp.vector2Value.x, 1f); primaryAspectRatioProp.vector2Value = LookupAspectRatio(primaryIndex);
} }
if (secondaryAspectRatioProp.vector2Value.y == 0) EditorGUILayout.Separator();
EditorGUILayout.PropertyField(secondaryAspectRatioProp, new GUIContent("Secondary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)"));
int secondaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios);
if (secondaryIndex > 0)
{ {
secondaryAspectRatioProp.vector2Value = new Vector2(secondaryAspectRatioProp.vector2Value.x, 1f); secondaryAspectRatioProp.vector2Value = LookupAspectRatio(secondaryIndex);
} }
EditorGUILayout.Separator();
SceneView.RepaintAll(); if (EditorGUI.EndChangeCheck())
} {
// Avoid divide by zero errors
serializedObject.ApplyModifiedProperties(); if (primaryAspectRatioProp.vector2Value.y == 0)
} {
primaryAspectRatioProp.vector2Value = new Vector2(primaryAspectRatioProp.vector2Value.x, 1f);
}
if (secondaryAspectRatioProp.vector2Value.y == 0)
{
secondaryAspectRatioProp.vector2Value = new Vector2(secondaryAspectRatioProp.vector2Value.x, 1f);
}
SceneView.RepaintAll();
}
void OnSceneGUI () serializedObject.ApplyModifiedProperties();
{
View t = target as View;
if (t.enabled)
{
EditViewBounds();
} }
if (GUI.changed) protected virtual void OnSceneGUI ()
{ {
EditorUtility.SetDirty(target); View t = target as View;
if (t.enabled)
{
EditViewBounds();
}
if (GUI.changed)
{
EditorUtility.SetDirty(target);
}
} }
}
void EditViewBounds() protected virtual void EditViewBounds()
{ {
View view = target as View; View view = target as View;
DrawView(view); DrawView(view);
Vector3 pos = view.transform.position; Vector3 pos = view.transform.position;
float viewSize = CalculateLocalViewSize(view); float viewSize = CalculateLocalViewSize(view);
Vector3[] handles = new Vector3[2]; Vector3[] handles = new Vector3[2];
handles[0] = view.transform.TransformPoint(new Vector3(0, -viewSize, 0)); handles[0] = view.transform.TransformPoint(new Vector3(0, -viewSize, 0));
handles[1] = view.transform.TransformPoint(new Vector3(0, viewSize, 0)); handles[1] = view.transform.TransformPoint(new Vector3(0, viewSize, 0));
Handles.color = Color.white; Handles.color = Color.white;
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{
Vector3 newPos = Handles.FreeMoveHandle(handles[i],
Quaternion.identity,
HandleUtility.GetHandleSize(pos) * 0.1f,
Vector3.zero,
Handles.CubeCap);
if (newPos != handles[i])
{ {
Undo.RecordObject(view, "Changed view size"); Vector3 newPos = Handles.FreeMoveHandle(handles[i],
view.viewSize = (newPos - pos).magnitude; Quaternion.identity,
break; HandleUtility.GetHandleSize(pos) * 0.1f,
Vector3.zero,
Handles.CubeCap);
if (newPos != handles[i])
{
Undo.RecordObject(view, "Changed view size");
view.viewSize = (newPos - pos).magnitude;
break;
}
} }
} }
}
public static void DrawView(View view) public static void DrawView(View view)
{ {
float height = CalculateLocalViewSize(view); float height = CalculateLocalViewSize(view);
float widthA = height * (view.primaryAspectRatio.x / view.primaryAspectRatio.y); float widthA = height * (view.primaryAspectRatio.x / view.primaryAspectRatio.y);
float widthB = height * (view.secondaryAspectRatio.x / view.secondaryAspectRatio.y); float widthB = height * (view.secondaryAspectRatio.x / view.secondaryAspectRatio.y);
Color transparent = new Color(1,1,1,0f); Color transparent = new Color(1,1,1,0f);
Color fill = viewColor; Color fill = viewColor;
Color outline = viewColor; Color outline = viewColor;
bool highlight = Selection.activeGameObject == view.gameObject; bool highlight = Selection.activeGameObject == view.gameObject;
FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); FungusScript fungusScript = FungusScriptWindow.GetFungusScript();
if (fungusScript != null) if (fungusScript != null)
{
MoveToView moveToViewCommand = fungusScript.selectedCommand as MoveToView;
if (moveToViewCommand != null)
{ {
highlight = (moveToViewCommand.targetView == view); MoveToView moveToViewCommand = fungusScript.selectedCommand as MoveToView;
if (moveToViewCommand != null)
{
highlight = (moveToViewCommand.targetView == view);
}
FadeToView fadeToViewCommand = fungusScript.selectedCommand as FadeToView;
if (fadeToViewCommand != null)
{
highlight = (fadeToViewCommand.targetView == view);
}
} }
FadeToView fadeToViewCommand = fungusScript.selectedCommand as FadeToView; if (highlight)
if (fadeToViewCommand != null)
{ {
highlight = (fadeToViewCommand.targetView == view); fill = outline = Color.green;
fill.a = 0.1f;
outline.a = 1f;
}
else
{
fill.a = 0.1f;
outline.a = 0.5f;
} }
}
if (highlight) // Draw left box
{ {
fill = outline = Color.green; Vector3[] verts = new Vector3[4];
fill.a = 0.1f; verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0));
outline.a = 1f; verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0));
} verts[2] = view.transform.TransformPoint(new Vector3(-widthA, height, 0));
else verts[3] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0));
{
fill.a = 0.1f;
outline.a = 0.5f;
}
// Draw left box Handles.DrawSolidRectangleWithOutline(verts, fill, transparent);
{ }
Vector3[] verts = new Vector3[4];
verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0));
verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0));
verts[2] = view.transform.TransformPoint(new Vector3(-widthA, height, 0));
verts[3] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0));
Handles.DrawSolidRectangleWithOutline(verts, fill, transparent); // Draw right box
} {
Vector3[] verts = new Vector3[4];
verts[0] = view.transform.TransformPoint(new Vector3(widthA, -height, 0));
verts[1] = view.transform.TransformPoint(new Vector3(widthA, height, 0));
verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0));
verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0));
// Draw right box Handles.DrawSolidRectangleWithOutline(verts, fill, transparent);
{ }
Vector3[] verts = new Vector3[4];
verts[0] = view.transform.TransformPoint(new Vector3(widthA, -height, 0));
verts[1] = view.transform.TransformPoint(new Vector3(widthA, height, 0));
verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0));
verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0));
Handles.DrawSolidRectangleWithOutline(verts, fill, transparent); // Draw inner box
} {
Vector3[] verts = new Vector3[4];
verts[0] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0));
verts[1] = view.transform.TransformPoint(new Vector3(-widthA, height, 0));
verts[2] = view.transform.TransformPoint(new Vector3(widthA, height, 0));
verts[3] = view.transform.TransformPoint(new Vector3(widthA, -height, 0));
// Draw inner box Handles.DrawSolidRectangleWithOutline(verts, transparent, outline );
{ }
Vector3[] verts = new Vector3[4];
verts[0] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0)); // Draw outer box
verts[1] = view.transform.TransformPoint(new Vector3(-widthA, height, 0)); {
verts[2] = view.transform.TransformPoint(new Vector3(widthA, height, 0)); Vector3[] verts = new Vector3[4];
verts[3] = view.transform.TransformPoint(new Vector3(widthA, -height, 0)); verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0));
verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0));
verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0));
verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0));
Handles.DrawSolidRectangleWithOutline(verts, transparent, outline ); Handles.DrawSolidRectangleWithOutline(verts, transparent, outline );
}
} }
// Draw outer box // Calculate view size in local coordinates
// Kinda expensive, but accurate and only called in editor.
static float CalculateLocalViewSize(View view)
{ {
Vector3[] verts = new Vector3[4]; return view.transform.InverseTransformPoint(view.transform.position + new Vector3(0, view.viewSize, 0)).magnitude;
verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0));
verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0));
verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0));
verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0));
Handles.DrawSolidRectangleWithOutline(verts, transparent, outline );
} }
} }
// Calculate view size in local coordinates
// 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;
}
} }

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

@ -39,23 +39,23 @@ namespace Fungus
[HideInInspector] [HideInInspector]
public bool waiting; public bool waiting;
float fadeAlpha = 0f; protected float fadeAlpha = 0f;
// Swipe panning control // Swipe panning control
View swipePanViewA; protected View swipePanViewA;
View swipePanViewB; protected View swipePanViewB;
Vector3 previousMousePos; protected Vector3 previousMousePos;
class CameraView protected class CameraView
{ {
public Vector3 cameraPos; public Vector3 cameraPos;
public Quaternion cameraRot; public Quaternion cameraRot;
public float cameraSize; public float cameraSize;
}; };
Dictionary<string, CameraView> storedViews = new Dictionary<string, CameraView>(); protected Dictionary<string, CameraView> storedViews = new Dictionary<string, CameraView>();
static CameraController instance; protected static CameraController instance;
/** /**
* Returns the CameraController singleton instance. * Returns the CameraController singleton instance.
@ -86,7 +86,7 @@ namespace Fungus
return texture; return texture;
} }
void OnGUI() protected virtual void OnGUI()
{ {
if (swipePanActive) if (swipePanActive)
{ {
@ -123,7 +123,7 @@ namespace Fungus
/** /**
* Perform a fullscreen fade over a duration. * Perform a fullscreen fade over a duration.
*/ */
public 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));
} }
@ -131,7 +131,7 @@ namespace Fungus
/** /**
* Fade out, move camera to view and then fade back in. * Fade out, move camera to view and then fade back in.
*/ */
public void FadeToView(View view, float fadeDuration, Action fadeAction) public virtual void FadeToView(View view, float fadeDuration, Action fadeAction)
{ {
swipePanActive = false; swipePanActive = false;
fadeAlpha = 0f; fadeAlpha = 0f;
@ -152,7 +152,7 @@ namespace Fungus
}); });
} }
IEnumerator FadeInternal(float targetAlpha, float fadeDuration, Action fadeAction) protected virtual IEnumerator FadeInternal(float targetAlpha, float fadeDuration, Action fadeAction)
{ {
float startAlpha = fadeAlpha; float startAlpha = fadeAlpha;
float timer = 0; float timer = 0;
@ -188,7 +188,7 @@ namespace Fungus
* Positions camera so sprite is centered and fills the screen. * Positions camera so sprite is centered and fills the screen.
* @param spriteRenderer The sprite to center the camera on * @param spriteRenderer The sprite to center the camera on
*/ */
public void CenterOnSprite(SpriteRenderer spriteRenderer) public virtual void CenterOnSprite(SpriteRenderer spriteRenderer)
{ {
swipePanActive = false; swipePanActive = false;
@ -202,7 +202,7 @@ namespace Fungus
SetCameraZ(); SetCameraZ();
} }
public void PanToView(View view, float duration, Action arriveAction) public virtual void PanToView(View view, float duration, Action arriveAction)
{ {
PanToPosition(view.transform.position, view.transform.rotation, view.viewSize, duration, arriveAction); PanToPosition(view.transform.position, view.transform.rotation, view.viewSize, duration, arriveAction);
} }
@ -210,7 +210,7 @@ namespace Fungus
/** /**
* Moves camera from current position to a target position over a period of time. * Moves camera from current position to a target position over a period of time.
*/ */
public void PanToPosition(Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction) public virtual void PanToPosition(Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction)
{ {
// Stop any pan that is currently active // Stop any pan that is currently active
StopAllCoroutines(); StopAllCoroutines();
@ -238,7 +238,7 @@ namespace Fungus
/** /**
* Stores the current camera view using a name. * Stores the current camera view using a name.
*/ */
public void StoreView(string viewName) public virtual void StoreView(string viewName)
{ {
CameraView currentView = new CameraView(); CameraView currentView = new CameraView();
currentView.cameraPos = Camera.main.transform.position; currentView.cameraPos = Camera.main.transform.position;
@ -250,7 +250,7 @@ namespace Fungus
/** /**
* Moves the camera to a previously stored camera view over a period of time. * Moves the camera to a previously stored camera view over a period of time.
*/ */
public void PanToStoredView(string viewName, float duration, Action arriveAction) public virtual void PanToStoredView(string viewName, float duration, Action arriveAction)
{ {
if (!storedViews.ContainsKey(viewName)) if (!storedViews.ContainsKey(viewName))
{ {
@ -282,7 +282,7 @@ namespace Fungus
} }
} }
IEnumerator PanInternal(Vector3 targetPos, Quaternion targetRot, float targetSize, float duration, Action arriveAction) protected virtual IEnumerator PanInternal(Vector3 targetPos, Quaternion targetRot, float targetSize, float duration, Action arriveAction)
{ {
float timer = 0; float timer = 0;
float startSize = Camera.main.orthographicSize; float startSize = Camera.main.orthographicSize;
@ -322,7 +322,7 @@ namespace Fungus
/** /**
* Moves camera smoothly through a sequence of Views over a period of time * Moves camera smoothly through a sequence of Views over a period of time
*/ */
public void PanToPath(View[] viewList, float duration, Action arriveAction) public virtual void PanToPath(View[] viewList, float duration, Action arriveAction)
{ {
swipePanActive = false; swipePanActive = false;
@ -348,7 +348,7 @@ namespace Fungus
StartCoroutine(PanToPathInternal(duration, arriveAction, pathList.ToArray())); StartCoroutine(PanToPathInternal(duration, arriveAction, pathList.ToArray()));
} }
IEnumerator PanToPathInternal(float duration, Action arriveAction, Vector3[] path) protected virtual IEnumerator PanToPathInternal(float duration, Action arriveAction, Vector3[] path)
{ {
float timer = 0; float timer = 0;
@ -377,7 +377,7 @@ namespace Fungus
* Activates swipe panning mode. * Activates swipe panning mode.
* The player can pan the camera within the area between viewA & viewB. * The player can pan the camera within the area between viewA & viewB.
*/ */
public void StartSwipePan(View viewA, View viewB, float duration, Action arriveAction) public virtual void StartSwipePan(View viewA, View viewB, float duration, Action arriveAction)
{ {
swipePanViewA = viewA; swipePanViewA = viewA;
swipePanViewB = viewB; swipePanViewB = viewB;
@ -401,19 +401,19 @@ namespace Fungus
/** /**
* Deactivates swipe panning mode. * Deactivates swipe panning mode.
*/ */
public void StopSwipePan() public virtual void StopSwipePan()
{ {
swipePanActive = false; swipePanActive = false;
swipePanViewA = null; swipePanViewA = null;
swipePanViewB = null; swipePanViewB = null;
} }
void SetCameraZ() protected virtual void SetCameraZ()
{ {
Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, cameraZ); Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, cameraZ);
} }
void Update() protected virtual void Update()
{ {
if (!swipePanActive) if (!swipePanActive)
{ {
@ -454,7 +454,7 @@ namespace Fungus
} }
// Clamp camera position to region defined by the two views // Clamp camera position to region defined by the two views
Vector3 CalcCameraPosition(Vector3 pos, View viewA, View viewB) protected virtual Vector3 CalcCameraPosition(Vector3 pos, View viewA, View viewB)
{ {
Vector3 safePos = pos; Vector3 safePos = pos;
@ -468,7 +468,7 @@ namespace Fungus
} }
// Smoothly interpolate camera orthographic size based on relative position to two views // Smoothly interpolate camera orthographic size based on relative position to two views
float CalcCameraSize(Vector3 pos, View viewA, View viewB) protected virtual float CalcCameraSize(Vector3 pos, View viewA, View viewB)
{ {
// Get ray and point in same space // Get ray and point in same space
Vector3 toViewB = viewB.transform.position - viewA.transform.position; Vector3 toViewB = viewB.transform.position - viewA.transform.position;

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

@ -31,7 +31,7 @@ namespace Fungus
[Tooltip("Aspect ratio of the secondary view rectangle. (e.g. 2:1 aspect ratio = 2.0)")] [Tooltip("Aspect ratio of the secondary view rectangle. (e.g. 2:1 aspect ratio = 2.0)")]
public Vector2 secondaryAspectRatio = new Vector2(2, 1); public Vector2 secondaryAspectRatio = new Vector2(2, 1);
void Update() protected virtual void Update()
{ {
// Disable scaling to avoid complicating the orthographic size calculations // Disable scaling to avoid complicating the orthographic size calculations
transform.localScale = new Vector3(1,1,1); transform.localScale = new Vector3(1,1,1);

4
Assets/Fungus/Dialog/Commands/Choose.cs

@ -25,7 +25,7 @@ namespace Fungus
public AudioClip voiceOverClip; public AudioClip voiceOverClip;
public float timeoutDuration; public float timeoutDuration;
bool showBasicGUI; protected bool showBasicGUI;
public override void OnEnter() public override void OnEnter()
{ {
@ -100,7 +100,7 @@ namespace Fungus
} }
} }
void OnGUI() protected virtual void OnGUI()
{ {
if (!showBasicGUI) if (!showBasicGUI)
{ {

7
Assets/Fungus/Dialog/Commands/Say.cs

@ -16,9 +16,8 @@ namespace Fungus
public Character character; public Character character;
public AudioClip voiceOverClip; public AudioClip voiceOverClip;
public bool showOnce; public bool showOnce;
int executionCount; protected int executionCount;
protected bool showBasicGUI;
bool showBasicGUI;
public override void OnEnter() public override void OnEnter()
{ {
@ -58,7 +57,7 @@ namespace Fungus
return "\"" + storyText + "\""; return "\"" + storyText + "\"";
} }
void OnGUI() protected virtual void OnGUI()
{ {
if (!showBasicGUI) if (!showBasicGUI)
{ {

8
Assets/Fungus/Dialog/Editor/AddOptionEditor.cs

@ -11,11 +11,11 @@ namespace Fungus
[CustomEditor (typeof(AddOption))] [CustomEditor (typeof(AddOption))]
public class AddOptionEditor : CommandEditor public class AddOptionEditor : CommandEditor
{ {
SerializedProperty optionTextProp; protected SerializedProperty optionTextProp;
SerializedProperty hideOnSelectedProp; protected SerializedProperty hideOnSelectedProp;
SerializedProperty targetSequenceProp; protected SerializedProperty targetSequenceProp;
void OnEnable() protected virtual void OnEnable()
{ {
optionTextProp = serializedObject.FindProperty("optionText"); optionTextProp = serializedObject.FindProperty("optionText");
hideOnSelectedProp = serializedObject.FindProperty("hideOnSelected"); hideOnSelectedProp = serializedObject.FindProperty("hideOnSelected");

16
Assets/Fungus/Dialog/Editor/CharacterEditor.cs

@ -8,14 +8,14 @@ namespace Fungus
[CustomEditor (typeof(Character))] [CustomEditor (typeof(Character))]
public class CharacterEditor : Editor public class CharacterEditor : Editor
{ {
Material spriteMaterial; protected Material spriteMaterial;
SerializedProperty nameTextProp; protected SerializedProperty nameTextProp;
SerializedProperty nameColorProp; protected SerializedProperty nameColorProp;
SerializedProperty profileSpriteProp; protected SerializedProperty profileSpriteProp;
SerializedProperty notesProp; protected SerializedProperty notesProp;
void OnEnable() protected virtual void OnEnable()
{ {
nameTextProp = serializedObject.FindProperty ("nameText"); nameTextProp = serializedObject.FindProperty ("nameText");
nameColorProp = serializedObject.FindProperty ("nameColor"); nameColorProp = serializedObject.FindProperty ("nameColor");
@ -30,7 +30,7 @@ namespace Fungus
} }
} }
void OnDisable() protected virtual void OnDisable()
{ {
DestroyImmediate(spriteMaterial); DestroyImmediate(spriteMaterial);
} }
@ -66,7 +66,7 @@ namespace Fungus
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
public void DrawPreview(Rect previewRect, Texture2D texture) public virtual void DrawPreview(Rect previewRect, Texture2D texture)
{ {
if (texture == null) if (texture == null)
{ {

10
Assets/Fungus/Dialog/Editor/ChooseEditor.cs

@ -13,12 +13,12 @@ namespace Fungus
{ {
static public bool showTagHelp; static public bool showTagHelp;
SerializedProperty chooseTextProp; protected SerializedProperty chooseTextProp;
SerializedProperty characterProp; protected SerializedProperty characterProp;
SerializedProperty voiceOverClipProp; protected SerializedProperty voiceOverClipProp;
SerializedProperty timeoutDurationProp; protected SerializedProperty timeoutDurationProp;
void OnEnable() protected virtual void OnEnable()
{ {
chooseTextProp = serializedObject.FindProperty("chooseText"); chooseTextProp = serializedObject.FindProperty("chooseText");
characterProp = serializedObject.FindProperty("character"); characterProp = serializedObject.FindProperty("character");

10
Assets/Fungus/Dialog/Editor/SayEditor.cs

@ -30,12 +30,12 @@ namespace Fungus
EditorGUILayout.SelectableLabel(tagsText, EditorStyles.miniLabel, GUILayout.MinHeight(pixelHeight)); EditorGUILayout.SelectableLabel(tagsText, EditorStyles.miniLabel, GUILayout.MinHeight(pixelHeight));
} }
SerializedProperty storyTextProp; protected SerializedProperty storyTextProp;
SerializedProperty characterProp; protected SerializedProperty characterProp;
SerializedProperty voiceOverClipProp; protected SerializedProperty voiceOverClipProp;
SerializedProperty showOnceProp; protected SerializedProperty showOnceProp;
void OnEnable() protected virtual void OnEnable()
{ {
storyTextProp = serializedObject.FindProperty("storyText"); storyTextProp = serializedObject.FindProperty("storyText");
characterProp = serializedObject.FindProperty("character"); characterProp = serializedObject.FindProperty("character");

4
Assets/Fungus/Dialog/Editor/SetChooseDialogEditor.cs

@ -11,9 +11,9 @@ namespace Fungus
[CustomEditor (typeof(SetChooseDialog))] [CustomEditor (typeof(SetChooseDialog))]
public class SetChooseDialogEditor : CommandEditor public class SetChooseDialogEditor : CommandEditor
{ {
SerializedProperty chooseDialogProp; protected SerializedProperty chooseDialogProp;
void OnEnable() protected virtual void OnEnable()
{ {
chooseDialogProp = serializedObject.FindProperty("chooseDialog"); chooseDialogProp = serializedObject.FindProperty("chooseDialog");
} }

4
Assets/Fungus/Dialog/Editor/SetSayDialogEditor.cs

@ -11,9 +11,9 @@ namespace Fungus
[CustomEditor (typeof(SetSayDialog))] [CustomEditor (typeof(SetSayDialog))]
public class SetSayDialogEditor : CommandEditor public class SetSayDialogEditor : CommandEditor
{ {
SerializedProperty sayDialogProp; protected SerializedProperty sayDialogProp;
void OnEnable() protected virtual void OnEnable()
{ {
sayDialogProp = serializedObject.FindProperty("sayDialog"); sayDialogProp = serializedObject.FindProperty("sayDialog");
} }

2
Assets/Fungus/Dialog/Scripts/Background.cs

@ -7,7 +7,7 @@ public class Background : MonoBehaviour
public Canvas backgroundCanvas; public Canvas backgroundCanvas;
public Image backgroundImage; public Image backgroundImage;
public void SetBackgroundImage(Sprite imageSprite) public virtual void SetBackgroundImage(Sprite imageSprite)
{ {
if (backgroundCanvas != null) if (backgroundCanvas != null)
{ {

4
Assets/Fungus/Dialog/Scripts/Character.cs

@ -17,7 +17,7 @@ namespace Fungus
static public List<Character> activeCharacters = new List<Character>(); static public List<Character> activeCharacters = new List<Character>();
void OnEnable() protected virtual void OnEnable()
{ {
if (!activeCharacters.Contains(this)) if (!activeCharacters.Contains(this))
{ {
@ -25,7 +25,7 @@ namespace Fungus
} }
} }
void OnDisable() protected virtual void OnDisable()
{ {
activeCharacters.Remove(this); activeCharacters.Remove(this);
} }

12
Assets/Fungus/Dialog/Scripts/ChooseDialog.cs

@ -23,7 +23,7 @@ namespace Fungus
static public List<ChooseDialog> activeDialogs = new List<ChooseDialog>(); static public List<ChooseDialog> activeDialogs = new List<ChooseDialog>();
void OnEnable() protected virtual void OnEnable()
{ {
if (!activeDialogs.Contains(this)) if (!activeDialogs.Contains(this))
{ {
@ -31,7 +31,7 @@ namespace Fungus
} }
} }
void OnDisable() protected virtual void OnDisable()
{ {
activeDialogs.Remove(this); activeDialogs.Remove(this);
} }
@ -42,7 +42,7 @@ namespace Fungus
timeoutSlider.gameObject.SetActive(false); timeoutSlider.gameObject.SetActive(false);
} }
public void Choose(string text, List<Option> options, float timeoutDuration, Action onTimeout) public virtual void Choose(string text, List<Option> options, float timeoutDuration, Action onTimeout)
{ {
Clear(); Clear();
@ -62,7 +62,7 @@ namespace Fungus
StartCoroutine(WriteText(text, onWritingComplete, onTimeout)); StartCoroutine(WriteText(text, onWritingComplete, onTimeout));
} }
IEnumerator WaitForTimeout(float timeoutDuration, Action onTimeout) protected virtual IEnumerator WaitForTimeout(float timeoutDuration, Action onTimeout)
{ {
float elapsedTime = 0; float elapsedTime = 0;
@ -93,7 +93,7 @@ namespace Fungus
ClearOptions(); ClearOptions();
} }
void ClearOptions() protected virtual void ClearOptions()
{ {
if (optionButtons == null) if (optionButtons == null)
{ {
@ -114,7 +114,7 @@ namespace Fungus
} }
} }
bool AddOption(string text, UnityAction action) protected virtual bool AddOption(string text, UnityAction action)
{ {
if (optionButtons == null) if (optionButtons == null)
{ {

32
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -21,12 +21,12 @@ namespace Fungus
public Text storyText; public Text storyText;
public Image characterImage; public Image characterImage;
float currentSpeed; protected float currentSpeed;
float currentPunctuationPause; protected float currentPunctuationPause;
bool boldActive; protected bool boldActive;
bool italicActive; protected bool italicActive;
bool colorActive; protected bool colorActive;
string colorText; protected string colorText;
protected enum GlyphType protected enum GlyphType
{ {
@ -60,7 +60,7 @@ namespace Fungus
} }
} }
public void SetCharacter(Character character) public virtual void SetCharacter(Character character)
{ {
if (character == null) if (character == null)
{ {
@ -84,7 +84,7 @@ namespace Fungus
} }
} }
public void SetCharacterImage(Sprite image) public virtual void SetCharacterImage(Sprite image)
{ {
if (characterImage != null) if (characterImage != null)
{ {
@ -100,7 +100,7 @@ namespace Fungus
} }
} }
public void SetCharacterName(string name, Color color) public virtual void SetCharacterName(string name, Color color)
{ {
if (nameText != null) if (nameText != null)
{ {
@ -109,7 +109,7 @@ namespace Fungus
} }
} }
protected IEnumerator WriteText(string text, Action onWritingComplete, Action onExitTag) protected virtual IEnumerator WriteText(string text, Action onWritingComplete, Action onExitTag)
{ {
storyText.text = ""; storyText.text = "";
boldActive = false; boldActive = false;
@ -370,7 +370,7 @@ namespace Fungus
ClearStoryText(); ClearStoryText();
} }
void ClearStoryText() protected virtual void ClearStoryText()
{ {
if (storyText != null) if (storyText != null)
{ {
@ -378,14 +378,14 @@ namespace Fungus
} }
} }
bool IsPunctuation(string character) protected virtual bool IsPunctuation(string character)
{ {
return character == "." || return character == "." ||
character == "?" || character == "?" ||
character == "!"; character == "!";
} }
List<Glyph> MakeGlyphList(string storyText) protected virtual List<Glyph> MakeGlyphList(string storyText)
{ {
List<Glyph> glyphList = new List<Glyph>(); List<Glyph> glyphList = new List<Glyph>();
@ -424,7 +424,7 @@ namespace Fungus
return glyphList; return glyphList;
} }
void AddCharacterGlyph(List<Glyph> glyphList, string character) protected virtual void AddCharacterGlyph(List<Glyph> glyphList, string character)
{ {
Glyph glyph = new Glyph(); Glyph glyph = new Glyph();
glyph.type = GlyphType.Character; glyph.type = GlyphType.Character;
@ -432,7 +432,7 @@ namespace Fungus
glyphList.Add(glyph); glyphList.Add(glyph);
} }
void AddTagGlyph(List<Glyph> glyphList, string tagText) protected virtual void AddTagGlyph(List<Glyph> glyphList, string tagText)
{ {
if (tagText.Length < 3 || if (tagText.Length < 3 ||
tagText.Substring(0,1) != "{" || tagText.Substring(0,1) != "{" ||
@ -522,7 +522,7 @@ namespace Fungus
glyphList.Add(glyph); glyphList.Add(glyph);
} }
protected IEnumerator WaitForInput(Action onInput) protected virtual IEnumerator WaitForInput(Action onInput)
{ {
while (!Input.GetMouseButtonDown(0)) while (!Input.GetMouseButtonDown(0))
{ {

8
Assets/Fungus/Dialog/Scripts/SayDialog.cs

@ -14,7 +14,7 @@ namespace Fungus
static public List<SayDialog> activeDialogs = new List<SayDialog>(); static public List<SayDialog> activeDialogs = new List<SayDialog>();
void OnEnable() protected virtual void OnEnable()
{ {
if (!activeDialogs.Contains(this)) if (!activeDialogs.Contains(this))
{ {
@ -22,12 +22,12 @@ namespace Fungus
} }
} }
void OnDisable() protected virtual void OnDisable()
{ {
activeDialogs.Remove(this); activeDialogs.Remove(this);
} }
public void Say(string text, Action onComplete) public virtual void Say(string text, Action onComplete)
{ {
Clear(); Clear();
@ -69,7 +69,7 @@ namespace Fungus
ShowContinueImage(waiting); ShowContinueImage(waiting);
} }
void ShowContinueImage(bool visible) protected virtual void ShowContinueImage(bool visible)
{ {
if (continueImage != null) if (continueImage != null)
{ {

11
Assets/Fungus/Sprite/Scripts/Parallax.cs

@ -28,12 +28,11 @@ namespace Fungus
*/ */
public float accelerometerScale = 0.5f; public float accelerometerScale = 0.5f;
Vector3 startPosition; protected Vector3 startPosition;
protected Vector3 acceleration;
protected Vector3 velocity;
Vector3 acceleration; protected virtual void Start ()
Vector3 velocity;
void Start ()
{ {
// Store the starting position and scale of the sprite object // Store the starting position and scale of the sprite object
startPosition = transform.position; startPosition = transform.position;
@ -45,7 +44,7 @@ namespace Fungus
} }
} }
void Update () protected virtual void Update ()
{ {
if (backgroundSprite == null) if (backgroundSprite == null)
{ {

20
Assets/Fungus/Sprite/Scripts/SpriteFader.cs

@ -11,16 +11,16 @@ namespace Fungus
[RequireComponent (typeof (SpriteRenderer))] [RequireComponent (typeof (SpriteRenderer))]
public class SpriteFader : MonoBehaviour public class SpriteFader : MonoBehaviour
{ {
float fadeDuration; protected float fadeDuration;
float fadeTimer; protected float fadeTimer;
Color startColor; protected Color startColor;
Color endColor; protected Color endColor;
Vector2 slideOffset; protected Vector2 slideOffset;
Vector3 endPosition; protected Vector3 endPosition;
SpriteRenderer spriteRenderer; protected SpriteRenderer spriteRenderer;
Action onFadeComplete; protected Action onFadeComplete;
/** /**
* Attaches a SpriteFader component to a sprite object to transition its color over time. * Attaches a SpriteFader component to a sprite object to transition its color over time.
@ -72,12 +72,12 @@ namespace Fungus
spriteFader.onFadeComplete = onComplete; spriteFader.onFadeComplete = onComplete;
} }
void Start() protected virtual void Start()
{ {
spriteRenderer = renderer as SpriteRenderer; spriteRenderer = renderer as SpriteRenderer;
} }
void Update() protected virtual void Update()
{ {
fadeTimer += Time.deltaTime; fadeTimer += Time.deltaTime;
if (fadeTimer > fadeDuration) if (fadeTimer > fadeDuration)

Loading…
Cancel
Save