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
Afficher le fichier Open project: arcoelho01/astrochimps Class Usage Examples

Méthodes publiques

Свойство 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

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

GetSelectedObject() public méthode

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

IWantToSelectAPosition() public méthode

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

PositionIsAlreadySelected() public méthode

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

RemoveCursor() public méthode

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

SelectObject() public méthode

public SelectObject ( Transform targetObject ) : void
targetObject Transform
Résultat void

WhatIsThePositionSelected() public méthode

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
Résultat Vector3

Property Details

cursorAttack public_oe property

public Texture2D,UnityEngine cursorAttack
Résultat UnityEngine.Texture2D

cursorBuild public_oe property

public Texture2D,UnityEngine cursorBuild
Résultat UnityEngine.Texture2D

cursorCaptureRay public_oe property

public Texture2D,UnityEngine cursorCaptureRay
Résultat UnityEngine.Texture2D

cursorGetInside public_oe property

public Texture2D,UnityEngine cursorGetInside
Résultat UnityEngine.Texture2D

cursorGetOut public_oe property

public Texture2D,UnityEngine cursorGetOut
Résultat UnityEngine.Texture2D

cursorNormal public_oe property

public Texture2D,UnityEngine cursorNormal
Résultat UnityEngine.Texture2D

cursorObject public_oe property

public Transform cursorObject
Résultat Transform

cursorRecycleEnable public_oe property

public Texture2D,UnityEngine cursorRecycleEnable
Résultat UnityEngine.Texture2D

cursorReprogramEnable public_oe property

public Texture2D,UnityEngine cursorReprogramEnable
Résultat UnityEngine.Texture2D

cursorSabotageEnable public_oe property

public Texture2D,UnityEngine cursorSabotageEnable
Résultat UnityEngine.Texture2D

cursorWalk public_oe property

public Texture2D,UnityEngine cursorWalk
Résultat UnityEngine.Texture2D

cursorWalkNotOk public_oe property

public Texture2D,UnityEngine cursorWalkNotOk
Résultat UnityEngine.Texture2D

gameBarBottom public_oe property

public float gameBarBottom
Résultat float

gameBarTop public_oe property

public float gameBarTop
Résultat float

mouseHitPointNow public_oe static_oe property

public static Vector3 mouseHitPointNow
Résultat Vector3

selectedObject public_oe property

public Transform selectedObject
Résultat Transform

targetPosition public_oe static_oe property

public static Vector3 targetPosition
Résultat Vector3