C# Class ExamplePongLogic, airconsole-unity-plugin

Inheritance: MonoBehaviour
Show file Open project: AirConsole/airconsole-unity-plugin

Public Properties

Property Type Description
ball UnityEngine.Rigidbody2D
ballSpeed float
racketLeft UnityEngine.Rigidbody2D
racketRight UnityEngine.Rigidbody2D
uiText Text

Public Methods

Method Description
Awake ( ) : void
FixedUpdate ( ) : void
OnConnect ( int device_id ) : void

We start the game if 2 players are connected and the game is not already running (activePlayers == null). NOTE: We store the controller device_ids of the active players. We do not hardcode player device_ids 1 and 2, because the two controllers that are connected can have other device_ids e.g. 3 and 7. For more information read: http://developers.airconsole.com/#/guides/device_ids_and_states

OnDestroy ( ) : void
OnDisconnect ( int device_id ) : void

If the game is running and one of the active players leaves, we reset the game.

OnMessage ( int device_id, JToken data ) : void

We check which one of the active players has moved the paddle.

ResetBall ( bool move ) : void
StartGame ( ) : void
UpdateScoreUI ( ) : void

Method Details

Awake() public method

public Awake ( ) : void
return void

FixedUpdate() public method

public FixedUpdate ( ) : void
return void

OnConnect() public method

We start the game if 2 players are connected and the game is not already running (activePlayers == null). NOTE: We store the controller device_ids of the active players. We do not hardcode player device_ids 1 and 2, because the two controllers that are connected can have other device_ids e.g. 3 and 7. For more information read: http://developers.airconsole.com/#/guides/device_ids_and_states
public OnConnect ( int device_id ) : void
device_id int The device_id that connected
return void

OnDestroy() public method

public OnDestroy ( ) : void
return void

OnDisconnect() public method

If the game is running and one of the active players leaves, we reset the game.
public OnDisconnect ( int device_id ) : void
device_id int The device_id that has left.
return void

OnMessage() public method

We check which one of the active players has moved the paddle.
public OnMessage ( int device_id, JToken data ) : void
device_id int
data JToken Data.
return void

ResetBall() public method

public ResetBall ( bool move ) : void
move bool
return void

StartGame() public method

public StartGame ( ) : void
return void

UpdateScoreUI() public method

public UpdateScoreUI ( ) : void
return void

Property Details

ball public property

public Rigidbody2D,UnityEngine ball
return UnityEngine.Rigidbody2D

ballSpeed public property

public float ballSpeed
return float

racketLeft public property

public Rigidbody2D,UnityEngine racketLeft
return UnityEngine.Rigidbody2D

racketRight public property

public Rigidbody2D,UnityEngine racketRight
return UnityEngine.Rigidbody2D

uiText public property

public Text uiText
return Text