home *** CD-ROM | disk | FTP | other *** search
- class PlayerStatus
- {
- var nScore;
- var nShownScore;
- var nMaxCombo;
- var nLevelToPlay;
- var nRemainingLives;
- var mcHUD;
- static var nTIME_FOR_EXTRA_POINTS = 30000;
- static var aSPEED_ADDONS = [1.25,1.5,1.75,2,2.25,2.25,2.5,2.5,2.75,2.75,3,3,3.25,3.25,3.5,3.5,3.75,3.75,4,4];
- static var nTOTAL_LEVELS = 20;
- static var nTOTAL_LIVES = 5;
- static var nSCORE_CHANGE_RATE = 15;
- static var nMAX_SCORE_GAP = 280;
- static var nPOINTS_COMBO_LEVEL = 250;
- static var nPOINTS_BLOCK_HIT = 10;
- static var nPOINTS_BLOCK_CRUSH = 50;
- static var nPOINTS_BONUS = 150;
- static var nPOINTS_LEVEL_END = 750;
- static var nPOINTS_PER_MILLISECONDS = 0.25;
- function PlayerStatus()
- {
- this.nScore = 0;
- this.nShownScore = 0;
- this.nMaxCombo = 0;
- this.nLevelToPlay = 1;
- this.nRemainingLives = PlayerStatus.nTOTAL_LIVES;
- this.doUpdateStaticHud();
- this.doUpdatePoints();
- Main.Instance.doAddListener(this);
- }
- function doEnterFrame()
- {
- if(this.nShownScore != this.nScore)
- {
- this.doUpdatePoints();
- }
- }
- function setHud(_mcHUD)
- {
- this.mcHUD = _mcHUD;
- this.doUpdateStaticHud();
- this.doUpdatePoints();
- }
- function onGainLive()
- {
- this.nRemainingLives = this.nRemainingLives + 1;
- this.doUpdateStaticHud();
- }
- function onLoseLive()
- {
- this.nRemainingLives = this.nRemainingLives - 1;
- this.doUpdateStaticHud();
- }
- function getPlayerCanContinue()
- {
- return this.nRemainingLives >= 0;
- }
- function onPlayerCompleteLevel(_nTimeRemaining)
- {
- this.doAddPoints(PlayerStatus.nPOINTS_LEVEL_END + _nTimeRemaining * PlayerStatus.nPOINTS_PER_MILLISECONDS);
- this.nLevelToPlay = this.nLevelToPlay + 1;
- this.doUpdateStaticHud();
- }
- function getIsMoreLevelToPlay()
- {
- return this.nLevelToPlay <= PlayerStatus.nTOTAL_LEVELS;
- }
- function getLevelToPlay()
- {
- return this.nLevelToPlay;
- }
- function onNewCombo(_nCombo)
- {
- var _loc2_ = this.nMaxCombo;
- this.nMaxCombo = Math.max(this.nMaxCombo,_nCombo);
- this.doUpdateStaticHud();
- this.doAddPoints(PlayerStatus.nPOINTS_COMBO_LEVEL * (this.nMaxCombo - _loc2_));
- }
- function doAddPoints(_nPoints)
- {
- this.nScore += Math.floor(_nPoints);
- }
- function onBlockHit()
- {
- this.doAddPoints(PlayerStatus.nPOINTS_BLOCK_HIT);
- }
- function onBlockCrushed()
- {
- this.doAddPoints(PlayerStatus.nPOINTS_BLOCK_CRUSH);
- }
- function onCatchBonus()
- {
- this.doAddPoints(PlayerStatus.nPOINTS_BONUS);
- }
- function doDestroy()
- {
- Main.Instance.doRemoveListener(this);
- delete this.mcHUD;
- }
- function get SpeedAddon()
- {
- return PlayerStatus.aSPEED_ADDONS[this.nLevelToPlay - 1];
- }
- function get Score()
- {
- return Math.floor(this.nScore);
- }
- function doUpdateStaticHud()
- {
- this.mcHUD.txtLives.text = Math.max(0,this.nRemainingLives);
- this.mcHUD.txtCombo.text = Library.Utils.Tools.getFormatedNumber(this.nMaxCombo,3);
- this.mcHUD.txtLevel.text = Library.Utils.Tools.getFormatedNumber(Math.min(PlayerStatus.nTOTAL_LEVELS,this.nLevelToPlay),2);
- }
- function doUpdatePoints()
- {
- this.nScore = Math.floor(this.nScore);
- if(this.nShownScore + PlayerStatus.nMAX_SCORE_GAP < this.nScore)
- {
- var _loc2_ = this.nScore - this.nShownScore;
- this.nShownScore += Math.floor(_loc2_ * 0.6666666666666666);
- }
- else
- {
- this.nShownScore = Library.Utils.MoreMath.getReachNum(this.nShownScore,this.nScore,PlayerStatus.nSCORE_CHANGE_RATE);
- }
- this.nShownScore = Math.floor(this.nShownScore);
- this.mcHUD.txtScore.text = Library.Utils.Tools.getFormatedNumber(this.nShownScore,6);
- }
- }
-