PowerQuest 0.19.0
|
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:
Properties | |
bool | IsDebugBuild [get] |
Returns true for developer builds, or if QUESTDEBUG is defined in player settings. Alternative to Debug.isDebugBuild , so you can have debug features enabled in non-developer builds. | |
bool | GameHasKeyboardFocus [get] |
Returns true if keyboard events should be processed by the game scripts. If a gui control is capturing keyboard, it returns false. | |
ICharacter | Player [get, set] |
Gets or sets the current player controlled character. | |
IInventory | ActiveInventory [get, set] |
Shortcut to the current player's active inventory (the one currently selected for use on things). You can use the shorter I.Active | |
int | InlineDialogResult [get] |
Retrieves the option that was picked in the last call to WaitForInlineDialog() | |
float | VerticalResolution [get] |
Returns the currentvertical resolution including any overrides from the current room. | |
float | DefaultVerticalResolution [get] |
Returns the project's vertical resolution set in PowerQuest. | |
QuestSettings | Settings [get] |
The game settings object. | |
float | TransitionFadeTime [get, set] |
Length of time transition between rooms takes. | |
string | DisplayBoxGui [get, set] |
The name of the gui used for "Display Text". | |
string | DialogTreeGui [get, set] |
The name of the gui used for Dialog Trees. | |
string | CustomSpeechGui [get, set] |
The name of the gui used for Custom Speech. | |
bool | AlwaysShowDisplayText [get, set] |
Whether "Display" text is shown regardless of the DialogDisplay setting. | |
eSpeechStyle | SpeechStyle [get, set] |
Controls how game speech captions are displayed. | |
bool | NextOccurrence [get] |
Continues a sequence of Occurrence checks, started with FirstOccurence. | |
bool | NextOption [get] |
Continues a if/else sequence starting with FirstOption. | |
Commands for empty blocking functions | |
YieldInstruction | ConsumeEvent [get] |
This is the same as Consume in quest scripts. It stops the script from falling back to Unhandled Event functions. | |
YieldInstruction | Break [get] |
This is the same as End in quest scripts. Empty functions need to return something and this stops the function consuming an update cycle like "yield break" does. | |
Access to other objects | |
ICamera | Camera [get] |
Convenient shortcut to the game camera. | |
ICursor | Cursor [get] |
Convenient shortcut to the Cursor. | |
Public Member Functions | |
void | InterruptNextLine (float secondsBeforeEndOfLine) |
The instruction for the next line of dialog will unblock early by bySeconds seconds. | |
void | SkipDialog (bool preventEarlySkip=true) |
Skips the current line of dialog,. | |
bool | SkipCutscene () |
Skips a currently active cutscene- Returns true if a cutscene was skipped. | |
bool | GetBlocked () |
Returns true if there's a blocking script currently running. | |
IGui | GetFocusedGui () |
Returns the currently focused gui. | |
bool | NavigateGui (eGuiNav input=eGuiNav.Ok) |
Allows navigation of gui by keyboard/controller. | |
bool | ConsumeGuiKey (eGuiNav input) |
Returns true if the specfied NavigateGui input was pressed or repeated (when held down after timer). Also 'consumes' the press event so other guis won't recieve it. | |
Coroutine | Display (string dialog, int id=-1) |
Display narrator dialog. | |
Coroutine | DisplayBG (string dialog, int id=-1) |
Display narrator dialog (without blocking) | |
void | StartCutscene () |
Flags the section of code as a cutscenes. If player presses esc, the game will skip forward until the next EndCutscene() | |
void | EndCutscene () |
Stops flagging a section of code as a cutscene. When plyer presses esc after a "StartCutscene", this is where they'll skip to. | |
bool | GetSkippingCutscene () |
Returns true when a cutscene (The code between StartCutscene() and EndCutscene() ) is currently being skipped. | |
void | ChangeRoomBG (IRoom room) |
Change the current room. Same as calling C.Player.Room = room;. | |
Coroutine | ChangeRoom (IRoom room) |
Change the current room. And blocks until after OnEnterAfterFade of the new room finishes. | |
Room | GetCurrentRoom () |
The room the player's in (R.Current) | |
void | DebugSetPreviousRoom (IRoom room) |
Debugging function that overrides the value of R.Previous . Useful for testing, paricularly in 'Play from` functions- (when using the [QuestPlayFromFunction] attribute) | |
Room | GetRoom (string scriptName) |
Retrieve a room by it's name. | |
Character | GetPlayer () |
Get the current player controlled character. | |
void | SetPlayer (ICharacter character, float cameraPanTime=0) |
Set the current player controlled character. If in another room, will trigger room transition. If in the same room, the camera will pan to the new character over 'cameraPanTime' seconds. | |
Character | GetCharacter (string scriptName) |
Retrieve a character by it's name. eg E.GetCharacter("Dave"); Usually you would just use C.Dave | |
Inventory | GetInventory (string scriptName) |
Retrieve an inventory item by it's name. Eg E.GetInventory("Screwdriver"); , Usually you would just use I.Screwdriver | |
DialogTree | GetDialogTree (string scriptName) |
Retrieve the currently active dialog. Eg. E.GetCurrentDialog().OptionOff(1); . Same as D.Current | |
Coroutine | WaitForInlineDialog (params string[] options) |
Gui | GetGui (string scriptName) |
Retreive a Gui item by it's name. | |
GameObject | GetSpawnablePrefab (string name) |
Find a prefab to spawn by name. Usage: E.GetSpawnablePrefab("SparkleEffect").Spawn(...);. | |
UnityEngine.Camera | GetCameraGui () |
Returns the Gui Camera. | |
Canvas | GetCanvas () |
Returns the Gui Canvas. | |
Vector2 | GetMousePosition () |
Returns the current mouse position in world space. | |
Vector2 | GetMousePositionGui () |
Returns the current mouse position in gui space. | |
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. | |
eQuestClickableType | GetMouseOverType () |
Returns the type of clickable that the mouse is over as an eQuestClickableType (eg, could be a character, hotspot, etc). | |
string | GetMouseOverDescription () |
Returns the display name of the object the mouse is over. | |
Vector2 | GetLastLookAt () |
Returns the "Look at" position of the last thing clicked. | |
Vector2 | GetLastWalkTo () |
Returns the "Walk To" position of the last thing clicked. | |
bool | ProcessClick (eQuestVerb verb) |
Starts the specified action for the verb on whatever the mouse is over (whatever the current GetMouseOverClickable() happens to be ). | |
bool | ProcessClick (eQuestVerb verb, IQuestClickable clickable, Vector2 mousePosition) |
Coroutine | HandleInteract (IHotspot target) |
Runs a "Use Hotspot" sequence. | |
Coroutine | HandleLookAt (IHotspot target) |
Runs a "Look at Hotspot" sequence. | |
Coroutine | HandleInventory (IHotspot target, IInventory item) |
Runs a "Use inventory on hostpot" sequence. | |
Coroutine | HandleInteract (IProp target) |
Runs a "Use Prop" sequence. | |
Coroutine | HandleLookAt (IProp target) |
Runs a "Look at Prop" sequence. | |
Coroutine | HandleInventory (IProp target, IInventory item) |
Runs a "Use inventory on Prop" sequence. | |
Coroutine | HandleInteract (ICharacter target) |
Runs a "Use Character" sequence. | |
Coroutine | HandleLookAt (ICharacter target) |
Runs a "Look at Character" sequence. | |
Coroutine | HandleInventory (ICharacter target, IInventory item) |
Runs a "Use inventory on Character" sequence. | |
Coroutine | HandleInteract (IInventory target) |
Runs a "Use Inventory" sequence. | |
Coroutine | HandleLookAt (IInventory target) |
Runs a "Look at Inventory" sequence. | |
Coroutine | HandleInventory (IInventory target, IInventory item) |
Runs a "Use inventory on Inventory" sequence. | |
Coroutine | HandleOption (IDialogTree dialog, string optionName) |
Runs a specific dialog option. NB: Does NOT start the dialog tree first. | |
void | DisableCancel () |
Stops sequence from being cancelled when user clicks something else while walking there. Place either at start of script to prevent first WalkTo being cancelable. | |
bool | FirstOccurrence (string uniqueString) |
Registers something "occurring", and returns whether it's the first time it's occurred. | |
int | Occurrence (string uniqueString) |
Registers something "occurring", and returns the number of time's it's occurred. Returns 0 the first time, then 1, etc. | |
int | GetOccurrenceCount (string uniqueString) |
Checks how many times something has occurred, without incrementing the occurrence. | |
bool | FirstOption (int count, string source=null) |
Start a sequence of options, passing in the total number of options in your list. Then call NextOption for the remaining options. | |
void | Restart () |
Returns a random int from 0 up to and including the "max". The id will not repeat until all ids have been used, and will not be repeated twice in a row. | |
void | Restart (IRoom room, string playFromFunction=null) |
Restart the game on a specific scene, optionally with a specific 'playFromFunction'. Useful for testing. | |
void | DisableAllClickablesExcept () |
Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass"); | |
void | DisableAllClickablesExcept (params string[] exceptions) |
Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass"); | |
void | DisableAllClickablesExcept (params IQuestClickableInterface[] exceptions) |
Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass"); | |
void | RestoreAllClickables () |
Helper function that restores clickables disabled with the DisableAllClickablesExcept function. | |
void | SetAllClickableCursors (string cursor, params string[] exceptions) |
Set all clickables to have a specific cursor temporarily, restore using RestoreAllClickableCursors(). Eg: E.SetAllClickableCursors("None", "Ropes","BrokenGlass"); | |
void | RestoreAllClickableCursors () |
Resets all clickable cursors after a call to "SetAllClickableCursors". | |
List< QuestSaveSlotData > | GetSaveSlotData () |
Returns a list of all save slot data. | |
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. | |
QuestSaveSlotData | GetLastSaveSlotData () |
Returns save slot data for the most recenly saved game. The data has info about the name, etc of the save file. | |
bool | SaveSettings () |
Saves game settings (volume, etc). This is a separate file to game saves. It's called already during game save, but can be done when options have changed too (like when leaving options menu) | |
bool | Save (int slot, string description, Texture2D imageOverride=null) |
Saves the game to a particular slot with a particular description. You may also override the image or provide extra slot data if desired, this will override the "Screenshot" that would otherwise be saved. | |
bool | RestoreSave (int slot) |
Restores the game from a particular slot. | |
bool | RestoreLastSave () |
Restores the last game saved. | |
bool | DeleteSave (int slot) |
Deletes a save game from a particular slot. | |
bool | GetRestoringGame () |
Returns true if game is in process of being restored from a save file. | |
void | AddSaveData (string name, object data, System.Action OnPostRestore=null) |
Advanced save/restore function: For saving data not in a QuestScript... | |
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. | |
T | GetScript< T > () |
PowerQuest internal function: 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;. | |
Timing/Waiting functions | |
Some of these have nice shortcuts in the quest script editor. Eg | |
Coroutine | Wait (float time=0.5f) |
Wait for time (or default 0.5 sec). In the Quest Script editor you can also just write ... with more or less dots for a shorter or longer time. | |
Coroutine | WaitSkip (float time=0.5f) |
Wait for time (or default 0.5 sec). Pressing button will skip the waiting. | |
Coroutine | WaitForTimer (string timerName, bool skippable=false) |
Wait for a timer to expire (use the name used with E.SetTimer()). Will remove the timer on complete, even if skipped. | |
Coroutine | WaitFor (PowerQuest.DelegateWaitForFunction functionToWaitFor, bool autoLoadQuestScript=true) |
Use this when you want to yield to another function that returns an IEnumerator. Note: In the Script Editor you can just do => MyFunction() | |
Coroutine | WaitWhile (System.Func< bool > condition, bool skippable=false) |
Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work! | |
Coroutine | WaitUntil (System.Func< bool > condition, bool skippable=false) |
Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work! | |
Coroutine | WaitForDialog () |
Waits until the current dialog has finished. Useful for waiting to the end of SayBG commands. | |
Coroutine | WaitForDialogSkip () |
Waits until the current dialog has finished, allowing it to be skipped. Useful when you start a SayBG, do a bunch of other things, then want to be able to skip the rest of the SayBG() | |
Coroutine | WaitForGui (IGui gui) |
Shows gui and waits for it to disappear. Useful for prompts. | |
void | DelayedInvoke (float time, System.Action functionToInvoke) |
Invokes the specified function after the specified time has elapsed (non-blocking). EG: E.DelayedInvoke(1, ()=>{ C.Player.FaceLeft(); } ); | |
void | StartBackgroundSequence (PowerQuest.DelegateWaitForFunction function) |
Starts a sequence in the background that can be stopped again StopBackgroundSequence(). Use it for background conversations. Since they can't be skippable, use SayBG and WaitForDialog. | |
void | StopBackgroundSequence (string function=null) |
Stops the background sequence with the specified name, or all background sequences if none specified. | |
Timers | |
void | SetTimer (string name, float time) |
Starts timer with a name, counting down from time in seconds. | |
bool | GetTimerExpired (string name) |
Checks whether the timer with specified name has expired. If the timeout set with SetTimer has elapsed, returns true. Otherwise, returns false. | |
float | GetTimer (string name) |
Returns the time remaining on the timer with specified name . | |
Enum shortcuts | |
void | Set< tEnum > (tEnum enumState) |
Sets an enum with the specified value. eg: E.Set(eDoor.Unlocked); . | |
bool | At< tEnum > (params tEnum[] enumStates) |
Returns true if this script has an enum with the specified enum value. Usage: if ( E.At(eSection.GettingMap) ) {...} . | |
bool | Is< tEnum > (params tEnum[] enumStates) |
Returns true if the enum has the specified value. Usage: if ( E.Is(eDoor.Unlocked) ) {...} . | |
bool | Reached< tEnum > (tEnum enumState) |
Returns true if reached state. Eg: if ( E.Reached(eProgress.FoundTreasure) ) . (Shorthand for m_state >= eState.myState ) | |
bool | After< tEnum > (tEnum enumState) |
Returns true if passed state. Eg: if ( E.After(eState.EscapedLava) ) . (Shorthand for m_state > eState.myState ) | |
bool | Before< tEnum > (tEnum enumState) |
Returns true if haven't reached state. Eg: if ( E.Before(eProgress.FoundTreasure) ) . (Shorthand for m_state < eState.myState ) | |
Screen Fade Functions | |
Color | FadeColor [get, set] |
Get/Set a temporary fade color. The fade color will be restored to FadeColorDefault after the next fade-in. | |
Color | FadeColorDefault [get, set] |
Get/Set the default fade color. | |
Coroutine | FadeIn (float time=0.2f, bool skippable=true) |
Fade the screen from the current FadeColor. | |
Coroutine | FadeOut (float time=0.2f, bool skippable=true) |
Fade the screen to the current FadeColor. | |
void | FadeInBG (float time=0.2f) |
Fade the screen from the current FadeColor (non-blocking) | |
void | FadeOutBG (float time=0.2f) |
Fade the screen to the current FadeColor (non-blocking) | |
Coroutine | FadeIn (float time, string source, bool skippable=true) |
Fade the screen from the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening. | |
Coroutine | FadeOut (float time, string source, bool skippable=true) |
Fade the screen to the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening. | |
void | FadeInBG (float time, string source) |
Fade the screen from the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening. | |
void | FadeOutBG (float time, string source) |
Fade the screen to the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening. | |
bool | GetFading () |
Returns true if a fadeout/in is currently active. | |
void | FadeColorRestore () |
Return fade color to its default value. | |
Pause/Unpause the game | |
bool | Paused [get, set] |
Gets or sets whether the game is paused. | |
void | Pause (string source=null) |
Pauses the game. Pass a string as a source in case multiple things have paused/unpaused the game. | |
void | UnPause (string source=null) |
Unpauses the game. Use the same source string you paused the game with (if any). | |
|
get |
This is the same as Consume
in quest scripts. It stops the script from falling back to Unhandled Event functions.
|
get |
This is the same as End
in quest scripts. Empty functions need to return something and this stops the function consuming an update cycle like "yield break" does.
|
get |
Returns true for developer builds, or if QUESTDEBUG
is defined in player settings. Alternative to Debug.isDebugBuild
, so you can have debug features enabled in non-developer builds.
|
get |
Convenient shortcut to the game camera.
|
get |
Convenient shortcut to the Cursor.
|
get |
Returns true if keyboard events should be processed by the game scripts. If a gui control is capturing keyboard, it returns false.
|
getset |
Get/Set a temporary fade color. The fade color will be restored to FadeColorDefault after the next fade-in.
|
getset |
Get/Set the default fade color.
|
getset |
Gets or sets whether the game is paused.
|
getset |
Gets or sets the current player controlled character.
|
getset |
Shortcut to the current player's active inventory (the one currently selected for use on things). You can use the shorter I.Active
|
get |
Retrieves the option that was picked in the last call to WaitForInlineDialog()
|
get |
Returns the currentvertical resolution including any overrides from the current room.
|
get |
Returns the project's vertical resolution set in PowerQuest.
|
get |
The game settings object.
|
getset |
Length of time transition between rooms takes.
|
getset |
The name of the gui used for "Display Text".
|
getset |
The name of the gui used for Dialog Trees.
|
getset |
The name of the gui used for Custom Speech.
|
getset |
Whether "Display" text is shown regardless of the DialogDisplay setting.
|
getset |
Controls how game speech captions are displayed.
|
get |
Continues a sequence of Occurrence checks, started with FirstOccurence.
Usage:
|
get |
Continues a if/else sequence starting with FirstOption.
Coroutine Wait | ( | float | time = 0.5f | ) |
Coroutine WaitSkip | ( | float | time = 0.5f | ) |
Wait for time (or default 0.5 sec). Pressing button will skip the waiting.
Coroutine WaitForTimer | ( | string | timerName, |
bool | skippable = false ) |
Wait for a timer to expire (use the name used with E.SetTimer()). Will remove the timer on complete, even if skipped.
Coroutine WaitFor | ( | PowerQuest.DelegateWaitForFunction | functionToWaitFor, |
bool | autoLoadQuestScript = true ) |
Use this when you want to yield to another function that returns an IEnumerator. Note: In the Script Editor you can just do => MyFunction()
Usage:
Create a new blocking function. Eg:
Then call it from any sequence. Eg:
Or if your function is used in multiple rooms, put it in your global script, then use => Globals.OpenDoor
Notes:
yield return MyFunction()
). This is so PQ knows its happening and if you change scenes or restore a game the function can be stopped, avoiding wierd bugs.yield return E.WaitFor( SimpleExampleFunction );
or yield return E.WaitFor( ()=>ExampleFunctionWithParams(C.Dave, "lol") );
Coroutine WaitWhile | ( | System.Func< bool > | condition, |
bool | skippable = false ) |
Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work!
Usage: yield return E.WaitWhile( ()=> C.Player.Walking )
Coroutine WaitUntil | ( | System.Func< bool > | condition, |
bool | skippable = false ) |
Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work!
Usage: yield return E.WaitUntil( ()=> C.Player.Position.x > 0 )
Coroutine WaitForDialog | ( | ) |
Waits until the current dialog has finished. Useful for waiting to the end of SayBG commands.
Coroutine WaitForDialogSkip | ( | ) |
Waits until the current dialog has finished, allowing it to be skipped. Useful when you start a SayBG, do a bunch of other things, then want to be able to skip the rest of the SayBG()
Coroutine WaitForGui | ( | IGui | gui | ) |
Shows gui and waits for it to disappear. Useful for prompts.
void DelayedInvoke | ( | float | time, |
System.Action | functionToInvoke ) |
Invokes the specified function after the specified time has elapsed (non-blocking). EG: E.DelayedInvoke(1, ()=>{ C.Player.FaceLeft(); } );
void StartBackgroundSequence | ( | PowerQuest.DelegateWaitForFunction | function | ) |
Starts a sequence in the background that can be stopped again StopBackgroundSequence(). Use it for background conversations. Since they can't be skippable, use SayBG and WaitForDialog.
Usage:
- Create a blocking function, eg: `IEnumerator BackgroundChatter()` - Call `E.StartBackroundSequence( BackgroundChatter );` - If you want to interrupt the sequence, call `E.StopBackgroundSequence("BackgroundChatter");` - These don't currently work when changing rooms, call `E.StopBackgroundSequence()` to stop all of them if leaving. - Since a regular mouse click skips dialog, and WaitSkip commands, you need to use: - `E.Wait(0.5f)` instead of `...` when waiting - `C.SayNoSkip("blah")` or `C.SayBG("blah");` followed by `E.WaitForDialog();`
Saving/Restoring:
- If the game is saved & restored when the background sequence is running, it'll be restarted. - If you want to be able to restore midway, you need to either: - Save a variable to skip over the already-done part of the sequence. - Or, have a chain of background sequences, so as one stops, it starts the next.
void StopBackgroundSequence | ( | string | function = null | ) |
Stops the background sequence with the specified name, or all background sequences if none specified.
Note: Only the base function will be stopped. You'll have to manually stop characters walking C.Dave.StopWalking();
, and talking E.CancelSay();
if desired.
void InterruptNextLine | ( | float | secondsBeforeEndOfLine | ) |
The instruction for the next line of dialog will unblock early by bySeconds seconds.
secondsBeforeEndOfLine | The script line following the next Say type command will execute early by this duration |
Speech text and any recorded VO will still be running in the background until completion when next instructions execute
void SkipDialog | ( | bool | preventEarlySkip = true | ) |
Skips the current line of dialog,.
bool SkipCutscene | ( | ) |
Skips a currently active cutscene- Returns true if a cutscene was skipped.
bool GetBlocked | ( | ) |
Returns true if there's a blocking script currently running.
IGui GetFocusedGui | ( | ) |
Returns the currently focused gui.
bool NavigateGui | ( | eGuiNav | input = eGuiNav.Ok | ) |
Allows navigation of gui by keyboard/controller.
Call from UpdateNoPause in GlobalScript when an input is held down. Eg.
This calls through to the Focused Gui's Navigate function, so alternatively you could call this yourself. Eg. E.MyGui.Navigate(eGuiNav.Right)
Returns true if handled by a gui.
bool ConsumeGuiKey | ( | eGuiNav | input | ) |
Returns true if the specfied NavigateGui input was pressed or repeated (when held down after timer). Also 'consumes' the press event so other guis won't recieve it.
Coroutine Display | ( | string | dialog, |
int | id = -1 ) |
Display narrator dialog.
Coroutine DisplayBG | ( | string | dialog, |
int | id = -1 ) |
Display narrator dialog (without blocking)
void StartCutscene | ( | ) |
Flags the section of code as a cutscenes. If player presses esc, the game will skip forward until the next EndCutscene()
void EndCutscene | ( | ) |
Stops flagging a section of code as a cutscene. When plyer presses esc after a "StartCutscene", this is where they'll skip to.
bool GetSkippingCutscene | ( | ) |
Returns true when a cutscene (The code between StartCutscene()
and EndCutscene()
) is currently being skipped.
Can be used to check if your own code should be skipped, or if a sequence you're in has been skipped.
eg: while ( m_boolToWaitFor && E.GetSkippingCutscene() == false ) yield return E.Wait(0);
Coroutine FadeIn | ( | float | time = 0.2f, |
bool | skippable = true ) |
Fade the screen from the current FadeColor.
Coroutine FadeOut | ( | float | time = 0.2f, |
bool | skippable = true ) |
Fade the screen to the current FadeColor.
void FadeInBG | ( | float | time = 0.2f | ) |
Fade the screen from the current FadeColor (non-blocking)
void FadeOutBG | ( | float | time = 0.2f | ) |
Fade the screen to the current FadeColor (non-blocking)
Coroutine FadeIn | ( | float | time, |
string | source, | ||
bool | skippable = true ) |
Fade the screen from the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
Coroutine FadeOut | ( | float | time, |
string | source, | ||
bool | skippable = true ) |
Fade the screen to the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
void FadeInBG | ( | float | time, |
string | source ) |
Fade the screen from the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
void FadeOutBG | ( | float | time, |
string | source ) |
Fade the screen to the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
bool GetFading | ( | ) |
Returns true if a fadeout/in is currently active.
void FadeColorRestore | ( | ) |
Return fade color to its default value.
void Pause | ( | string | source = null | ) |
Pauses the game. Pass a string as a source in case multiple things have paused/unpaused the game.
void UnPause | ( | string | source = null | ) |
Unpauses the game. Use the same source string you paused the game with (if any).
void SetTimer | ( | string | name, |
float | time ) |
Starts timer with a name, counting down from time
in seconds.
Use the same name to check whether the timer has finished by calling the GetTimerExpired(string name)
function. The name is NOT case sensitive.
You can check the current time remaining on a timer by calling the GetTimer(string name)
function, using the same name used to start the timer.
Pass time as 0 to disable a currently running timer.
NOTE: the timer will not tick while the game is paused.
Example:
Will set the timer "egg" to expire after 6 seconds.
Rolling your own timers:
AGS users are familiar with the SetTimer() function, which is why it is included. However, it's good to know how to make your own timers, it's a fundamental building block of game coding!
This is how most coders would implement a simple timer:
In your script body or header, add a float variable: float m_myTimer = 0;
When you want to start a timer, in an interaction script for example: m_myTimer = 4; // Set to 4 seconds
And in your Update function:
bool GetTimerExpired | ( | string | name | ) |
Checks whether the timer with specified name
has expired. If the timeout set with SetTimer has elapsed, returns true. Otherwise, returns false.
Note that this function will only return true once - after that, the timer will always return false until restarted
Example: (in UpdateBlocking)
will display a message when timer "egg" expires.
float GetTimer | ( | string | name | ) |
Returns the time remaining on the timer with specified name
.
void ChangeRoomBG | ( | IRoom | room | ) |
Change the current room. Same as calling C.Player.Room = room;.
Coroutine ChangeRoom | ( | IRoom | room | ) |
Change the current room. And blocks until after OnEnterAfterFade of the new room finishes.
Example: Have a player look through a window, show the other room, then change back, in a single script:
Room GetCurrentRoom | ( | ) |
The room the player's in (R.Current)
void DebugSetPreviousRoom | ( | IRoom | room | ) |
Debugging function that overrides the value of R.Previous
. Useful for testing, paricularly in 'Play from` functions- (when using the [QuestPlayFromFunction] attribute)
Room GetRoom | ( | string | scriptName | ) |
Retrieve a room by it's name.
Character GetPlayer | ( | ) |
Get the current player controlled character.
void SetPlayer | ( | ICharacter | character, |
float | cameraPanTime = 0 ) |
Set the current player controlled character. If in another room, will trigger room transition. If in the same room, the camera will pan to the new character over 'cameraPanTime' seconds.
Character GetCharacter | ( | string | scriptName | ) |
Retrieve a character by it's name. eg E.GetCharacter("Dave");
Usually you would just use C.Dave
Inventory GetInventory | ( | string | scriptName | ) |
Retrieve an inventory item by it's name. Eg E.GetInventory("Screwdriver");
, Usually you would just use I.Screwdriver
DialogTree GetDialogTree | ( | string | scriptName | ) |
Retrieve the currently active dialog. Eg. E.GetCurrentDialog().OptionOff(1);
. Same as D.Current
Retrieve an dialog tree by it's name. Eg: E.GetDialogTree("ChatWithBarney")
. Usually you would just use D.ChatWithBarney
Coroutine WaitForInlineDialog | ( | params string[] | options | ) |
Example:
Gui GetGui | ( | string | scriptName | ) |
Retreive a Gui item by it's name.
GameObject GetSpawnablePrefab | ( | string | name | ) |
Find a prefab to spawn by name. Usage: E.GetSpawnablePrefab("SparkleEffect").Spawn(...);.
UnityEngine.Camera GetCameraGui | ( | ) |
Returns the Gui Camera.
Canvas GetCanvas | ( | ) |
Returns the Gui Canvas.
Vector2 GetMousePosition | ( | ) |
Returns the current mouse position in world space.
Vector2 GetMousePositionGui | ( | ) |
Returns the current mouse position in gui space.
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.
eQuestClickableType GetMouseOverType | ( | ) |
Returns the type of clickable that the mouse is over as an eQuestClickableType (eg, could be a character, hotspot, etc).
string GetMouseOverDescription | ( | ) |
Returns the display name of the object the mouse is over.
Vector2 GetLastLookAt | ( | ) |
Returns the "Look at" position of the last thing clicked.
Vector2 GetLastWalkTo | ( | ) |
Returns the "Walk To" position of the last thing clicked.
bool 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 Returns true if the click resulted in a blocking function
Coroutine HandleInteract | ( | IHotspot | target | ) |
Runs a "Use Hotspot" sequence.
Coroutine HandleLookAt | ( | IHotspot | target | ) |
Runs a "Look at Hotspot" sequence.
Coroutine HandleInventory | ( | IHotspot | target, |
IInventory | item ) |
Runs a "Use inventory on hostpot" sequence.
Coroutine HandleInteract | ( | IProp | target | ) |
Runs a "Use Prop" sequence.
Coroutine HandleLookAt | ( | IProp | target | ) |
Runs a "Look at Prop" sequence.
Coroutine HandleInventory | ( | IProp | target, |
IInventory | item ) |
Runs a "Use inventory on Prop" sequence.
Coroutine HandleInteract | ( | ICharacter | target | ) |
Runs a "Use Character" sequence.
Coroutine HandleLookAt | ( | ICharacter | target | ) |
Runs a "Look at Character" sequence.
Coroutine HandleInventory | ( | ICharacter | target, |
IInventory | item ) |
Runs a "Use inventory on Character" sequence.
Coroutine HandleInteract | ( | IInventory | target | ) |
Runs a "Use Inventory" sequence.
Coroutine HandleLookAt | ( | IInventory | target | ) |
Runs a "Look at Inventory" sequence.
Coroutine HandleInventory | ( | IInventory | target, |
IInventory | item ) |
Runs a "Use inventory on Inventory" sequence.
Coroutine HandleOption | ( | IDialogTree | dialog, |
string | optionName ) |
Runs a specific dialog option. NB: Does NOT start the dialog tree first.
void DisableCancel | ( | ) |
Stops sequence from being cancelled when user clicks something else while walking there. Place either at start of script to prevent first WalkTo being cancelable.
bool FirstOccurrence | ( | string | uniqueString | ) |
int Occurrence | ( | string | uniqueString | ) |
Registers something "occurring", and returns the number of time's it's occurred. Returns 0 the first time, then 1, etc.
Usage:
int GetOccurrenceCount | ( | string | uniqueString | ) |
Checks how many times something has occurred, without incrementing the occurrence.
Usage:
bool FirstOption | ( | int | count, |
string | source = null ) |
Start a sequence of options, passing in the total number of options in your list. Then call NextOption for the remaining options.
Usage:
You can also pass a string "source", if you want it to remember which ones have been used before to avoid repeats until whole list is used.
void Restart | ( | ) |
Returns a random int from 0 up to and including the "max". The id will not repeat until all ids have been used, and will not be repeated twice in a row.
Restart the game from the first scene
void Restart | ( | IRoom | room, |
string | playFromFunction = null ) |
Restart the game on a specific scene, optionally with a specific 'playFromFunction'. Useful for testing.
void DisableAllClickablesExcept | ( | ) |
Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");
void DisableAllClickablesExcept | ( | params string[] | exceptions | ) |
Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");
void DisableAllClickablesExcept | ( | params IQuestClickableInterface[] | exceptions | ) |
Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");
void RestoreAllClickables | ( | ) |
Helper function that restores clickables disabled with the DisableAllClickablesExcept function.
void SetAllClickableCursors | ( | string | cursor, |
params string[] | exceptions ) |
Set all clickables to have a specific cursor temporarily, restore using RestoreAllClickableCursors(). Eg: E.SetAllClickableCursors("None", "Ropes","BrokenGlass");
void RestoreAllClickableCursors | ( | ) |
Resets all clickable cursors after a call to "SetAllClickableCursors".
void Set< tEnum > | ( | tEnum | enumState | ) |
Sets an enum with the specified value. eg: E.Set(eDoor.Unlocked);
.
This is a shortcut that makes c# enums much easier to use for tracking your puzzle stuff.
Usage:
Add your enums to your GlobalScript and/or Room script file headers. Eg:
Then use enum functions like this in any PowerQuest script:
tEnum | : | struct | |
tEnum | : | System.IConvertible |
bool At< tEnum > | ( | params tEnum[] | enumStates | ) |
Returns true if this script has an enum with the specified enum value. Usage: if ( E.At(eSection.GettingMap) ) {...}
.
You can check multiple at the same time too. Eg: if ( E.At(eSection.GettingMap, eSection.FindingShovel) )
This is the same as the Is() function and is shorthand for: if ( m_door == eSection.GettingMap ) {...}
tEnum | : | struct | |
tEnum | : | System.IConvertible | |
tEnum | : | System.IComparable |
bool Is< tEnum > | ( | params tEnum[] | enumStates | ) |
Returns true if the enum has the specified value. Usage: if ( E.Is(eDoor.Unlocked) ) {...}
.
You can check multiple at the same time too. Eg: if ( E.At(eDoor.Unlocked,eDoor.Open) )
This is the same as the At() function and is shorthand for: if ( m_door == eSection.Unlocked ) {...}
tEnum | : | struct | |
tEnum | : | System.IConvertible | |
tEnum | : | System.IComparable |
bool Reached< tEnum > | ( | tEnum | enumState | ) |
Returns true if reached state. Eg: if ( E.Reached(eProgress.FoundTreasure) )
. (Shorthand for m_state >= eState.myState
)
tEnum | : | struct | |
tEnum | : | System.IConvertible | |
tEnum | : | System.IComparable |
bool After< tEnum > | ( | tEnum | enumState | ) |
Returns true if passed state. Eg: if ( E.After(eState.EscapedLava) )
. (Shorthand for m_state > eState.myState
)
tEnum | : | struct | |
tEnum | : | System.IConvertible | |
tEnum | : | System.IComparable |
bool Before< tEnum > | ( | tEnum | enumState | ) |
Returns true if haven't reached state. Eg: if ( E.Before(eProgress.FoundTreasure) )
. (Shorthand for m_state < eState.myState
)
tEnum | : | struct | |
tEnum | : | System.IConvertible | |
tEnum | : | System.IComparable |
List< QuestSaveSlotData > GetSaveSlotData | ( | ) |
Returns a list of all save slot data.
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.
QuestSaveSlotData GetLastSaveSlotData | ( | ) |
Returns save slot data for the most recenly saved game. The data has info about the name, etc of the save file.
bool SaveSettings | ( | ) |
Saves game settings (volume, etc). This is a separate file to game saves. It's called already during game save, but can be done when options have changed too (like when leaving options menu)
bool Save | ( | int | slot, |
string | description, | ||
Texture2D | imageOverride = null ) |
Saves the game to a particular slot with a particular description. You may also override the image or provide extra slot data if desired, this will override the "Screenshot" that would otherwise be saved.
bool RestoreSave | ( | int | slot | ) |
Restores the game from a particular slot.
bool RestoreLastSave | ( | ) |
Restores the last game saved.
bool DeleteSave | ( | int | slot | ) |
Deletes a save game from a particular slot.
bool GetRestoringGame | ( | ) |
Returns true if game is in process of being restored from a save file.
Useful in OnEnterAfterFade if you're saving games in OnEnter. eg.
if ( E.GetRestoringGame() == false ) Save(1,"AutoSave");
Or maybe you need to set something up in OnEnterAfterFade when you restore there. eg.
if ( E.GetRestoringGame() ) E.FadeOutBG(0); Display: My eyes adjust to the darkness E.FadeIn(10);
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 object containing the data you want to save.
If you want to do things when the game is restored, pass the function you want ot be called as OnPostRestore
Notes:
Examples saving a simple data class:
Example using the [QuestSave] attribute:
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.
T GetScript< T > | ( | ) |
PowerQuest internal function: 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;.
T | : | QuestScript |