home *** CD-ROM | disk | FTP | other *** search
- class GameInterface extends MovieClip
- {
- var specialDisplay;
- var tfLives;
- var tfScore;
- var tfTrackTime;
- var message;
- var bestTimes;
- var watchObject;
- var avatar;
- var score;
- var lives;
- var timeRemaining;
- var maxDamage;
- var letters;
- var damage;
- var specialItem;
- var raceTime;
- var raceTimeDisplay;
- var damageBar;
- var menuDisplay;
- var onMenuOpen;
- var onMenuClose;
- function GameInterface()
- {
- super();
- this.specialDisplay._visible = false;
- this.setMenuEnabled(true);
- }
- function setOpenTextFieldColor(hexValue)
- {
- this.tfLives.textColor = this.tfScore.textColor = this.tfTrackTime.textColor = hexValue;
- }
- function showScreen(id, time)
- {
- this.message.play();
- _root.messageName = id;
- }
- function showRecordTime(record)
- {
- this.bestTimes.gotoAndPlay("intro");
- this.bestTimes.character.gotoAndStop(record.name);
- this.bestTimes.value = _global.formatTime(record.time);
- }
- function hideRecordTime()
- {
- this.bestTimes.gotoAndPlay("outro");
- }
- function showLetters()
- {
- }
- function hideLetters()
- {
- }
- function watch(obj, characterName)
- {
- this.watchObject = obj;
- this.avatar.gotoAndStop(characterName);
- this.score = this.watchObject.score;
- this.lives = "X" + this.watchObject.lives;
- this.timeRemaining = this.watchObject.timeRemaining;
- this.setRaceTime(this.watchObject.raceTime);
- this.maxDamage = this.watchObject.maxDamage;
- this.setDamage(this.watchObject.damage);
- this.letters = 0;
- }
- function update(elapsed)
- {
- if(this.score != this.watchObject.score)
- {
- this.score = this.watchObject.score;
- }
- if(this.damage != this.watchObject.damage)
- {
- this.setDamage(this.watchObject.damage);
- }
- if(this.letters != this.watchObject.letters)
- {
- this.setLetters(this.watchObject.letters);
- }
- if(this.specialItem != this.watchObject.specialItem)
- {
- this.setNewSpecialItem(this.watchObject.specialItem);
- }
- else if(this.specialItem)
- {
- this.setSpecialValue(this.specialItem.power);
- }
- this.setRaceTime(this.watchObject.raceTime);
- this.setTimeRemaining(this.watchObject.timeRemaining);
- }
- function setTimeRemaining(value)
- {
- if(this.timeRemaining == Math.ceil(value))
- {
- return undefined;
- }
- this.timeRemaining = Math.ceil(value);
- }
- function setRaceTime(value)
- {
- if(this.raceTime == (this.raceTime = Math.floor(value * 10) * 0.1))
- {
- return undefined;
- }
- this.raceTimeDisplay = _global.formatTime(value);
- }
- function setDamage(damage)
- {
- this.damage = damage;
- this.damageBar.setValue(1 - damage / this.maxDamage);
- }
- function setSpecialValue(value)
- {
- this.specialDisplay.value.setValue(value);
- }
- function setNewSpecialItem(newSpecialItem)
- {
- this.specialItem = newSpecialItem;
- if(this.specialItem)
- {
- this.specialDisplay._visible = true;
- this.specialDisplay.value.maxValue = this.specialItem.power;
- this.setSpecialValue(this.specialItem.power);
- switch(this.specialItem.collisionGroup)
- {
- case BB.MAGNETS:
- this.specialDisplay.gotoAndStop(1);
- break;
- case BB.BLADES:
- this.specialDisplay.gotoAndStop(2);
- break;
- case BB.LASERS:
- this.specialDisplay.gotoAndStop(3);
- }
- }
- else
- {
- this.specialDisplay._visible = false;
- }
- }
- function setLetters(letters)
- {
- this.letters = letters;
- }
- function setMenuEnabled(enabled)
- {
- this.menu.enabled = enabled;
- }
- function showMenu()
- {
- this.menuDisplay.gotoAndPlay("Intro");
- this.onMenuOpen();
- this.setMenuEnabled(false);
- }
- function hideMenu()
- {
- this.setMenuEnabled(true);
- this.menuDisplay.gotoAndStop(1);
- this.onMenuClose();
- }
- }
-