var Block = ate( function( top, left, width, height ){

this.left = left;
this.border = false;
},
{
init: function(){
},
changeBg: function( bg, framesNum, combo, position ){
var _oWidth = this.width;
this.width =  Util.imgObj[ bg ].width / framesNum;
this._oWidth = ( this.width - _oWidth ) * Config.map.spiritZoom;
if ( this.direction === -1 ){
this.left = this.left - this._oWidth;
}
if ( ( this.currState === 'somesault_up' ) &&  this.border === 'right' ){
this.left = this.left - 60;
}
if ( !combo ){
var _oHeight = this.height;
this.height = Util.imgObj[ bg ].height ;
this._oHeight = ( this.height - _oHeight ) * Config.map.spiritZoom;

}else{
}
this.position = position || 0;
},
crossBorder: function( left ){
if ( !Map || !MaxX() ) return left;
var maxX =  MaxX();
var right = this.state === 'jump_back' ? 130 : 85;
if ( left < 15 ){
this.border = 'left';
return 15;
}else if ( left + this.width > maxX - right ){
this.border = 'right';
return maxX - this.width - right;
}
this.border = false;
return left;
}
})
var Spirit = Block.subClass( function( config ){
this.name = config.name;
this.states = config.states;
this.f_top = 0;
this.f_left = 0;

this.left = 0;
this.width = 0;
this.height = 0;
this.bottom = 0;
this.direction = 1;
this.state = null;
this.currState = null;
< = null;
this.animate = null; //移动
this.animateDirection = [ 0, 0 ];
this.frames = null;  //动画帧 
this.shadow = null;  //阴影
this.queue = null;  //动画队列
this.keyManage = null;//键盘管理
this.attack = null;  //攻击
this.waveBoxing = null; //波动拳
this.status = null;  //人物状态机, 保存人物所有即时状态
this.bloodBar = null;
this.statusManage = null;
this.stageManage = null;
},
{
init: function( f_left, f_top, direction ){
this.f_left = f_left;
this.f_top = f_top;
this.f_height = Util.imgObj[ this.states[ this.states.default ].bg ].height;
this.direction = direction;
this.frames = this.implement( 'SpiritFrames' );
this.shadow = this.implement( 'Shadow');
this.animate = this.implement( 'Animate' );
this.queue = this.implement( 'Queue' );
this.lock = this.implement( 'Lock' );
this.keyManage = this.implement( 'KeyManage', fig.keyMap );
this.attack = Instance( this ).init();
this.waveBoxing = WaveBoxing.g
etInstance( this ).init();
this.statusManage = this.implement( 'StatusManage' );
this.stageManage = this.implement( 'Stage' );
this.event();
var currState = this.states[ this.states.default ];
this.changeBg( currState.bg, currState.framesNum );
this.play( this.states.default );
veto( f_left, f_top );
return this;
},
setEnemy: function( enemy ){
< = enemy;
},
play: function( state, force ){
if ( this.statusManage.isCrouch() && ( state === 'wait' || state === 'force_wait' ) ){  //蹲下的状态站起来.
return this.play( 'stand_up', true );
}
if ( this.jump_combo( state ) && state !== 'force_wait' ) return;  //空中组合技
if ( this.defense( state ) ) return;  //是否在防御状态
var lock_level = Config.play[ state ].lock || 0; 
var old_lock_leval = Level() || 0;
if ( !force ){
if ( state === this.state || ( this.lock.locked() && old_lock_leval >= lock_level ) ) {
return;
}
}
this.lock.lock( lock_level );  //级别, 解锁延迟.
this.queue.clean();
var composes = Config.play[ state ]pose;  //组合states
for ( var i = 0, c; c = composes[i++]; ){
var s = py( this.states[ c ] );
s.currState = c;
this.queue.add( s );
}
this.state = state;
if ( state === 'light_wave_boxing' || state === 'heavy_wave_boxing' ){
if ( this.waveBoxing.firing ){
this.queue.clean();
this.lock.lock(0);
return this.play( state === 'light_wave_boxing' ? 'light_boxing' : 'heavy_boxing' );
}
this.waveBoxing.start( this.direction, state === 'light_wave_boxing' ? this.states[ 'light_wave' ] : this.states[ 'heavy_wave' ] );
}
this.fireFrames();
this.animate.event.fireEvent( 'playStart' );
},
jump_combo: function( state ){  //跳跃的组合技能
if ( !this.state || !this.statusManage.isJump() ) return false;
if ( state === 'jump_fall_down' || state === 'jump_dead' || state === 'after_dead2' || state === 'heavy_attacked_fall_down' || state === 'crouch_kick_attacked_fall' ){
this.framesbo_attack.stop();
return false;
}
var combo = this.statesbo && this.statesbo[ this.state + '_' + state ];
if ( !combo ) return true;
var flag = this.framesbo_attack.start( combo.bg, combo.framesNum, peat, combo.afterFrame );
this.statusManage.set_attack_type( combo.attack_type );
var attack_config = combo.attack_config;
this.statusManage.set_attack_power( combo.attack_power );
if ( flag ){  //是否组合拳已经结束
this.attack.stickStart( attack_config, combo.effect_position, combo.sound );
var self = this;
this.framesbo_attack.done( function(){
self.statusManage.
set_attack_type( 0 );
self.attack.stop();
})
}
return true;
},
defense: function( state ){
if ( state === 'back' ){
if ( waveBoxing.firing || ( ().attack_type === 'attack' && ().enemy_distance_type !== 'furthest' ) ){
if ( ().attack_type === 'wait' ){
this.play( 'stand_up_defense' );  //防御状态
this.statusManage.set_attack_type( 1 );
}
return true;
}
}
else if ( state === 'stand_crouch_defense' ){
if ( !waveBoxing.firing && ( ().attack_type !== 'attack' || ().enemy_distance_type === 'furthest' ) ){
this.play( 'crouch' );  //防御状态
this.statusManage.set_attack_type( 0 );
return true;
}
}
},
fireFrames: function(){
var state = this.queue.dequeue();
if ( !state ){  //队列里没有动作的时候
var old_dir = this.direction;
var new_direction = this.left > ( && left ) ? -1 : 1;
if ( new_direction !== old_dir ){
if ( this.border ){
this.left = this.left + new_direction * 18;
}else{
this.left = this.left + new_direction * 105;
}
}
this.direction = this.left > ( && left ) ? -1 : 1;  //调整方向
this.animate.mirror( this.direction );  //方向镜像
this.keyManage.mirror( this.direction );  //键盘镜像
if ( this.statusManage.isCrouch()  ){  //蹲下的状态站起来.
return this.play( 'stand_up', true );
}else{
this.queue.add( this.states[ this.states.default ] );
}
this.lock.lock( 0 );
this.state = this.states.default;
this.framesbo_attack.stop();
if ( this.attack.animate_type === 'stick' ){
this.attack.stop();
}
return this.fireFrames();
}
if ( state !== this.state ){
this.changeBg( state.bg, state.framesNum, null, state.position );
}
if ( state.easing[ 1 ] === null ){
var top = this.f_top - p + ( this.f_height - this.height ) * Config.map.spiritZoom;
}
this.currState = state.currState;
this.frames.start( state.bg, state.framesNum, state.easing[2], peat, state.position, this.direction );
this.animate.start( state.easing[0] * this.direction, top || state.easing[1], state.easing[2] * Config.fps * state.framesNum, state.easing[3] );
var _left = state.easing[0] * this.direction, _top = top || state.easing[1];
this.animateDirection = [ _left === 0 ? 0 : _left / Math.abs( _left ), _top === 0 ? 0 : _top / Math.abs( _top )  ];
this.statusManage.set_attack_type( state.attack_type || 0 );
this.statusManage.set_attack_power( state.attack_power || [] );
if ( state.attack_type
> 0 || this.statusManage.isJump() ){
/
/this.frames.checkZindex();  //调整层级
}
if ( state.attack_type === 2 ){
var attack_config = state.attack_config, effect_position = state.effect_position;
attack_config && this.attack.start( attack_config[0], attack_config[1], [ attack_config[ 2 ] * this.direction, attack_config[ 3 ], attack_config[ 4 ], attack_config[ 5 ], attack_config[ 6 ], attack_config[ 7 ], attack_config[ 8 ] ], effect_position, state.sound );
}
html导航源码if ( state.specialSound ){
this.attack.audio.play( state.specialSound );
}
if ( this.currState !== 'wait' ){
}
this.animate.event.fireEvent( 'framesStart' );
},
/************************************** 自定义事件 *****************************************/
event: function( type ){
var self = this;
this.frames.event.listen( 'framesDone', function(){
if ( self.currState === 'crouch_kick_attacked_fall' || self.currState === 'after_heavy_attacked_fall_down' || self.currState === 'dead' ){
self.attack.audio.play( 'sound/fall.mp3' );
}
if ( self.currState === 'somesault_up' ){
self.statusManage.setInvincible( 100 );  //爬起来的时候短暂无敌.
}
self.fireFrames();
})
this.frames.event.listen( 'framesStart', function(){
self.animate.unlock();
if ( self.state === 'wait' ){
t();  //修正位置
}
})
this.frames.event.listen( 'frameStart', function(){
if ( self.state === 'wait' || self.state === 'crouch' ){
self.direction = self.left > ( && left ) ? -1 : 1;  //调整方向
}
ve();  //每帧开始前调整位置.
veto( Map.height - 73, self.statusManage.isJump() && self.direction === -1 ? self.left + ( self.width - 62 ) * Config.map.spiritZoom : self.left, self.statusManage.isJump() ? 62 : self.width, self.direction );  //移动阴影
self.statusManage.check_enemy_distance( );
})
this.animate.event.listen( 'stopPush', function(){
self.states.forward.easing[ 0 ] = 150;
});
this.animate.event.listen( 'frameStart', function(){
var d = 0;
if ( ( self.border === 'left' && self.animateDirection[ 0 ] === -1 ) || ( self.border === 'right' && self.animateDirection[ 0 ] === 1 ) ){
if ( ().enemy_distance_type === 'furthest' ) return;
self.stageManage.scroll( self.border );
if ( animateDirection[ 0 ] === 0 && animateDirection[ 1 ] === 0 ){
self.stageMa
nage.pushEnemy();
}else{
if ( self.stageManage.isScrolling() ){
}else{
}
}
}, 1 )
}else{
self.stageManage.stop();
}
});
if ( obj === ){
if ( self.state === 'forward' && ( obj.state === 'wait' || obj.state === 'crouch' ) ){
obj.animate.push( 3 );
self.states.forward.easing[ 0 ] = 90;
if ( obj.border ){
self.animate.lock( obj.border );
}
}
if ( self.currState === 'jump_forward_down' || self.currState === 'jumpDown' ){
var distance = ().enemy_distance;
obj.animate.push( ( 234 - distance ) / 40 );
}
if ( self.state === 'forward' &&  obj.state === 'forward'  ){
self.animate.lock( dir );
}
}
})
this.keyManage.match( function( state ){
if ( self.statusManage.isCrouch() && self.states[ 'crouch_' + state ] ){
return  self.play( 'crouch_' + state );
}
if ( !self.statusManage.isJump() && self.states[ 'near_' + state ] && ().enemy_distance <= self.states[ 'near_' + state ].near  ){
return self.play( 'near_' + state );
}
return self.play( state );
});
this.keyManage.unmatch( function( state ){
if ( self.state === 'stand_up' && state === 'wait' ){
return;
}
if ( self.state === 'back' || self.state === 'forward' || self.state === 'stand_up_defense' || self.state === 'stand_crouch_defense' || self.state === 'crouch' ){
self.play( self.states.default );
}
});
}
}
)
Spirit.interface( 'Animate', Interfaces.Animate );
Spirit.interface( 'SpiritFrames', Interfaces.SpiritFrames );
Spirit.interface( 'Shadow', Interfaces.Shadow );
Spirit.interface( 'Queue', Interfaces.Queue );
Spirit.interface( 'Lock', Interfaces.Lock );
Spirit.interface( 'KeyManage', Interfaces.KeyManage );
Spirit.interface( 'Collision', Interfaces.Collision );
Spirit.interface( 'StatusManage', Interfaces.StatusManage );
Spirit.interface( 'Ai', Ai );
var Fighter = ate( function( master ){
this.width = 50;
this.height = 50;
this.left = 0;

this.master = master;
this.timer = null;
this.animate = null;
this.attackEffect = null;
this.effect_position = null;
this.sound = null;
this.easing = null;
},
{
init: function(){
var self = this;
this.animate = this.implement( 'Animate' );
this.attackEffect = this.implement( 'AttackEffect' );
this.audio = this.implement( 'Audio' );
this.animate.event.listen( 'framesDone', function(){   

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。