Adventure Creator  1.57
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2017
AC.PlayerInput Class Reference
Inheritance diagram for AC.PlayerInput:

Public Member Functions

delegate bool InputButtonDelegate (string buttonName)
 
delegate float InputAxisDelegate (string axisName)
 
delegate Vector2 InputMouseDelegate (bool cusorIsLocked=false)
 
delegate bool InputMouseButtonDelegate (int button)
 
void OnAwake ()
 
void UpdateInput ()
 
bool ClickedRecently (bool checkForDouble=false)
 Checks if the player clicked within the last few frames. This is useful when checking for input in Actions, because Actions do not run every frame. More...
 
Vector2 GetMousePosition ()
 Gets the cursor's position in screen space. More...
 
Vector2 GetInvertedMouse ()
 Gets the y-inverted cursor position. This is useful because Menu Rects are drawn upwards, while screen space is measured downwards. More...
 
void InitialiseCursorLock (MovementMethod movementMethod)
 Initialises the cursor lock based on a given movement method. More...
 
bool IsCursorReadable ()
 Checks if the cursor's position can be read. This is only ever False if the cursor cannot be dragged on a touch-screen. More...
 
void DetectConversationNumerics ()
 
void DetectConversationInputs ()
 
void DrawDragLine ()
 
void UpdateDirectInput ()
 
void RemoveActiveArrows ()
 
void ResetClick ()
 
bool CanClick ()
 Checks if a mouse click will be registered. More...
 
bool CanDoubleClick ()
 Checks if a mouse double-click will be registered. More...
 
void SimulateInputButton (string button)
 Simulates the pressing of an Input button. More...
 
void SimulateInputAxis (string axis, float value)
 Simulates the pressing of an Input axis. More...
 
void SimulateInput (SimulateInputType input, string axis, float value)
 Simulates the pressing of an Input button or axis. More...
 
bool IsCursorLocked ()
 Checks if the cursor is locked. More...
 
bool InputAnyKey ()
 Checks if any input button is currently being pressed, simulated or otherwise. More...
 
float InputGetAxis (string axis)
 Replaces "Input.GetAxis", allowing for custom overrides. More...
 
bool InputGetButton (string axis)
 Replaces "Input.GetButton", allowing for custom overrides. More...
 
bool InputGetButtonDown (string axis, bool showError=false)
 Replaces "Input.GetButton", allowing for custom overrides. More...
 
bool InputGetButtonUp (string axis)
 Replaces "Input.GetButtonUp". More...
 
void _FixedUpdate ()
 
void SetFreeAimLock (bool _state)
 Enables or disables the free-aiming lock. More...
 
Vector2 GetDragVector ()
 Gets the drag vector. More...
 
void SetUpLock (bool state)
 Enables or disabled the Player's "up movement" lock. More...
 
void SetLeftLock (bool state)
 Enables or disabled the Player's "left movement" lock. More...
 
void SetRightLock (bool state)
 Enables or disabled the Player's "right movement" lock. More...
 
void SetDownLock (bool state)
 Enables or disabled the Player's "down movement" lock. More...
 
void SetJumpLock (bool state)
 Enables or disabled the Player's ability to jump. More...
 
bool CanDirectControlPlayer ()
 Checks if the Player can be directly-controlled during gameplay. More...
 
bool ActiveArrowsDisablingHotspots ()
 Checks if the active ArrowPrompt prevents Hotspots from being interactive. More...
 
void SetInGameCursorState (bool lockState)
 Sets the lock state of the in-game cursor manually. When locked, the cursor will be placed in the centre of the screen during gameplay. More...
 
bool GetInGameCursorState ()
 Gets the locked state of the cursor during gameplay (i.e. when the game is not paused). More...
 
bool IsDragObjectHeld (DragBase _dragBase)
 Checks if a specific DragBase object is being held by the player. More...
 
float GetDragMovementSlowDown ()
 Gets the factor by which Player movement is slowed when holding a DragBase object. More...
 
void SetTimeScale (float _timeScale)
 Sets the timeScale. More...
 
void SetTimeCurve (AnimationCurve _timeCurve)
 Assigns an AnimationCurve that controls the timeScale over time. More...
 
bool HasTimeCurve ()
 Checks if time is being controlled by an AnimationCurve. More...
 
DragState GetDragState ()
 Get what kind of object is currently being dragged (None, Player, Inventory, Menu, ScreenArrows, Moveable, _Camera). More...
 
MouseState GetMouseState ()
 Gets the current state of the mouse buttons (Normal, SingleClick, RightClick, DoubleClick, HeldDown, LetGo). More...
 
void ResetMouseClick ()
 
Vector2 GetMoveKeys ()
 Gets the input movement as a vector More...
 
bool IsPlayerControlledRunning ()
 Checks if the Player is running due to user-controlled input. More...
 
void SetActiveDragElement (MenuDrag menuDrag)
 Assigns a MenuDrag element as the one to drag. More...
 
bool LastClickWasDouble ()
 Checks if the last mouse click made was a double-click. More...
 
void ResetDragMovement ()
 
bool IsDragMoveSpeedOverWalkThreshold ()
 Checks if the magnitude of "Drag" Player input is above the minimum needed to move the Player. More...
 
bool IsMouseOnScreen ()
 Checks if the cursor's position is within the boundary of the screen. More...
 
Vector2 GetFreeAim ()
 Gets the free-aim input vector. More...
 
bool IsFreeAimingLocked ()
 Checks if free-aiming is locked. More...
 
bool AllDirectionsLocked ()
 Checks if the Player is prevented from being moved directly in all four directions. More...
 
void ReturnToGameplayAfterLoad ()
 
MainData SaveMainData (MainData mainData)
 Updates a MainData class with its own variables that need saving. More...
 
void LoadMainData (MainData mainData)
 Updates its own variables from a MainData class. More...
 
PlayerData SavePlayerData (PlayerData playerData)
 Updates a PlayerData class with its own variables that need saving. More...
 
void LoadPlayerData (PlayerData playerData)
 Updates its own variables from a PlayerData class. More...
 
void InputControlMenu (Menu menu)
 Controls an OnGUI-based Menu with keyboard or Controller inputs. More...
 
void EndConversation ()
 Ends the active Conversation.
 

Public Attributes

float timeScale = 1f
 
bool canKeyboardControlMenusDuringGameplay = false
 
PlayerMoveLock runLock = PlayerMoveLock.Free
 
string skipMovieKey = ""
 
float clickDelay = 0.3f
 
float doubleClickDelay = 1f
 
float cursorMoveSpeed = 4f
 
bool cameraLockSnap = false
 
ForceGameplayCursor forceGameplayCursor = ForceGameplayCursor.None
 
Conversation activeConversation = null
 
ArrowPrompt activeArrows = null
 
Container activeContainer = null
 
InputButtonDelegate InputGetButtonDownDelegate = null
 
InputButtonDelegate InputGetButtonUpDelegate = null
 
InputButtonDelegate InputGetButtonDelegate = null
 
InputAxisDelegate InputGetAxisDelegate = null
 
InputMouseButtonDelegate InputGetMouseButtonDelegate
 
InputMouseButtonDelegate InputGetMouseButtonDownDelegate
 
InputMouseDelegate InputMousePositionDelegate
 
InputMouseDelegate InputGetFreeAimDelegate
 

Detailed Description

This script recieves and processes all input, for use by other scripts. It should be placed on the GameEngine prefab.

Member Function Documentation

bool AC.PlayerInput.ActiveArrowsDisablingHotspots ( )

Checks if the active ArrowPrompt prevents Hotspots from being interactive.

Returns
True if the active ArrowPrompt prevents Hotspots from being interactive
bool AC.PlayerInput.AllDirectionsLocked ( )

Checks if the Player is prevented from being moved directly in all four directions.

Returns
True if the Player is prevented from being moved directly in all four direction
bool AC.PlayerInput.CanClick ( )

Checks if a mouse click will be registered.

Returns
True if a mouse click will be registered
bool AC.PlayerInput.CanDirectControlPlayer ( )

Checks if the Player can be directly-controlled during gameplay.

Returns
True if the Player can be directly-controlled during gameplay.
bool AC.PlayerInput.CanDoubleClick ( )

Checks if a mouse double-click will be registered.

Returns
True if a mouse double-click will be registered
bool AC.PlayerInput.ClickedRecently ( bool  checkForDouble = false)

Checks if the player clicked within the last few frames. This is useful when checking for input in Actions, because Actions do not run every frame.

Parameters
checkForDoubleIf True, then the check will be made for a double-click, rather than a single-click.
Returns
True if the player recently clicked.
void AC.PlayerInput.DetectConversationInputs ( )

Detects the pressing of the defined input buttons if they can be used to trigger a Conversation's dialogue options.

void AC.PlayerInput.DetectConversationNumerics ( )

Detects the pressing of the numeric keys if they can be used to trigger a Conversation's dialogue options.

void AC.PlayerInput.DrawDragLine ( )

Draws a drag-line on screen if the chosen movement method allows for one.

float AC.PlayerInput.GetDragMovementSlowDown ( )

Gets the factor by which Player movement is slowed when holding a DragBase object.

Returns
The factor by which Player movement is slowed when holding a DragBase object
DragState AC.PlayerInput.GetDragState ( )

Get what kind of object is currently being dragged (None, Player, Inventory, Menu, ScreenArrows, Moveable, _Camera).

Returns
What kind of object is currently being dragged (None, Player, Inventory, Menu, ScreenArrows, Moveable, _Camera).
Vector2 AC.PlayerInput.GetDragVector ( )

Gets the drag vector.

Returns
The drag vector
Vector2 AC.PlayerInput.GetFreeAim ( )

Gets the free-aim input vector.

Returns
The free-aim input vector
bool AC.PlayerInput.GetInGameCursorState ( )

Gets the locked state of the cursor during gameplay (i.e. when the game is not paused).

Returns
True if the in-game cursor is locked in the centre of the screen
Vector2 AC.PlayerInput.GetInvertedMouse ( )

Gets the y-inverted cursor position. This is useful because Menu Rects are drawn upwards, while screen space is measured downwards.

Returns
Gets the y-inverted cursor position. This is useful because Menu Rects are drawn upwards, while screen space is measured downwards.
Vector2 AC.PlayerInput.GetMousePosition ( )

Gets the cursor's position in screen space.

Returns
The cursor's position in screen space
MouseState AC.PlayerInput.GetMouseState ( )

Gets the current state of the mouse buttons (Normal, SingleClick, RightClick, DoubleClick, HeldDown, LetGo).

Returns
The current state of the mouse buttons (Normal, SingleClick, RightClick, DoubleClick, HeldDown, LetGo).
Vector2 AC.PlayerInput.GetMoveKeys ( )

Gets the input movement as a vector

Returns
The input movement as a vector
bool AC.PlayerInput.HasTimeCurve ( )

Checks if time is being controlled by an AnimationCurve.

Returns
True if time is being controlled by an AnimationCurve.
void AC.PlayerInput.InitialiseCursorLock ( MovementMethod  movementMethod)

Initialises the cursor lock based on a given movement method.

Parameters
movementMethodThe new movement method
bool AC.PlayerInput.InputAnyKey ( )

Checks if any input button is currently being pressed, simulated or otherwise.

Returns
True if any input button is currently being pressed, simulated or otherwise.
delegate float AC.PlayerInput.InputAxisDelegate ( string  axisName)

A delegate template for overriding input axis detection

delegate bool AC.PlayerInput.InputButtonDelegate ( string  buttonName)

A delegate template for overriding input button detection

void AC.PlayerInput.InputControlMenu ( Menu  menu)

Controls an OnGUI-based Menu with keyboard or Controller inputs.

Parameters
menuThe Menu to control
float AC.PlayerInput.InputGetAxis ( string  axis)

Replaces "Input.GetAxis", allowing for custom overrides.

Parameters
axisThe Input axis to detect
Returns
The Input axis' value
bool AC.PlayerInput.InputGetButton ( string  axis)

Replaces "Input.GetButton", allowing for custom overrides.

Parameters
axisThe Input button to detect
Returns
True if the Input button is pressed
bool AC.PlayerInput.InputGetButtonDown ( string  axis,
bool  showError = false 
)

Replaces "Input.GetButton", allowing for custom overrides.

Parameters
axisThe Input button to detect
showErrorIf True, then an error message will appear in the Console window if the button is not defined in the Input manager
Returns
True if the Input button is pressed
bool AC.PlayerInput.InputGetButtonUp ( string  axis)

Replaces "Input.GetButtonUp".

Parameters
axisThe Input button to detect
Returns
True if the Input button is released
delegate bool AC.PlayerInput.InputMouseButtonDelegate ( int  button)

A delegate template for overriding mouse button detection

delegate Vector2 AC.PlayerInput.InputMouseDelegate ( bool  cusorIsLocked = false)

A delegate template for overriding mouse position detection

bool AC.PlayerInput.IsCursorLocked ( )

Checks if the cursor is locked.

Returns
True if the cursor is locked
bool AC.PlayerInput.IsCursorReadable ( )

Checks if the cursor's position can be read. This is only ever False if the cursor cannot be dragged on a touch-screen.

Returns
True if the cursor's position can be read
bool AC.PlayerInput.IsDragMoveSpeedOverWalkThreshold ( )

Checks if the magnitude of "Drag" Player input is above the minimum needed to move the Player.

Returns
True if the magnitude of "Drag" Player input is above the minimum needed to move the Player.
bool AC.PlayerInput.IsDragObjectHeld ( DragBase  _dragBase)

Checks if a specific DragBase object is being held by the player.

<param name "_dragBase">The DragBase to check for

Returns
True if the DragBase object is being held by the Player
bool AC.PlayerInput.IsFreeAimingLocked ( )

Checks if free-aiming is locked.

Returns
True if free-aiming is locked
bool AC.PlayerInput.IsMouseOnScreen ( )

Checks if the cursor's position is within the boundary of the screen.

Returns
True if the cursor's position is within the boundary of the screen
bool AC.PlayerInput.IsPlayerControlledRunning ( )

Checks if the Player is running due to user-controlled input.

Returns
True if the Player is running due to user-controller input
bool AC.PlayerInput.LastClickWasDouble ( )

Checks if the last mouse click made was a double-click.

Returns
True if the last mouse click made was a double-click
void AC.PlayerInput.LoadMainData ( MainData  mainData)

Updates its own variables from a MainData class.

Parameters
mainDataThe MainData class to load from
void AC.PlayerInput.LoadPlayerData ( PlayerData  playerData)

Updates its own variables from a PlayerData class.

Parameters
playerDataThe PlayerData class to load from
void AC.PlayerInput.RemoveActiveArrows ( )

Disables the active ArrowPrompt.

void AC.PlayerInput.ResetClick ( )

Records the current click time, so that another click will not register for the duration of clickDelay.

void AC.PlayerInput.ResetDragMovement ( )

Resets the speed of "Drag" Player input.

void AC.PlayerInput.ResetMouseClick ( )

Resets the mouse click so that nothing else will be affected by it this frame.

void AC.PlayerInput.ReturnToGameplayAfterLoad ( )

Resets the mouse and assigns the correct gameState in StateHandler after loading a save game.

MainData AC.PlayerInput.SaveMainData ( MainData  mainData)

Updates a MainData class with its own variables that need saving.

Parameters
mainDataThe original MainData class
Returns
The updated MainData class
PlayerData AC.PlayerInput.SavePlayerData ( PlayerData  playerData)

Updates a PlayerData class with its own variables that need saving.

Parameters
playerDataThe original PlayerData class
Returns
The updated PlayerData class
void AC.PlayerInput.SetActiveDragElement ( MenuDrag  menuDrag)

Assigns a MenuDrag element as the one to drag.

Parameters
menuDragThe MenuDrag to begin dragging
void AC.PlayerInput.SetDownLock ( bool  state)

Enables or disabled the Player's "down movement" lock.

Parameters
stateIf True, the "up movement" lock is enabled, and the player cannot move down
void AC.PlayerInput.SetFreeAimLock ( bool  _state)

Enables or disables the free-aiming lock.

Parameters
_stateIf True, the free-aiming lock is enabled, and free-aiming is disabled
void AC.PlayerInput.SetInGameCursorState ( bool  lockState)

Sets the lock state of the in-game cursor manually. When locked, the cursor will be placed in the centre of the screen during gameplay.

Parameters
lockStateIf True, the cursor will be locked during gameplay
void AC.PlayerInput.SetJumpLock ( bool  state)

Enables or disabled the Player's ability to jump.

Parameters
stateIf True, the "jump" lock is enabled, and the player cannot jump
void AC.PlayerInput.SetLeftLock ( bool  state)

Enables or disabled the Player's "left movement" lock.

Parameters
stateIf True, the "up movement" lock is enabled, and the player cannot move left
void AC.PlayerInput.SetRightLock ( bool  state)

Enables or disabled the Player's "right movement" lock.

Parameters
stateIf True, the "up movement" lock is enabled, and the player cannot move right
void AC.PlayerInput.SetTimeCurve ( AnimationCurve  _timeCurve)

Assigns an AnimationCurve that controls the timeScale over time.

Parameters
_timeCurveThe AnimationCurve to use
void AC.PlayerInput.SetTimeScale ( float  _timeScale)

Sets the timeScale.

Parameters
_timeScaleThe new timeScale. A value of 0 will have no effect<param>
void AC.PlayerInput.SetUpLock ( bool  state)

Enables or disabled the Player's "up movement" lock.

Parameters
stateIf True, the "up movement" lock is enabled, and the player cannot move up
void AC.PlayerInput.SimulateInput ( SimulateInputType  input,
string  axis,
float  value 
)

Simulates the pressing of an Input button or axis.

Parameters
inputThe type of Input this is simulating (Button, Axis)
axisThe name of the Input button or axis
valueThe value to assign the Input axis, if input = SimulateInputType.Axis
void AC.PlayerInput.SimulateInputAxis ( string  axis,
float  value 
)

Simulates the pressing of an Input axis.

Parameters
axisThe name of the Input axis
valueThe value to assign the Input axis
void AC.PlayerInput.SimulateInputButton ( string  button)

Simulates the pressing of an Input button.

Parameters
buttonThe name of the Input button
void AC.PlayerInput.UpdateDirectInput ( )

Updates the input variables needed for Direct movement. This is called every frame by StateHandler.

void AC.PlayerInput.UpdateInput ( )

Updates the input handler. This is called every frame by StateHandler.

Member Data Documentation

ArrowPrompt AC.PlayerInput.activeArrows = null

The active ArrowPrompt

Container AC.PlayerInput.activeContainer = null

The active Container

Conversation AC.PlayerInput.activeConversation = null

The active Conversation

bool AC.PlayerInput.cameraLockSnap = false

If True, and Direct movement is used to control the Player, then the Player will not change direction. This is to avoid the Player moving in unwanted directions when the camera cuts.

bool AC.PlayerInput.canKeyboardControlMenusDuringGameplay = false

If True, Menus can be controlled via the keyboard or controller during gameplay (if SettingsManager.inputMethod = InputMethod.KeyboardOrController

float AC.PlayerInput.clickDelay = 0.3f

The minimum duration, in seconds, that can elapse between mouse clicks

float AC.PlayerInput.cursorMoveSpeed = 4f

The movement speed of a keyboard or controller-controlled cursor

float AC.PlayerInput.doubleClickDelay = 1f

The maximum duration, in seconds, between two successive mouse clicks to register a "double-click"

InputAxisDelegate AC.PlayerInput.InputGetAxisDelegate = null

A delegate for the InputGetAxis function, used to detect the value of an input axis

InputButtonDelegate AC.PlayerInput.InputGetButtonDelegate = null

A delegate for the InputGetButton function, used to detect when a button is held down

InputButtonDelegate AC.PlayerInput.InputGetButtonDownDelegate = null

A delegate for the InputGetButtonDown function, used to detect when a button is first pressed

InputButtonDelegate AC.PlayerInput.InputGetButtonUpDelegate = null

A delegate for the InputGetButtonUp function, used to detect when a button is released

InputMouseDelegate AC.PlayerInput.InputGetFreeAimDelegate

A delegate for the InputGetFreeAim function, used to get the free-aiming vector

InputMouseButtonDelegate AC.PlayerInput.InputGetMouseButtonDelegate

A delagate for the InputGetMouseButton function, used to detect mouse clicks

InputMouseButtonDelegate AC.PlayerInput.InputGetMouseButtonDownDelegate

A delagate for the InputGetMouseDownButton function, used to detect when a mouse button is first clicked

InputMouseDelegate AC.PlayerInput.InputMousePositionDelegate

A delagate for the InputMousePosition function, used to detect the mouse position

PlayerMoveLock AC.PlayerInput.runLock = PlayerMoveLock.Free

If True, then the Player prefab cannot run

string AC.PlayerInput.skipMovieKey = ""

The name of the Input button that skips movies played with ActionMove

float AC.PlayerInput.timeScale = 1f

The game's current Time.timeScale value