PowerQuest
IPowerQuest Interface Reference

Detailed Description

PowerQuest is the main hub for the adventure game engine (Access with E) - eg. E.Wait(2);.

Most adventure game functionality not tied to a room/character/item/etc is accessed through here. Including:

  • Pausing scripts with Wait commands
  • Displaying text boxes
  • Save/Restore games
  • Accessing Camera, Cursor, and other adventure game objects
  • Access to game settings
  • Triggering "interactions" of other objects
  • Little helper utilities

Properties

YieldInstruction Break [get]
 yield return this in an empty function (so it doesn't give an error, and doesn't consume an update cycle like a doing "yield break" does) More...
 
YieldInstruction ConsumeEvent [get]
 yield return this if nothing is happening in a function, but you don't want to fall back to an Unhandled Event More...
 
ICamera Camera [get]
 Convenient shortcut to the game camera. More...
 
ICursor Cursor [get]
 Convenient shortcut to the Cursor. More...
 
Color FadeColor [get, set]
 Get/Set the face colour. More...
 
bool Paused [get, set]
 Gets or sets whether the game is paused. More...
 
ICharacter Player [get, set]
 Gets or sets the current player controlled character. More...
 
IInventory ActiveInventory [get, set]
 Shortcut to the current player's active inventory (the one currently selected for use on things) More...
 
float VerticalResolution [get]
 Returns the currentvertical resolution including any overrides from the current room. More...
 
float DefaultVerticalResolution [get]
 Returns the project's vertical resolution set in PowerQuest. More...
 
QuestSettings Settings [get]
 The game settings object. More...
 

Public Member Functions

Coroutine Wait (float time=0.5f)
 Wait for time (or default 0.5 sec) More...
 
Coroutine WaitSkip (float time=0.5f)
 Wait for time (or default 0.5 sec). Pressing button will skip the waiting. More...
 
Coroutine WaitFor (PowerQuest.DelegateWaitForFunction functionToWaitFor)
 Use this when you want to yield to another function that returns an IEnumerator Usage: yield return E.WaitFor( SimpleExampleFunction ); or yield return E.WaitFor( ()=>ExampleFunctionWithParams(C.Dave, "lol") ); More...
 
Coroutine WaitWhile (System.Func< bool > condition, bool skippable=false)
 Use this when you want to wait until a condition is net. You need the ()=> to Usage: yield return E.WaitWhile( ()=> C.Player.Walking ) More...
 
Coroutine WaitUntil (System.Func< bool > condition, bool skippable=false)
 Use this when you want to wait until a condition is net. You need the ()=> to Usage: yield return E.WaitUntil( ()=> C.Player.Position.x > 0 ) More...
 
Coroutine WaitForDialog ()
 
Coroutine Display (string dialog, int id=-1)
 Display narrator dialog. More...
 
Coroutine DisplayBG (string dialog, int id=-1)
 Display narrator dialog (without blocking) More...
 
void StartCutscene ()
 Starts a cutscene. If player presses esc, the game will skip forward until the next EndCutscene() More...
 
void EndCutscene ()
 Ends a cutscene. When plyer presses esc after a "StartCutscene", this is where they'll skip to. More...
 
Coroutine FadeIn (float time=0.2f, bool skippable=true)
 Fade the screen from the current FadeColor. More...
 
Coroutine FadeOut (float time=0.2f, bool skippable=true)
 Fade the screen to the current FadeColor. More...
 
void FadeInBG (float time=0.2f)
 Fade the screen from the current FadeColor (non-blocking) More...
 
void FadeOutBG (float time=0.2f)
 Fade the screen to the current FadeColor (non-blocking) More...
 
bool GetFading ()
 Returns true if a fadeout/in is currently active. More...
 
void FadeColorRestore ()
 Return fade color to it's original value. More...
 
void Pause (string source=null)
 Pauses the game. Pass a string as a source in case multiple things have paused/unpaused the game. More...
 
void UnPause (string source=null)
 Unpauses the game. Use the same source string you paused the game with (if any). More...
 
void ChangeRoomBG (IRoom room)
 Change the current room. Same as calling C.Player.Room = room;. More...
 
Coroutine ChangeRoom (IRoom room)
 Change the current room. Can be yielded too, and blocks until after OnEnterAfterFade of the new room finishes. More...
 
GetScript< T > ()
 Retrieve a quest script by it's type. So you can access your functions/variables in your own scripts. Eg: E.GetScript<RoomKitchen>().m_tapsOn = true;. More...
 
Room GetCurrentRoom ()
 The room the player's in (R.Current) More...
 
Room GetRoom (string scriptName)
 Retrieve a room by it's name. More...
 
Character GetPlayer ()
 Get the current player controlled character. More...
 
void SetPlayer (ICharacter character)
 Set the current player controlled character. If in another room, will trigger room transition. More...
 
Character GetCharacter (string scriptName)
 Retrieve a character by it's name. More...
 
Inventory GetInventory (string scriptName)
 Retrieve an inventory item by it's name. More...
 
DialogTree GetCurrentDialog ()
 The Current dialog that's playing (if any) More...
 
DialogTree GetDialogTree (string scriptName)
 Retrieve an dialog tree by it's name. More...
 
Gui GetGui (string scriptName)
 Retreive a Gui item by it's name. More...
 
GameObject GetSpawnablePrefab (string name)
 Find a prefab to spawn by name. Usage: E.GetSpawnablePrefab("SparkleEffect").Spawn(...);. More...
 
UnityEngine.Camera GetCameraGui ()
 Returns the Gui Camera. More...
 
Canvas GetCanvas ()
 Returns the Gui Canvas. More...
 
Vector2 GetMousePosition ()
 Returns the current mouse position. More...
 
IQuestClickable GetMouseOverClickable ()
 Returns the "clickable object" that the mouse is over (could be a character, hotspot, etc). Returns null of the mouse cursor isn't over anything. More...
 
string GetMouseOverDescription ()
 Returns the display name of the object the mouse is over. More...
 
Vector2 GetLastLookAt ()
 Returns the "Look at" position of the last thing clicked. More...
 
Vector2 GetLastWalkTo ()
 Returns the "Walk To" position of the last thing clicked. More...
 
void SetTextSpeedMultiplier (float multiplier)
 Sets the text speed multiplier, for slowing/speeding up game text. More...
 
float GetTextSpeedMultiplier ()
 Gets the text speed multiplier, for slowing/speeding up game text. More...
 
void ProcessClick (eQuestVerb verb)
 Starts the specified action for the verb on whatever the mouse is over (whatever the current GetMouseOverClickable() happens to be ). More...
 
void ProcessClick (eQuestVerb verb, IQuestClickable clickable, Vector2 mousePosition)
 
Coroutine HandleInteract (IHotspot target)
 Runs a "Use Hotspot" sequence. More...
 
Coroutine HandleLookAt (IHotspot target)
 Runs a "Look at Hotspot" sequence. More...
 
Coroutine HandleInventory (IHotspot target, IInventory item)
 Runs a "Use inventory on hostpot" sequence. More...
 
Coroutine HandleInteract (IProp target)
 Runs a "Use Prop" sequence. More...
 
Coroutine HandleLookAt (IProp target)
 Runs a "Look at Prop" sequence. More...
 
Coroutine HandleInventory (IProp target, IInventory item)
 Runs a "Use inventory on Prop" sequence. More...
 
Coroutine HandleInteract (ICharacter target)
 Runs a "Use Character" sequence. More...
 
Coroutine HandleLookAt (ICharacter target)
 Runs a "Look at Character" sequence. More...
 
Coroutine HandleInventory (ICharacter target, IInventory item)
 Runs a "Use inventory on Character" sequence. More...
 
Coroutine HandleInteract (IInventory target)
 Runs a "Use Inventory" sequence. More...
 
Coroutine HandleLookAt (IInventory target)
 Runs a "Look at Inventory" sequence. More...
 
Coroutine HandleInventory (IInventory target, IInventory item)
 Runs a "Use inventory on Inventory" sequence. More...
 
void EnableCancel ()
 Allows the current sequence to be cancelled by clicking something else. Automatically done for first "WalkTo" in an interaction. More...
 
void DisableCancel ()
 Stops sequence from being cancelled when user clicks something else. Place either at start of script (to prevent first WalkTo being cancelable) or after an EnableCancel call. More...
 
void CancelCurrentInteraction ()
 Advanced function- allows you to cancel current sequence in progress. Use to interupt player interactions when something else happens (eg: on trigger or something in UpdateBlocking) More...
 
bool FirstOccurance (string uniqueString)
 Registers something "occuring", and returns whether it's the first time it's occurred. More...
 
int Occurrance (string thing)
 Registers something "occuring", and returns the number of time's it's occurred. More...
 
int GetOccuranceCount (string thing)
 Checks how many times something has occurred, without incrementing the occurance. More...
 
List< QuestSaveSlotData > GetSaveSlotData ()
 Returns a list of all save slot data. More...
 
QuestSaveSlotData GetSaveSlotData (int slot)
 Returns save slot data for a particular save game. The data has info about the name, etc of the save file. More...
 
bool Save (int slot, string description)
 Saves the game to a particular slot with a particular description. More...
 
bool RestoreSave (int slot)
 Restores the game from a particular slot. More...
 
bool DeleteSave (int slot)
 Deletes a save game from a particular slot. More...
 
void AddSaveData (string name, object data, System.Action OnPostRestore=null)
 Advanced save/restore function: For saving data not in a QuestScript... More...
 
void RemoveSaveData (string name)
 Advanced save/restore function: For aving data not in a QuestScript. Call this when you've called AddSaveData, but no longer want to save that data. More...
 

Property Documentation

◆ Break

YieldInstruction Break
get

yield return this in an empty function (so it doesn't give an error, and doesn't consume an update cycle like a doing "yield break" does)

◆ ConsumeEvent

YieldInstruction ConsumeEvent
get

yield return this if nothing is happening in a function, but you don't want to fall back to an Unhandled Event

◆ Camera

ICamera Camera
get

Convenient shortcut to the game camera.

◆ Cursor

ICursor Cursor
get

Convenient shortcut to the Cursor.

◆ FadeColor

Color FadeColor
getset

Get/Set the face colour.

◆ Paused

bool Paused
getset

Gets or sets whether the game is paused.

◆ Player

ICharacter Player
getset

Gets or sets the current player controlled character.

◆ ActiveInventory

IInventory ActiveInventory
getset

Shortcut to the current player's active inventory (the one currently selected for use on things)

◆ VerticalResolution

float VerticalResolution
get

Returns the currentvertical resolution including any overrides from the current room.

◆ DefaultVerticalResolution

float DefaultVerticalResolution
get

Returns the project's vertical resolution set in PowerQuest.

◆ Settings

QuestSettings Settings
get

The game settings object.

Member Function Documentation

◆ Wait()

Coroutine Wait ( float  time = 0.5f)

Wait for time (or default 0.5 sec)

◆ WaitSkip()

Coroutine WaitSkip ( float  time = 0.5f)

Wait for time (or default 0.5 sec). Pressing button will skip the waiting.

◆ WaitFor()

Coroutine WaitFor ( PowerQuest.DelegateWaitForFunction  functionToWaitFor)

Use this when you want to yield to another function that returns an IEnumerator Usage: yield return E.WaitFor( SimpleExampleFunction ); or yield return E.WaitFor( ()=>ExampleFunctionWithParams(C.Dave, "lol") );

Parameters
functionToWaitForA function that returns IEnumerator. Eg: "SimpleExampleFunction" or, "()=/>ExampleFunctionWithParams(C.Dave, 69)" if it has params

◆ WaitWhile()

Coroutine WaitWhile ( System.Func< bool >  condition,
bool  skippable = false 
)

Use this when you want to wait until a condition is net. You need the ()=> to Usage: yield return E.WaitWhile( ()=> C.Player.Walking )

◆ WaitUntil()

Coroutine WaitUntil ( System.Func< bool >  condition,
bool  skippable = false 
)

Use this when you want to wait until a condition is net. You need the ()=> to Usage: yield return E.WaitUntil( ()=> C.Player.Position.x > 0 )

◆ Display()

Coroutine Display ( string  dialog,
int  id = -1 
)

Display narrator dialog.

◆ DisplayBG()

Coroutine DisplayBG ( string  dialog,
int  id = -1 
)

Display narrator dialog (without blocking)

◆ StartCutscene()

void StartCutscene ( )

Starts a cutscene. If player presses esc, the game will skip forward until the next EndCutscene()

◆ EndCutscene()

void EndCutscene ( )

Ends a cutscene. When plyer presses esc after a "StartCutscene", this is where they'll skip to.

◆ FadeIn()

Coroutine FadeIn ( float  time = 0.2f,
bool  skippable = true 
)

Fade the screen from the current FadeColor.

◆ FadeOut()

Coroutine FadeOut ( float  time = 0.2f,
bool  skippable = true 
)

Fade the screen to the current FadeColor.

◆ FadeInBG()

void FadeInBG ( float  time = 0.2f)

Fade the screen from the current FadeColor (non-blocking)

◆ FadeOutBG()

void FadeOutBG ( float  time = 0.2f)

Fade the screen to the current FadeColor (non-blocking)

◆ GetFading()

bool GetFading ( )

Returns true if a fadeout/in is currently active.

◆ FadeColorRestore()

void FadeColorRestore ( )

Return fade color to it's original value.

◆ Pause()

void Pause ( string  source = null)

Pauses the game. Pass a string as a source in case multiple things have paused/unpaused the game.

◆ UnPause()

void UnPause ( string  source = null)

Unpauses the game. Use the same source string you paused the game with (if any).

◆ ChangeRoomBG()

void ChangeRoomBG ( IRoom  room)

Change the current room. Same as calling C.Player.Room = room;.

◆ ChangeRoom()

Coroutine ChangeRoom ( IRoom  room)

Change the current room. Can be yielded too, and blocks until after OnEnterAfterFade of the new room finishes.

◆ GetScript< T >()

T GetScript< T > ( )

Retrieve a quest script by it's type. So you can access your functions/variables in your own scripts. Eg: E.GetScript<RoomKitchen>().m_tapsOn = true;.

Type Constraints
T :QuestScript 

◆ GetCurrentRoom()

Room GetCurrentRoom ( )

The room the player's in (R.Current)

◆ GetRoom()

Room GetRoom ( string  scriptName)

Retrieve a room by it's name.

◆ GetPlayer()

Character GetPlayer ( )

Get the current player controlled character.

◆ SetPlayer()

void SetPlayer ( ICharacter  character)

Set the current player controlled character. If in another room, will trigger room transition.

◆ GetCharacter()

Character GetCharacter ( string  scriptName)

Retrieve a character by it's name.

◆ GetInventory()

Inventory GetInventory ( string  scriptName)

Retrieve an inventory item by it's name.

◆ GetCurrentDialog()

DialogTree GetCurrentDialog ( )

The Current dialog that's playing (if any)

◆ GetDialogTree()

DialogTree GetDialogTree ( string  scriptName)

Retrieve an dialog tree by it's name.

◆ GetGui()

Gui GetGui ( string  scriptName)

Retreive a Gui item by it's name.

◆ GetSpawnablePrefab()

GameObject GetSpawnablePrefab ( string  name)

Find a prefab to spawn by name. Usage: E.GetSpawnablePrefab("SparkleEffect").Spawn(...);.

◆ GetCameraGui()

UnityEngine.Camera GetCameraGui ( )

Returns the Gui Camera.

◆ GetCanvas()

Canvas GetCanvas ( )

Returns the Gui Canvas.

◆ GetMousePosition()

Vector2 GetMousePosition ( )

Returns the current mouse position.

◆ GetMouseOverClickable()

IQuestClickable GetMouseOverClickable ( )

Returns the "clickable object" that the mouse is over (could be a character, hotspot, etc). Returns null of the mouse cursor isn't over anything.

◆ GetMouseOverDescription()

string GetMouseOverDescription ( )

Returns the display name of the object the mouse is over.

◆ GetLastLookAt()

Vector2 GetLastLookAt ( )

Returns the "Look at" position of the last thing clicked.

◆ GetLastWalkTo()

Vector2 GetLastWalkTo ( )

Returns the "Walk To" position of the last thing clicked.

◆ SetTextSpeedMultiplier()

void SetTextSpeedMultiplier ( float  multiplier)

Sets the text speed multiplier, for slowing/speeding up game text.

◆ GetTextSpeedMultiplier()

float GetTextSpeedMultiplier ( )

Gets the text speed multiplier, for slowing/speeding up game text.

◆ ProcessClick()

void ProcessClick ( eQuestVerb  verb)

Starts the specified action for the verb on whatever the mouse is over (whatever the current GetMouseOverClickable() happens to be ).

This would usually be called from the OnMouseClick function in your global script

◆ HandleInteract() [1/4]

Coroutine HandleInteract ( IHotspot  target)

Runs a "Use Hotspot" sequence.

◆ HandleLookAt() [1/4]

Coroutine HandleLookAt ( IHotspot  target)

Runs a "Look at Hotspot" sequence.

◆ HandleInventory() [1/4]

Coroutine HandleInventory ( IHotspot  target,
IInventory  item 
)

Runs a "Use inventory on hostpot" sequence.

◆ HandleInteract() [2/4]

Coroutine HandleInteract ( IProp  target)

Runs a "Use Prop" sequence.

◆ HandleLookAt() [2/4]

Coroutine HandleLookAt ( IProp  target)

Runs a "Look at Prop" sequence.

◆ HandleInventory() [2/4]

Coroutine HandleInventory ( IProp  target,
IInventory  item 
)

Runs a "Use inventory on Prop" sequence.

◆ HandleInteract() [3/4]

Coroutine HandleInteract ( ICharacter  target)

Runs a "Use Character" sequence.

◆ HandleLookAt() [3/4]

Coroutine HandleLookAt ( ICharacter  target)

Runs a "Look at Character" sequence.

◆ HandleInventory() [3/4]

Coroutine HandleInventory ( ICharacter  target,
IInventory  item 
)

Runs a "Use inventory on Character" sequence.

◆ HandleInteract() [4/4]

Coroutine HandleInteract ( IInventory  target)

Runs a "Use Inventory" sequence.

◆ HandleLookAt() [4/4]

Coroutine HandleLookAt ( IInventory  target)

Runs a "Look at Inventory" sequence.

◆ HandleInventory() [4/4]

Coroutine HandleInventory ( IInventory  target,
IInventory  item 
)

Runs a "Use inventory on Inventory" sequence.

◆ EnableCancel()

void EnableCancel ( )

Allows the current sequence to be cancelled by clicking something else. Automatically done for first "WalkTo" in an interaction.

◆ DisableCancel()

void DisableCancel ( )

Stops sequence from being cancelled when user clicks something else. Place either at start of script (to prevent first WalkTo being cancelable) or after an EnableCancel call.

◆ CancelCurrentInteraction()

void CancelCurrentInteraction ( )

Advanced function- allows you to cancel current sequence in progress. Use to interupt player interactions when something else happens (eg: on trigger or something in UpdateBlocking)

◆ FirstOccurance()

bool FirstOccurance ( string  uniqueString)

Registers something "occuring", and returns whether it's the first time it's occurred.

Usage: if ( FirstOccurance("unlockdoor") ) C.Display("You unlock the door"); else C.Display("It's already unlocked");

◆ Occurrance()

int Occurrance ( string  thing)

Registers something "occuring", and returns the number of time's it's occurred.

Usage: if ( Occurance("knocked on door") < 3 ) C.Display("You knock on the door");

◆ GetOccuranceCount()

int GetOccuranceCount ( string  thing)

Checks how many times something has occurred, without incrementing the occurance.

Usage: if ( GetOccuranceCount("knocked on door") == 3 ) C.Doorman("Who's there?");

◆ GetSaveSlotData() [1/2]

List<QuestSaveSlotData> GetSaveSlotData ( )

Returns a list of all save slot data.

◆ GetSaveSlotData() [2/2]

QuestSaveSlotData GetSaveSlotData ( int  slot)

Returns save slot data for a particular save game. The data has info about the name, etc of the save file.

◆ Save()

bool Save ( int  slot,
string  description 
)

Saves the game to a particular slot with a particular description.

◆ RestoreSave()

bool RestoreSave ( int  slot)

Restores the game from a particular slot.

◆ DeleteSave()

bool DeleteSave ( int  slot)

Deletes a save game from a particular slot.

◆ AddSaveData()

void AddSaveData ( string  name,
object  data,
System.Action  OnPostRestore = null 
)

Advanced save/restore function: For saving data not in a QuestScript...

To use, call AddSaveData in Start, passing in a name for what you want to save, and the data to save as an object. Only simple data is saved, including arrays/lists/classes of data, but not unity game objects or components If you want to do things when the game is restored, pass the function you want ot be called as OnPostRestore

Remember to call "RemoveSaveData" if you no longer need to restore the data (eg: on destroy for temporary objects)

◆ RemoveSaveData()

void RemoveSaveData ( string  name)

Advanced save/restore function: For aving data not in a QuestScript. Call this when you've called AddSaveData, but no longer want to save that data.