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. 24
      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;
}
void Start()
protected virtual void Start()
{
audio.playOnAwake = false;
audio.loop = true;
@ -49,7 +49,7 @@ namespace Fungus
/**
* Stops playing game music.
*/
public void StopMusic()
public virtual void StopMusic()
{
audio.Stop();
}
@ -59,7 +59,7 @@ namespace Fungus
* @param volume The new music volume value [0..1]
* @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);
}
@ -70,7 +70,7 @@ namespace Fungus
* @param soundClip The sound effect clip to play
* @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);
}

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

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

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

@ -2,16 +2,18 @@ using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Fungus;
[CanEditMultipleObjects]
[CustomEditor (typeof(View))]
public class ViewEditor : Editor
namespace Fungus
{
[CanEditMultipleObjects]
[CustomEditor (typeof(View))]
public class ViewEditor : Editor
{
static Color viewColor = Color.yellow;
SerializedProperty primaryAspectRatioProp;
SerializedProperty secondaryAspectRatioProp;
protected SerializedProperty primaryAspectRatioProp;
protected SerializedProperty secondaryAspectRatioProp;
// Draw Views when they're not selected
[DrawGizmo(GizmoType.NotSelected | GizmoType.SelectedOrChild)]
@ -24,7 +26,7 @@ public class ViewEditor : Editor
}
}
Vector2 LookupAspectRatio(int index)
protected virtual Vector2 LookupAspectRatio(int index)
{
switch (index)
{
@ -56,7 +58,7 @@ public class ViewEditor : Editor
}
}
void OnEnable()
protected virtual void OnEnable()
{
primaryAspectRatioProp = serializedObject.FindProperty ("primaryAspectRatio");
secondaryAspectRatioProp = serializedObject.FindProperty ("secondaryAspectRatio");
@ -104,7 +106,7 @@ public class ViewEditor : Editor
serializedObject.ApplyModifiedProperties();
}
void OnSceneGUI ()
protected virtual void OnSceneGUI ()
{
View t = target as View;
if (t.enabled)
@ -118,7 +120,7 @@ public class ViewEditor : Editor
}
}
void EditViewBounds()
protected virtual void EditViewBounds()
{
View view = target as View;
@ -241,4 +243,6 @@ public class ViewEditor : Editor
{
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]
public bool waiting;
float fadeAlpha = 0f;
protected float fadeAlpha = 0f;
// Swipe panning control
View swipePanViewA;
View swipePanViewB;
Vector3 previousMousePos;
protected View swipePanViewA;
protected View swipePanViewB;
protected Vector3 previousMousePos;
class CameraView
protected class CameraView
{
public Vector3 cameraPos;
public Quaternion cameraRot;
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.
@ -86,7 +86,7 @@ namespace Fungus
return texture;
}
void OnGUI()
protected virtual void OnGUI()
{
if (swipePanActive)
{
@ -123,7 +123,7 @@ namespace Fungus
/**
* 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));
}
@ -131,7 +131,7 @@ namespace Fungus
/**
* 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;
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 timer = 0;
@ -188,7 +188,7 @@ namespace Fungus
* Positions camera so sprite is centered and fills the screen.
* @param spriteRenderer The sprite to center the camera on
*/
public void CenterOnSprite(SpriteRenderer spriteRenderer)
public virtual void CenterOnSprite(SpriteRenderer spriteRenderer)
{
swipePanActive = false;
@ -202,7 +202,7 @@ namespace Fungus
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);
}
@ -210,7 +210,7 @@ namespace Fungus
/**
* 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
StopAllCoroutines();
@ -238,7 +238,7 @@ namespace Fungus
/**
* Stores the current camera view using a name.
*/
public void StoreView(string viewName)
public virtual void StoreView(string viewName)
{
CameraView currentView = new CameraView();
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.
*/
public void PanToStoredView(string viewName, float duration, Action arriveAction)
public virtual void PanToStoredView(string viewName, float duration, Action arriveAction)
{
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 startSize = Camera.main.orthographicSize;
@ -322,7 +322,7 @@ namespace Fungus
/**
* 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;
@ -348,7 +348,7 @@ namespace Fungus
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;
@ -377,7 +377,7 @@ namespace Fungus
* Activates swipe panning mode.
* 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;
swipePanViewB = viewB;
@ -401,19 +401,19 @@ namespace Fungus
/**
* Deactivates swipe panning mode.
*/
public void StopSwipePan()
public virtual void StopSwipePan()
{
swipePanActive = false;
swipePanViewA = 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);
}
void Update()
protected virtual void Update()
{
if (!swipePanActive)
{
@ -454,7 +454,7 @@ namespace Fungus
}
// 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;
@ -468,7 +468,7 @@ namespace Fungus
}
// 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
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)")]
public Vector2 secondaryAspectRatio = new Vector2(2, 1);
void Update()
protected virtual void Update()
{
// Disable scaling to avoid complicating the orthographic size calculations
transform.localScale = new Vector3(1,1,1);

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

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

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

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

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

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

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

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

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

@ -13,12 +13,12 @@ namespace Fungus
{
static public bool showTagHelp;
SerializedProperty chooseTextProp;
SerializedProperty characterProp;
SerializedProperty voiceOverClipProp;
SerializedProperty timeoutDurationProp;
protected SerializedProperty chooseTextProp;
protected SerializedProperty characterProp;
protected SerializedProperty voiceOverClipProp;
protected SerializedProperty timeoutDurationProp;
void OnEnable()
protected virtual void OnEnable()
{
chooseTextProp = serializedObject.FindProperty("chooseText");
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));
}
SerializedProperty storyTextProp;
SerializedProperty characterProp;
SerializedProperty voiceOverClipProp;
SerializedProperty showOnceProp;
protected SerializedProperty storyTextProp;
protected SerializedProperty characterProp;
protected SerializedProperty voiceOverClipProp;
protected SerializedProperty showOnceProp;
void OnEnable()
protected virtual void OnEnable()
{
storyTextProp = serializedObject.FindProperty("storyText");
characterProp = serializedObject.FindProperty("character");

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

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

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

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

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

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

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

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

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

@ -23,7 +23,7 @@ namespace Fungus
static public List<ChooseDialog> activeDialogs = new List<ChooseDialog>();
void OnEnable()
protected virtual void OnEnable()
{
if (!activeDialogs.Contains(this))
{
@ -31,7 +31,7 @@ namespace Fungus
}
}
void OnDisable()
protected virtual void OnDisable()
{
activeDialogs.Remove(this);
}
@ -42,7 +42,7 @@ namespace Fungus
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();
@ -62,7 +62,7 @@ namespace Fungus
StartCoroutine(WriteText(text, onWritingComplete, onTimeout));
}
IEnumerator WaitForTimeout(float timeoutDuration, Action onTimeout)
protected virtual IEnumerator WaitForTimeout(float timeoutDuration, Action onTimeout)
{
float elapsedTime = 0;
@ -93,7 +93,7 @@ namespace Fungus
ClearOptions();
}
void ClearOptions()
protected virtual void ClearOptions()
{
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)
{

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

@ -21,12 +21,12 @@ namespace Fungus
public Text storyText;
public Image characterImage;
float currentSpeed;
float currentPunctuationPause;
bool boldActive;
bool italicActive;
bool colorActive;
string colorText;
protected float currentSpeed;
protected float currentPunctuationPause;
protected bool boldActive;
protected bool italicActive;
protected bool colorActive;
protected string colorText;
protected enum GlyphType
{
@ -60,7 +60,7 @@ namespace Fungus
}
}
public void SetCharacter(Character character)
public virtual void SetCharacter(Character character)
{
if (character == null)
{
@ -84,7 +84,7 @@ namespace Fungus
}
}
public void SetCharacterImage(Sprite image)
public virtual void SetCharacterImage(Sprite image)
{
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)
{
@ -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 = "";
boldActive = false;
@ -370,7 +370,7 @@ namespace Fungus
ClearStoryText();
}
void ClearStoryText()
protected virtual void ClearStoryText()
{
if (storyText != null)
{
@ -378,14 +378,14 @@ namespace Fungus
}
}
bool IsPunctuation(string character)
protected virtual bool IsPunctuation(string character)
{
return character == "." ||
character == "?" ||
character == "!";
}
List<Glyph> MakeGlyphList(string storyText)
protected virtual List<Glyph> MakeGlyphList(string storyText)
{
List<Glyph> glyphList = new List<Glyph>();
@ -424,7 +424,7 @@ namespace Fungus
return glyphList;
}
void AddCharacterGlyph(List<Glyph> glyphList, string character)
protected virtual void AddCharacterGlyph(List<Glyph> glyphList, string character)
{
Glyph glyph = new Glyph();
glyph.type = GlyphType.Character;
@ -432,7 +432,7 @@ namespace Fungus
glyphList.Add(glyph);
}
void AddTagGlyph(List<Glyph> glyphList, string tagText)
protected virtual void AddTagGlyph(List<Glyph> glyphList, string tagText)
{
if (tagText.Length < 3 ||
tagText.Substring(0,1) != "{" ||
@ -522,7 +522,7 @@ namespace Fungus
glyphList.Add(glyph);
}
protected IEnumerator WaitForInput(Action onInput)
protected virtual IEnumerator WaitForInput(Action onInput)
{
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>();
void OnEnable()
protected virtual void OnEnable()
{
if (!activeDialogs.Contains(this))
{
@ -22,12 +22,12 @@ namespace Fungus
}
}
void OnDisable()
protected virtual void OnDisable()
{
activeDialogs.Remove(this);
}
public void Say(string text, Action onComplete)
public virtual void Say(string text, Action onComplete)
{
Clear();
@ -69,7 +69,7 @@ namespace Fungus
ShowContinueImage(waiting);
}
void ShowContinueImage(bool visible)
protected virtual void ShowContinueImage(bool visible)
{
if (continueImage != null)
{

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

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

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

@ -11,16 +11,16 @@ namespace Fungus
[RequireComponent (typeof (SpriteRenderer))]
public class SpriteFader : MonoBehaviour
{
float fadeDuration;
float fadeTimer;
Color startColor;
Color endColor;
Vector2 slideOffset;
Vector3 endPosition;
protected float fadeDuration;
protected float fadeTimer;
protected Color startColor;
protected Color endColor;
protected Vector2 slideOffset;
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.
@ -72,12 +72,12 @@ namespace Fungus
spriteFader.onFadeComplete = onComplete;
}
void Start()
protected virtual void Start()
{
spriteRenderer = renderer as SpriteRenderer;
}
void Update()
protected virtual void Update()
{
fadeTimer += Time.deltaTime;
if (fadeTimer > fadeDuration)

Loading…
Cancel
Save