C# Class RTSObject, ES2015C

Inheritance: MonoBehaviour
Afficher le fichier Open project: jgirald/ES2015C Class Usage Examples

Méthodes publiques

Свойство Type Description
baseMoveSpeed float
cost int
objectIconAttack Sprite
objectIconAttackRange Sprite
objectIconDefense Sprite
objectIconResource Sprite
objectIconSprite Sprite
objectName string
owner Player,
target RTSObject,

Protected Properties

Свойство Type Description
aiming bool
anim Animator
attacking bool
audio UnityEngine.AudioSource
baseAttackRange int
baseAttackSpeed float
baseAttackStrength int
baseBuildFactor float
baseDefense int?
creationSound UnityEngine.AudioClip
currentlySelected bool
dieSound UnityEngine.AudioClip
dying bool
ent LOSEntity,
fightSound UnityEngine.AudioClip
healthPercentage float
nearbyObjects List
programmedAttackPosition Vector3
remainingTimeToAttack float
remainingTimeToDead float
rigbody UnityEngine.Rigidbody

Private Properties

Свойство Type Description
BeginDead void
EndAttack void
OnMouseExit void
OnMouseOver void
PerformAttack void
UpdateDeadObject bool
updateSelection void

Méthodes publiques

Méthode Description
AssignBuildingProject ( Building, newProject ) : void

Assigns a new building project to this object.

AttackObject ( RTSObject, target ) : void

Begins an attack on the given target object. To stop the current attack sequence, pass null to this method.

BeginAttack ( RTSObject, newTarget ) : void

Begins an attack sequence on the given target.

CanAttack ( ) : bool

Tells if the object can attack.

CanBeAttacked ( ) : bool

Tell if the object can be attacked by military units.

CanBeBuilt ( ) : bool
CanBuild ( ) : bool
CanMove ( ) : bool

Tells if the object can change its position.

GetActions ( ) : Action[],

Get the list of actions available for this object.

GetAttackRange ( ) : float

Gets the distance at which the unit can attack, if it is a range unit (e.g. an archer). Otherwise, returns zero if the unit is not a range unit.

GetAttackSpeed ( ) : float

Gets the attack strengh that the unit has when it is attacking, in attack/second.

GetAttackStrength ( ) : int

Gets the attack strengh that the unit has when it is attacking.

GetDefense ( ) : int

Gets the defense points that the unit has when it is being attacked.

GetHarvestAmount ( ) : float

Get the current amount of resource that the unit has harvested.

GetHarvestType ( ) : ResourceType,

Get the current type of resource that the unit is harvesting.

GetMovementSpeed ( ) : float

Gets the movement speed of a object.

IsBuilding ( ) : bool

Checks if the object is currently building another object.

IsHarvesting ( ) : bool

Check if the unit is currently harvesting.

IsOwnedBy ( Player, owner ) : bool
MouseClick ( GameObject hitObject, Vector3 hitPoint, Player, controller ) : void
MoveTo ( Vector3 target, bool isRunning ) : void

Tells the object to start a free (non-attack) movement to the given position.

OnDestroy ( ) : void

This method is called when the object is destroyed. In this case, we need to update the paths for A* to no longer consider our destroyed object.

PerformAction ( string actionToPerform ) : void
ReplaceChildWithChildFromGameObjectTemplate ( GameObject newGameObjectTemplate ) : void

Replaces all the child nodes of the GameObject associated with this object, with the child nodes of the given GameObject template. This can be used, for instance, to exchange the model that is used to display the different versions (on construction, semidemolished, complete, ...) of a building.

SetSelection ( bool selected ) : void
TakeDamage ( int damage ) : void

Substract health points from this object.

makeCreationSound ( ) : void

Méthodes protégées

Méthode Description
AimAtTarget ( ) : void
Animating ( ) : void
Awake ( ) : void
CalculateCurrentHealth ( ) : void
CancelPath ( ) : void

Tell the object to cancel the movement path to the given position.

ExtendBounds ( Transform t, Bounds &b ) : void
HasPath ( ) : bool

Returns true if the unit has programmed a movement path to a given position.

OnGUI ( ) : void
SetNewPath ( Vector3 target, bool isRunning ) : void

Tells the object to move to the given position, by generating and following a route to the desired position.

Start ( ) : void
Update ( ) : void
UseWeapon ( ) : void
chargeSounds ( string objectName ) : void

Private Methods

Méthode Description
BeginDead ( ) : void

Begins the dead transition.

EndAttack ( ) : void

Cancels an attack sequence on the given target.

OnMouseExit ( ) : void
OnMouseOver ( ) : void
PerformAttack ( ) : void

If the object is performing an attack, inflicts damage to the target according to the attack speed, strength and target defense, or moves closer to the target in order to perform the attack.

UpdateDeadObject ( ) : bool

Checks if the required time between the unit having zero health points and the unit disappearing has elapsed.

updateSelection ( ) : void

Method Details

AimAtTarget() protected méthode

protected AimAtTarget ( ) : void
Résultat void

Animating() protected méthode

protected Animating ( ) : void
Résultat void

AssignBuildingProject() public méthode

Assigns a new building project to this object.
public AssignBuildingProject ( Building, newProject ) : void
newProject Building, The new project to assign, or null to deassign the current project.
Résultat void

AttackObject() public méthode

Begins an attack on the given target object. To stop the current attack sequence, pass null to this method.
public AttackObject ( RTSObject, target ) : void
target RTSObject, The target of the attack. If null is given, the attack will stop.
Résultat void

Awake() protected méthode

protected Awake ( ) : void
Résultat void

BeginAttack() public méthode

Begins an attack sequence on the given target.
public BeginAttack ( RTSObject, newTarget ) : void
newTarget RTSObject, The target of the attack.
Résultat void

CalculateCurrentHealth() protected méthode

protected CalculateCurrentHealth ( ) : void
Résultat void

CanAttack() public méthode

Tells if the object can attack.
public CanAttack ( ) : bool
Résultat bool

CanBeAttacked() public méthode

Tell if the object can be attacked by military units.
public CanBeAttacked ( ) : bool
Résultat bool

CanBeBuilt() public méthode

public CanBeBuilt ( ) : bool
Résultat bool

CanBuild() public méthode

public CanBuild ( ) : bool
Résultat bool

CanMove() public méthode

Tells if the object can change its position.
public CanMove ( ) : bool
Résultat bool

CancelPath() protected méthode

Tell the object to cancel the movement path to the given position.
protected CancelPath ( ) : void
Résultat void

ExtendBounds() protected méthode

protected ExtendBounds ( Transform t, Bounds &b ) : void
t Transform
b Bounds
Résultat void

GetActions() public méthode

Get the list of actions available for this object.
public GetActions ( ) : Action[],
Résultat Action[],

GetAttackRange() public méthode

Gets the distance at which the unit can attack, if it is a range unit (e.g. an archer). Otherwise, returns zero if the unit is not a range unit.
public GetAttackRange ( ) : float
Résultat float

GetAttackSpeed() public méthode

Gets the attack strengh that the unit has when it is attacking, in attack/second.
public GetAttackSpeed ( ) : float
Résultat float

GetAttackStrength() public méthode

Gets the attack strengh that the unit has when it is attacking.
public GetAttackStrength ( ) : int
Résultat int

GetDefense() public méthode

Gets the defense points that the unit has when it is being attacked.
public GetDefense ( ) : int
Résultat int

GetHarvestAmount() public méthode

Get the current amount of resource that the unit has harvested.
public GetHarvestAmount ( ) : float
Résultat float

GetHarvestType() public méthode

Get the current type of resource that the unit is harvesting.
public GetHarvestType ( ) : ResourceType,
Résultat ResourceType,

GetMovementSpeed() public méthode

Gets the movement speed of a object.
public GetMovementSpeed ( ) : float
Résultat float

HasPath() protected méthode

Returns true if the unit has programmed a movement path to a given position.
protected HasPath ( ) : bool
Résultat bool

IsBuilding() public méthode

Checks if the object is currently building another object.
public IsBuilding ( ) : bool
Résultat bool

IsHarvesting() public méthode

Check if the unit is currently harvesting.
public IsHarvesting ( ) : bool
Résultat bool

IsOwnedBy() public méthode

public IsOwnedBy ( Player, owner ) : bool
owner Player,
Résultat bool

MouseClick() public méthode

public MouseClick ( GameObject hitObject, Vector3 hitPoint, Player, controller ) : void
hitObject GameObject
hitPoint Vector3
controller Player,
Résultat void

MoveTo() public méthode

Tells the object to start a free (non-attack) movement to the given position.
public MoveTo ( Vector3 target, bool isRunning ) : void
target Vector3 The position we want the object to move to.
isRunning bool
Résultat void

OnDestroy() public méthode

This method is called when the object is destroyed. In this case, we need to update the paths for A* to no longer consider our destroyed object.
public OnDestroy ( ) : void
Résultat void

OnGUI() protected méthode

protected OnGUI ( ) : void
Résultat void

PerformAction() public méthode

public PerformAction ( string actionToPerform ) : void
actionToPerform string
Résultat void

ReplaceChildWithChildFromGameObjectTemplate() public méthode

Replaces all the child nodes of the GameObject associated with this object, with the child nodes of the given GameObject template. This can be used, for instance, to exchange the model that is used to display the different versions (on construction, semidemolished, complete, ...) of a building.
public ReplaceChildWithChildFromGameObjectTemplate ( GameObject newGameObjectTemplate ) : void
newGameObjectTemplate GameObject The object to use as a template for the new child nodes.
Résultat void

SetNewPath() protected méthode

Tells the object to move to the given position, by generating and following a route to the desired position.
protected SetNewPath ( Vector3 target, bool isRunning ) : void
target Vector3 The position we want the object to move to.
isRunning bool
Résultat void

SetSelection() public méthode

public SetSelection ( bool selected ) : void
selected bool
Résultat void

Start() protected méthode

protected Start ( ) : void
Résultat void

TakeDamage() public méthode

Substract health points from this object.
public TakeDamage ( int damage ) : void
damage int The number of health points to substract to this object.
Résultat void

Update() protected méthode

protected Update ( ) : void
Résultat void

UseWeapon() protected méthode

protected UseWeapon ( ) : void
Résultat void

chargeSounds() protected méthode

protected chargeSounds ( string objectName ) : void
objectName string
Résultat void

makeCreationSound() public méthode

public makeCreationSound ( ) : void
Résultat void

Property Details

aiming protected_oe property

protected bool aiming
Résultat bool

anim protected_oe property

protected Animator anim
Résultat Animator

attacking protected_oe property

true if the unit is attacking or moving into position to attack another unit.
protected bool attacking
Résultat bool

audio protected_oe property

protected AudioSource,UnityEngine audio
Résultat UnityEngine.AudioSource

baseAttackRange protected_oe property

Default attack strength. Leave at zero if the object isn't a range unit.
protected int baseAttackRange
Résultat int

baseAttackSpeed protected_oe property

Default number of hits per second of the object. Leave at zero if the object can't attack.
protected float baseAttackSpeed
Résultat float

baseAttackStrength protected_oe property

Default attack strength. Leave at zero if the object can't attack.
protected int baseAttackStrength
Résultat int

baseBuildFactor protected_oe property

Default speed factor of building (x1 = default building time, x2 = half building time, etc). Leave at zero if the unit can't build.
protected float baseBuildFactor
Résultat float

baseDefense protected_oe property

Default attack defense. Leave at null if the object can't defend.
protected int? baseDefense
Résultat int?

baseMoveSpeed public_oe property

Default movement speed. Leave at zero if the object can't move.
public float baseMoveSpeed
Résultat float

cost public_oe property

public int cost
Résultat int

creationSound protected_oe property

protected AudioClip,UnityEngine creationSound
Résultat UnityEngine.AudioClip

currentlySelected protected_oe property

protected bool currentlySelected
Résultat bool

dieSound protected_oe property

protected AudioClip,UnityEngine dieSound
Résultat UnityEngine.AudioClip

dying protected_oe property

true if the unit is dying (it has zero hit points and it playing the dead animation).
protected bool dying
Résultat bool

ent protected_oe property

protected LOSEntity, ent
Résultat LOSEntity,

fightSound protected_oe property

protected AudioClip,UnityEngine fightSound
Résultat UnityEngine.AudioClip

healthPercentage protected_oe property

protected float healthPercentage
Résultat float

nearbyObjects protected_oe property

protected List nearbyObjects
Résultat List

objectIconAttack public_oe property

public Sprite objectIconAttack
Résultat Sprite

objectIconAttackRange public_oe property

public Sprite objectIconAttackRange
Résultat Sprite

objectIconDefense public_oe property

public Sprite objectIconDefense
Résultat Sprite

objectIconResource public_oe property

public Sprite objectIconResource
Résultat Sprite

objectIconSprite public_oe property

public Sprite objectIconSprite
Résultat Sprite

objectName public_oe property

public string objectName
Résultat string

owner public_oe property

public Player, owner
Résultat Player,

programmedAttackPosition protected_oe property

If attacking, position where the unit is programmed to move in order to attack another unit.
protected Vector3 programmedAttackPosition
Résultat Vector3

remainingTimeToAttack protected_oe property

If attacking, number of seconds remaining until the unit takes another hit to the target.
protected float remainingTimeToAttack
Résultat float

remainingTimeToDead protected_oe property

Number of seconds until the unit is considered dead and it disappears from the map.
protected float remainingTimeToDead
Résultat float

rigbody protected_oe property

protected Rigidbody,UnityEngine rigbody
Résultat UnityEngine.Rigidbody

target public_oe property

public RTSObject, target
Résultat RTSObject,