var gameOptionsManager={fillSpeed:1500,outOfPlayAreaKills:true,additiveMode:false,godMode:false,selectedPipeValue:[1,1,1,0],topLeftPipe:null} var Node=function(connections,connectionStatus){var defaults={connections:[null,null,null,null],connectionStatus:[0,0,0,0]};this._connections=connections||defaults.connections;this._connectionStatus=connectionStatus||defaults.connectionStatus;this.proxy=$({});Node.nodes.push(this);} Node.nodes=[];Node.removeAll=function(){for(var i=0;i0){var pipeLine=this._connectionStatus[startConnectionIndex];this.full=pipeLine;var thispipe=this;var animationOptions={width:"71px"};if(startConnectionIndex==0){animationOptions={'height':"71px"};}else if(startConnectionIndex==2){animationOptions={'margin-top':"-71px"};} thispipe._htmlElement.find(".water"+waterLayer).animate(animationOptions,gameOptionsManager.fillSpeed,function(){thispipe._htmlElement.addClass("full");if(waterLayer==2){thispipe._htmlElement.addClass("full2");} for(var i=0;i0){this.timeout=setTimeout(this.tick.bind(this),1000);}} DisplayTimer.prototype.stop=function(){clearTimeout(this.timeout);this.displayTime=0;$(".timer").html(this.addLeadingDigit(this.displayTime));} DisplayTimer.prototype.tick=function(){this.displayTime-=1;if(this.displayTime>0){$(".timer").html(this.addLeadingDigit(this.displayTime));if(!this.paused){this.timeout=setTimeout(this.tick.bind(this),1000);}}else{if(typeof this.callback!="undefined"){this.callback();} $(".timer").html("00");}} DisplayTimer.prototype.addLeadingDigit=function(num){if(num<10){return "0"+num;}else{return num;}} var PipeGame=(function(){var _numCols=8;var _numRows=4;var _firstx=0;var _firsty=0;var _lastx=3;var _lasty=0;var _lastToFill;var _firstToFill;var _score=0;var _scoreMultiplier=1;var _numberOfPipesFilled=0;var _fillSpeed=3000;var _startTimer;var _autoStart=null;var _displayTimer=null;var _paused=false;var _eventsAdded=false;function _configure(options){_numCols=options.cols;_numRows=options.rows;_firstx=options.startX;_firsty=options.StartY;_lastx=options.lastX;_lasty=options.lastY;_autoStart=options.autoStart||null;gameOptionsManager.godMode=options.godMode||false;gameOptionsManager.additiveMode=options.additiveMode||false;} function _setGameBoard(level){var prevTopNode;var prevCol=[];var topNode;var random;var pipeclasst;var pipeclass;var nodeAbove;var bottomNode;if(typeof window.SoundManager!="undefined"){window.SoundManager.reset();if(gameOptionsManager.godMode==true){window.SoundManager.startBackground("three");}else if(gameOptionsManager.additiveMode==true){window.SoundManager.startBackground("two");}else{window.SoundManager.startBackground("one");}} _lastToFill=null;_firstToFill=null;_paused=false;_score=0;_scoreMultiplier=1;_displayTimer=null;_startTimer=null;Node.removeAll();gameOptionsManager.fillSpeed=1500;$(".plumbing").html("");if(typeof level!='undefined'){_numCols=level.length;_numRows=level[0].length;} for(var i=0;i<_numCols;i++){$(".plumbing").append("");nodeAbove=null;for(var j=0;j<_numRows;j++){bottomNode=new Pipe();bottomNode.on("full",function(){_addPoints();});if(i==0&&j==0){gameOptionsManager.topLeftPipe=bottomNode;} if(typeof level!='undefined'){bottomNode.setConnectionStatusList(level[i][j]);}else{bottomNode.setConnectionStatusList();} pipeclass="pipe-"+bottomNode._connectionStatus.toString().replace(/,/g,"");bottomNode.setHTMLElement($(".plumbing .col-"+i).append("
  • ").find("li").last());if(nodeAbove!=null&&typeof nodeAbove!='undefined'){bottomNode.setConnection(0,nodeAbove);nodeAbove.setConnection(2,bottomNode);} if(i>0){bottomNode.setConnection(3,prevCol[j]);prevCol[j].setConnection(1,bottomNode);} if(i==_firstx&&j==_firsty){_firstToFill=bottomNode;} if(i==_lastx&&j==_lasty){_lastToFill=bottomNode;var winPipe=new WinPipe();_lastToFill.setConnection(1,winPipe);winPipe.setConnection(3,_lastToFill);} prevCol[j]=bottomNode;nodeAbove=bottomNode;} prevTopNode=topNode;} _displayTimer=null;if(typeof _autoStart!='undefined'&&_autoStart!=null){_displayTimer=new DisplayTimer(_autoStart);_showStartMessage("

    WARNING


    The water will start in
    "+(_autoStart/1000)+" seconds.",function(){_displayTimer.start(function(){_startWater();})},true);} if(!_eventsAdded){_eventsAdded=true;_addButtonEvents();}} function _showStartMessage(message,callback,_startmessage){var popclass="";var startmessage=_startmessage||false;if(startmessage){popclass="start";$(".message-box").addClass(popclass);}else{$(".message-box").removeClass("start");popclass="";} $(".message-box").html(message);$(".message-holder").fadeIn("fast",function(){$(this).delay(2500).fadeOut("slow",function(){$(".message-box").removeClass("start");if(typeof callback!="undefined"){callback();}});});} function _showMessage(message,callback){$(".message-box").html(message);$(".message-holder").fadeIn("fast",function(){if(typeof callback!="undefined"){callback();}});} function _gameOver(){PipeGame.showMessage("

    You Lost


    +"+_score+" Points
    Retry");if(typeof window.SoundManager!="undefined"){window.SoundManager.pause();window.SoundManager.playLost();}} function _gameWin(){if(!gameOptionsManager.additiveMode){PipeGame.showMessage("

    Stage Cleared


    +"+_score+" Points
    Next LevelMain Menu");}else{PipeGame.showMessage("

    Stage Cleared


    +"+_score+" Points
    Play AgainMain Menu");} if(typeof window.SoundManager!="undefined"){window.SoundManager.playWin();var current=parseInt(window.location.hash.substring(1));if(window.SoundManager.getLevelsComplete()