Example #1
0
		return function renderEntity()
		{
			// Update shadow
			SpriteRenderer.shadow = Ground.getShadowFactor( this.position[0], this.position[1] );

			var animation  = this.animation;
			var Entity     = this.constructor;
			_position[0]   = 0;
			_position[1]   = 0;

			// Animation change ! Get it now
			if (animation.save && animation.delay < Renderer.tick) {
				this.setAction(animation.save);
			}

			// Avoid look up, render as IDLE all not supported frames
			var action    = this.action < 0 ? this.ACTION.IDLE : this.action;
			var direction = (Camera.direction + this.direction + 8) % 8;
			var behind    = direction > 1 && direction < 6;

			// Render shadow (shadow isn't render when player is sit or dead).
			if (action !== this.ACTION.DIE && action !== this.ACTION.SIT) {
	
				// Shadow is base on gat height
				SpriteRenderer.position[0] = this.position[0];
				SpriteRenderer.position[1] = this.position[1];
				SpriteRenderer.position[2] = Altitude.getCellHeight(this.position[0], this.position[1]);

				renderElement( this, this.files.shadow, 'shadow', _position, false );
			}

			SpriteRenderer.position.set(this.position);

			// Shield is behind on some position, seems to be hardcoded by the client
			if (this.objecttype === Entity.TYPE_PC && this.shield && behind) {
				renderElement( this, this.files.shield, 'shield', _position, true );
			}

			// Draw body, get head position
			renderElement( this, this.files.body, 'body', _position, true );

			if (this.objecttype === Entity.TYPE_PC) {
				// Draw Head
				renderElement( this, this.files.head, 'head', _position, false);

				// Draw Hats
				if (this.accessory > 0) {
					renderElement( this, this.files.accessory, 'head', _position, false);
				}
	
				if (this.accessory2 > 0 && this.accessory2 !== this.accessory) {
					renderElement( this, this.files.accessory2, 'head', _position, false);
				}

				if (this.accessory3 > 0 && this.accessory3 !== this.accessory2 && this.accessory3 !== this.accessory) {
					renderElement( this, this.files.accessory3, 'head', _position, false);
				}

				// Draw Others elements
				if (this.weapon > 0) {
					renderElement( this, this.files.weapon, 'weapon', _position, true );
				}

				if (this.shield > 0 && !behind) {
					renderElement( this, this.files.shield, 'shield', _position, true );
				}
			}
		};
Example #2
0
		return function RenderSub( pick_color )
		{
			// Update shadow
			SpriteRenderer.shadow    = Ground.getShadowFactor( this.position[0], this.position[1] );
			SpriteRenderer.pickindex = pick_color;
	
			var animation  = this.animation;
			var Entity     = this.constructor;
			_position[0]   = 0;
			_position[1]   = 0;
	
			// Animation change ! Get it now
			if ( animation.save && animation.delay < Renderer.tick ) {
				this.setAction(animation.save);
			}
	
			// Picking only render body.
			if( pick_color ) {
				SpriteRenderer.position.set(this.position);
				this._renderElement( this.files.body, 'body', _position, true );
				return;
			}
	
			// Avoid look up, render as IDLE all not supported frames
			var action    = this.action === -1 ? this.ACTION.IDLE : this.action;
			var direction = ( Camera.direction + this.direction + 8 ) % 8;
			var behind    = direction > 1 && direction < 6;
	
			// Render shadow (shadow isn't render when player is sit or dead).
			if( action !== this.ACTION.DIE && action !== this.ACTION.SIT ) {
	
				// Shadow is base on gat height
				SpriteRenderer.position[0] = this.position[0];
				SpriteRenderer.position[1] = this.position[1];
				SpriteRenderer.position[2] = Altitude.getCellHeight(this.position[0], this.position[1]);
	
				// Item shadow is smaller
				// TODO: find a better way
				if( this.objecttype === Entity.TYPE_ITEM ) {
					this.xSize = this.ySize = 10;
					this._renderElement( this.files.shadow, 'shadow', _position, false );
					this.xSize = this.ySize = 5;
				}
				else {
					this._renderElement( this.files.shadow, 'shadow', _position, false );
				}
			}
	
			SpriteRenderer.position.set(this.position);
	
			// Shield is behind on some position, seems to be hardcoded by the client
			if( this.objecttype === Entity.TYPE_PC && this.shield && behind ) {
				this._renderElement( this.files.shield, 'shield', _position, true );
			}
	
			// Draw body, get head position
			this._renderElement( this.files.body, 'body', _position, true );
	
			if( this.objecttype === Entity.TYPE_PC ) {
				// Draw Head
				this._renderElement( this.files.head, 'head', _position, false);
	
				// Draw Hats
				if( this.accessory ) {
					this._renderElement( this.files.accessory, 'head', _position, false);
				}
	
				if( this.accessory2 && this.accessory2 !== this.accessory ) {
					this._renderElement( this.files.accessory2, 'head', _position, false);
				}
	
				if( this.accessory3 && this.accessory3 !== this.accessory2 && this.accessory3 !== this.accessory ) {
					this._renderElement( this.files.accessory3, 'head', _position, false);
				}
	
				// Draw Others elements
				if( this.weapon ) {
					this._renderElement( this.files.weapon, 'weapon', _position, true );
				}
	
				if( this.shield && !behind ) {
					this._renderElement( this.files.shield, 'shield', _position, true );
				}
			}
		};