Browse Source

Reverted Character interface

master
Christopher 8 years ago
parent
commit
bc7c9bc74a
  1. 45
      Assets/Fungus/Scripts/Components/Character.cs
  2. 6
      Assets/Fungus/Scripts/Components/SayDialog.cs
  3. 74
      Assets/Fungus/Scripts/Interfaces/ICharacter.cs
  4. 12
      Assets/Fungus/Scripts/Interfaces/ICharacter.cs.meta
  5. 2
      Assets/Fungus/Scripts/Interfaces/ISayDialog.cs

45
Assets/Fungus/Scripts/Components/Character.cs

@ -13,7 +13,7 @@ namespace Fungus
/// A Character that can be used in dialogue via the Say, Conversation and Portrait commands.
/// </summary>
[ExecuteInEditMode]
public class Character : MonoBehaviour, ICharacter, ILocalizable
public class Character : MonoBehaviour, ILocalizable
{
[Tooltip("Character name as displayed in Say Dialog.")]
[SerializeField] protected string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad")
@ -54,32 +54,69 @@ namespace Fungus
activeCharacters.Remove(this);
}
#region ICharacter implementation
#region Public methods
/// <summary>
/// Character name as displayed in Say Dialog.
/// </summary>
public virtual string NameText { get { return nameText; } }
/// <summary>
/// Color to display the character name in Say Dialog.
/// </summary>
public virtual Color NameColor { get { return nameColor; } }
/// <summary>
/// Sound effect to play when this character is speaking.
/// </summary>
/// <value>The sound effect.</value>
public virtual AudioClip SoundEffect { get { return soundEffect; } }
public virtual Sprite ProfileSprite { get; set; }
/// <summary>
/// List of portrait images that can be displayed for this character.
/// </summary>
public virtual List<Sprite> Portraits { get { return portraits; } }
/// <summary>
/// Direction that portrait sprites face.
/// </summary>
public virtual FacingDirection PortraitsFace { get { return portraitsFace; } }
/// <summary>
/// Currently display profile sprite for this character.
/// </summary>
/// <value>The profile sprite.</value>
public virtual Sprite ProfileSprite { get; set; }
/// <summary>
/// Current display state of this character's portrait.
/// </summary>
/// <value>The state.</value>
public virtual PortraitState State { get { return portaitState; } }
/// <summary>
/// Sets the active Say dialog with a reference to a Say Dialog object in the scene. This Say Dialog will be used whenever the character speaks.
/// </summary>
public virtual ISayDialog SetSayDialog { get { return setSayDialog; } }
/// <summary>
/// Returns the name of the game object.
/// </summary>
public string GetObjectName() { return gameObject.name; }
/// <summary>
/// Returns true if the character name starts with the specified string. Case insensitive.
/// </summary>
public virtual bool NameStartsWith(string matchString)
{
return name.StartsWith(matchString, true, System.Globalization.CultureInfo.CurrentCulture)
|| nameText.StartsWith(matchString, true, System.Globalization.CultureInfo.CurrentCulture);
}
/// <summary>
/// Looks for a portrait by name on a character
/// If none is found, give a warning and return a blank sprite
/// </summary>
public virtual Sprite GetPortrait(string portraitString)
{
if (String.IsNullOrEmpty(portraitString))

6
Assets/Fungus/Scripts/Components/SayDialog.cs

@ -53,7 +53,7 @@ namespace Fungus
public static ISayDialog activeSayDialog;
// Most recent speaking character
public static ICharacter speakingCharacter;
public static Character speakingCharacter;
public static ISayDialog GetSayDialog()
{
@ -245,7 +245,7 @@ namespace Fungus
gameObject.SetActive(state);
}
public virtual void SetCharacter(ICharacter character, IFlowchart flowchart = null)
public virtual void SetCharacter(Character character, IFlowchart flowchart = null)
{
if (character == null)
{
@ -261,7 +261,7 @@ namespace Fungus
}
else
{
ICharacter prevSpeakingCharacter = speakingCharacter;
var prevSpeakingCharacter = speakingCharacter;
speakingCharacter = character;
// Dim portraits of non-speaking characters

74
Assets/Fungus/Scripts/Interfaces/ICharacter.cs

@ -1,74 +0,0 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using System.Collections.Generic;
using Fungus.Utils;
namespace Fungus
{
/// <summary>
/// A Character that can be used in dialogue via the Say, Conversation and Portrait commands.
/// </summary>
public interface ICharacter
{
/// <summary>
/// Character name as displayed in Say Dialog.
/// </summary>
string NameText { get; }
/// <summary>
/// Color to display the character name in Say Dialog.
/// </summary>
Color NameColor { get; }
/// <summary>
/// Sound effect to play when this character is speaking.
/// </summary>
/// <value>The sound effect.</value>
AudioClip SoundEffect { get; }
/// <summary>
/// List of portrait images that can be displayed for this character.
/// </summary>
List<Sprite> Portraits { get; }
/// <summary>
/// Direction that portrait sprites face.
/// </summary>
FacingDirection PortraitsFace { get; }
/// <summary>
/// Currently display profile sprite for this character.
/// </summary>
/// <value>The profile sprite.</value>
Sprite ProfileSprite { get; set; }
/// <summary>
/// Current display state of this character's portrait.
/// </summary>
/// <value>The state.</value>
PortraitState State { get; }
/// <summary>
/// Sets the active Say dialog with a reference to a Say Dialog object in the scene. This Say Dialog will be used whenever the character speaks.
/// </summary>
ISayDialog SetSayDialog { get; }
/// <summary>
/// Returns the name of the game object.
/// </summary>
string GetObjectName();
/// <summary>
/// Returns true if the character name starts with the specified string. Case insensitive.
/// </summary>
bool NameStartsWith(string matchString);
/// <summary>
/// Looks for a portrait by name on a character
/// If none is found, give a warning and return a blank sprite
/// </summary>
Sprite GetPortrait(string portraitString);
}
}

12
Assets/Fungus/Scripts/Interfaces/ICharacter.cs.meta

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 07a9457a850c147049f1fb7ea4b860cf
timeCreated: 1473676955
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/Fungus/Scripts/Interfaces/ISayDialog.cs

@ -21,7 +21,7 @@ namespace Fungus
/// </summary>
/// <param name="character">The active speaking character.</param>
/// <param name="flowchart">An optional Flowchart to use for variable substitution in the character name string.</param>
void SetCharacter(ICharacter character, IFlowchart flowchart = null);
void SetCharacter(Character character, IFlowchart flowchart = null);
/// <summary>
/// Sets the character image to display on the Say Dialog.

Loading…
Cancel
Save