You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.9 KiB
74 lines
1.9 KiB
11 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
11 years ago
|
namespace Fungus.Example
|
||
11 years ago
|
{
|
||
11 years ago
|
public class DialogRoom : Room
|
||
11 years ago
|
{
|
||
11 years ago
|
// This is a reference to the menu room so we can transition back to the menu using MoveToRoom()
|
||
|
public Room menuRoom;
|
||
11 years ago
|
|
||
11 years ago
|
// The OnEnter() method is called whenever the player enters the room
|
||
|
void OnEnter()
|
||
|
{
|
||
|
// Each Say() command writes one line of text, followed by a continue button
|
||
11 years ago
|
Say("One day in the deep dark forest, a mushroom grew.");
|
||
|
|
||
|
SetCharacter("Mushroom");
|
||
11 years ago
|
|
||
11 years ago
|
Say("What am I doing here?");
|
||
11 years ago
|
Say("I think I will wait for a while and see if something happens.");
|
||
11 years ago
|
|
||
11 years ago
|
// Wait for a few seconds
|
||
11 years ago
|
Wait(2);
|
||
11 years ago
|
|
||
11 years ago
|
Say("Hmmm. Nothing seems to be happening.");
|
||
11 years ago
|
|
||
11 years ago
|
// Add a some user options, you can add as many as you like.
|
||
11 years ago
|
// The first parameter is the option text
|
||
|
// The second parameter is the method to call if the user selects the option
|
||
|
AddOption("Go to sleep", GoToSleep);
|
||
|
AddOption("Produce spores", ProduceSpores);
|
||
11 years ago
|
|
||
11 years ago
|
// Write some story text.
|
||
|
// The previously added options will be displayed as buttons.
|
||
|
Say("Whatever will I do?");
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
void GoToSleep()
|
||
|
{
|
||
|
// Check to see if a game value has been set
|
||
|
if (HasValue("spawned"))
|
||
|
{
|
||
|
Say("I am feeling rather sleepy after all that spawning!");
|
||
|
Say("Yawn! Good night world!");
|
||
|
|
||
|
// Leave the current room and enter the menu room
|
||
|
MoveToRoom(menuRoom);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Say("I'm not feeling tired. I'm a fresh mushroom!");
|
||
|
Say("Maybe I should spawn some spores?");
|
||
|
|
||
|
// Use Call() to call another method whenever you want.
|
||
|
Call(ProduceSpores);
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
void ProduceSpores()
|
||
|
{
|
||
|
Say("Yeah! I feel like doing some sporing!");
|
||
|
Say("Wow - look at all these spores! COOL!");
|
||
11 years ago
|
|
||
11 years ago
|
// Sets a global value flag which we check above in GoToSleep
|
||
|
SetValue("spawned");
|
||
11 years ago
|
|
||
11 years ago
|
AddOption("So tired. I sleep now.", GoToSleep);
|
||
|
AddOption("No way! More spores!", ProduceSpores);
|
||
11 years ago
|
|
||
11 years ago
|
Say("What will I do now?");
|
||
11 years ago
|
}
|
||
11 years ago
|
}
|
||
|
}
|