//Augment Module
var ITW = (function(itw){
"use strict";
//aliases
var components, protot;
itw.components = itw.components || Object.create(null);
components = itw.components;
components.Reef = function( type ){
this.super.call(this);
var _init = function(){
// init stuff here
this._reefType = type;
if( this._reefType === 3 ){
this._armature = ITW.DBoneFactory.createArmature( "Seaweed" );
this._sprMain = this._armature.display;
this._armature.animation.gotoAndPlay( "seaweed", -1, -1, 0 );
}
else{
var _texMain = EHDI.Assets.images[ "reef" + this._reefType ];
this._sprMain = new EHDI.aka.Sprite( _texMain );
}
this._sprMain.x = this._sprMain.width * -0.5;
this._sprMain.y = this._sprMain.height * -0.5;
this.addChild( this._sprMain );
this.x = -( this._sprMain.width * 0.5 );
this.y = ITW.SceneMgr.getStageHeight() - ( this._sprMain.height * 0.6 );
}.bind(this);
_init();
}
protot = components.Reef.prototype = Object.create(EHDI.aka.Container.prototype);
protot.constructor = components.Reef;
protot.super = EHDI.aka.Container;
protot.getCollisionArea = function(){
switch( this._reefType ){
case 1:
return {
x: this.x - ( this._sprMain.width * 0.03 ),
y: this.y + ( this._sprMain.height * 0.05 ),
r: ( this._sprMain.width * 0.26 )
};
break;
case 2:
return {
x: this.x - ( this._sprMain.width * 0.085 ),
y: this.y - ( this._sprMain.height * 0.03 ),
r: ( this._sprMain.height * 0.42 )
};
break;
case 3:
return {
x: this.x + ( this._sprMain.width * 0.05 ),
y: this.y + ( this._sprMain.height * 0.05 ),
r: ( this._sprMain.height * 0.45 )
};
break;
}
}
protot.resetState = function(){
this._sprMain.scale.set( EHDI.NumberUtil.randomRange(0.5, 1) );
this._sprMain.x = this._sprMain.width * -0.5;
this._sprMain.y = this._sprMain.height * -0.5;
this.x = ITW.SceneMgr.getStageWidth() + ( this._sprMain.width * 0.5 );
this.y = ITW.SceneMgr.getStageHeight() - ( this._sprMain.height * 0.6 );
if( ITW.GameMgr.getDebug() === true ){
if( typeof this.pixiCircle !== "undefined" ){
if( this.pixiCircle.parent !== null ) this.removeChild( this.pixiCircle );
}
this.pixiCircle = new EHDI.aka.Graphics();
this.pixiCircle.beginFill( 0xFF00FF, 0.5 );
switch( this._reefType ){
case 1:
this.pixiCircle.drawCircle( ( -( this._sprMain.width * 0.03 ) ),
( this._sprMain.height * 0.05 ),
( this._sprMain.width * 0.26 ) ); //(x,y,radius)
break;
case 2:
this.pixiCircle.drawCircle( ( -( this._sprMain.width * 0.085 ) ),
( -( this._sprMain.height * 0.03 ) ),
( this._sprMain.height * 0.42 ) ); //(x,y,radius)
break;
case 3:
this.pixiCircle.drawCircle( ( this._sprMain.width * 0.05 ),
( this._sprMain.height * 0.05 ),
( this._sprMain.height * 0.45 ) ); //(x,y,radius)
break;
}
this.pixiCircle.endFill();
this.addChild( this.pixiCircle );
}
}
protot.destroy = function(){
if( this._reefType === 3 ) ITW.DBoneFactory.destroyArmature( this._armature );
this.super.prototype.destroy.call(this, {children: true});
}
return itw;
}(ITW || Object.create(null)));