Browse Source

extract ControlWithDisplay generic base class

master
Pavel Kvas 9 years ago
parent
commit
977c2472a0
  1. 7
      Assets/Fungus/Narrative/Scripts/Commands/ControlStage.cs
  2. 17
      Assets/Fungus/Narrative/Scripts/Commands/ControlWithDisplay.cs
  3. 12
      Assets/Fungus/Narrative/Scripts/Commands/ControlWithDisplay.cs.meta
  4. 7
      Assets/Fungus/Narrative/Scripts/Commands/Portrait.cs

7
Assets/Fungus/Narrative/Scripts/Commands/ControlStage.cs

@ -21,11 +21,8 @@ namespace Fungus
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Control Stage", "Control Stage",
"Controls the stage on which character portraits are displayed.")] "Controls the stage on which character portraits are displayed.")]
public class ControlStage : Command public class ControlStage : ControlWithDisplay<StageDisplayType>
{ {
[Tooltip("Display type")]
public StageDisplayType display;
[Tooltip("Stage to display characters on")] [Tooltip("Stage to display characters on")]
public Stage stage; public Stage stage;
@ -44,7 +41,7 @@ namespace Fungus
public override void OnEnter() public override void OnEnter()
{ {
// If no display specified, do nothing // If no display specified, do nothing
if (display == StageDisplayType.None) if (IsDisplayNone(display))
{ {
Continue(); Continue();
return; return;

17
Assets/Fungus/Narrative/Scripts/Commands/ControlWithDisplay.cs

@ -0,0 +1,17 @@
using System;
using UnityEngine;
namespace Fungus
{
public class ControlWithDisplay<TDisplayEnum> : Command
{
[Tooltip("Display type")]
public TDisplayEnum display;
protected bool IsDisplayNone<TEnum>(TEnum enumValue)
{
string displayTypeStr = Enum.GetName(typeof (TEnum), enumValue);
return displayTypeStr == "None";
}
}
}

12
Assets/Fungus/Narrative/Scripts/Commands/ControlWithDisplay.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6b4717bbde4a5e64893724b3db7eb32c
timeCreated: 1463225157
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
Assets/Fungus/Narrative/Scripts/Commands/Portrait.cs

@ -44,14 +44,11 @@ namespace Fungus
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Portrait", "Portrait",
"Controls a character portrait. ")] "Controls a character portrait. ")]
public class Portrait : Command public class Portrait : ControlWithDisplay<DisplayType>
{ {
[Tooltip("Stage to display portrait on")] [Tooltip("Stage to display portrait on")]
public Stage stage; public Stage stage;
[Tooltip("Display type")]
public DisplayType display;
[Tooltip("Character to display")] [Tooltip("Character to display")]
public Character character; public Character character;
@ -100,7 +97,7 @@ namespace Fungus
public override void OnEnter() public override void OnEnter()
{ {
// If no display specified, do nothing // If no display specified, do nothing
if (display == DisplayType.None) if (IsDisplayNone(display))
{ {
Continue(); Continue();
return; return;

Loading…
Cancel
Save