Exemplo n.º 1
0
    public Character( StatExpressionsInfo statExpressions, CharacterPlanetPawn pawn, IInputSource inputSource, CharacterStatus status, CharacterStateController stateController, CharacterStateController weaponStateController, int teamId, CharacterInfo info )
    {
        this.statExpressions = statExpressions;
        this.status = status;
        this.health = new IntReactiveProperty( this.status.maxHealth.Value );
        this.pawn = pawn;
        this.inputSource = inputSource;
        this.stateController = stateController;
        this.weaponStateController = weaponStateController;
        this.teamId = teamId;
        this.info = info;
        this.inventory = new BasicInventory( this );

        pawn.SetCharacter( this );

        this.stateController.Initialize( this );
        this.weaponStateController.Initialize( this );

        var inputSourceDisposable = inputSource as IDisposable;
        if ( inputSourceDisposable != null ) {

            _compositeDisposable.Add( inputSourceDisposable );
        }

        Observable.EveryUpdate().Subscribe( OnUpdate ).AddTo( _compositeDisposable );
        status.moveSpeed.Subscribe( UpdatePawnSpeed ).AddTo( _compositeDisposable );
        health.Subscribe( OnHealthChange );//.AddTo( _compositeDisposable );

        instances.Add( this );
    }
Exemplo n.º 2
0
    public CharacterStatus GetInstance( StatExpressionsInfo statExpressionsInfo )
    {
        return new CharacterStatus( statExpressionsInfo ) {

            agility = { Value = status.agility.Value },
            strength = { Value = status.strength.Value }
        };
    }
Exemplo n.º 3
0
    public CharacterStatus( StatExpressionsInfo expressionsInfo )
    {
        strength = new IntReactiveProperty( 0 );
        agility = new IntReactiveProperty( 0 );

        maxHealth = CreateCalculator( expressionsInfo.healthExpression ).Select( _ => (int)_ ).ToReactiveProperty();
        moveSpeed = CreateCalculator( expressionsInfo.moveSpeedExpression ).Select( _ => (float)_ ).ToReactiveProperty();
    }