Browse Source

New Dialog system (replaces Pages)

- Added clickSound property to Button component
- Added new Dialog component and prefab (replaces Page)
- Moved deprecated files to Legacy folder
- Game components (CommandQueue, etc.) are now created in Game prefab
- Moved all camera related properties and functions from Game to
CameraController
- Added IDialog interface to support backwards compatibility between
Page class and the new Dialog class
- Added SetDialog() and SetTimeout() commands
- Marked all Page commands as Obsolete
- Added character images for use with Dialog component
- Added timed multiple choice menus
- Added looping typing sound while text is being written
- Updated example rooms to use new Dialog system
master
chrisgregan 11 years ago
parent
commit
759105166b
  1. 5
      Assets/Fungus/Legacy.meta
  2. 0
      Assets/Fungus/Legacy/ContinueIcon.png
  3. 0
      Assets/Fungus/Legacy/ContinueIcon.png.meta
  4. 0
      Assets/Fungus/Legacy/OptionButton1.psd
  5. 0
      Assets/Fungus/Legacy/OptionButton1.psd.meta
  6. 0
      Assets/Fungus/Legacy/OptionButton2.psd
  7. 0
      Assets/Fungus/Legacy/OptionButton2.psd.meta
  8. 0
      Assets/Fungus/Legacy/Page.cs
  9. 0
      Assets/Fungus/Legacy/Page.cs.meta
  10. BIN
      Assets/Fungus/Legacy/Page.prefab
  11. 0
      Assets/Fungus/Legacy/Page.prefab.meta
  12. 25
      Assets/Fungus/Legacy/PageCommands.cs
  13. 0
      Assets/Fungus/Legacy/PageCommands.cs.meta
  14. 174
      Assets/Fungus/Legacy/PageController.cs
  15. 0
      Assets/Fungus/Legacy/PageController.cs.meta
  16. 0
      Assets/Fungus/Legacy/PageStyle.cs
  17. 0
      Assets/Fungus/Legacy/PageStyle.cs.meta
  18. BIN
      Assets/Fungus/Legacy/PageStyle1.prefab
  19. 0
      Assets/Fungus/Legacy/PageStyle1.prefab.meta
  20. BIN
      Assets/Fungus/Legacy/PageStyle2.prefab
  21. 0
      Assets/Fungus/Legacy/PageStyle2.prefab.meta
  22. 3
      Assets/Fungus/Legacy/Readme.txt
  23. 4
      Assets/Fungus/Legacy/Readme.txt.meta
  24. 0
      Assets/Fungus/Legacy/StoryBox1.psd
  25. 0
      Assets/Fungus/Legacy/StoryBox1.psd.meta
  26. 0
      Assets/Fungus/Legacy/StoryBox2.psd
  27. 0
      Assets/Fungus/Legacy/StoryBox2.psd.meta
  28. BIN
      Assets/Fungus/Prefabs/Button.prefab
  29. BIN
      Assets/Fungus/Prefabs/Dialog.prefab
  30. 4
      Assets/Fungus/Prefabs/Dialog.prefab.meta
  31. BIN
      Assets/Fungus/Prefabs/GUIButton.prefab
  32. 0
      Assets/Fungus/Prefabs/GUIButton.prefab.meta
  33. BIN
      Assets/Fungus/Prefabs/Game.prefab
  34. 12
      Assets/Fungus/Scripts/Button.cs
  35. 80
      Assets/Fungus/Scripts/CameraController.cs
  36. 796
      Assets/Fungus/Scripts/Dialog.cs
  37. 8
      Assets/Fungus/Scripts/Dialog.cs.meta
  38. 146
      Assets/Fungus/Scripts/Game.cs
  39. 386
      Assets/Fungus/Scripts/GameController.cs
  40. 4
      Assets/Fungus/Scripts/RoomTemplate.cs
  41. BIN
      Assets/Fungus/Sprites/ButtonBlank.psd
  42. BIN
      Assets/Fungus/Sprites/FungusSmall.png
  43. BIN
      Assets/Fungus/Textures/BlueAlienHappy.png
  44. 9
      Assets/Fungus/Textures/BlueAlienHappy.png.meta
  45. BIN
      Assets/Fungus/Textures/BlueAlienSad.png
  46. 19
      Assets/Fungus/Textures/BlueAlienSad.png.meta
  47. BIN
      Assets/Fungus/Textures/Button.png
  48. BIN
      Assets/Fungus/Textures/ButtonBlack.psd
  49. 3
      Assets/Fungus/Textures/ButtonBlack.psd.meta
  50. BIN
      Assets/Fungus/Textures/ButtonOrange.psd
  51. 3
      Assets/Fungus/Textures/ButtonOrange.psd.meta
  52. BIN
      Assets/Fungus/Textures/Continue.psd
  53. 46
      Assets/Fungus/Textures/Continue.psd.meta
  54. BIN
      Assets/Fungus/Textures/DialogBackground.psd
  55. 46
      Assets/Fungus/Textures/DialogBackground.psd.meta
  56. BIN
      Assets/Fungus/Textures/GreenAlienHappy.png
  57. 46
      Assets/Fungus/Textures/GreenAlienHappy.png.meta
  58. BIN
      Assets/Fungus/Textures/GreenAlienSad.png
  59. 46
      Assets/Fungus/Textures/GreenAlienSad.png.meta
  60. BIN
      Assets/Fungus/Textures/Icon.png
  61. BIN
      Assets/Fungus/Textures/Mushroom.png
  62. 46
      Assets/Fungus/Textures/Mushroom.png.meta
  63. BIN
      Assets/Fungus/Textures/PinkAlienHappy.png
  64. 46
      Assets/Fungus/Textures/PinkAlienHappy.png.meta
  65. BIN
      Assets/Fungus/Textures/PinkAlienSad.png
  66. 46
      Assets/Fungus/Textures/PinkAlienSad.png.meta
  67. 0
      Assets/Fungus/Textures/ScreenFade.png
  68. 0
      Assets/Fungus/Textures/ScreenFade.png.meta
  69. 5
      Assets/Fungus/Textures/TimerFrames.meta
  70. BIN
      Assets/Fungus/Textures/TimerFrames/Timer.psd
  71. 46
      Assets/Fungus/Textures/TimerFrames/Timer.psd.meta
  72. BIN
      Assets/Fungus/Textures/TimerFrames/Timer00.png
  73. 46
      Assets/Fungus/Textures/TimerFrames/Timer00.png.meta
  74. BIN
      Assets/Fungus/Textures/TimerFrames/Timer01.png
  75. 46
      Assets/Fungus/Textures/TimerFrames/Timer01.png.meta
  76. BIN
      Assets/Fungus/Textures/TimerFrames/Timer02.png
  77. 46
      Assets/Fungus/Textures/TimerFrames/Timer02.png.meta
  78. BIN
      Assets/Fungus/Textures/TimerFrames/Timer03.png
  79. 46
      Assets/Fungus/Textures/TimerFrames/Timer03.png.meta
  80. BIN
      Assets/Fungus/Textures/TimerFrames/Timer04.png
  81. 46
      Assets/Fungus/Textures/TimerFrames/Timer04.png.meta
  82. BIN
      Assets/Fungus/Textures/TimerFrames/Timer05.png
  83. 46
      Assets/Fungus/Textures/TimerFrames/Timer05.png.meta
  84. BIN
      Assets/Fungus/Textures/TimerFrames/Timer06.png
  85. 46
      Assets/Fungus/Textures/TimerFrames/Timer06.png.meta
  86. BIN
      Assets/Fungus/Textures/TimerFrames/Timer07.png
  87. 46
      Assets/Fungus/Textures/TimerFrames/Timer07.png.meta
  88. BIN
      Assets/Fungus/Textures/TimerFrames/Timer08.png
  89. 46
      Assets/Fungus/Textures/TimerFrames/Timer08.png.meta
  90. 10
      Assets/Fungus/Textures/license.txt
  91. BIN
      Assets/FungusExample/Scenes/Example.unity
  92. 9
      Assets/FungusExample/Scripts/AudioRoom.cs
  93. 40
      Assets/FungusExample/Scripts/DialogRoom.cs
  94. 0
      Assets/FungusExample/Scripts/DialogRoom.cs.meta
  95. 13
      Assets/FungusExample/Scripts/MenuRoom.cs
  96. 29
      Assets/FungusExample/Scripts/SpriteRoom.cs
  97. 2
      Assets/FungusExample/Scripts/ViewRoom.cs
  98. BIN
      ProjectSettings/EditorBuildSettings.asset

5
Assets/Fungus/Legacy.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 91a179baad49c4be29b82e774d9a5bb6
folderAsset: yes
DefaultImporter:
userData:

0
Assets/Fungus/Textures/ContinueIcon.png → Assets/Fungus/Legacy/ContinueIcon.png

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

0
Assets/Fungus/Textures/ContinueIcon.png.meta → Assets/Fungus/Legacy/ContinueIcon.png.meta

0
Assets/Fungus/Textures/OptionButton1.psd → Assets/Fungus/Legacy/OptionButton1.psd

0
Assets/Fungus/Textures/OptionButton1.psd.meta → Assets/Fungus/Legacy/OptionButton1.psd.meta

0
Assets/Fungus/Textures/OptionButton2.psd → Assets/Fungus/Legacy/OptionButton2.psd

0
Assets/Fungus/Textures/OptionButton2.psd.meta → Assets/Fungus/Legacy/OptionButton2.psd.meta

0
Assets/Fungus/Scripts/Page.cs → Assets/Fungus/Legacy/Page.cs

0
Assets/Fungus/Scripts/Page.cs.meta → Assets/Fungus/Legacy/Page.cs.meta

BIN
Assets/Fungus/Prefabs/Page.prefab → Assets/Fungus/Legacy/Page.prefab

Binary file not shown.

0
Assets/Fungus/Prefabs/Page.prefab.meta → Assets/Fungus/Legacy/Page.prefab.meta

25
Assets/Fungus/Scripts/Commands/PageCommands.cs → Assets/Fungus/Legacy/PageCommands.cs

@ -79,7 +79,7 @@ namespace Fungus
public override void Execute(CommandQueue commandQueue, Action onComplete) public override void Execute(CommandQueue commandQueue, Action onComplete)
{ {
Game.GetInstance().activePageStyle = pageStyle; Game.GetInstance().pageController.activePageStyle = pageStyle;
if (onComplete != null) if (onComplete != null)
{ {
onComplete(); onComplete();
@ -150,8 +150,8 @@ namespace Fungus
public override void Execute(CommandQueue commandQueue, Action onComplete) public override void Execute(CommandQueue commandQueue, Action onComplete)
{ {
PageController page = Game.GetInstance().pageController; IDialog sayDialog = Game.GetInstance().GetDialog();
page.Say(storyText, onComplete); sayDialog.Say(storyText, onComplete);
} }
} }
@ -172,8 +172,8 @@ namespace Fungus
public override void Execute(CommandQueue commandQueue, Action onComplete) public override void Execute(CommandQueue commandQueue, Action onComplete)
{ {
PageController page = Game.GetInstance().pageController; IDialog characterDialog = Game.GetInstance().GetDialog();
page.AddOption(optionText, optionAction); characterDialog.AddOption(optionText, optionAction);
if (onComplete != null) if (onComplete != null)
{ {
@ -196,8 +196,19 @@ namespace Fungus
public override void Execute(CommandQueue commandQueue, Action onComplete) public override void Execute(CommandQueue commandQueue, Action onComplete)
{ {
PageController page = Game.GetInstance().pageController; IDialog dialog = Game.GetInstance().GetDialog();
page.Choose(chooseText);
PageController pageController = dialog as PageController;
if (pageController != null)
{
// Legacy support for old Pages system
pageController.Choose(chooseText);
}
else
{
// Support for modern IDialog interface
dialog.Say(chooseText, null);
}
// Choose always clears the commandQueue, so there's no need to call onComplete() // Choose always clears the commandQueue, so there's no need to call onComplete()
} }

0
Assets/Fungus/Scripts/Commands/PageCommands.cs.meta → Assets/Fungus/Legacy/PageCommands.cs.meta

174
Assets/Fungus/Scripts/PageController.cs → Assets/Fungus/Legacy/PageController.cs

@ -10,7 +10,7 @@ namespace Fungus
* Manages and draws a text box for rendering story text and multiple choice menus. * Manages and draws a text box for rendering story text and multiple choice menus.
*/ */
[ExecuteInEditMode] [ExecuteInEditMode]
public class PageController : MonoBehaviour public class PageController : MonoBehaviour, IDialog
{ {
/// Options for default Page position on screen /// Options for default Page position on screen
public enum PagePosition public enum PagePosition
@ -62,12 +62,61 @@ namespace Fungus
Choose Choose
}; };
/**
* The style to apply when displaying Pages.
*/
public PageStyle activePageStyle;
/// Current Page story telling state /// Current Page story telling state
[HideInInspector]
public Mode mode = Mode.Idle; public Mode mode = Mode.Idle;
/// Screen space rect for Page in pixels. /// Screen space rect for Page in pixels.
[HideInInspector]
public Rect pageRect; public Rect pageRect;
/**
* Writing speed for page text.
*/
public int charactersPerSecond = 60;
/**
* Icon to display when waiting for player input to continue
*/
public Texture2D continueIcon;
/**
* Position of continue and swipe icons in normalized screen space coords.
* (0,0) = top left, (1,1) = bottom right
*/
public Vector2 iconPosition = new Vector2(1,1);
/**
* Default screen position for Page when player enters a Room.
*/
public PageController.PagePosition defaultPagePosition;
/**
* Default width and height of Page as a fraction of screen height [0..1]
*/
public Vector2 defaultPageScale = new Vector2(0.75f, 0.25f);
/**
* Automatically center the Page when player is choosing from multiple options.
*/
public bool centerChooseMenu = true;
/**
* Width of Page as a fraction of screen width [0..1] when automatically centering a Choose menu.
* This setting only has an effect when centerChooseMenu is enabled.
*/
public float chooseMenuWidth = 0.5f;
/**
* Sound effect to play when buttons are clicked.
*/
public AudioClip clickSound;
string headerText = ""; string headerText = "";
string footerText = ""; string footerText = "";
@ -155,19 +204,18 @@ namespace Fungus
*/ */
public void SetDefaultPageLayout() public void SetDefaultPageLayout()
{ {
Game game = Game.GetInstance(); ScreenRect screenRect = CalcScreenRect(defaultPageScale, defaultPagePosition);
ScreenRect screenRect = CalcScreenRect(game.defaultPageScale, game.defaultPagePosition);
pageRect = CalcPageRect(screenRect); pageRect = CalcPageRect(screenRect);
switch (game.defaultPagePosition) switch (defaultPagePosition)
{ {
case PageController.PagePosition.Top: case PageController.PagePosition.Top:
game.pageController.layout = PageController.Layout.FullSize; layout = PageController.Layout.FullSize;
break; break;
case PageController.PagePosition.Middle: case PageController.PagePosition.Middle:
game.pageController.layout = PageController.Layout.FitToMiddle; layout = PageController.Layout.FitToMiddle;
break; break;
case PageController.PagePosition.Bottom: case PageController.PagePosition.Bottom:
game.pageController.layout = PageController.Layout.FullSize; layout = PageController.Layout.FullSize;
break; break;
} }
} }
@ -191,14 +239,27 @@ namespace Fungus
footerText = _footerText; footerText = _footerText;
} }
public void Say(string sayText, Action sayAction) public void Say(string sayText, Action sayAction = null)
{ {
// IDialog does not support the legacy Choose() command
// Instead, the assumption is that if you call Say() after some options have been added then show the choice menu.
if (options.Count > 0)
{
Choose(sayText);
return;
}
mode = Mode.Say; mode = Mode.Say;
string subbedText = Game.stringTable.SubstituteStrings(sayText); string subbedText = Game.stringTable.SubstituteStrings(sayText);
continueAction = sayAction; continueAction = sayAction;
WriteStory(subbedText); WriteStory(subbedText);
} }
public void ClearOptions()
{
options.Clear();
}
public void AddOption(string optionText, Action optionAction) public void AddOption(string optionText, Action optionAction)
{ {
string subbedText = Game.stringTable.FormatLinkText(Game.stringTable.SubstituteStrings(optionText)); string subbedText = Game.stringTable.FormatLinkText(Game.stringTable.SubstituteStrings(optionText));
@ -212,10 +273,14 @@ namespace Fungus
WriteStory(subbedText); WriteStory(subbedText);
} }
public void SetTimeout(float _timeoutDuration, Action _timeoutAction)
{
Debug.Log("SetTimeout() is not supported by PageController.");
}
void WriteStory(string storyText) void WriteStory(string storyText)
{ {
PageStyle pageStyle = Game.GetInstance().activePageStyle; if (activePageStyle == null)
if (pageStyle == null)
{ {
return; return;
} }
@ -240,8 +305,6 @@ namespace Fungus
// Coroutine to write story text out over a period of time // Coroutine to write story text out over a period of time
IEnumerator WriteStoryInternal() IEnumerator WriteStoryInternal()
{ {
int charactersPerSecond = Game.GetInstance().charactersPerSecond;
// Zero CPS means write instantly // Zero CPS means write instantly
if (charactersPerSecond == 0) if (charactersPerSecond == 0)
{ {
@ -298,30 +361,49 @@ namespace Fungus
return; return;
} }
PageStyle pageStyle = Game.GetInstance().activePageStyle; if (activePageStyle == null)
if (pageStyle == null)
{ {
return; return;
} }
GUIStyle boxStyle = pageStyle.boxStyle; if (mode == PageController.Mode.Say &&
GUIStyle headerStyle = pageStyle.GetScaledHeaderStyle(); FinishedWriting())
GUIStyle footerStyle = pageStyle.GetScaledFooterStyle(); {
GUIStyle sayStyle = pageStyle.GetScaledSayStyle(); // Draw the continue icon
GUIStyle optionStyle = pageStyle.GetScaledOptionStyle(); if (continueIcon)
GUIStyle optionAlternateStyle = pageStyle.GetScaledOptionAlternateStyle(); {
float x = Screen.width * iconPosition.x;
float y = Screen.height * iconPosition.y;
float width = continueIcon.width;
float height = continueIcon.height;
x = Mathf.Max(x, 0);
y = Mathf.Max(y, 0);
x = Mathf.Min(x, Screen.width - width);
y = Mathf.Min(y, Screen.height - height);
Rect rect = new Rect(x, y, width, height);
GUI.DrawTexture(rect, continueIcon);
}
}
GUIStyle boxStyle = activePageStyle.boxStyle;
GUIStyle headerStyle = activePageStyle.GetScaledHeaderStyle();
GUIStyle footerStyle = activePageStyle.GetScaledFooterStyle();
GUIStyle sayStyle = activePageStyle.GetScaledSayStyle();
GUIStyle optionStyle = activePageStyle.GetScaledOptionStyle();
GUIStyle optionAlternateStyle = activePageStyle.GetScaledOptionAlternateStyle();
Rect outerRect; Rect outerRect;
Layout tempLayout; Layout tempLayout;
Game game = Game.GetInstance();
if (mode == Mode.Choose && if (mode == Mode.Choose &&
game.centerChooseMenu) centerChooseMenu)
{ {
// Position the Choose menu in middle of screen // Position the Choose menu in middle of screen
// The width is controlled by game.chooseMenuWidth // The width is controlled by game.chooseMenuWidth
// The height is automatically fitted to the text content // The height is automatically fitted to the text content
Vector2 pageScale = new Vector2(game.chooseMenuWidth, 0.5f); Vector2 pageScale = new Vector2(chooseMenuWidth, 0.5f);
PageController.ScreenRect screenRect = PageController.CalcScreenRect(pageScale, PageController.PagePosition.Middle); PageController.ScreenRect screenRect = PageController.CalcScreenRect(pageScale, PageController.PagePosition.Middle);
outerRect = PageController.CalcPageRect(screenRect); outerRect = PageController.CalcPageRect(screenRect);
tempLayout = PageController.Layout.FitToMiddle; tempLayout = PageController.Layout.FitToMiddle;
@ -458,7 +540,7 @@ namespace Fungus
{ {
if (deferredAction != null) if (deferredAction != null)
{ {
Game.GetInstance().PlayButtonClick(); PlayButtonClick();
Action tempAction = deferredAction; Action tempAction = deferredAction;
@ -468,7 +550,7 @@ namespace Fungus
if (mode == Mode.Choose) if (mode == Mode.Choose)
{ {
options.Clear(); ClearOptions();
// Reset to idle, but calling action may set this again // Reset to idle, but calling action may set this again
mode = Mode.Idle; mode = Mode.Idle;
@ -490,16 +572,14 @@ namespace Fungus
float CalcHeaderHeight(float boxWidth) float CalcHeaderHeight(float boxWidth)
{ {
PageStyle pageStyle = Game.GetInstance().activePageStyle; if (activePageStyle == null ||
if (pageStyle == null ||
mode == Mode.Idle || mode == Mode.Idle ||
headerText.Length == 0) headerText.Length == 0)
{ {
return 0; return 0;
} }
GUIStyle headerStyle = pageStyle.GetScaledHeaderStyle(); GUIStyle headerStyle = activePageStyle.GetScaledHeaderStyle();
GUIContent headerContent = new GUIContent(headerText); GUIContent headerContent = new GUIContent(headerText);
return headerStyle.CalcHeight(headerContent, boxWidth); return headerStyle.CalcHeight(headerContent, boxWidth);
@ -507,16 +587,14 @@ namespace Fungus
float CalcFooterHeight(float boxWidth) float CalcFooterHeight(float boxWidth)
{ {
PageStyle pageStyle = Game.GetInstance().activePageStyle; if (activePageStyle == null ||
if (pageStyle == null ||
mode == Mode.Idle || mode == Mode.Idle ||
footerText.Length == 0) footerText.Length == 0)
{ {
return 0; return 0;
} }
GUIStyle footerStyle = pageStyle.GetScaledFooterStyle(); GUIStyle footerStyle = activePageStyle.GetScaledFooterStyle();
GUIContent headerContent = new GUIContent(headerText); GUIContent headerContent = new GUIContent(headerText);
return footerStyle.CalcHeight(headerContent, boxWidth); return footerStyle.CalcHeight(headerContent, boxWidth);
@ -524,10 +602,9 @@ namespace Fungus
float CalcStoryHeight(float boxWidth) float CalcStoryHeight(float boxWidth)
{ {
PageStyle pageStyle = Game.GetInstance().activePageStyle; GUIStyle sayStyle = activePageStyle.GetScaledSayStyle();
GUIStyle sayStyle = pageStyle.GetScaledSayStyle();
if (pageStyle == null || if (activePageStyle == null ||
mode == Mode.Idle || mode == Mode.Idle ||
originalStoryText.Length == 0) originalStoryText.Length == 0)
{ {
@ -541,9 +618,7 @@ namespace Fungus
float CalcOptionsHeight(float boxWidth) float CalcOptionsHeight(float boxWidth)
{ {
PageStyle pageStyle = Game.GetInstance().activePageStyle; if (activePageStyle == null ||
if (pageStyle == null ||
mode == Mode.Idle || mode == Mode.Idle ||
options.Count == 0) options.Count == 0)
{ {
@ -551,7 +626,7 @@ namespace Fungus
} }
// This assumes that the alternate option style is the same height as the regular style // This assumes that the alternate option style is the same height as the regular style
GUIStyle optionStyle = pageStyle.GetScaledOptionStyle(); GUIStyle optionStyle = activePageStyle.GetScaledOptionStyle();
float totalHeight = 0; float totalHeight = 0;
foreach (Option option in options) foreach (Option option in options)
@ -562,7 +637,7 @@ namespace Fungus
} }
// Add space at bottom // Add space at bottom
GUIStyle sayStyle = pageStyle.GetScaledSayStyle(); GUIStyle sayStyle = activePageStyle.GetScaledSayStyle();
totalHeight += sayStyle.lineHeight; totalHeight += sayStyle.lineHeight;
return totalHeight; return totalHeight;
@ -571,14 +646,12 @@ namespace Fungus
// Returns smaller internal box rect with padding style applied // Returns smaller internal box rect with padding style applied
Rect CalcInnerRect(Rect outerRect) Rect CalcInnerRect(Rect outerRect)
{ {
PageStyle pageStyle = Game.GetInstance().activePageStyle; if (activePageStyle == null)
if (pageStyle == null)
{ {
return new Rect(); return new Rect();
} }
GUIStyle boxStyle = pageStyle.boxStyle; GUIStyle boxStyle = activePageStyle.boxStyle;
Rect innerRect = new Rect(outerRect.x + boxStyle.padding.left, Rect innerRect = new Rect(outerRect.x + boxStyle.padding.left,
outerRect.y + boxStyle.padding.top, outerRect.y + boxStyle.padding.top,
@ -587,5 +660,16 @@ namespace Fungus
return innerRect; return innerRect;
} }
/**
* Plays the button clicked sound effect
*/
public void PlayButtonClick()
{
if (clickSound != null)
{
audio.PlayOneShot(clickSound);
}
}
} }
} }

0
Assets/Fungus/Scripts/PageController.cs.meta → Assets/Fungus/Legacy/PageController.cs.meta

0
Assets/Fungus/Scripts/PageStyle.cs → Assets/Fungus/Legacy/PageStyle.cs

0
Assets/Fungus/Scripts/PageStyle.cs.meta → Assets/Fungus/Legacy/PageStyle.cs.meta

BIN
Assets/Fungus/Prefabs/PageStyle1.prefab → Assets/Fungus/Legacy/PageStyle1.prefab

Binary file not shown.

0
Assets/Fungus/Prefabs/PageStyle1.prefab.meta → Assets/Fungus/Legacy/PageStyle1.prefab.meta

BIN
Assets/Fungus/Prefabs/PageStyle2.prefab → Assets/Fungus/Legacy/PageStyle2.prefab

Binary file not shown.

0
Assets/Fungus/Prefabs/PageStyle2.prefab.meta → Assets/Fungus/Legacy/PageStyle2.prefab.meta

3
Assets/Fungus/Legacy/Readme.txt

@ -0,0 +1,3 @@
These files are included to support backwards compatibility for games created with earlier versions of Fungus.
They will be deleted in a future release so don’t use them!

4
Assets/Fungus/Legacy/Readme.txt.meta

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: afad86a262b5948f2982ede375a25b54
TextScriptImporter:
userData:

0
Assets/Fungus/Textures/StoryBox1.psd → Assets/Fungus/Legacy/StoryBox1.psd

0
Assets/Fungus/Textures/StoryBox1.psd.meta → Assets/Fungus/Legacy/StoryBox1.psd.meta

0
Assets/Fungus/Textures/StoryBox2.psd → Assets/Fungus/Legacy/StoryBox2.psd

0
Assets/Fungus/Textures/StoryBox2.psd.meta → Assets/Fungus/Legacy/StoryBox2.psd.meta

BIN
Assets/Fungus/Prefabs/Button.prefab

Binary file not shown.

BIN
Assets/Fungus/Prefabs/Dialog.prefab

Binary file not shown.

4
Assets/Fungus/Prefabs/Dialog.prefab.meta

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: c380eb5097e094010b380ed4e37cca24
NativeFormatImporter:
userData:

BIN
Assets/Fungus/Prefabs/AnchorGUITexture.prefab → Assets/Fungus/Prefabs/GUIButton.prefab

Binary file not shown.

0
Assets/Fungus/Prefabs/AnchorGUITexture.prefab.meta → Assets/Fungus/Prefabs/GUIButton.prefab.meta

BIN
Assets/Fungus/Prefabs/Game.prefab

Binary file not shown.

12
Assets/Fungus/Scripts/Button.cs

@ -27,6 +27,11 @@ namespace Fungus
*/ */
public string hideOnSetValue; public string hideOnSetValue;
/**
* Sound effect to play when button is clicked.
*/
public AudioClip clickSound;
float targetAlpha; float targetAlpha;
bool showButton; bool showButton;
@ -130,8 +135,11 @@ namespace Fungus
return; return;
} }
// Sound effect // Click sound effect
Game.GetInstance().PlayButtonClick(); if (clickSound != null)
{
AudioSource.PlayClipAtPoint(clickSound, Vector3.zero);
}
CommandQueue commandQueue = Game.GetInstance().commandQueue; CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.CallCommandMethod(buttonAction); commandQueue.CallCommandMethod(buttonAction);

80
Assets/Fungus/Scripts/CameraController.cs

@ -12,7 +12,31 @@ namespace Fungus
*/ */
public class CameraController : MonoBehaviour public class CameraController : MonoBehaviour
{ {
Game game; /**
* Full screen texture used for screen fade effect.
*/
public Texture2D screenFadeTexture;
/**
* Icon to display when swipe pan mode is active.
*/
public Texture2D swipePanIcon;
/**
* Position of continue and swipe icons in normalized screen space coords.
* (0,0) = top left, (1,1) = bottom right
*/
public Vector2 swipeIconPosition = new Vector2(1,0);
/**
* Fixed Z coordinate of main camera.
*/
public float cameraZ = -10f;
[HideInInspector]
public bool swipePanActive;
float fadeAlpha = 0f;
// Swipe panning control // Swipe panning control
View swipePanViewA; View swipePanViewA;
@ -27,9 +51,37 @@ namespace Fungus
Dictionary<string, CameraView> storedViews = new Dictionary<string, CameraView>(); Dictionary<string, CameraView> storedViews = new Dictionary<string, CameraView>();
void Start() void OnGUI()
{ {
game = Game.GetInstance(); if (swipePanActive)
{
// Draw the swipe panning icon
if (swipePanIcon)
{
float x = Screen.width * swipeIconPosition.x;
float y = Screen.height * swipeIconPosition.y;
float width = swipePanIcon.width;
float height = swipePanIcon.height;
x = Mathf.Max(x, 0);
y = Mathf.Max(y, 0);
x = Mathf.Min(x, Screen.width - width);
y = Mathf.Min(y, Screen.height - height);
Rect rect = new Rect(x, y, width, height);
GUI.DrawTexture(rect, swipePanIcon);
}
}
// Draw full screen fade texture
if (fadeAlpha < 1f)
{
// 1 = scene fully visible
// 0 = scene fully obscured
GUI.color = new Color(1,1,1, 1f - fadeAlpha);
GUI.depth = -1000;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), screenFadeTexture);
}
} }
public void Fade(float targetAlpha, float fadeDuration, Action fadeAction) public void Fade(float targetAlpha, float fadeDuration, Action fadeAction)
@ -39,7 +91,7 @@ namespace Fungus
public void FadeToView(View view, float fadeDuration, Action fadeAction) public void FadeToView(View view, float fadeDuration, Action fadeAction)
{ {
game.swipePanActive = false; swipePanActive = false;
// Fade out // Fade out
Fade(0f, fadeDuration / 2f, delegate { Fade(0f, fadeDuration / 2f, delegate {
@ -59,7 +111,7 @@ namespace Fungus
IEnumerator FadeInternal(float targetAlpha, float fadeDuration, Action fadeAction) IEnumerator FadeInternal(float targetAlpha, float fadeDuration, Action fadeAction)
{ {
float startAlpha = Game.GetInstance().fadeAlpha; float startAlpha = fadeAlpha;
float timer = 0; float timer = 0;
// If already at the target alpha then complete immediately // If already at the target alpha then complete immediately
@ -76,12 +128,12 @@ namespace Fungus
t = Mathf.Clamp01(t); t = Mathf.Clamp01(t);
Game.GetInstance().fadeAlpha = Mathf.Lerp(startAlpha, targetAlpha, t); fadeAlpha = Mathf.Lerp(startAlpha, targetAlpha, t);
yield return null; yield return null;
} }
} }
Game.GetInstance().fadeAlpha = targetAlpha; fadeAlpha = targetAlpha;
if (fadeAction != null) if (fadeAction != null)
{ {
@ -95,7 +147,7 @@ namespace Fungus
*/ */
public void CenterOnSprite(SpriteRenderer spriteRenderer) public void CenterOnSprite(SpriteRenderer spriteRenderer)
{ {
game.swipePanActive = false; swipePanActive = false;
Sprite sprite = spriteRenderer.sprite; Sprite sprite = spriteRenderer.sprite;
Vector3 extents = sprite.bounds.extents; Vector3 extents = sprite.bounds.extents;
@ -112,7 +164,7 @@ namespace Fungus
*/ */
public void PanToPosition(Vector3 targetPosition, float targetSize, float duration, Action arriveAction) public void PanToPosition(Vector3 targetPosition, float targetSize, float duration, Action arriveAction)
{ {
game.swipePanActive = false; swipePanActive = false;
if (duration == 0f) if (duration == 0f)
{ {
@ -215,7 +267,7 @@ namespace Fungus
*/ */
public void PanToPath(View[] viewList, float duration, Action arriveAction) public void PanToPath(View[] viewList, float duration, Action arriveAction)
{ {
game.swipePanActive = false; swipePanActive = false;
List<Vector3> pathList = new List<Vector3>(); List<Vector3> pathList = new List<Vector3>();
@ -280,7 +332,7 @@ namespace Fungus
PanToPosition(targetPosition, targetSize, duration, delegate { PanToPosition(targetPosition, targetSize, duration, delegate {
game.swipePanActive = true; swipePanActive = true;
if (arriveAction != null) if (arriveAction != null)
{ {
@ -294,7 +346,7 @@ namespace Fungus
*/ */
public void StopSwipePan() public void StopSwipePan()
{ {
game.swipePanActive = false; swipePanActive = false;
swipePanViewA = null; swipePanViewA = null;
swipePanViewB = null; swipePanViewB = null;
} }
@ -309,12 +361,12 @@ namespace Fungus
void SetCameraZ() void SetCameraZ()
{ {
Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, game.cameraZ); Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, cameraZ);
} }
void Update() void Update()
{ {
if (!game.swipePanActive) if (!swipePanActive)
{ {
return; return;
} }

796
Assets/Fungus/Scripts/Dialog.cs

@ -0,0 +1,796 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
/**
* Interface for Dialog implementations.
* This allows us to introduce new types of Dialog in future.
*/
public interface IDialog
{
/**
* Display a line of story text.
* If any options have previously been added using AddOption(), these will be displayed and the
* user must choose an option to continue. The sayAction parameter is ignored
* @param sayText The line of story text to be displayed.
* @param sayAction Delegate method to call when the player taps to continue.
*/
void Say(string sayText, Action sayAction);
/**
* Clear the current list of options previously added using AddOption().
*/
void ClearOptions();
/**
* Add an option to the list of options to be displayed on the next call to Say().
* @param optionText Text to display on the button for the option.
* @param optionAction Delegate method to call when the option button is pressed.
*/
void AddOption(string optionText, Action optionAction);
/**
* Sets a time limit for the player to choose between multiple options.
* If the player fails to make a choice in time then the timeoutAction delegate method is called.
* This setting only applies to the next Say() command and will be reset afterwards.
* @timeoutDuration Length of time for the player to choose an option.
* @timeoutAction Delegate method to call when player fails to choose an option.
*/
void SetTimeout(float timeoutDuration, Action timeoutAction);
}
[ExecuteInEditMode]
public class Dialog : MonoBehaviour, IDialog
{
/**
* Padding values for each side of the dialog.
* Values are in normalized screen coords [0..1]
*/
[Serializable]
public class Layout
{
/**
* Pushes the left dialog edge away from the left side of the screen.
*/
public bool leftSpace = false;
/**
* Pushes the top dialog edge away from the top side of the screen.
*/
public bool topSpace = true;
/**
* Pushes the right dialog edge away from the right side of the screen.
*/
public bool rightSpace = false;
/**
* Pushes the bottom dialog edge away from the bottom side of the screen.
*/
public bool bottomSpace = false;
/**
* Minimum dimensions of the dialog.
* The dialog may expand beyond these dimensions to fit content.
* Coordinates are in normalized screen coordinates [0..1]
*/
public Vector2 size = new Vector2(1f, 0.25f);
/**
* Offsets the dialog relative to the top left corner of the screen.
* Coordinates are in normalized screen coordinates [0..1]
*/
public Vector2 offset;
}
/**
* Layout values used to control size and position of the dialog.
*/
public Layout layout;
/**
* Defines the dialog display properties of a game character.
*/
[System.Serializable]
public class Character
{
/**
* Side of screen to display character image.
*/
public enum ImageSide
{
/// Display image on the left side of the dialog.
Left,
/// Display image on the right side of the dialog.
Right
}
/**
* Indentifier for this character for use with the SetCharacter() method.
*/
public string characterID;
/**
* Name text to display for the character.
* If empty then the name field is not displayed.
*/
public string name;
/**
* The color for the name text.
* This always overrides any color value specified in the NameStyle property.
*/
public Color nameColor;
/**
* Image to display for the character.
* If no image is specified then no character image will be displayed.
*/
public Texture2D image;
/**
* Side of dialog where character image will be displayed.
*/
public ImageSide imageSide;
}
/**
* List of game characters that can be displayed using this dialog.
*/
public Character[] characters;
/**
* Active character to use when displaying dialog.
*/
public int activeCharacter;
/**
* Writing speed for say text in Characters Per Second.
*/
public int writingSpeed = 100;
/**
* Sound to play while text is being written in the dialog.
*/
public AudioClip writingSound;
/**
* Loop the writing sound as long as text is being written.
*/
public bool loopWritingSound = true;
/**
* Sound effect to play when the player taps to continue.
*/
public AudioClip continueSound;
/**
* Icon to display under the story text when waiting for player to tap to continue.
*/
public Texture2D continueIcon;
/**
* Number of buttons to display in the same row when showing multiple options
*/
public int buttonsPerRow = 2;
/**
* Minimum width of each button as a fraction of the screen width [0..1].
* This is useful to create a column of buttons with matching width.
*/
public float minButtonWidth = 0;
/**
* Padding offset to apply around the character image, in pixels.
*/
public RectOffset imagePadding;
/**
* Scale of character image, specified as a fraction of current screen height [0..1].
*/
public float imageScale = 0.25f;
/**
* Animation frames for multiple choice time indicator
*/
public Texture2D[] timerAnimation;
/**
* Scale of timer image, specified as a fraction of current screen height [0..1].
*/
public float timerScale = 0.2f;
/**
* Sound effect to play when time indicator advances.
*/
public AudioClip timerSound;
/**
* Style for dialog box background.
*/
public GUIStyle boxStyle;
/**
* Style for name text.
*/
public GUIStyle nameTextStyle;
/**
* Style for say text.
*/
public GUIStyle sayTextStyle;
/**
* Style for option buttons
*/
public GUIStyle buttonStyle;
/**
* Allowed states for dialog
*/
public enum DialogMode
{
Idle,
Writing,
Waiting
}
/**
* Current state of dialog
*/
[HideInInspector]
public DialogMode dialogMode;
class Option
{
public string optionText;
public Action optionAction;
public Option(string _optionText, Action _optionAction)
{
optionText = _optionText;
optionAction = _optionAction;
}
}
List<Option> options = new List<Option>();
float timeoutDuration;
Action timeoutAction;
float timeoutTimer;
int timeoutAnimationIndex;
string sayText = "";
string previousSayText = "";
string displayedSayText = "";
Action deferredAction;
Action continueAction;
bool executeAsCommand;
float continueTimer;
bool instantCompleteText;
GameObject typingAudio;
// Cached versions of scaled style objects
GUIStyle cachedBoxStyle;
GUIStyle cachedNameTextStyle;
GUIStyle cachedSayTextStyle;
GUIStyle cachedButtonStyle;
void Start()
{
if (!Application.isPlaying)
{
return;
}
// Apply resolution independent scaling to styles
// Cache these so we're not creating lots of new objects every frame
cachedBoxStyle = ScaleFontSize(boxStyle);
cachedNameTextStyle = ScaleFontSize(nameTextStyle);
cachedSayTextStyle = ScaleFontSize(sayTextStyle);
cachedButtonStyle = ScaleFontSize (buttonStyle);
}
void Update()
{
writingSpeed = Math.Max(writingSpeed, 0);
buttonsPerRow = Math.Max(buttonsPerRow, 1);
minButtonWidth = Mathf.Max(minButtonWidth, 0);
imageScale = Mathf.Max(imageScale, 0);
timerScale = Mathf.Max(timerScale, 0);
layout.size.x = Mathf.Clamp01(layout.size.x);
layout.size.y = Mathf.Clamp01(layout.size.y);
layout.offset.x = Mathf.Clamp01(layout.offset.x);
layout.offset.y = Mathf.Clamp01(layout.offset.y);
if (!Application.isPlaying)
{
return;
}
if (continueTimer > 0)
{
continueTimer -= Time.deltaTime;
continueTimer = Mathf.Max(continueTimer, 0f);
}
if (sayText.Length == 0)
{
dialogMode = DialogMode.Idle;
}
// Check if the sayText field has been modified directly.
// If that has happened, then write the text with no Action
if (sayText != previousSayText &&
sayText.Length > 0)
{
StopAllCoroutines();
Say(sayText, null);
}
if (timeoutTimer > 0)
{
timeoutTimer -= Time.deltaTime;
timeoutTimer = Mathf.Max(timeoutTimer, 0f);
}
if (Application.isEditor)
{
// Live update of GUIStyles when running in editor
// Not bid deal if we're triggering garbage collection inside editor
cachedBoxStyle = ScaleFontSize(boxStyle);
cachedNameTextStyle = ScaleFontSize(nameTextStyle);
cachedSayTextStyle = ScaleFontSize(sayTextStyle);
cachedButtonStyle = ScaleFontSize(buttonStyle);
}
}
public void Say(string _sayText, Action sayAction)
{
string subbedText = Game.stringTable.SubstituteStrings(_sayText);
continueAction = sayAction;
previousSayText = subbedText;
if (timeoutDuration > 0 &&
options.Count > 0)
{
// Activate timeout timer
timeoutTimer = timeoutDuration;
}
WriteSayText(subbedText);
}
void WriteSayText(string _sayText)
{
// Disable quick continue for a short period to prevent accidental taps
continueTimer = 0.4f;
instantCompleteText = false;
sayText = _sayText;
// Hack to avoid displaying partial color tag text
if (_sayText.Contains("<"))
{
displayedSayText = _sayText;
}
else
{
// Use a coroutine to write the story text out over time
StartCoroutine(WriteStoryInternal());
}
}
// Coroutine to write story text out over a period of time
IEnumerator WriteStoryInternal()
{
// Zero CPS means write instantly
if (writingSpeed == 0)
{
displayedSayText = sayText;
yield break;
}
if (writingSound != null)
{
typingAudio = new GameObject();
typingAudio.AddComponent<AudioSource>();
typingAudio.audio.clip = writingSound;
typingAudio.audio.loop = loopWritingSound;
typingAudio.audio.Play();
}
dialogMode = DialogMode.Writing;
displayedSayText = "";
// Make one character visible at a time
float writeDelay = (1f / (float)writingSpeed);
float timeAccumulator = 0f;
int i = 0;
while (true)
{
if (instantCompleteText)
{
instantCompleteText = false;
displayedSayText = sayText;
break;
}
timeAccumulator += Time.deltaTime;
while (timeAccumulator > writeDelay)
{
i++;
timeAccumulator -= writeDelay;
}
if (i >= sayText.Length)
{
displayedSayText = sayText;
break;
}
else
{
string left = sayText.Substring(0, i + 1);
string right = sayText.Substring(i + 1);
displayedSayText = left;
displayedSayText += "<color=#FFFFFF00>";
displayedSayText += right;
displayedSayText += "</color>";
}
yield return null;
}
dialogMode = DialogMode.Waiting;
if (typingAudio != null)
{
Destroy(typingAudio);
}
}
GUIStyle ScaleFontSize(GUIStyle style)
{
GUIStyle styleCopy = new GUIStyle(style);
styleCopy.fontSize = Mathf.RoundToInt(styleCopy.fontSize * ((float)Screen.height / 768f));
return styleCopy;
}
public void ClearOptions()
{
options.Clear();
}
public void AddOption(string optionText, Action optionAction)
{
string subbedText = Game.stringTable.FormatLinkText(Game.stringTable.SubstituteStrings(optionText));
options.Add(new Option(subbedText, optionAction));
}
public void SetTimeout(float _timeoutDuration, Action _timeoutAction)
{
timeoutDuration = _timeoutDuration;
timeoutAction = _timeoutAction;
}
public void SetCharacter(string characterID)
{
for (int i = 0; i < characters.Length; ++i)
{
if (characters[i].characterID == characterID)
{
activeCharacter = i;
return;
}
}
Debug.Log ("Failed to find character ID " + characterID);
}
public virtual void OnGUI()
{
if (!Application.isPlaying ||
dialogMode == DialogMode.Idle ||
characters.Length == 0 ||
activeCharacter >= characters.Length)
{
return;
}
Rect areaRect = new Rect(layout.offset.x * Screen.width, layout.offset.y * Screen.height, Screen.width, Screen.height);
Rect sideImageRect = new Rect();
Rect dialogRect = new Rect();
Character character = characters[activeCharacter];
GUILayout.BeginArea(areaRect);
{
if (layout.topSpace)
{
GUILayout.FlexibleSpace();
}
GUILayout.BeginHorizontal();
{
if (layout.leftSpace)
{
GUILayout.FlexibleSpace();
}
GUILayout.BeginHorizontal(cachedBoxStyle, GUILayout.MinWidth(Screen.width * layout.size.x), GUILayout.MinHeight(Screen.height * layout.size.y));
{
if (character.imageSide == Character.ImageSide.Left &&
character.image != null)
{
// Reserve a rect for the side image based on the current screen height and imageScale
float sideImageHeight = Screen.height * imageScale;
float sideImageWidth = (sideImageHeight / character.image.height) * character.image.width;
float w = sideImageWidth + imagePadding.left + imagePadding.right;
float h = sideImageHeight + imagePadding.top + imagePadding.bottom;
sideImageRect = GUILayoutUtility.GetRect(w, h, GUILayout.Width(w), GUILayout.Height(h));
}
else if (character.imageSide == Character.ImageSide.Right)
{
DrawTimer();
}
GUILayout.BeginVertical(GUILayout.ExpandWidth(false));
{
if (character.name.Length > 0)
{
cachedNameTextStyle.normal.textColor = character.nameColor;
GUILayout.Label(new GUIContent(character.name), cachedNameTextStyle);
}
GUILayout.FlexibleSpace();
GUILayout.Label(new GUIContent(displayedSayText), cachedSayTextStyle);
GUILayout.FlexibleSpace();
// Show buttons for player options, or the continue icon if there are no options
if (options.Count > 0)
{
GUILayout.BeginHorizontal();
{
GUILayout.BeginVertical();
{
int buttonCount = 0;
for (int i = 0; i < options.Count; ++i)
{
if (buttonCount == 0)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
}
buttonCount++;
if (GUILayout.Button(options[i].optionText, cachedButtonStyle, GUILayout.MinWidth(Screen.width * minButtonWidth)))
{
if (options[i].optionAction == null)
{
deferredAction = DoNullAction;
executeAsCommand = false;
}
else
{
deferredAction = options[i].optionAction;
executeAsCommand = true;
}
}
if (buttonCount == buttonsPerRow ||
i == options.Count - 1)
{
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
buttonCount = 0;
}
}
}
GUILayout.EndVertical();
}
GUILayout.EndHorizontal();
}
else if (continueIcon != null)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
Rect continueButtonRect = GUILayoutUtility.GetRect(continueIcon.width,
continueIcon.height,
GUILayout.MaxWidth(continueIcon.width),
GUILayout.MaxHeight(continueIcon.height));
if (dialogMode == DialogMode.Waiting)
{
continueButtonRect.y += Mathf.Sin(Time.timeSinceLevelLoad * 15f) * (float)(continueIcon.height * 0.2f);
GUI.DrawTexture(continueButtonRect, continueIcon);
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
GUILayout.FlexibleSpace();
}
GUILayout.EndVertical();
if (character.imageSide == Character.ImageSide.Right &&
character.image != null)
{
// Reserve a rect for the side image based on the current screen height and imageScale
float sideImageHeight = Screen.height * imageScale;
float sideImageWidth = (sideImageHeight / character.image.height) * character.image.width;
float w = sideImageWidth + imagePadding.left + imagePadding.right;
float h = sideImageHeight + imagePadding.top + imagePadding.bottom;
sideImageRect = GUILayoutUtility.GetRect(w, h, GUILayout.Width(w), GUILayout.Height(h));
}
else if (character.imageSide == Character.ImageSide.Left)
{
DrawTimer();
}
}
GUILayout.EndHorizontal();
// Get rect of dialog for testing mouse hit later on
dialogRect = GUILayoutUtility.GetLastRect();
if (layout.rightSpace)
{
GUILayout.FlexibleSpace();
}
}
GUILayout.EndHorizontal();
if (layout.bottomSpace)
{
GUILayout.FlexibleSpace();
}
}
GUILayout.EndArea();
if (character.image != null)
{
// Adjust side image rect based on aspect ratio of the image.
float sideImageHeight = character.image.height * ((sideImageRect.width - imagePadding.left - imagePadding.right) / character.image.width);
sideImageRect.yMax = sideImageRect.yMin + sideImageHeight + imagePadding.bottom + imagePadding.top;
sideImageRect = imagePadding.Remove(sideImageRect);
// Adjust rect based on layout offset
sideImageRect.x += areaRect.x;
sideImageRect.y += areaRect.y;
// Draw side image
GUI.DrawTexture(sideImageRect, character.image);
}
bool clickedOnDialog = (Input.GetMouseButtonUp(0) && dialogRect.Contains(Event.current.mousePosition));
if (dialogMode == DialogMode.Writing)
{
if (clickedOnDialog || Input.GetKeyUp("space"))
{
instantCompleteText = true;
}
}
if (dialogMode == DialogMode.Waiting)
{
// Player can continue by clicking anywhere
if (options.Count == 0 &&
continueTimer == 0 &&
(clickedOnDialog || Input.GetKeyUp("space")))
{
if (continueSound != null)
{
AudioSource.PlayClipAtPoint(continueSound, new Vector3());
}
if (continueAction == null)
{
deferredAction = DoNullAction;
executeAsCommand = false;
}
else
{
deferredAction = continueAction;
executeAsCommand = false;
}
}
// Check if timeout timer has expired
if (options.Count > 0 &&
timeoutDuration > 0 &&
timeoutTimer == 0)
{
deferredAction = timeoutAction;
executeAsCommand = true;
}
}
// Execute any deferred actions on the last call to OnGUI
if (Event.current.type == EventType.Repaint)
{
if (deferredAction != null)
{
Action tempAction = deferredAction;
displayedSayText = "";
sayText = "";
deferredAction = null;
dialogMode = DialogMode.Idle;
ClearOptions();
timeoutAction = null;
timeoutDuration = 0;
timeoutTimer = 0;
timeoutAnimationIndex = 0;
if (executeAsCommand)
{
executeAsCommand = false;
// Execute next command
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.CallCommandMethod(tempAction);
}
else
{
tempAction();
}
}
}
}
void DrawTimer()
{
if (timeoutTimer > 0 &&
timerAnimation.Length > 0)
{
GUILayout.BeginHorizontal();
{
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
{
GUILayout.FlexibleSpace();
float t = 1f - timeoutTimer / timeoutDuration;
int index = Mathf.RoundToInt(Mathf.Lerp(0, timerAnimation.Length - 1, t));
// Play a sound effect for each animation frame
if (timeoutAnimationIndex != index &&
timerSound != null)
{
AudioSource.PlayClipAtPoint(timerSound, Vector3.zero);
}
timeoutAnimationIndex = index;
float height = Screen.height * timerScale;
GUILayout.Box(timerAnimation[timeoutAnimationIndex], new GUIStyle(), GUILayout.Height(height));
GUILayout.FlexibleSpace();
}
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
}
GUILayout.EndHorizontal();
}
}
void DoNullAction()
{}
}
}

8
Assets/Fungus/Scripts/Dialog.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d5fe4de5a03e34488bb65c75039a328d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

146
Assets/Fungus/Scripts/Game.cs

@ -14,6 +14,10 @@ namespace Fungus
/** /**
* Manages global game state and movement between rooms. * Manages global game state and movement between rooms.
*/ */
[RequireComponent(typeof(Dialog))]
[RequireComponent(typeof(CommandQueue))]
[RequireComponent(typeof(CameraController))]
[RequireComponent(typeof(PageController))]
public class Game : GameController public class Game : GameController
{ {
/** /**
@ -22,26 +26,11 @@ namespace Fungus
*/ */
public Room activeRoom; public Room activeRoom;
/**
* The style to apply when displaying Pages.
*/
public PageStyle activePageStyle;
/** /**
* Automatically display links between connected Rooms. * Automatically display links between connected Rooms.
*/ */
public bool showLinks = true; public bool showLinks = true;
/**
* Writing speed for page text.
*/
public int charactersPerSecond = 60;
/**
* Fixed Z coordinate of main camera.
*/
public float cameraZ = - 10f;
/** /**
* Time for fade transition to complete when moving to a different Room. * Time for fade transition to complete when moving to a different Room.
*/ */
@ -58,51 +47,9 @@ namespace Fungus
public float autoHideButtonDuration = 5f; public float autoHideButtonDuration = 5f;
/** /**
* Full screen texture used for screen fade effect. * Currently active Dialog object used to display character text and menus.
*/
public Texture2D screenFadeTexture;
/**
* Position of continue and swipe icons in normalized screen space coords.
* (0,0) = top left, (1,1) = bottom right
*/
public Vector2 iconPosition = new Vector2(1,1);
/**
* Icon to display when waiting for player input to continue
*/
public Texture2D continueIcon;
/**
* Icon to display when swipe pan mode is active.
*/
public Texture2D swipePanIcon;
/**
* Sound effect to play when buttons are clicked.
*/
public AudioClip buttonClickClip;
/**
* Default screen position for Page when player enters a Room.
*/
public PageController.PagePosition defaultPagePosition;
/**
* Default width and height of Page as a fraction of screen height [0..1]
*/ */
public Vector2 defaultPageScale = new Vector2(0.75f, 0.25f); public Dialog dialog;
/**
* Automatically center the Page when player is choosing from multiple options.
*/
public bool centerChooseMenu = true;
/**
* Width of Page as a fraction of screen width [0..1] when automatically centering a Choose menu.
* This setting only has an effect when centerChooseMenu is enabled.
*/
public float chooseMenuWidth = 0.5f;
/** /**
* Global dictionary of integer values for storing game state. * Global dictionary of integer values for storing game state.
@ -128,12 +75,6 @@ namespace Fungus
[HideInInspector] [HideInInspector]
public bool waiting; public bool waiting;
[HideInInspector]
public bool swipePanActive;
[HideInInspector]
public float fadeAlpha = 0f;
float autoHideButtonTimer; float autoHideButtonTimer;
static Game instance; static Game instance;
@ -157,14 +98,11 @@ namespace Fungus
public virtual void Start() public virtual void Start()
{ {
// Add components for additional game functionality // Acquire references to required components
commandQueue = gameObject.AddComponent<CommandQueue>();
cameraController = gameObject.AddComponent<CameraController>();
pageController = gameObject.AddComponent<PageController>();
AudioSource audioSource = gameObject.AddComponent<AudioSource>(); commandQueue = gameObject.GetComponent<CommandQueue>();
audioSource.playOnAwake = false; cameraController = gameObject.GetComponent<CameraController>();
audioSource.loop = true; pageController = gameObject.GetComponent<PageController>();
// Auto-hide buttons should be visible at start of game // Auto-hide buttons should be visible at start of game
autoHideButtonTimer = autoHideButtonDuration; autoHideButtonTimer = autoHideButtonDuration;
@ -195,70 +133,14 @@ namespace Fungus
} }
} }
void OnGUI() public IDialog GetDialog()
{ {
if (swipePanActive) if (dialog != null)
{
// Draw the swipe panning icon
if (swipePanIcon)
{
float x = Screen.width * iconPosition.x;
float y = Screen.height * iconPosition.y;
float width = swipePanIcon.width;
float height = swipePanIcon.height;
x = Mathf.Max(x, 0);
y = Mathf.Max(y, 0);
x = Mathf.Min(x, Screen.width - width);
y = Mathf.Min(y, Screen.height - height);
Rect rect = new Rect(x, y, width, height);
GUI.DrawTexture(rect, swipePanIcon);
}
}
if (pageController.mode == PageController.Mode.Say &&
pageController.FinishedWriting())
{ {
// Draw the continue icon return dialog as IDialog;
if (continueIcon)
{
float x = Screen.width * iconPosition.x;
float y = Screen.height * iconPosition.y;
float width = continueIcon.width;
float height = continueIcon.height;
x = Mathf.Max(x, 0);
y = Mathf.Max(y, 0);
x = Mathf.Min(x, Screen.width - width);
y = Mathf.Min(y, Screen.height - height);
Rect rect = new Rect(x, y, width, height);
GUI.DrawTexture(rect, continueIcon);
}
} }
// Draw full screen fade texture return pageController as IDialog;
if (fadeAlpha < 1f)
{
// 1 = scene fully visible
// 0 = scene fully obscured
GUI.color = new Color(1,1,1, 1f - fadeAlpha);
GUI.depth = -1000;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), screenFadeTexture);
}
}
/**
* Plays the button clicked sound effect
*/
public void PlayButtonClick()
{
if (buttonClickClip == null)
{
return;
}
audio.PlayOneShot(buttonClickClip);
} }
/** /**

386
Assets/Fungus/Scripts/GameController.cs

@ -9,7 +9,7 @@ namespace Fungus
*/ */
public class GameController : MonoBehaviour public class GameController : MonoBehaviour
{ {
#region General Methods #region Game Methods
/** /**
* Clears the command queue. * Clears the command queue.
@ -221,164 +221,33 @@ namespace Fungus
} }
#endregion #endregion
#region Page Methods #region Dialog Methods
/** /**
* Sets the screen space rectangle used to display the story text using a Page object. * Sets the Dialog object to use for displaying story text and options.
* Page objects can be edited visually in the Unity editor which is useful for accurate placement.
* The actual screen space rect used is based on both the Page bounds and the camera transform at the time the command is executed.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param page A Page object which defines the screen rect to use when rendering story text.
*/
public static void SetPage(Page page, PageController.Layout pageLayout = PageController.Layout.FullSize)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetPage(page, pageLayout));
}
/**
* Sets the screen space rectangle used to display the story text using a ScreenRect object.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param screenRect A ScreenRect object which defines a rect in normalized screen space coordinates.
*/
public static void SetPageRect(PageController.ScreenRect screenRect, PageController.Layout pageLayout = PageController.Layout.FullSize)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetPageRect(screenRect, pageLayout));
}
/**
* Sets the screen space rectangle used to display the story text.
* The rectangle coordinates are in normalized screen space. e.g. x1 = 0 (left), y1 = 0 (top) x2 = 1 (right) y2 = 1 (bottom).
* The origin is at the top left of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param x1 Page rect left coordinate in normalized screen space coords [0..1]
* @param y1 Page rect top coordinate in normalized screen space coords [0..1
* @param x2 Page rect right coordinate in normalized screen space coords [0..1]
* @param y2 Page rect bottom coordinate in normalized screen space coords [0..1]
* @param pageLayout Layout mode for positioning page within the rect.
*/
public static void SetPageRect(float x1, float y1, float x2, float y2, PageController.Layout pageLayout = PageController.Layout.FullSize)
{
PageController.ScreenRect screenRect = new PageController.ScreenRect();
screenRect.x1 = x1;
screenRect.y1 = y1;
screenRect.x2 = x2;
screenRect.y2 = y2;
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the top of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param scaleX Scales the width of the Page [0..1]. 1 = full screen width.
* @param scaleY Scales the height of the Page [0..1]. 1 = full screen height.
* @param pageLayout Controls how the Page is positioned and sized based on the displayed content.
*/
public static void SetPageTop(float scaleX, float scaleY, PageController.Layout pageLayout)
{
PageController.ScreenRect screenRect = PageController.CalcScreenRect(new Vector2(scaleX, scaleY), PageController.PagePosition.Top);
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the top of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
*/
public static void SetPageTop()
{
Vector2 pageScale = Game.GetInstance().defaultPageScale;
SetPageTop(pageScale.x, pageScale.y, PageController.Layout.FullSize);
}
/**
* Display story page at the middle of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param scaleX Scales the width of the Page [0..1]. 1 = full screen width.
* @param scaleY Scales the height of the Page [0..1]. 1 = full screen height.
* @param pageLayout Controls how the Page is positioned and sized based on the displayed content.
*/
public static void SetPageMiddle(float scaleX, float scaleY, PageController.Layout pageLayout)
{
PageController.ScreenRect screenRect = PageController.CalcScreenRect(new Vector2(scaleX, scaleY), PageController.PagePosition.Middle);
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the middle of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
*/
public static void SetPageMiddle()
{
Vector2 pageScale = Game.GetInstance().defaultPageScale;
SetPageMiddle(pageScale.x, pageScale.y, PageController.Layout.FitToMiddle);
}
/**
* Display story page at the bottom of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param scaleX Scales the width of the Page [0..1]. 1 = full screen width.
* @param scaleY Scales the height of the Page [0..1]. 1 = full screen height.
* @param pageLayout Controls how the Page is positioned and sized based on the displayed content.
*/
public static void SetPageBottom(float scaleX, float scaleY, PageController.Layout pageLayout)
{
PageController.ScreenRect screenRect = PageController.CalcScreenRect(new Vector2(scaleX, scaleY), PageController.PagePosition.Bottom);
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the bottom of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
*/ */
public static void SetPageBottom() public static void SetDialog(Dialog dialog)
{
Vector2 pageScale = Game.GetInstance().defaultPageScale;
SetPageBottom(pageScale.x, pageScale.y, PageController.Layout.FullSize);
}
/**
* Sets the active style for displaying the Page.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param pageStyle The style object to make active
*/
public static void SetPageStyle(PageStyle pageStyle)
{ {
CommandQueue commandQueue = Game.GetInstance().commandQueue; CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetPageStyle(pageStyle)); commandQueue.AddCommand(new Command.Call(delegate {
Game.GetInstance().dialog = dialog;
}));
} }
/** /**
* Obsolete! Use SetHeader() instead. * Sets the active Character within the current active Dialog.
* Each character has a distinct name, color & image.
*/ */
[System.Obsolete("use SetHeader() instead")] public static void SetCharacter(string characterID)
public static void Title(string titleText)
{
SetHeader(titleText);
}
/**
* Sets the header text displayed at the top of the page.
* The header text is only displayed when there is some story text or options to be shown.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param footerText The text to display as the header of the Page.
*/
public static void SetHeader(string headerText)
{ {
CommandQueue commandQueue = Game.GetInstance().commandQueue; CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetHeader(headerText)); commandQueue.AddCommand(new Command.Call(delegate {
} Dialog dialog = Game.GetInstance().dialog;
if (dialog != null)
/** {
* Sets the footer text displayed at the top of the page. dialog.SetCharacter(characterID);
* The footer text is only displayed when there is some story text or options to be shown. }
* This method returns immediately but it queues an asynchronous command for later execution. }));
* @param footerText The text to display as the footer of the Page.
*/
public static void SetFooter(string footerText)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetFooter(footerText));
} }
/** /**
@ -420,23 +289,19 @@ namespace Fungus
} }
/** /**
* Display all previously added options as buttons, with no text prompt. * Sets a time limit for choosing from a list of options.
* This method returns immediately but it queues an asynchronous command for later execution. * The timer will activate the next time a Say() command is executed that displays options.
*/ */
public static void Choose() public static void SetTimeout(float timeoutDuration, Action timeoutAction)
{
Choose("");
}
/**
* Displays a story text prompt, followed by all previously added options.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param chooseText The story text to be written above the list of options
*/
public static void Choose(string chooseText)
{ {
CommandQueue commandQueue = Game.GetInstance().commandQueue; CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.Choose(chooseText)); commandQueue.AddCommand(new Command.Call( delegate {
IDialog dialog = Game.GetInstance().GetDialog();
if (dialog != null)
{
dialog.SetTimeout(timeoutDuration, timeoutAction);
}
}));
} }
#endregion #endregion
@ -694,6 +559,203 @@ namespace Fungus
commandQueue.AddCommand(new Command.PlaySound(audioClip, volume)); commandQueue.AddCommand(new Command.PlaySound(audioClip, volume));
} }
#endregion
#region Obsolete Methods
// These methods are provided for backwards compatibility purposes and will be removed in a future release.
/**
* Sets the screen space rectangle used to display the story text using a Page object.
* Page objects can be edited visually in the Unity editor which is useful for accurate placement.
* The actual screen space rect used is based on both the Page bounds and the camera transform at the time the command is executed.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param page A Page object which defines the screen rect to use when rendering story text.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPage(Page page, PageController.Layout pageLayout = PageController.Layout.FullSize)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetPage(page, pageLayout));
}
/**
* Sets the screen space rectangle used to display the story text using a ScreenRect object.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param screenRect A ScreenRect object which defines a rect in normalized screen space coordinates.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageRect(PageController.ScreenRect screenRect, PageController.Layout pageLayout = PageController.Layout.FullSize)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetPageRect(screenRect, pageLayout));
}
/**
* Sets the screen space rectangle used to display the story text.
* The rectangle coordinates are in normalized screen space. e.g. x1 = 0 (left), y1 = 0 (top) x2 = 1 (right) y2 = 1 (bottom).
* The origin is at the top left of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param x1 Page rect left coordinate in normalized screen space coords [0..1]
* @param y1 Page rect top coordinate in normalized screen space coords [0..1
* @param x2 Page rect right coordinate in normalized screen space coords [0..1]
* @param y2 Page rect bottom coordinate in normalized screen space coords [0..1]
* @param pageLayout Layout mode for positioning page within the rect.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageRect(float x1, float y1, float x2, float y2, PageController.Layout pageLayout = PageController.Layout.FullSize)
{
PageController.ScreenRect screenRect = new PageController.ScreenRect();
screenRect.x1 = x1;
screenRect.y1 = y1;
screenRect.x2 = x2;
screenRect.y2 = y2;
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the top of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param scaleX Scales the width of the Page [0..1]. 1 = full screen width.
* @param scaleY Scales the height of the Page [0..1]. 1 = full screen height.
* @param pageLayout Controls how the Page is positioned and sized based on the displayed content.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageTop(float scaleX, float scaleY, PageController.Layout pageLayout)
{
PageController.ScreenRect screenRect = PageController.CalcScreenRect(new Vector2(scaleX, scaleY), PageController.PagePosition.Top);
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the top of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageTop()
{
Vector2 pageScale = Game.GetInstance().pageController.defaultPageScale;
SetPageTop(pageScale.x, pageScale.y, PageController.Layout.FullSize);
}
/**
* Display story page at the middle of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param scaleX Scales the width of the Page [0..1]. 1 = full screen width.
* @param scaleY Scales the height of the Page [0..1]. 1 = full screen height.
* @param pageLayout Controls how the Page is positioned and sized based on the displayed content.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageMiddle(float scaleX, float scaleY, PageController.Layout pageLayout)
{
PageController.ScreenRect screenRect = PageController.CalcScreenRect(new Vector2(scaleX, scaleY), PageController.PagePosition.Middle);
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the middle of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageMiddle()
{
Vector2 pageScale = Game.GetInstance().pageController.defaultPageScale;
SetPageMiddle(pageScale.x, pageScale.y, PageController.Layout.FitToMiddle);
}
/**
* Display story page at the bottom of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param scaleX Scales the width of the Page [0..1]. 1 = full screen width.
* @param scaleY Scales the height of the Page [0..1]. 1 = full screen height.
* @param pageLayout Controls how the Page is positioned and sized based on the displayed content.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageBottom(float scaleX, float scaleY, PageController.Layout pageLayout)
{
PageController.ScreenRect screenRect = PageController.CalcScreenRect(new Vector2(scaleX, scaleY), PageController.PagePosition.Bottom);
SetPageRect(screenRect, pageLayout);
}
/**
* Display story page at the bottom of the screen.
* This method returns immediately but it queues an asynchronous command for later execution.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageBottom()
{
Vector2 pageScale = Game.GetInstance().pageController.defaultPageScale;
SetPageBottom(pageScale.x, pageScale.y, PageController.Layout.FullSize);
}
/**
* Sets the active style for displaying the Page.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param pageStyle The style object to make active
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetPageStyle(PageStyle pageStyle)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetPageStyle(pageStyle));
}
/**
* Obsolete: Use SetHeader() instead.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void Title(string titleText)
{
SetHeader(titleText);
}
/**
* Sets the header text displayed at the top of the page.
* The header text is only displayed when there is some story text or options to be shown.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param footerText The text to display as the header of the Page.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetHeader(string headerText)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetHeader(headerText));
}
/**
* Sets the footer text displayed at the top of the page.
* The footer text is only displayed when there is some story text or options to be shown.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param footerText The text to display as the footer of the Page.
*/
[Obsolete("Pages are deprecated. Please use the new Dialog system instead.")]
public static void SetFooter(string footerText)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetFooter(footerText));
}
/**
* Display all previously added options as buttons, with no text prompt.
* This method returns immediately but it queues an asynchronous command for later execution.
*/
[Obsolete("No longer required. Use Say() instead.")]
public static void Choose()
{
Choose("");
}
/**
* Displays a story text prompt, followed by all previously added options.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param chooseText The story text to be written above the list of options
*/
[Obsolete("No longer required. Use Say() instead.")]
public static void Choose(string chooseText)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.Choose(chooseText));
}
#endregion #endregion
} }
} }

4
Assets/Fungus/Scripts/RoomTemplate.cs

@ -21,11 +21,11 @@ namespace Fungus
// Some common examples: // Some common examples:
// public View mainView; // public View mainView;
// public Page dialogPage; // public Dialog otherDialog;
// public Room otherRoom; // public Room otherRoom;
// public SpriteRenderer characterSprite; // public SpriteRenderer characterSprite;
// public Animator characterAnim; // public Animator characterAnim;
// public AudioClip musicClip; // public AudioClip musicSound;
/** /**
* OnEnter() is always called when the player enters the room * OnEnter() is always called when the player enters the room

BIN
Assets/Fungus/Sprites/ButtonBlank.psd

Binary file not shown.

BIN
Assets/Fungus/Sprites/FungusSmall.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

BIN
Assets/Fungus/Textures/BlueAlienHappy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

9
Assets/Fungus/Sprites/ButtonBlank.psd.meta → Assets/Fungus/Textures/BlueAlienHappy.png.meta

@ -1,11 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 0a068860829d14b48a48e6245e0e591c guid: 3109dcfd9a13c47fb9b3b75fb156a600
TextureImporter: TextureImporter:
serializedVersion: 2 serializedVersion: 2
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
enableMipMap: 0 enableMipMap: 0
linearTexture: 0 linearTexture: 1
correctGamma: 0 correctGamma: 0
fadeOut: 0 fadeOut: 0
borderMipMap: 0 borderMipMap: 0
@ -30,14 +30,15 @@ TextureImporter:
nPOTScale: 0 nPOTScale: 0
lightmap: 0 lightmap: 0
compressionQuality: 50 compressionQuality: 50
spriteMode: 1 spriteMode: 0
spriteExtrude: 1 spriteExtrude: 1
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: .5, y: .5} spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100 spritePixelsToUnits: 100
alphaIsTransparency: 1 alphaIsTransparency: 1
textureType: 8 textureType: 2
buildTargetSettings: [] buildTargetSettings: []
spriteSheet: spriteSheet:
sprites: [] sprites: []

BIN
Assets/Fungus/Textures/BlueAlienSad.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

19
Assets/Fungus/Textures/Icon.png.meta → Assets/Fungus/Textures/BlueAlienSad.png.meta

@ -1,11 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 6dce816d2c9914696b4c538a8cfb2726 guid: 5c1b43979efc34396b490f10158df9fd
TextureImporter: TextureImporter:
serializedVersion: 2 serializedVersion: 2
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
enableMipMap: 1 enableMipMap: 0
linearTexture: 0 linearTexture: 1
correctGamma: 0 correctGamma: 0
fadeOut: 0 fadeOut: 0
borderMipMap: 0 borderMipMap: 0
@ -20,14 +20,14 @@ TextureImporter:
grayScaleToAlpha: 0 grayScaleToAlpha: 0
generateCubemap: 0 generateCubemap: 0
seamlessCubemap: 0 seamlessCubemap: 0
textureFormat: -1 textureFormat: -3
maxTextureSize: 1024 maxTextureSize: 1024
textureSettings: textureSettings:
filterMode: -1 filterMode: -1
aniso: -1 aniso: 1
mipBias: -1 mipBias: -1
wrapMode: -1 wrapMode: 1
nPOTScale: 1 nPOTScale: 0
lightmap: 0 lightmap: 0
compressionQuality: 50 compressionQuality: 50
spriteMode: 0 spriteMode: 0
@ -35,9 +35,10 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: .5, y: .5} spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100 spritePixelsToUnits: 100
alphaIsTransparency: 0 alphaIsTransparency: 1
textureType: -1 textureType: 2
buildTargetSettings: [] buildTargetSettings: []
spriteSheet: spriteSheet:
sprites: [] sprites: []

BIN
Assets/Fungus/Textures/Button.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

BIN
Assets/Fungus/Textures/ButtonBlack.psd

Binary file not shown.

3
Assets/Fungus/Sprites/FungusSmall.png.meta → Assets/Fungus/Textures/ButtonBlack.psd.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 901325229c7f9494b8810f5a5b8add9b guid: 5177d6c51ac1a49ebb26f3f0c550fdc8
TextureImporter: TextureImporter:
serializedVersion: 2 serializedVersion: 2
mipmaps: mipmaps:
@ -35,6 +35,7 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: .5, y: .5} spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100 spritePixelsToUnits: 100
alphaIsTransparency: 0 alphaIsTransparency: 0
textureType: -1 textureType: -1

BIN
Assets/Fungus/Textures/ButtonOrange.psd

Binary file not shown.

3
Assets/Fungus/Textures/Button.png.meta → Assets/Fungus/Textures/ButtonOrange.psd.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 764e29ce895594123870bdd331a6a5d1 guid: 295b89efeb7ca4b9394a6de15b246ae1
TextureImporter: TextureImporter:
serializedVersion: 2 serializedVersion: 2
mipmaps: mipmaps:
@ -35,6 +35,7 @@ TextureImporter:
spriteMeshType: 1 spriteMeshType: 1
alignment: 0 alignment: 0
spritePivot: {x: .5, y: .5} spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100 spritePixelsToUnits: 100
alphaIsTransparency: 0 alphaIsTransparency: 0
textureType: -1 textureType: -1

BIN
Assets/Fungus/Textures/Continue.psd

Binary file not shown.

46
Assets/Fungus/Textures/Continue.psd.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 363331a570f304a599a78d96cb27ef9c
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/DialogBackground.psd

Binary file not shown.

46
Assets/Fungus/Textures/DialogBackground.psd.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 0975349aaf3674f38871e243a020e7f6
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/GreenAlienHappy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

46
Assets/Fungus/Textures/GreenAlienHappy.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: eb694ae0efdbf4249b07f412f75eac36
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/GreenAlienSad.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

46
Assets/Fungus/Textures/GreenAlienSad.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 25ad45ce587f8477eb40ee585c3d9bd7
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/Icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

BIN
Assets/Fungus/Textures/Mushroom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

46
Assets/Fungus/Textures/Mushroom.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 448e1c099245748b0b678d7459c7fd9e
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/PinkAlienHappy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

46
Assets/Fungus/Textures/PinkAlienHappy.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: a9d1d81f685ad4f6187e8fbc9741c0f7
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/PinkAlienSad.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

46
Assets/Fungus/Textures/PinkAlienSad.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: dfc218f95e17b40aebd7098a43eadb1c
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

0
Assets/Fungus/Textures/Fade.png → Assets/Fungus/Textures/ScreenFade.png

0
Assets/Fungus/Textures/Fade.png.meta → Assets/Fungus/Textures/ScreenFade.png.meta

5
Assets/Fungus/Textures/TimerFrames.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 365ec981102f744e7aadd03229567f5c
folderAsset: yes
DefaultImporter:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer.psd

Binary file not shown.

46
Assets/Fungus/Textures/TimerFrames/Timer.psd.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 5f7ee045af2534886a16662db3f7006d
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer00.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer00.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: ac73b583dc1504c6491a325836ad94b1
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer01.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 555662858b0934b0190253d207e5307c
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer02.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer02.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: ec79ba3732a0a4a97b4a76a6c17553ff
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer03.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer03.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: ea73cab89b59b4f9f8041f7e9cd1c67c
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer04.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer04.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 99864c2132a774486ad645356b9eb3e6
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer05.png

Binary file not shown.

46
Assets/Fungus/Textures/TimerFrames/Timer05.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: dfab90fb1315749dc846d15b6abd2a77
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer06.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer06.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 94135642b514c40af8c9f51c76a5f8f2
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer07.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer07.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 0b4a9c44132cf4a748b257b3c72fa778
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

BIN
Assets/Fungus/Textures/TimerFrames/Timer08.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

46
Assets/Fungus/Textures/TimerFrames/Timer08.png.meta

@ -0,0 +1,46 @@
fileFormatVersion: 2
guid: 48617ec39d5af466b9b5bda1ec6c5fc0
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

10
Assets/Fungus/Textures/license.txt

@ -1,2 +1,8 @@
The Swipe.png icon uses a Creative Commons license. Creative Commons Attribution
See http://www.icons8.com/ for more information. ============================
Swipe and Continue icons by icons8
http://www.icons8.com/
Buttons by BrightRetro
http://opengameart.org/content/various-gui-elements-part-2

BIN
Assets/FungusExample/Scenes/Example.unity

Binary file not shown.

9
Assets/FungusExample/Scripts/AudioRoom.cs

@ -27,14 +27,7 @@ namespace Fungus.Example
AddOption("Play a sound effect", PlaySound); AddOption("Play a sound effect", PlaySound);
AddOption("Back to menu", MainMenu); AddOption("Back to menu", MainMenu);
if (IsFirstVisit()) Say("We are the music makers, and we are the dreamers of dreams.");
{
Choose("We are the music makers, and we are the dreamers of dreams.");
}
else
{
Choose();
}
} }
void StartGameMusic() void StartGameMusic()

40
Assets/FungusExample/Scripts/PageRoom.cs → Assets/FungusExample/Scripts/DialogRoom.cs

@ -3,48 +3,36 @@ using System.Collections;
namespace Fungus.Example namespace Fungus.Example
{ {
public class PageRoom : Room public class DialogRoom : Room
{ {
// This is a reference to the menu room so we can transition back to the menu using MoveToRoom() // This is a reference to the menu room so we can transition back to the menu using MoveToRoom()
public Room menuRoom; public Room menuRoom;
// References to PageStyle prefab assets
// Use these with SetPageStyle() to change the Page rendering style
public PageStyle defaultStyle;
public PageStyle alternateStyle;
// The OnEnter() method is called whenever the player enters the room // The OnEnter() method is called whenever the player enters the room
void OnEnter() void OnEnter()
{ {
// Sets the header text on the page
SetHeader("The Mushroom");
// Each Say() command writes one line of text, followed by a continue button // Each Say() command writes one line of text, followed by a continue button
Say("One day in the forest, a mushroom grew."); Say("One day in the deep dark forest, a mushroom grew.");
Say("What am I doing here he wondered?");
SetCharacter("Mushroom");
SetPageTop(); Say("What am I doing here?");
Say("I think I will wait for a while and see if something happens."); Say("I think I will wait for a while and see if something happens.");
// Wait for a few seconds // Wait for a few seconds
Wait(3); Wait(2);
// Set the header text to the empty string to remove the page title
SetHeader("");
SetPageBottom();
Say("...");
Say("Hmmm. Nothing seems to be happening."); Say("Hmmm. Nothing seems to be happening.");
// Add a couple of user options // Add a some user options, you can add as many as you like.
// The first parameter is the option text // The first parameter is the option text
// The second parameter is the method to call if the user selects the option // The second parameter is the method to call if the user selects the option
// You can add as many options as you like
AddOption("Go to sleep", GoToSleep); AddOption("Go to sleep", GoToSleep);
AddOption("Produce spores", ProduceSpores); AddOption("Produce spores", ProduceSpores);
// Display all the previously added options, with a text prompt // Write some story text.
Choose("Whatever will I do?"); // The previously added options will be displayed as buttons.
Say("Whatever will I do?");
} }
void GoToSleep() void GoToSleep()
@ -70,22 +58,16 @@ namespace Fungus.Example
void ProduceSpores() void ProduceSpores()
{ {
// Set a PageStyle with no background box texture
SetPageStyle(alternateStyle);
Say("Yeah! I feel like doing some sporing!"); Say("Yeah! I feel like doing some sporing!");
Say("Wow - look at all these spores! COOL!"); Say("Wow - look at all these spores! COOL!");
// Set the default style with background box texture
SetPageStyle(defaultStyle);
// Sets a global value flag which we check above in GoToSleep // Sets a global value flag which we check above in GoToSleep
SetValue("spawned"); SetValue("spawned");
AddOption("So tired. I sleep now.", GoToSleep); AddOption("So tired. I sleep now.", GoToSleep);
AddOption("No way! More spores!", ProduceSpores); AddOption("No way! More spores!", ProduceSpores);
Choose("What will I do now?"); Say("What will I do now?");
} }
} }
} }

0
Assets/FungusExample/Scripts/PageRoom.cs.meta → Assets/FungusExample/Scripts/DialogRoom.cs.meta

13
Assets/FungusExample/Scripts/MenuRoom.cs

@ -5,7 +5,7 @@ namespace Fungus.Example
{ {
public class MenuRoom : Room public class MenuRoom : Room
{ {
public Room pageRoom; public Room dialogRoom;
public Room viewRoom; public Room viewRoom;
public Room spriteRoom; public Room spriteRoom;
public Room parallaxRoom; public Room parallaxRoom;
@ -14,20 +14,21 @@ namespace Fungus.Example
void OnEnter() void OnEnter()
{ {
SetPageMiddle(); SetCharacter("Narrator");
AddOption("Writing a story with Pages", MoveToWritingRoom); AddOption("Telling a story with the Dialog", MoveToDialogRoom);
AddOption("Controlling the camera with Views", MoveToViewRoom); AddOption("Controlling the camera with Views", MoveToViewRoom);
AddOption("Sprites and Animations", MoveToSpriteRoom); AddOption("Sprites and Animations", MoveToSpriteRoom);
AddOption("Swipe panning and parallax", MoveToParallaxRoom); AddOption("Swipe panning and parallax", MoveToParallaxRoom);
AddOption("Using Buttons", MoveToButtonsRoom); AddOption("Using Buttons", MoveToButtonsRoom);
AddOption("Playing music and sound effects", MoveToAudioRoom); AddOption("Playing music and sound effects", MoveToAudioRoom);
Choose("Choose an example");
Say("Choose an example");
} }
void MoveToWritingRoom() void MoveToDialogRoom()
{ {
MoveToRoom(pageRoom); MoveToRoom(dialogRoom);
} }
void MoveToViewRoom() void MoveToViewRoom()

29
Assets/FungusExample/Scripts/SpriteRoom.cs

@ -17,31 +17,44 @@ namespace Fungus.Example
ShowSprite(blueAlienSprite); ShowSprite(blueAlienSprite);
Say("Pink Alien says to Blue Alien..."); SetCharacter("PinkAlienHappy");
Say("...'Show me your funky moves!'"); Say("Hey Blue Alien!");
Say("Show me your funky moves!");
SetCharacter("BlueAlienHappy");
Say("Watch and learn Pinky!");
SetAnimatorTrigger(blueAlienAnim, "StartBlueWalk"); SetAnimatorTrigger(blueAlienAnim, "StartBlueWalk");
Say("Blue Alien starts to dance.");
Wait(4); Wait(4);
SetAnimatorTrigger(blueAlienAnim, "Stop"); SetAnimatorTrigger(blueAlienAnim, "Stop");
SetCharacter("PinkAlienHappy");
Say("Nice moves there Blue Alien!"); Say("Nice moves there Blue Alien!");
Say("Would you like a nice mushroom to sit down on?");
FadeSprite(redMushroomSprite, 1f, 1f); FadeSprite(redMushroomSprite, 1f, 1f);
Say("Maybe you want a nice mushroom to sit down on?"); SetCharacter("BlueAlienSad");
Say("Don't want to sit? Ok, no problem."); Say("I'd love to, but alas I cannot!");
Say("The artist didn't make a sitting animation for me.");
Say("It's a very rare genetic condition. Sniff.");
SetCharacter("PinkAlienSad");
Say("Oh! Sorry to hear that.");
Wait(1f);
FadeSprite(redMushroomSprite, 0f, 1f); FadeSprite(redMushroomSprite, 0f, 1f);
Say("Uh oh, you look like you're turning a little green after all that dancing!"); SetCharacter("PinkAlienSad");
Say("Uh... are you ok?");
Say("Looks like you're turning a little bit green after all that dancing!");
SetAnimatorTrigger(blueAlienAnim, "StartGreenWalk"); SetAnimatorTrigger(blueAlienAnim, "StartGreenWalk");
Wait(2f);
Say("Never mind, you'll feel better soon!"); SetCharacter("PinkAlienHappy");
Say("Never mind, I'm sure you'll feel better soon!");
} }
// This method is called by the Animation Event Listener component on the blue alien. // This method is called by the Animation Event Listener component on the blue alien.

2
Assets/FungusExample/Scripts/ViewRoom.cs

@ -20,7 +20,7 @@ namespace Fungus.Example
AddOption ("Give me the full tour", FullTour); AddOption ("Give me the full tour", FullTour);
AddOption("Back to menu", MoveToMenu); AddOption("Back to menu", MoveToMenu);
Choose("Wanna move the camera?"); Say("Wanna move the camera?");
} }
void MoveToMenu() void MoveToMenu()

BIN
ProjectSettings/EditorBuildSettings.asset

Binary file not shown.
Loading…
Cancel
Save