Table of Contents

Class PlayerBuilder

Concrete builder that constructs a Player using a fluent API. Call the Set* methods in any order, then call Build() to get the result.

public class PlayerBuilder : Builder<Player>, IBuilder<Player>
Inheritance
PlayerBuilder
Implements
Inherited Members

Examples

var player = new PlayerBuilder()
    .SetName("Hero")
    .SetHealth(100)
    .SetSpeed(5.5f)
    .Build();

Methods

Build()

Finalises and returns the constructed object.

public override Player Build()

Returns

Player

SetHealth(int)

Sets the player's starting health.

public PlayerBuilder SetHealth(int health)

Parameters

health int

Health point value (e.g. 100).

Returns

PlayerBuilder

SetName(string)

Sets the player's name.

public PlayerBuilder SetName(string name)

Parameters

name string

Display name for the player.

Returns

PlayerBuilder

SetSpeed(float)

Sets the player's movement speed.

public PlayerBuilder SetSpeed(float speed)

Parameters

speed float

Speed in units per second.

Returns

PlayerBuilder