import { WWAConsts , Position , Direction , speedList } from "./wwa_data" ; import { Player } from "./wwa_parts_player" ; export class Camera { private _player : Player ; private _position : Position ; private _positionPrev : Position ; private _transitionStep : number ; private _isResetting : boolean ; param position constructor ( position ) { this . _position = null ; this . reset ( position ) ; } public setPlayer ( player ) { this . _player = player ; } public isResetting ( ) { return this . _isResetting ; } public getPosition ( ) { return this . _position ; } public getPreviousPosition ( ) { return this . _positionPrev ; } public resetPreviousPosition ( ) { this . _positionPrev = null ; } public move ( dir ) { var speed = speedList [ this . _player . getSpeedIndex ( ) ] ; this . _position = this . _position . getNextFramePosition ( dir , speed * ( WWAConsts . H_PARTS_NUM_IN_WINDOW - 1 ) , speed * ( WWAConsts . V_PARTS_NUM_IN_WINDOW - 1 ) ) ; } public getTransitionStepNum ( ) { return this . _transitionStep ; } public advanceTransitionStepNum ( ) { ++ this . _transitionStep ; if ( this . _transitionStep === WWAConsts . V_PARTS_NUM_IN_WINDOW ) { this . _isResetting = false ; this . _transitionStep = 0 ; } return this . _transitionStep ; } public isFinalStep ( ) { if ( this . _isResetting === false ) { throw new Error ( "リセット中ではありません。" ) ; } return this . _transitionStep === WWAConsts . V_PARTS_NUM_IN_WINDOW - 1 ; } public reset ( position ) { this . _positionPrev = this . _position ; this . _position = position . getDefaultCameraPosition ( ) ; this . _transitionStep = 0 ; this . _isResetting = true ; } }