Browse Source

Renamed PortraitStage to Stage #84

master
chrisgregan 10 years ago
parent
commit
796c2df48d
  1. 6
      Assets/Fungus/Dialog/Editor/DialogMenuItems.cs
  2. 12
      Assets/Fungus/Dialog/Scripts/Dialog.cs
  3. 4
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  4. 26
      Assets/Fungus/Portrait/Editor/PortraitEditor.cs
  5. 28
      Assets/Fungus/Portrait/Editor/StageEditor.cs
  6. 2
      Assets/Fungus/Portrait/Prefabs/Stage.prefab
  7. 0
      Assets/Fungus/Portrait/Prefabs/Stage.prefab.meta
  8. 85
      Assets/Fungus/Portrait/Scripts/Commands/ControlStage.cs
  9. 60
      Assets/Fungus/Portrait/Scripts/Commands/Portrait.cs
  10. 10
      Assets/Fungus/Portrait/Scripts/Stage.cs
  11. 0
      Assets/Fungus/Portrait/Scripts/Stage.cs.meta
  12. 77
      Assets/FungusExamples/Sherlock/TheExperiment.unity

6
Assets/Fungus/Dialog/Editor/DialogMenuItems.cs

@ -53,10 +53,10 @@ namespace Fungus
} }
} }
[MenuItem("GameObject/Fungus/Portrait/PortraitStage")] [MenuItem("GameObject/Fungus/Portrait/Stage")]
static void CreatePortraitStage() static void CreateStage()
{ {
FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab"); FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Portrait/Prefabs/Stage.prefab");
} }
[MenuItem("GameObject/Fungus/Portrait/PortraitPosition")] [MenuItem("GameObject/Fungus/Portrait/PortraitPosition")]

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

@ -1,4 +1,4 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.Events; using UnityEngine.Events;
using System; using System;
@ -167,21 +167,21 @@ namespace Fungus
speakingCharacter = character; speakingCharacter = character;
// Dim portraits of non-speaking characters // Dim portraits of non-speaking characters
foreach (PortraitStage ps in PortraitStage.activePortraitStages) foreach (Stage s in Stage.activeStages)
{ {
if (ps.dimPortraits) if (s.dimPortraits)
{ {
foreach (Character c in ps.charactersOnStage) foreach (Character c in s.charactersOnStage)
{ {
if (prevSpeakingCharacter != speakingCharacter) if (prevSpeakingCharacter != speakingCharacter)
{ {
if (c != speakingCharacter) if (c != speakingCharacter)
{ {
Portrait.Dim(c,ps); Portrait.Dim(c,s);
} }
else else
{ {
Portrait.Undim(c,ps); Portrait.Undim(c,s);
} }
} }
} }

4
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs

@ -11,13 +11,13 @@ namespace Fungus
[CustomEditor (typeof(FungusScript))] [CustomEditor (typeof(FungusScript))]
public class FungusScriptEditor : Editor public class FungusScriptEditor : Editor
{ {
protected SerializedProperty descriptionProp;
protected SerializedProperty defaultPortraitStageProp;
protected class AddVariableInfo protected class AddVariableInfo
{ {
public FungusScript fungusScript; public FungusScript fungusScript;
public System.Type variableType; public System.Type variableType;
} }
protected SerializedProperty descriptionProp;
protected SerializedProperty colorCommandsProp; protected SerializedProperty colorCommandsProp;
protected SerializedProperty hideComponentsProp; protected SerializedProperty hideComponentsProp;
protected SerializedProperty runSlowDurationProp; protected SerializedProperty runSlowDurationProp;

26
Assets/Fungus/Portrait/Editor/PortraitEditor.cs

@ -15,7 +15,7 @@ namespace Fungus
[CustomEditor (typeof(Portrait))] [CustomEditor (typeof(Portrait))]
public class PortraitEditor : CommandEditor public class PortraitEditor : CommandEditor
{ {
protected SerializedProperty portraitStageProp; protected SerializedProperty stageProp;
protected SerializedProperty displayProp; protected SerializedProperty displayProp;
protected SerializedProperty characterProp; protected SerializedProperty characterProp;
protected SerializedProperty replacedCharacterProp; protected SerializedProperty replacedCharacterProp;
@ -34,7 +34,7 @@ namespace Fungus
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
portraitStageProp = serializedObject.FindProperty("portraitStage"); stageProp = serializedObject.FindProperty("stage");
displayProp = serializedObject.FindProperty("display"); displayProp = serializedObject.FindProperty("display");
characterProp = serializedObject.FindProperty("character"); characterProp = serializedObject.FindProperty("character");
replacedCharacterProp = serializedObject.FindProperty("replacedCharacter"); replacedCharacterProp = serializedObject.FindProperty("replacedCharacter");
@ -58,16 +58,16 @@ namespace Fungus
Portrait t = target as Portrait; Portrait t = target as Portrait;
if (PortraitStage.activePortraitStages.Count > 1) if (Stage.activeStages.Count > 1)
{ {
CommandEditor.ObjectField<PortraitStage>(portraitStageProp, CommandEditor.ObjectField<Stage>(stageProp,
new GUIContent("Portrait Stage", "Stage to display the character portraits on"), new GUIContent("Portrait Stage", "Stage to display the character portraits on"),
new GUIContent("<Default>"), new GUIContent("<Default>"),
PortraitStage.activePortraitStages); Stage.activeStages);
} }
else else
{ {
t.portraitStage = null; t.stage = null;
} }
// Format Enum names // Format Enum names
string[] displayLabels = StringFormatter.FormatEnumNames(t.display,"<None>"); string[] displayLabels = StringFormatter.FormatEnumNames(t.display,"<None>");
@ -89,7 +89,7 @@ namespace Fungus
Character.activeCharacters); Character.activeCharacters);
bool showOptionalFields = true; bool showOptionalFields = true;
PortraitStage ps = t.portraitStage; Stage s = t.stage;
// Only show optional portrait fields once required fields have been filled... // Only show optional portrait fields once required fields have been filled...
if (t.character != null) // Character is selected if (t.character != null) // Character is selected
{ {
@ -99,14 +99,14 @@ namespace Fungus
EditorGUILayout.HelpBox("This character has no portraits. Please add portraits to the character's prefab before using this command.", MessageType.Error); EditorGUILayout.HelpBox("This character has no portraits. Please add portraits to the character's prefab before using this command.", MessageType.Error);
showOptionalFields = false; showOptionalFields = false;
} }
if (t.portraitStage == null) // If default portrait stage selected if (t.stage == null) // If default portrait stage selected
{ {
if (t.portraitStage == null) // If no default specified, try to get any portrait stage in the scene if (t.stage == null) // If no default specified, try to get any portrait stage in the scene
{ {
ps = GameObject.FindObjectOfType<PortraitStage>(); s = GameObject.FindObjectOfType<Stage>();
} }
} }
if (ps == null) if (s == null)
{ {
EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error); EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error);
showOptionalFields = false; showOptionalFields = false;
@ -176,7 +176,7 @@ namespace Fungus
CommandEditor.ObjectField<RectTransform>(fromPositionProp, CommandEditor.ObjectField<RectTransform>(fromPositionProp,
new GUIContent("From Position", "Move the portrait to this position"), new GUIContent("From Position", "Move the portrait to this position"),
new GUIContent("<Previous>"), new GUIContent("<Previous>"),
ps.positions); s.positions);
} }
} }
toPositionPrefix = "To "; toPositionPrefix = "To ";
@ -193,7 +193,7 @@ namespace Fungus
CommandEditor.ObjectField<RectTransform>(toPositionProp, CommandEditor.ObjectField<RectTransform>(toPositionProp,
new GUIContent(toPositionPrefix+"Position", "Move the portrait to this position"), new GUIContent(toPositionPrefix+"Position", "Move the portrait to this position"),
new GUIContent("<Previous>"), new GUIContent("<Previous>"),
ps.positions); s.positions);
} }
else else
{ {

28
Assets/Fungus/Portrait/Editor/StageEditor.cs

@ -16,8 +16,8 @@ namespace Fungus
public class StageEditor : CommandEditor public class StageEditor : CommandEditor
{ {
protected SerializedProperty displayProp; protected SerializedProperty displayProp;
protected SerializedProperty portraitStageProp; protected SerializedProperty stageProp;
protected SerializedProperty replacedPortraitStageProp; protected SerializedProperty replacedStageProp;
protected SerializedProperty useDefaultSettingsProp; protected SerializedProperty useDefaultSettingsProp;
protected SerializedProperty fadeDurationProp; protected SerializedProperty fadeDurationProp;
protected SerializedProperty waitUntilFinishedProp; protected SerializedProperty waitUntilFinishedProp;
@ -25,8 +25,8 @@ namespace Fungus
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
displayProp = serializedObject.FindProperty("display"); displayProp = serializedObject.FindProperty("display");
portraitStageProp = serializedObject.FindProperty("portraitStage"); stageProp = serializedObject.FindProperty("stage");
replacedPortraitStageProp = serializedObject.FindProperty("replacedPortraitStage"); replacedStageProp = serializedObject.FindProperty("replacedStage");
useDefaultSettingsProp = serializedObject.FindProperty("useDefaultSettings"); useDefaultSettingsProp = serializedObject.FindProperty("useDefaultSettings");
fadeDurationProp = serializedObject.FindProperty("fadeDuration"); fadeDurationProp = serializedObject.FindProperty("fadeDuration");
waitUntilFinishedProp = serializedObject.FindProperty("waitUntilFinished"); waitUntilFinishedProp = serializedObject.FindProperty("waitUntilFinished");
@ -45,31 +45,31 @@ namespace Fungus
string replaceLabel = "Portrait Stage"; string replaceLabel = "Portrait Stage";
if (t.display == StageDisplayType.Swap) if (t.display == StageDisplayType.Swap)
{ {
CommandEditor.ObjectField<PortraitStage>(replacedPortraitStageProp, CommandEditor.ObjectField<Stage>(replacedStageProp,
new GUIContent("Replace", "Character to swap with"), new GUIContent("Replace", "Character to swap with"),
new GUIContent("<Default>"), new GUIContent("<Default>"),
PortraitStage.activePortraitStages); Stage.activeStages);
replaceLabel = "With"; replaceLabel = "With";
} }
if (PortraitStage.activePortraitStages.Count > 1) if (Stage.activeStages.Count > 1)
{ {
CommandEditor.ObjectField<PortraitStage>(portraitStageProp, CommandEditor.ObjectField<Stage>(stageProp,
new GUIContent(replaceLabel, "Stage to display the character portraits on"), new GUIContent(replaceLabel, "Stage to display the character portraits on"),
new GUIContent("<Default>"), new GUIContent("<Default>"),
PortraitStage.activePortraitStages); Stage.activeStages);
} }
bool showOptionalFields = true; bool showOptionalFields = true;
PortraitStage ps = t.portraitStage; Stage s = t.stage;
// Only show optional portrait fields once required fields have been filled... // Only show optional portrait fields once required fields have been filled...
if (t.portraitStage != null) // Character is selected if (t.stage != null) // Character is selected
{ {
if (t.portraitStage == null) // If no default specified, try to get any portrait stage in the scene if (t.stage == null) // If no default specified, try to get any portrait stage in the scene
{ {
ps = GameObject.FindObjectOfType<PortraitStage>(); s = GameObject.FindObjectOfType<Stage>();
} }
if (ps == null) if (s == null)
{ {
EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error); EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error);
showOptionalFields = false; showOptionalFields = false;

2
Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab → Assets/Fungus/Portrait/Prefabs/Stage.prefab

@ -44,7 +44,7 @@ GameObject:
- 4: {fileID: 410270} - 4: {fileID: 410270}
- 114: {fileID: 11410274} - 114: {fileID: 11410274}
m_Layer: 0 m_Layer: 0
m_Name: PortraitStage m_Name: Stage
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0

0
Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab.meta → Assets/Fungus/Portrait/Prefabs/Stage.prefab.meta

85
Assets/Fungus/Portrait/Scripts/Commands/ControlStage.cs

@ -27,10 +27,10 @@ namespace Fungus
public StageDisplayType display; public StageDisplayType display;
[Tooltip("Stage to display characters on")] [Tooltip("Stage to display characters on")]
public PortraitStage portraitStage; public Stage stage;
[Tooltip("PortraitStage to swap with")] [Tooltip("Stage to swap with")]
public PortraitStage replacedPortraitStage; public Stage replacedStage;
[Tooltip("Use Default Settings")] [Tooltip("Use Default Settings")]
public bool useDefaultSettings = true; public bool useDefaultSettings = true;
@ -50,15 +50,15 @@ namespace Fungus
return; return;
} }
// Selected "use default Portrait Stage" // Selected "use default Portrait Stage"
if (portraitStage == null) // Default portrait stage selected if (stage == null) // Default portrait stage selected
{ {
if (portraitStage == null) // If no default specified, try to get any portrait stage in the scene if (stage == null) // If no default specified, try to get any portrait stage in the scene
{ {
portraitStage = GameObject.FindObjectOfType<PortraitStage>(); stage = GameObject.FindObjectOfType<Stage>();
} }
} }
// If portrait stage does not exist, do nothing // If portrait stage does not exist, do nothing
if (portraitStage == null) if (stage == null)
{ {
Continue(); Continue();
return; return;
@ -66,12 +66,12 @@ namespace Fungus
// Selected "use default Portrait Stage" // Selected "use default Portrait Stage"
if (display == StageDisplayType.Swap) // Default portrait stage selected if (display == StageDisplayType.Swap) // Default portrait stage selected
{ {
if (replacedPortraitStage == null) // If no default specified, try to get any portrait stage in the scene if (replacedStage == null) // If no default specified, try to get any portrait stage in the scene
{ {
replacedPortraitStage = GameObject.FindObjectOfType<PortraitStage>(); replacedStage = GameObject.FindObjectOfType<Stage>();
} }
// If portrait stage does not exist, do nothing // If portrait stage does not exist, do nothing
if (replacedPortraitStage == null) if (replacedStage == null)
{ {
Continue(); Continue();
return; return;
@ -80,28 +80,28 @@ namespace Fungus
// Use default settings // Use default settings
if (useDefaultSettings) if (useDefaultSettings)
{ {
fadeDuration = portraitStage.fadeDuration; fadeDuration = stage.fadeDuration;
} }
switch(display) switch(display)
{ {
case (StageDisplayType.Show): case (StageDisplayType.Show):
Show(portraitStage); Show(stage);
break; break;
case (StageDisplayType.Hide): case (StageDisplayType.Hide):
Hide(portraitStage); Hide(stage);
break; break;
case (StageDisplayType.Swap): case (StageDisplayType.Swap):
Show(portraitStage); Show(stage);
Hide(replacedPortraitStage); Hide(replacedStage);
break; break;
case (StageDisplayType.MoveToFront): case (StageDisplayType.MoveToFront):
MoveToFront(portraitStage); MoveToFront(stage);
break; break;
case (StageDisplayType.UndimAllPortraits): case (StageDisplayType.UndimAllPortraits):
UndimAllPortraits(portraitStage); UndimAllPortraits(stage);
break; break;
case (StageDisplayType.DimNonSpeakingPortraits): case (StageDisplayType.DimNonSpeakingPortraits):
DimNonSpeakingPortraits(portraitStage); DimNonSpeakingPortraits(stage);
break; break;
} }
@ -110,7 +110,8 @@ namespace Fungus
Continue(); Continue();
} }
} }
protected void Show(PortraitStage portraitStage)
protected void Show(Stage stage)
{ {
if (fadeDuration == 0) if (fadeDuration == 0)
{ {
@ -119,14 +120,14 @@ namespace Fungus
LeanTween.value(gameObject,0,1,fadeDuration).setOnUpdate( LeanTween.value(gameObject,0,1,fadeDuration).setOnUpdate(
(float fadeAmount)=>{ (float fadeAmount)=>{
foreach ( Character c in portraitStage.charactersOnStage) foreach ( Character c in stage.charactersOnStage)
{ {
c.state.portraitImage.material.SetFloat("_Alpha",fadeAmount); c.state.portraitImage.material.SetFloat("_Alpha",fadeAmount);
} }
} }
).setOnComplete( ).setOnComplete(
()=>{ ()=>{
foreach ( Character c in portraitStage.charactersOnStage) foreach ( Character c in stage.charactersOnStage)
{ {
c.state.portraitImage.material.SetFloat("_Alpha",1); c.state.portraitImage.material.SetFloat("_Alpha",1);
} }
@ -134,7 +135,8 @@ namespace Fungus
} }
); );
} }
protected void Hide(PortraitStage portraitStage)
protected void Hide(Stage stage)
{ {
if (fadeDuration == 0) if (fadeDuration == 0)
{ {
@ -143,14 +145,14 @@ namespace Fungus
LeanTween.value(gameObject,1,0,fadeDuration).setOnUpdate( LeanTween.value(gameObject,1,0,fadeDuration).setOnUpdate(
(float fadeAmount)=>{ (float fadeAmount)=>{
foreach ( Character c in portraitStage.charactersOnStage) foreach ( Character c in stage.charactersOnStage)
{ {
c.state.portraitImage.material.SetFloat("_Alpha",fadeAmount); c.state.portraitImage.material.SetFloat("_Alpha",fadeAmount);
} }
} }
).setOnComplete( ).setOnComplete(
()=>{ ()=>{
foreach ( Character c in portraitStage.charactersOnStage) foreach ( Character c in stage.charactersOnStage)
{ {
c.state.portraitImage.material.SetFloat("_Alpha",0); c.state.portraitImage.material.SetFloat("_Alpha",0);
} }
@ -158,32 +160,36 @@ namespace Fungus
} }
); );
} }
protected void MoveToFront(PortraitStage portraitStage)
protected void MoveToFront(Stage stage)
{ {
foreach (PortraitStage ps in PortraitStage.activePortraitStages) foreach (Stage s in Stage.activeStages)
{ {
if (ps == portraitStage) if (s == stage)
{ {
ps.portraitCanvas.sortingOrder = 1; s.portraitCanvas.sortingOrder = 1;
} }
else else
{ {
ps.portraitCanvas.sortingOrder = 0; s.portraitCanvas.sortingOrder = 0;
} }
} }
} }
protected void UndimAllPortraits(PortraitStage portraitStage)
protected void UndimAllPortraits(Stage stage)
{ {
portraitStage.dimPortraits = false; stage.dimPortraits = false;
foreach (Character character in portraitStage.charactersOnStage) foreach (Character character in stage.charactersOnStage)
{ {
Portrait.Undim(character,portraitStage); Portrait.Undim(character, stage);
} }
} }
protected void DimNonSpeakingPortraits(PortraitStage portraitStage)
protected void DimNonSpeakingPortraits(Stage stage)
{ {
portraitStage.dimPortraits = true; stage.dimPortraits = true;
} }
protected void OnComplete() protected void OnComplete()
{ {
if (waitUntilFinished) if (waitUntilFinished)
@ -191,6 +197,7 @@ namespace Fungus
Continue(); Continue();
} }
} }
public override string GetSummary() public override string GetSummary()
{ {
string displaySummary = ""; string displaySummary = "";
@ -202,12 +209,12 @@ namespace Fungus
{ {
return "Error: No display selected"; return "Error: No display selected";
} }
string portraitStageSummary = ""; string stageSummary = "";
if (portraitStage != null) if (stage != null)
{ {
portraitStageSummary = " \"" + portraitStage.name + "\""; stageSummary = " \"" + stage.name + "\"";
} }
return displaySummary + portraitStageSummary; return displaySummary + stageSummary;
} }
public override Color GetButtonColor() public override Color GetButtonColor()

60
Assets/Fungus/Portrait/Scripts/Commands/Portrait.cs

@ -46,8 +46,8 @@ namespace Fungus
"Controls a character portrait. ")] "Controls a character portrait. ")]
public class Portrait : Command public class Portrait : Command
{ {
[Tooltip("Display type")] [Tooltip("Stage to display portrait on")]
public PortraitStage portraitStage; public Stage stage;
[Tooltip("Display type")] [Tooltip("Display type")]
public DisplayType display; public DisplayType display;
@ -117,15 +117,15 @@ namespace Fungus
return; return;
} }
// Selected "use default Portrait Stage" // Selected "use default Portrait Stage"
if (portraitStage == null) // Default portrait stage selected if (stage == null) // Default portrait stage selected
{ {
if (portraitStage == null) // If no default specified, try to get any portrait stage in the scene if (stage == null) // If no default specified, try to get any portrait stage in the scene
{ {
portraitStage = GameObject.FindObjectOfType<PortraitStage>(); stage = GameObject.FindObjectOfType<Stage>();
} }
} }
// If portrait stage does not exist, do nothing // If portrait stage does not exist, do nothing
if (portraitStage == null) if (stage == null)
{ {
Continue(); Continue();
return; return;
@ -133,7 +133,7 @@ namespace Fungus
if (character.state.portraitImage == null) if (character.state.portraitImage == null)
{ {
CreatePortraitObject(character,portraitStage); CreatePortraitObject(character,stage);
} }
// if no previous portrait, use default portrait // if no previous portrait, use default portrait
if (character.state.portrait == null) if (character.state.portrait == null)
@ -148,7 +148,7 @@ namespace Fungus
// if no previous position, use default position // if no previous position, use default position
if (character.state.position == null) if (character.state.position == null)
{ {
character.state.position = portraitStage.defaultPosition.rectTransform; character.state.position = stage.defaultPosition.rectTransform;
} }
// Selected "use previous position" // Selected "use previous position"
if (toPosition == null) if (toPosition == null)
@ -160,7 +160,7 @@ namespace Fungus
// if no previous position, use default position // if no previous position, use default position
if (replacedCharacter.state.position == null) if (replacedCharacter.state.position == null)
{ {
replacedCharacter.state.position = portraitStage.defaultPosition.rectTransform; replacedCharacter.state.position = stage.defaultPosition.rectTransform;
} }
} }
// If swapping, use replaced character's position // If swapping, use replaced character's position
@ -195,29 +195,29 @@ namespace Fungus
// Use default settings // Use default settings
if (useDefaultSettings) if (useDefaultSettings)
{ {
fadeDuration = portraitStage.fadeDuration; fadeDuration = stage.fadeDuration;
moveSpeed = portraitStage.moveSpeed; moveSpeed = stage.moveSpeed;
shiftOffset = portraitStage.shiftOffset; shiftOffset = stage.shiftOffset;
} }
switch(display) switch(display)
{ {
case (DisplayType.Show): case (DisplayType.Show):
Show(character,fromPosition,toPosition); Show(character,fromPosition,toPosition);
character.state.onScreen = true; character.state.onScreen = true;
portraitStage.charactersOnStage.Add(character); stage.charactersOnStage.Add(character);
break; break;
case (DisplayType.Hide): case (DisplayType.Hide):
Hide(character,fromPosition,toPosition); Hide(character,fromPosition,toPosition);
character.state.onScreen = false; character.state.onScreen = false;
portraitStage.charactersOnStage.Remove(character); stage.charactersOnStage.Remove(character);
break; break;
case (DisplayType.Replace): case (DisplayType.Replace):
Show(character,fromPosition,toPosition); Show(character,fromPosition,toPosition);
Hide(replacedCharacter, replacedCharacter.state.position, replacedCharacter.state.position); Hide(replacedCharacter, replacedCharacter.state.position, replacedCharacter.state.position);
character.state.onScreen = true; character.state.onScreen = true;
replacedCharacter.state.onScreen = false; replacedCharacter.state.onScreen = false;
portraitStage.charactersOnStage.Add(character); stage.charactersOnStage.Add(character);
portraitStage.charactersOnStage.Remove(replacedCharacter); stage.charactersOnStage.Remove(replacedCharacter);
break; break;
case (DisplayType.MoveToFront): case (DisplayType.MoveToFront):
MoveToFront(character); MoveToFront(character);
@ -241,10 +241,10 @@ namespace Fungus
Continue(); Continue();
} }
} }
public static void CreatePortraitObject(Character character, PortraitStage portraitStage) public static void CreatePortraitObject(Character character, Stage stage)
{ {
GameObject portraitObj = new GameObject(character.name, typeof(RectTransform), typeof(CanvasRenderer), typeof(Image)); GameObject portraitObj = new GameObject(character.name, typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));
portraitObj.transform.SetParent(portraitStage.portraitCanvas.transform, true); portraitObj.transform.SetParent(stage.portraitCanvas.transform, true);
Image portraitImage = portraitObj.GetComponent<Image>(); Image portraitImage = portraitObj.GetComponent<Image>();
portraitImage.preserveAspect = true; portraitImage.preserveAspect = true;
portraitImage.sprite = character.profileSprite; portraitImage.sprite = character.profileSprite;
@ -337,27 +337,27 @@ namespace Fungus
protected void UpdateTweens(Character character, RectTransform fromPosition, RectTransform toPosition) protected void UpdateTweens(Character character, RectTransform fromPosition, RectTransform toPosition)
{ {
if (fadeDuration == 0) fadeDuration = float.Epsilon; if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,0,1,fadeDuration).setEase(portraitStage.fadeEaseType).setOnComplete(OnComplete).setOnUpdate( LeanTween.value(character.state.portraitObj,0,1,fadeDuration).setEase(stage.fadeEaseType).setOnComplete(OnComplete).setOnUpdate(
(float fadeAmount)=>{ (float fadeAmount)=>{
character.state.portraitImage.material.SetFloat("_Fade", fadeAmount); character.state.portraitImage.material.SetFloat("_Fade", fadeAmount);
} }
); );
float moveDuration = (Vector3.Distance(fromPosition.anchoredPosition,toPosition.anchoredPosition)/moveSpeed); float moveDuration = (Vector3.Distance(fromPosition.anchoredPosition,toPosition.anchoredPosition)/moveSpeed);
if (moveSpeed == 0) moveDuration = float.Epsilon; if (moveSpeed == 0) moveDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,fromPosition.anchoredPosition,toPosition.anchoredPosition,moveDuration).setEase(portraitStage.moveEaseType).setOnComplete(OnComplete).setOnUpdate( LeanTween.value(character.state.portraitObj,fromPosition.anchoredPosition,toPosition.anchoredPosition,moveDuration).setEase(stage.moveEaseType).setOnComplete(OnComplete).setOnUpdate(
(Vector3 updatePosition)=>{ (Vector3 updatePosition)=>{
character.state.portraitImage.rectTransform.anchoredPosition = updatePosition; character.state.portraitImage.rectTransform.anchoredPosition = updatePosition;
} }
); );
} }
public static void Dim(Character character, PortraitStage portraitStage) public static void Dim(Character character, Stage stage)
{ {
if (character.state.dimmed == false) if (character.state.dimmed == false)
{ {
character.state.dimmed = true; character.state.dimmed = true;
float fadeDuration = portraitStage.fadeDuration; float fadeDuration = stage.fadeDuration;
if (fadeDuration == 0) fadeDuration = float.Epsilon; if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,1f,0.5f,fadeDuration).setEase(portraitStage.fadeEaseType).setOnUpdate( LeanTween.value(character.state.portraitObj,1f,0.5f,fadeDuration).setEase(stage.fadeEaseType).setOnUpdate(
(float tintAmount)=>{ (float tintAmount)=>{
Color tint = new Color(tintAmount,tintAmount,tintAmount,1); Color tint = new Color(tintAmount,tintAmount,tintAmount,1);
character.state.portraitImage.material.SetColor("_Color", tint); character.state.portraitImage.material.SetColor("_Color", tint);
@ -365,14 +365,14 @@ namespace Fungus
); );
} }
} }
public static void Undim(Character character, PortraitStage portraitStage) public static void Undim(Character character, Stage stage)
{ {
if (character.state.dimmed == true) if (character.state.dimmed == true)
{ {
character.state.dimmed = false; character.state.dimmed = false;
float fadeDuration = portraitStage.fadeDuration; float fadeDuration = stage.fadeDuration;
if (fadeDuration == 0) fadeDuration = float.Epsilon; if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,0.5f,1f,fadeDuration).setEase(portraitStage.fadeEaseType).setOnUpdate( LeanTween.value(character.state.portraitObj,0.5f,1f,fadeDuration).setEase(stage.fadeEaseType).setOnUpdate(
(float tintAmount)=>{ (float tintAmount)=>{
Color tint = new Color(tintAmount,tintAmount,tintAmount,1); Color tint = new Color(tintAmount,tintAmount,tintAmount,1);
character.state.portraitImage.material.SetColor("_Color", tint); character.state.portraitImage.material.SetColor("_Color", tint);
@ -408,7 +408,7 @@ namespace Fungus
string characterSummary = ""; string characterSummary = "";
string fromPositionSummary = ""; string fromPositionSummary = "";
string toPositionSummary = ""; string toPositionSummary = "";
string portraitStageSummary = ""; string stageSummary = "";
string portraitSummary = ""; string portraitSummary = "";
string facingSummary = ""; string facingSummary = "";
@ -422,9 +422,9 @@ namespace Fungus
} }
} }
characterSummary = character.name; characterSummary = character.name;
if (portraitStage != null) if (stage != null)
{ {
portraitStageSummary = " on \"" + portraitStage.name + "\""; stageSummary = " on \"" + stage.name + "\"";
} }
if (portrait != null) if (portrait != null)
@ -464,7 +464,7 @@ namespace Fungus
} }
facingSummary = " facing \"" + facingSummary + "\""; facingSummary = " facing \"" + facingSummary + "\"";
} }
return displaySummary + " \"" + characterSummary + portraitSummary + "\"" + portraitStageSummary + facingSummary + fromPositionSummary + toPositionSummary; return displaySummary + " \"" + characterSummary + portraitSummary + "\"" + stageSummary + facingSummary + fromPositionSummary + toPositionSummary;
} }
public override Color GetButtonColor() public override Color GetButtonColor()

10
Assets/Fungus/Portrait/Scripts/PortraitStage.cs → Assets/Fungus/Portrait/Scripts/Stage.cs

@ -7,7 +7,7 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
public class PortraitStage : MonoBehaviour public class Stage : MonoBehaviour
{ {
public Canvas portraitCanvas; public Canvas portraitCanvas;
public bool dimPortraits; public bool dimPortraits;
@ -21,20 +21,20 @@ namespace Fungus
public List<Character> charactersOnStage = new List<Character>(); public List<Character> charactersOnStage = new List<Character>();
[HideInInspector] [HideInInspector]
static public List<PortraitStage> activePortraitStages = new List<PortraitStage>(); static public List<Stage> activeStages = new List<Stage>();
[ExecuteInEditMode] [ExecuteInEditMode]
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
if (!activePortraitStages.Contains(this)) if (!activeStages.Contains(this))
{ {
activePortraitStages.Add(this); activeStages.Add(this);
} }
} }
[ExecuteInEditMode] [ExecuteInEditMode]
protected virtual void OnDisable() protected virtual void OnDisable()
{ {
activePortraitStages.Remove(this); activeStages.Remove(this);
} }
} }
} }

0
Assets/Fungus/Portrait/Scripts/PortraitStage.cs.meta → Assets/Fungus/Portrait/Scripts/Stage.cs.meta

77
Assets/FungusExamples/Sherlock/TheExperiment.unity

@ -2403,7 +2403,7 @@ GameObject:
- 4: {fileID: 876464347} - 4: {fileID: 876464347}
- 114: {fileID: 876464348} - 114: {fileID: 876464348}
m_Layer: 0 m_Layer: 0
m_Name: PortraitStage m_Name: Stage
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -3523,6 +3523,10 @@ Prefab:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 3 value: 3
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11410280, guid: c6289d5f8fa843145a2355af9cb09719, type: 2}
propertyPath: m_Color.a
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c6289d5f8fa843145a2355af9cb09719, type: 2} m_ParentPrefab: {fileID: 100100000, guid: c6289d5f8fa843145a2355af9cb09719, type: 2}
m_RootGameObject: {fileID: 876464346} m_RootGameObject: {fileID: 876464346}
@ -4033,9 +4037,8 @@ MonoBehaviour:
y: -1729.35046 y: -1729.35046
width: 5969.4458 width: 5969.4458
height: 2818.85034 height: 2818.85034
selectedSequence: {fileID: 1390555298} selectedSequence: {fileID: 0}
selectedCommands: selectedCommands: []
- {fileID: 1390555345}
variables: [] variables: []
description: 'Example scene from Sherlock: The Game Is On' description: 'Example scene from Sherlock: The Game Is On'
runSlowDuration: 0 runSlowDuration: 0
@ -4142,7 +4145,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 2 display: 2
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5106,7 +5109,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5136,7 +5139,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5202,7 +5205,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5232,7 +5235,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5262,7 +5265,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5311,7 +5314,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5341,7 +5344,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5371,7 +5374,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5401,7 +5404,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5431,7 +5434,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5486,7 +5489,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5516,7 +5519,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5545,7 +5548,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 2 display: 2
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5574,7 +5577,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5627,7 +5630,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 2 display: 2
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5702,7 +5705,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 2 display: 2
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5731,7 +5734,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5846,8 +5849,8 @@ MonoBehaviour:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
display: 2 display: 2
portraitStage: {fileID: 0} stage: {fileID: 0}
replacedPortraitStage: {fileID: 0} replacedStage: {fileID: 0}
useDefaultSettings: 1 useDefaultSettings: 1
fadeDuration: 1 fadeDuration: 1
waitUntilFinished: 0 waitUntilFinished: 0
@ -5890,7 +5893,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5919,7 +5922,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5948,7 +5951,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -5977,7 +5980,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6006,7 +6009,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6035,7 +6038,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6064,7 +6067,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6093,7 +6096,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6122,7 +6125,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6176,7 +6179,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6205,7 +6208,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 1880195408} character: {fileID: 1880195408}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6234,7 +6237,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}
@ -6263,7 +6266,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
portraitStage: {fileID: 0} stage: {fileID: 0}
display: 1 display: 1
character: {fileID: 137130844} character: {fileID: 137130844}
replacedCharacter: {fileID: 0} replacedCharacter: {fileID: 0}

Loading…
Cancel
Save