Browse Source

Reverted IPortraitController interface

master
Christopher 8 years ago
parent
commit
79e98815be
  1. 108
      Assets/Fungus/Scripts/Components/PortraitController.cs
  2. 139
      Assets/Fungus/Scripts/Interfaces/IPortraitController.cs
  3. 12
      Assets/Fungus/Scripts/Interfaces/IPortraitController.cs.meta

108
Assets/Fungus/Scripts/Components/PortraitController.cs

@ -10,10 +10,53 @@ using Fungus.Utils;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Types of display operations supported by portraits.
/// </summary>
public enum DisplayType
{
/// <summary> Do nothing. </summary>
None,
/// <summary> Show the portrait. </summary>
Show,
/// <summary> Hide the portrait. </summary>
Hide,
/// <summary> Replace the existing portrait. </summary>
Replace,
/// <summary> Move portrait to the front. </summary>
MoveToFront
}
/// <summary>
/// Directions that character portraits can face.
/// </summary>
public enum FacingDirection
{
/// <summary> Unknown direction </summary>
None,
/// <summary> Facing left. </summary>
Left,
/// <summary> Facing right. </summary>
Right
}
/// <summary>
/// Offset direction for position.
/// </summary>
public enum PositionOffset
{
/// <summary> Unknown offset direction. </summary>
None,
/// <summary> Offset applies to the left. </summary>
OffsetLeft,
/// <summary> Offset applies to the right. </summary>
OffsetRight
}
/// <summary> /// <summary>
/// Controls the Portrait sprites on stage /// Controls the Portrait sprites on stage
/// </summary> /// </summary>
public class PortraitController : MonoBehaviour, IPortraitController public class PortraitController : MonoBehaviour
{ {
// Timer for waitUntilFinished functionality // Timer for waitUntilFinished functionality
protected float waitTimer; protected float waitTimer;
@ -249,8 +292,13 @@ namespace Fungus
} }
} }
#region IPortraitController implentation #region Public methods
/// <summary>
/// Using all portrait options available, run any portrait command.
/// </summary>
/// <param name="options">Portrait Options</param>
/// <param name="onComplete">The function that will run once the portrait command finishes</param>
public virtual void RunPortraitCommand(PortraitOptions options, Action onComplete) public virtual void RunPortraitCommand(PortraitOptions options, Action onComplete)
{ {
waitTimer = 0f; waitTimer = 0f;
@ -301,6 +349,9 @@ namespace Fungus
} }
} }
/// <summary>
/// Moves Character in front of other characters on stage
/// </summary>
public virtual void MoveToFront(Character character) public virtual void MoveToFront(Character character)
{ {
PortraitOptions options = new PortraitOptions(true); PortraitOptions options = new PortraitOptions(true);
@ -309,6 +360,9 @@ namespace Fungus
MoveToFront(CleanPortraitOptions(options)); MoveToFront(CleanPortraitOptions(options));
} }
/// <summary>
/// Moves Character in front of other characters on stage
/// </summary>
public virtual void MoveToFront(PortraitOptions options) public virtual void MoveToFront(PortraitOptions options)
{ {
options.character.State.portraitImage.transform.SetSiblingIndex(options.character.State.portraitImage.transform.parent.childCount); options.character.State.portraitImage.transform.SetSiblingIndex(options.character.State.portraitImage.transform.parent.childCount);
@ -316,6 +370,11 @@ namespace Fungus
FinishCommand(options); FinishCommand(options);
} }
/// <summary>
/// Shows character at a named position in the stage
/// </summary>
/// <param name="character"></param>
/// <param name="position">Named position on stage</param>
public virtual void Show(Character character, string position) public virtual void Show(Character character, string position)
{ {
PortraitOptions options = new PortraitOptions(true); PortraitOptions options = new PortraitOptions(true);
@ -325,6 +384,13 @@ namespace Fungus
Show(options); Show(options);
} }
/// <summary>
/// Shows character moving from a position to a position
/// </summary>
/// <param name="character"></param>
/// <param name="portrait"></param>
/// <param name="fromPosition">Where the character will appear</param>
/// <param name="toPosition">Where the character will move to</param>
public virtual void Show(Character character, string portrait, string fromPosition, string toPosition) public virtual void Show(Character character, string portrait, string fromPosition, string toPosition)
{ {
PortraitOptions options = new PortraitOptions(true); PortraitOptions options = new PortraitOptions(true);
@ -337,11 +403,22 @@ namespace Fungus
Show(options); Show(options);
} }
/// <summary>
/// From lua, you can pass an options table with named arguments
/// example:
/// stage.show{character=jill, portrait="happy", fromPosition="right", toPosition="left"}
/// Any option available in the PortraitOptions is available from Lua
/// </summary>
/// <param name="optionsTable">Moonsharp Table</param>
public virtual void Show(Table optionsTable) public virtual void Show(Table optionsTable)
{ {
Show(PortraitUtil.ConvertTableToPortraitOptions(optionsTable, stage)); Show(PortraitUtil.ConvertTableToPortraitOptions(optionsTable, stage));
} }
/// <summary>
/// Show portrait with the supplied portrait options
/// </summary>
/// <param name="options"></param>
public virtual void Show(PortraitOptions options) public virtual void Show(PortraitOptions options)
{ {
options = CleanPortraitOptions(options); options = CleanPortraitOptions(options);
@ -416,6 +493,11 @@ namespace Fungus
options.character.State.position = options.toPosition; options.character.State.position = options.toPosition;
} }
/// <summary>
/// Simple show command that shows the character with an available named portrait
/// </summary>
/// <param name="character">Character to show</param>
/// <param name="portrait">Named portrait to show for the character, i.e. "angry", "happy", etc</param>
public virtual void ShowPortrait(Character character, string portrait) public virtual void ShowPortrait(Character character, string portrait)
{ {
PortraitOptions options = new PortraitOptions(true); PortraitOptions options = new PortraitOptions(true);
@ -434,6 +516,10 @@ namespace Fungus
Show(options); Show(options);
} }
/// <summary>
/// Simple character hide command
/// </summary>
/// <param name="character">Character to hide</param>
public virtual void Hide(Character character) public virtual void Hide(Character character)
{ {
PortraitOptions options = new PortraitOptions(true); PortraitOptions options = new PortraitOptions(true);
@ -442,6 +528,11 @@ namespace Fungus
Hide(options); Hide(options);
} }
/// <summary>
/// Move the character to a position then hide it
/// </summary>
/// <param name="character">Character to hide</param>
/// <param name="toPosition">Where the character will disapear to</param>
public virtual void Hide(Character character, string toPosition) public virtual void Hide(Character character, string toPosition)
{ {
PortraitOptions options = new PortraitOptions(true); PortraitOptions options = new PortraitOptions(true);
@ -452,11 +543,21 @@ namespace Fungus
Hide(options); Hide(options);
} }
/// <summary>
/// From lua, you can pass an options table with named arguments
/// example:
/// stage.hide{character=jill, toPosition="left"}
/// Any option available in the PortraitOptions is available from Lua
/// </summary>
/// <param name="optionsTable">Moonsharp Table</param>
public virtual void Hide(Table optionsTable) public virtual void Hide(Table optionsTable)
{ {
Hide(PortraitUtil.ConvertTableToPortraitOptions(optionsTable, stage)); Hide(PortraitUtil.ConvertTableToPortraitOptions(optionsTable, stage));
} }
/// <summary>
/// Hide portrait with provided options
/// </summary>
public virtual void Hide(PortraitOptions options) public virtual void Hide(PortraitOptions options)
{ {
CleanPortraitOptions(options); CleanPortraitOptions(options);
@ -487,6 +588,9 @@ namespace Fungus
FinishCommand(options); FinishCommand(options);
} }
/// <summary>
/// Sets the dimmed state of a character on the stage.
/// </summary>
public virtual void SetDimmed(Character character, bool dimmedState) public virtual void SetDimmed(Character character, bool dimmedState)
{ {
if (character.State.dimmed == dimmedState) if (character.State.dimmed == dimmedState)

139
Assets/Fungus/Scripts/Interfaces/IPortraitController.cs

@ -1,139 +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 MoonSharp.Interpreter;
using Fungus.Utils;
namespace Fungus
{
/// <summary>
/// Types of display operations supported by portraits.
/// </summary>
public enum DisplayType
{
/// <summary> Do nothing. </summary>
None,
/// <summary> Show the portrait. </summary>
Show,
/// <summary> Hide the portrait. </summary>
Hide,
/// <summary> Replace the existing portrait. </summary>
Replace,
/// <summary> Move portrait to the front. </summary>
MoveToFront
}
/// <summary>
/// Directions that character portraits can face.
/// </summary>
public enum FacingDirection
{
/// <summary> Unknown direction </summary>
None,
/// <summary> Facing left. </summary>
Left,
/// <summary> Facing right. </summary>
Right
}
/// <summary>
/// Offset direction for position.
/// </summary>
public enum PositionOffset
{
/// <summary> Unknown offset direction. </summary>
None,
/// <summary> Offset applies to the left. </summary>
OffsetLeft,
/// <summary> Offset applies to the right. </summary>
OffsetRight
}
/// <summary>
/// Controls the Portrait sprites on stage
/// </summary>
public interface IPortraitController
{
/// <summary>
/// Using all portrait options available, run any portrait command.
/// </summary>
/// <param name="options">Portrait Options</param>
/// <param name="onComplete">The function that will run once the portrait command finishes</param>
void RunPortraitCommand(PortraitOptions options, System.Action onComplete);
/// <summary>
/// Moves Character in front of other characters on stage
/// </summary>
void MoveToFront(Character character);
/// <summary>
/// Moves Character in front of other characters on stage
/// </summary>
void MoveToFront(PortraitOptions options);
/// <summary>
/// Shows character at a named position in the stage
/// </summary>
/// <param name="character"></param>
/// <param name="position">Named position on stage</param>
void Show(Character character, string position);
/// <summary>
/// Shows character moving from a position to a position
/// </summary>
/// <param name="character"></param>
/// <param name="portrait"></param>
/// <param name="fromPosition">Where the character will appear</param>
/// <param name="toPosition">Where the character will move to</param>
void Show(Character character, string portrait, string fromPosition, string toPosition);
/// <summary>
/// From lua, you can pass an options table with named arguments
/// example:
/// stage.show{character=jill, portrait="happy", fromPosition="right", toPosition="left"}
/// Any option available in the PortraitOptions is available from Lua
/// </summary>
/// <param name="optionsTable">Moonsharp Table</param>
void Show(Table optionsTable);
/// <summary>
/// Show portrait with the supplied portrait options
/// </summary>
/// <param name="options"></param>
void Show(PortraitOptions options);
/// <summary>
/// Simple show command that shows the character with an available named portrait
/// </summary>
/// <param name="character">Character to show</param>
/// <param name="portrait">Named portrait to show for the character, i.e. "angry", "happy", etc</param>
void ShowPortrait(Character character, string portrait);
/// <summary>
/// Simple character hide command
/// </summary>
/// <param name="character">Character to hide</param>
void Hide(Character character);
/// <summary>
/// Move the character to a position then hide it
/// </summary>
/// <param name="character">Character to hide</param>
/// <param name="toPosition">Where the character will disapear to</param>
void Hide(Character character, string toPosition);
/// <summary>
/// From lua, you can pass an options table with named arguments
/// example:
/// stage.hide{character=jill, toPosition="left"}
/// Any option available in the PortraitOptions is available from Lua
/// </summary>
/// <param name="optionsTable">Moonsharp Table</param>
void Hide(Table optionsTable);
/// <summary>
/// Hide portrait with provided options
/// </summary>
void Hide(PortraitOptions options);
}
}

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

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 51067f95c67324a0ba05a260dced682f
timeCreated: 1473685101
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save