示例#1
0
#pragma warning restore IDE0032 // Use auto property

    private Player(
        PlayerState state,
        ILocationStore locationStore,
        IRoadStore roadStore,
        Action <string> updateMessagingGroup)
    {
        _locationStore        = locationStore;
        _roadStore            = roadStore;
        _updateMessagingGroup = updateMessagingGroup;

        _playerId   = state.PlayerId;
        _locationId = state.LocationId;

        if (state.RoadMovementState != null)
        {
            var road = roadStore.Find(state.RoadMovementState.RoadId);
            if (road == null)
            {
                throw new InvalidOperationException($"Road {state.RoadMovementState.RoadId} is not found in the store.");
            }

            _roadMovementComponent = new RoadMovementComponent(road, state.RoadMovementState.Progress, state.RoadMovementState.MovementDirection);
        }

        UpdateMessagingGroup();
    }
示例#2
0
 public PlayerPersistenceFactory(
     ILocationStore locationStore,
     IRoadStore roadStore,
     IConnectedClientStore connectedClientStore)
 {
     _locationStore        = locationStore;
     _roadStore            = roadStore;
     _connectedClientStore = connectedClientStore;
 }
示例#3
0
 public static Player FromState(
     PlayerState state,
     ILocationStore locationStore,
     IRoadStore roadStore,
     Action <string> updateMessagingGroup)
 {
     return(new Player(
                state,
                locationStore,
                roadStore,
                updateMessagingGroup));
 }