package com.arc.dh.state { import com.arc.dh.util.AchievementSystem; import com.arc.dh.util.Config; import com.arc.dh.util.Data; import com.arc.dh.util.Fonts; import com.arc.flixel.ArcButton; import com.arc.flixel.ArcGroup; import com.arc.flixel.ArcSprite; import org.flixel.FlxBitmapText; import org.flixel.FlxG; import org.flixel.FlxPoint; import org.flixel.FlxU; public class UI extends ArcGroup { public static const diamondsSprite:Class = UI_diamondsSprite; private static const heightSprite:Class = UI_heightSprite; private static const distanceSprite:Class = UI_distanceSprite; private static const sButtonSprite:Class = UI_sButtonSprite; private static const cButtonSprite:Class = UI_cButtonSprite; private static const mButtonSprite:Class = UI_mButtonSprite; private static const mg:Class = UI_mg; private var _hearts:HeartMeter; private var _diamonds:ArcSprite; private var _diamondsText:FlxBitmapText; private var _height:ArcSprite; private var _heightText:FlxBitmapText; private var _lastDiamonds:int; private var _lastHeight:int; private var _gun:WeaponUI; private var _characterButton:ArcButton; private var _statisticsButton:ArcButton; private var _messageButton:ArcButton; private var maxgames:ArcButton; public function UI() { var h:int = 0; super(); this._hearts = new HeartMeter(2,2); if(!(Data.state is TadpoleMode)) { this.add(this._hearts); } this._diamonds = new ArcSprite(0,Config.HEIGHT - 16); this._diamonds.loadGraphic(diamondsSprite,true,false,45,16); this.add(this._diamonds); this._diamondsText = new FlxBitmapText(-1,Config.HEIGHT - 7,Fonts.font(Fonts.SMALL_WHITE),"0","right",40); this.add(this._diamondsText); this._characterButton = new ArcButton(1,Config.HEIGHT - 22,13,12,cButtonSprite).selectable(false).callback(function():void { Data.state.menu.fade(!Data.state.inMenu,1); }); this.add(this._characterButton); this._statisticsButton = new ArcButton(14,Config.HEIGHT - 22,13,12,sButtonSprite).selectable(false).callback(function():void { Data.state.menu.fade(!Data.state.inMenu,2); }); this.add(this._statisticsButton); this._messageButton = new ArcButton(27,Config.HEIGHT - 22,13,12,mButtonSprite).selectable(false).callback(function():void { Data.state.menu.fade(!Data.state.inMenu,3); }); this.add(this._messageButton); this._gun = new WeaponUI(140,0); if(PlayMode.mode == PlayMode.ESCAPE_MODE || PlayMode.mode == PlayMode.RUN_MODE || PlayMode.mode == PlayMode.TADPOLE_MODE) { this._height = new ArcSprite(Config.WIDTH - 45,Config.HEIGHT - 18); this._height.loadGraphic(PlayMode.mode == PlayMode.ESCAPE_MODE ? heightSprite : distanceSprite,true,false,45,18); this.add(this._height); h = Data.state.caveHeight; this._heightText = new FlxBitmapText(322,Config.HEIGHT - 7,Fonts.font(Fonts.SMALL_WHITE),h + "M","center",34); this.add(this._heightText); } if(Config.RELEASE == Config.MAXGAMES) { this.maxgames = new ArcButton(FlxG.width - 80,0,80,15,mg).callback(function():void { FlxU.openURL("http://maxgames.com"); }).hoverable(false).selectable(false); this.add(this.maxgames); } this.update(); setAll("scrollFactor",new FlxPoint(0,0)); } override public function update() : void { if(Data.diamonds != this._lastDiamonds) { this._lastDiamonds = Data.diamonds; this._diamondsText.text = Data.diamonds > 99999 ? "99999" : Data.diamonds.toString(); } var _loc1_:int = Data.state.caveHeight; if(this._heightText != null && _loc1_ != this._lastHeight) { if(Data.state is EscapeMode) { AchievementSystem.climb(_loc1_); } else if(Data.state is TadpoleMode) { AchievementSystem.tadpolemode(_loc1_); } else if(Data.state is RunMode) { AchievementSystem.runmode(_loc1_); } this._lastHeight = Data.state.caveHeight; this._heightText.text = this._lastHeight + "M"; } this._gun.update(); this._characterButton.update(); this._statisticsButton.update(); this._messageButton.update(); if(this.maxgames != null) { this.maxgames.update(); } } public function showGuns(param1:Boolean = false) : void { if(!(Data.state is TadpoleMode)) { this._gun.show(param1); } } override public function draw() : void { if(!Data.state.inMenu) { super.draw(); this._gun.draw(); } } } }