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 ); }
public CharacterStatus GetInstance( StatExpressionsInfo statExpressionsInfo ) { return new CharacterStatus( statExpressionsInfo ) { agility = { Value = status.agility.Value }, strength = { Value = status.strength.Value } }; }
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(); }