C# Класс RTSObject, ES2015C

Наследование: MonoBehaviour
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
baseMoveSpeed float
cost int
objectIconAttack Sprite
objectIconAttackRange Sprite
objectIconDefense Sprite
objectIconResource Sprite
objectIconSprite Sprite
objectName string
owner Player,
target RTSObject,

Защищенные свойства (Protected)

Свойство Тип Описание
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

Свойство Тип Описание
BeginDead void
EndAttack void
OnMouseExit void
OnMouseOver void
PerformAttack void
UpdateDeadObject bool
updateSelection void

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

AimAtTarget() защищенный Метод

protected AimAtTarget ( ) : void
Результат void

Animating() защищенный Метод

protected Animating ( ) : void
Результат void

AssignBuildingProject() публичный Метод

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.
Результат void

AttackObject() публичный Метод

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.
Результат void

Awake() защищенный Метод

protected Awake ( ) : void
Результат void

BeginAttack() публичный Метод

Begins an attack sequence on the given target.
public BeginAttack ( RTSObject, newTarget ) : void
newTarget RTSObject, The target of the attack.
Результат void

CalculateCurrentHealth() защищенный Метод

protected CalculateCurrentHealth ( ) : void
Результат void

CanAttack() публичный Метод

Tells if the object can attack.
public CanAttack ( ) : bool
Результат bool

CanBeAttacked() публичный Метод

Tell if the object can be attacked by military units.
public CanBeAttacked ( ) : bool
Результат bool

CanBeBuilt() публичный Метод

public CanBeBuilt ( ) : bool
Результат bool

CanBuild() публичный Метод

public CanBuild ( ) : bool
Результат bool

CanMove() публичный Метод

Tells if the object can change its position.
public CanMove ( ) : bool
Результат bool

CancelPath() защищенный Метод

Tell the object to cancel the movement path to the given position.
protected CancelPath ( ) : void
Результат void

ExtendBounds() защищенный Метод

protected ExtendBounds ( Transform t, Bounds &b ) : void
t Transform
b Bounds
Результат void

GetActions() публичный Метод

Get the list of actions available for this object.
public GetActions ( ) : Action[],
Результат Action[],

GetAttackRange() публичный Метод

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
Результат float

GetAttackSpeed() публичный Метод

Gets the attack strengh that the unit has when it is attacking, in attack/second.
public GetAttackSpeed ( ) : float
Результат float

GetAttackStrength() публичный Метод

Gets the attack strengh that the unit has when it is attacking.
public GetAttackStrength ( ) : int
Результат int

GetDefense() публичный Метод

Gets the defense points that the unit has when it is being attacked.
public GetDefense ( ) : int
Результат int

GetHarvestAmount() публичный Метод

Get the current amount of resource that the unit has harvested.
public GetHarvestAmount ( ) : float
Результат float

GetHarvestType() публичный Метод

Get the current type of resource that the unit is harvesting.
public GetHarvestType ( ) : ResourceType,
Результат ResourceType,

GetMovementSpeed() публичный Метод

Gets the movement speed of a object.
public GetMovementSpeed ( ) : float
Результат float

HasPath() защищенный Метод

Returns true if the unit has programmed a movement path to a given position.
protected HasPath ( ) : bool
Результат bool

IsBuilding() публичный Метод

Checks if the object is currently building another object.
public IsBuilding ( ) : bool
Результат bool

IsHarvesting() публичный Метод

Check if the unit is currently harvesting.
public IsHarvesting ( ) : bool
Результат bool

IsOwnedBy() публичный Метод

public IsOwnedBy ( Player, owner ) : bool
owner Player,
Результат bool

MouseClick() публичный Метод

public MouseClick ( GameObject hitObject, Vector3 hitPoint, Player, controller ) : void
hitObject GameObject
hitPoint Vector3
controller Player,
Результат void

MoveTo() публичный Метод

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
Результат void

OnDestroy() публичный Метод

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
Результат void

OnGUI() защищенный Метод

protected OnGUI ( ) : void
Результат void

PerformAction() публичный Метод

public PerformAction ( string actionToPerform ) : void
actionToPerform string
Результат void

ReplaceChildWithChildFromGameObjectTemplate() публичный Метод

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.
Результат void

SetNewPath() защищенный Метод

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
Результат void

SetSelection() публичный Метод

public SetSelection ( bool selected ) : void
selected bool
Результат void

Start() защищенный Метод

protected Start ( ) : void
Результат void

TakeDamage() публичный Метод

Substract health points from this object.
public TakeDamage ( int damage ) : void
damage int The number of health points to substract to this object.
Результат void

Update() защищенный Метод

protected Update ( ) : void
Результат void

UseWeapon() защищенный Метод

protected UseWeapon ( ) : void
Результат void

chargeSounds() защищенный Метод

protected chargeSounds ( string objectName ) : void
objectName string
Результат void

makeCreationSound() публичный Метод

public makeCreationSound ( ) : void
Результат void

Описание свойств

aiming защищенное свойство

protected bool aiming
Результат bool

anim защищенное свойство

protected Animator anim
Результат Animator

attacking защищенное свойство

true if the unit is attacking or moving into position to attack another unit.
protected bool attacking
Результат bool

audio защищенное свойство

protected AudioSource,UnityEngine audio
Результат UnityEngine.AudioSource

baseAttackRange защищенное свойство

Default attack strength. Leave at zero if the object isn't a range unit.
protected int baseAttackRange
Результат int

baseAttackSpeed защищенное свойство

Default number of hits per second of the object. Leave at zero if the object can't attack.
protected float baseAttackSpeed
Результат float

baseAttackStrength защищенное свойство

Default attack strength. Leave at zero if the object can't attack.
protected int baseAttackStrength
Результат int

baseBuildFactor защищенное свойство

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
Результат float

baseDefense защищенное свойство

Default attack defense. Leave at null if the object can't defend.
protected int? baseDefense
Результат int?

baseMoveSpeed публичное свойство

Default movement speed. Leave at zero if the object can't move.
public float baseMoveSpeed
Результат float

cost публичное свойство

public int cost
Результат int

creationSound защищенное свойство

protected AudioClip,UnityEngine creationSound
Результат UnityEngine.AudioClip

currentlySelected защищенное свойство

protected bool currentlySelected
Результат bool

dieSound защищенное свойство

protected AudioClip,UnityEngine dieSound
Результат UnityEngine.AudioClip

dying защищенное свойство

true if the unit is dying (it has zero hit points and it playing the dead animation).
protected bool dying
Результат bool

ent защищенное свойство

protected LOSEntity, ent
Результат LOSEntity,

fightSound защищенное свойство

protected AudioClip,UnityEngine fightSound
Результат UnityEngine.AudioClip

healthPercentage защищенное свойство

protected float healthPercentage
Результат float

nearbyObjects защищенное свойство

protected List nearbyObjects
Результат List

objectIconAttack публичное свойство

public Sprite objectIconAttack
Результат Sprite

objectIconAttackRange публичное свойство

public Sprite objectIconAttackRange
Результат Sprite

objectIconDefense публичное свойство

public Sprite objectIconDefense
Результат Sprite

objectIconResource публичное свойство

public Sprite objectIconResource
Результат Sprite

objectIconSprite публичное свойство

public Sprite objectIconSprite
Результат Sprite

objectName публичное свойство

public string objectName
Результат string

owner публичное свойство

public Player, owner
Результат Player,

programmedAttackPosition защищенное свойство

If attacking, position where the unit is programmed to move in order to attack another unit.
protected Vector3 programmedAttackPosition
Результат Vector3

remainingTimeToAttack защищенное свойство

If attacking, number of seconds remaining until the unit takes another hit to the target.
protected float remainingTimeToAttack
Результат float

remainingTimeToDead защищенное свойство

Number of seconds until the unit is considered dead and it disappears from the map.
protected float remainingTimeToDead
Результат float

rigbody защищенное свойство

protected Rigidbody,UnityEngine rigbody
Результат UnityEngine.Rigidbody

target публичное свойство

public RTSObject, target
Результат RTSObject,