Tanks Multiplayer  1.4
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Player

Networked player class implementing movement control and shooting. Contains both server and client logic in an authoritative approach. More...

Inheritance diagram for Player:
PlayerBot

Public Member Functions

override void OnStartClient ()
 Initialize synced values on every client. More...
 
override void OnStartLocalPlayer ()
 Initialize camera and input for this local client. This is being called after OnStartClient. More...
 
void TakeDamage (Bullet bullet)
 Server only: calculate damage to be taken by the Player, triggers score increase and respawn workflow on death. More...
 
void CmdRespawn ()
 Command telling the server that this client is ready for respawn. This is when the respawn delay is over or a video ad has been watched. More...
 
void ResetPosition ()
 Repositions in team area and resets camera & input variables. This should only be called for the local player. More...
 
void RpcGameOver (int teamIndex)
 Called on all clients on game end providing the winning team. This is when a target kill count or goal (e.g. flag captured) was achieved. More...
 

Public Attributes

string myName
 Player name synced across the network. More...
 
Text label
 UI Text displaying the player name. More...
 
int teamIndex
 Team value assigned by the server. More...
 
int health = 10
 Current health value. More...
 
int maxHealth
 Maximum health value at game start. More...
 
int shield = 0
 Current shield value absorbing hits. More...
 
int turretRotation
 Current turret rotation and shooting direction. More...
 
int ammo = 0
 Amount of special ammunition left. More...
 
int currentBullet = 0
 Index of currently selected bullet. More...
 
float fireRate = 0.75f
 Delay between shots. More...
 
float moveSpeed = 8f
 Movement speed in all directions. More...
 
Slider healthSlider
 UI Slider visualizing health value. More...
 
Slider shieldSlider
 UI Slider visualizing shield value. More...
 
AudioClip shotClip
 Clip to play when a shot has been fired. More...
 
AudioClip explosionClip
 Clip to play on player death. More...
 
GameObject shotFX
 Object to spawn on shooting. More...
 
GameObject explosionFX
 Object to spawn on player death. More...
 
Transform turret
 Turret to rotate with look direction. More...
 
Transform shotPos
 Position to spawn new bullets at. More...
 
GameObject[] bullets
 Array of available bullets for shooting. More...
 
MeshRenderer[] renderers
 MeshRenderers that should be highlighted in team color. More...
 
GameObject killedBy
 Last player gameobject that killed this one. More...
 
FollowTarget camFollow
 Reference to the camera following component. More...
 

Protected Member Functions

void Shoot (Vector2 direction=default(Vector2))
 
void RpcOnShot ()
 
void OnHealthChange (int value)
 
void OnShieldChange (int value)
 
virtual void RpcRespawn (short senderId)
 

Detailed Description

Networked player class implementing movement control and shooting. Contains both server and client logic in an authoritative approach.

Member Function Documentation

void CmdRespawn ( )

Command telling the server that this client is ready for respawn. This is when the respawn delay is over or a video ad has been watched.

void OnHealthChange ( int  value)
protected
void OnShieldChange ( int  value)
protected
override void OnStartClient ( )

Initialize synced values on every client.

override void OnStartLocalPlayer ( )

Initialize camera and input for this local client. This is being called after OnStartClient.

void ResetPosition ( )

Repositions in team area and resets camera & input variables. This should only be called for the local player.

void RpcGameOver ( int  teamIndex)

Called on all clients on game end providing the winning team. This is when a target kill count or goal (e.g. flag captured) was achieved.

void RpcOnShot ( )
protected
virtual void RpcRespawn ( short  senderId)
protectedvirtual

Reimplemented in PlayerBot.

void Shoot ( Vector2  direction = default(Vector2))
protected
void TakeDamage ( Bullet  bullet)

Server only: calculate damage to be taken by the Player, triggers score increase and respawn workflow on death.

Member Data Documentation

int ammo = 0

Amount of special ammunition left.

GameObject [] bullets

Array of available bullets for shooting.

FollowTarget camFollow

Reference to the camera following component.

int currentBullet = 0

Index of currently selected bullet.

AudioClip explosionClip

Clip to play on player death.

GameObject explosionFX

Object to spawn on player death.

float fireRate = 0.75f

Delay between shots.

int health = 10

Current health value.

Slider healthSlider

UI Slider visualizing health value.

GameObject killedBy

Last player gameobject that killed this one.

Text label

UI Text displaying the player name.

int maxHealth

Maximum health value at game start.

float moveSpeed = 8f

Movement speed in all directions.

string myName

Player name synced across the network.

MeshRenderer [] renderers

MeshRenderers that should be highlighted in team color.

int shield = 0

Current shield value absorbing hits.

Slider shieldSlider

UI Slider visualizing shield value.

AudioClip shotClip

Clip to play when a shot has been fired.

GameObject shotFX

Object to spawn on shooting.

Transform shotPos

Position to spawn new bullets at.

int teamIndex

Team value assigned by the server.

Transform turret

Turret to rotate with look direction.

int turretRotation

Current turret rotation and shooting direction.


The documentation for this class was generated from the following file: