C# Class MouseWorldPosition, astrochimps

Script to filter all the mouse actions, including moving and clicking the buttons. Right now, we use left click to 'select' units and buildings, and right click to issue 'action' commands
Inheritance: MonoBehaviour
Exibir arquivo Open project: arcoelho01/astrochimps Class Usage Examples

Public Properties

Property Type Description
cursorAttack UnityEngine.Texture2D
cursorBuild UnityEngine.Texture2D
cursorCaptureRay UnityEngine.Texture2D
cursorGetInside UnityEngine.Texture2D
cursorGetOut UnityEngine.Texture2D
cursorNormal UnityEngine.Texture2D
cursorObject Transform
cursorRecycleEnable UnityEngine.Texture2D
cursorReprogramEnable UnityEngine.Texture2D
cursorSabotageEnable UnityEngine.Texture2D
cursorWalk UnityEngine.Texture2D
cursorWalkNotOk UnityEngine.Texture2D
gameBarBottom float
gameBarTop float
mouseHitPointNow Vector3
selectedObject Transform
targetPosition Vector3

Public Methods

Method Description
DeselectedObject ( ) : void

Called from an external script, when a unit is deselected

GetSelectedObject ( ) : Transform

Return the transform of the object currently selected, if any

IWantToSelectAPosition ( ) : void

Executed when a script wants to receive a position when a mouse button is clicked

PositionIsAlreadySelected ( ) : bool

Used after IWantToSelectAPosition by another script, so it will know when something is clicked and a position is selected

RemoveCursor ( ) : void

Removes the cursor projector, destroying its object Used when we have deselected a unit

SelectObject ( Transform targetObject ) : void
WhatIsThePositionSelected ( ) : Vector3

Used in conjuction with IWantToSelectAPosition and PositionIsAlreadySelected. If the position is already select, them polls this script to know what is this position

Private Methods

Method Description
Awake ( ) : void
CheckLeftMouseClick ( ) : void

Execute when the player presses the left mouse button Behaviours: select an unit, deselect-it if clicked in the terrain

CheckRightMouseClick ( ) : void

Execute when the player presses the right mouse button Behaviours: when a movable unit is selected, select where it should walk to

DoCheatingStuff ( ) : void

Do some cheats, for development purposes only

GetWhatIClicked ( ) : Transform

When the player presses the mouse button, check whatever is under the mouse cursor through a raycast

MouseOver ( ) : void

Checks the objects under the mouse cursor, showing its info in the info panel Actually, this is the main function of this script: it analyzes the context and set the mouse state and cursor accordingly

OnGUI ( ) : void

For now, the OnGUI only draws the custom mouse cursor

ShowSelectedPositionWithAProjector ( Vector3 position, float timeToShow ) : IEnumerator

When the player select a position to walk to, we show a cursor in the ground for visual aid

Start ( ) : void
Update ( ) : void

Method Details

DeselectedObject() public method

Called from an external script, when a unit is deselected
public DeselectedObject ( ) : void
return void

GetSelectedObject() public method

Return the transform of the object currently selected, if any
public GetSelectedObject ( ) : Transform
return Transform

IWantToSelectAPosition() public method

Executed when a script wants to receive a position when a mouse button is clicked
public IWantToSelectAPosition ( ) : void
return void

PositionIsAlreadySelected() public method

Used after IWantToSelectAPosition by another script, so it will know when something is clicked and a position is selected
public PositionIsAlreadySelected ( ) : bool
return bool

RemoveCursor() public method

Removes the cursor projector, destroying its object Used when we have deselected a unit
public RemoveCursor ( ) : void
return void

SelectObject() public method

public SelectObject ( Transform targetObject ) : void
targetObject Transform
return void

WhatIsThePositionSelected() public method

Used in conjuction with IWantToSelectAPosition and PositionIsAlreadySelected. If the position is already select, them polls this script to know what is this position
public WhatIsThePositionSelected ( ) : Vector3
return Vector3

Property Details

cursorAttack public_oe property

public Texture2D,UnityEngine cursorAttack
return UnityEngine.Texture2D

cursorBuild public_oe property

public Texture2D,UnityEngine cursorBuild
return UnityEngine.Texture2D

cursorCaptureRay public_oe property

public Texture2D,UnityEngine cursorCaptureRay
return UnityEngine.Texture2D

cursorGetInside public_oe property

public Texture2D,UnityEngine cursorGetInside
return UnityEngine.Texture2D

cursorGetOut public_oe property

public Texture2D,UnityEngine cursorGetOut
return UnityEngine.Texture2D

cursorNormal public_oe property

public Texture2D,UnityEngine cursorNormal
return UnityEngine.Texture2D

cursorObject public_oe property

public Transform cursorObject
return Transform

cursorRecycleEnable public_oe property

public Texture2D,UnityEngine cursorRecycleEnable
return UnityEngine.Texture2D

cursorReprogramEnable public_oe property

public Texture2D,UnityEngine cursorReprogramEnable
return UnityEngine.Texture2D

cursorSabotageEnable public_oe property

public Texture2D,UnityEngine cursorSabotageEnable
return UnityEngine.Texture2D

cursorWalk public_oe property

public Texture2D,UnityEngine cursorWalk
return UnityEngine.Texture2D

cursorWalkNotOk public_oe property

public Texture2D,UnityEngine cursorWalkNotOk
return UnityEngine.Texture2D

gameBarBottom public_oe property

public float gameBarBottom
return float

gameBarTop public_oe property

public float gameBarTop
return float

mouseHitPointNow public_oe static_oe property

public static Vector3 mouseHitPointNow
return Vector3

selectedObject public_oe property

public Transform selectedObject
return Transform

targetPosition public_oe static_oe property

public static Vector3 targetPosition
return Vector3