package com.arc.dh.state { import com.arc.dh.entities.PlayerTadpole; import com.arc.dh.menu.MenuTooltip; import com.arc.dh.menu.StatisticsChapter; import com.arc.dh.util.Data; import com.arc.dh.util.Fonts; import com.arc.dh.util.SoundSystem; import com.arc.flixel.ArcButton; import com.arc.flixel.ArcSprite; import org.flixel.FlxBitmapText; import org.flixel.FlxG; public class MinigameScreen extends MenuScreen { private static const buttonBackSprite:Class = MinigameScreen_buttonBackSprite; private static const buttonPlaySprite:Class = MinigameScreen_buttonPlaySprite; private static const buttonLockedSprite:Class = MinigameScreen_buttonLockedSprite; private static const buttonRunUnlockedSprite:Class = MinigameScreen_buttonRunUnlockedSprite; private var _buttonBack:ArcButton; private var _buttonRun:ArcButton; private var _buttonTadpole:ArcButton; private var runUnlocked:Boolean; private var tadpoleUnlocked:Boolean; public function MinigameScreen(param1:MainMenu) { var run:ArcSprite; var tadpole:ArcSprite; var heroicUnlocked:Boolean; var red:ArcSprite; var M:MainMenu = param1; super(M); this.add(new InstructionWindow(0,100,FlxG.width,33)); this.add(new FlxBitmapText(10,104,Fonts.font(Fonts.OUTLINE_GRADIENT),"As you explore the various environments of story mode, you will find red diamonds hidden in the darkest corners of the cave. In addition to providing you with 100 diamonds, these will unlock the minigames below.".toUpperCase(),"center",FlxG.width - 20)); this.runUnlocked = Data.redDiamondCount >= 15; this.tadpoleUnlocked = Data.redDiamondCount >= 25; this.add(new InstructionWindow(0,140,FlxG.width,30)); this.add(new InstructionWindow(0,177,FlxG.width,30)); run = new ArcSprite(10,145); run.loadGraphic(buttonRunUnlockedSprite,true,false,13,18); run.frame = 0; this.add(run); this.add(new FlxBitmapText(30,142,Fonts.font(Fonts.OUTLINE_GRADIENT),"Runner Mode".toUpperCase(),"center",237)); this.add(new FlxBitmapText(30,150,Fonts.font(Fonts.OUTLINE_BLACK),"Protect yourself as you run at increasing speeds in an attempt to escape once and for all.".toUpperCase(),"center",237)); this.add(new FlxBitmapText(30,179,Fonts.font(Fonts.OUTLINE_GRADIENT),"Tadpole Mode".toUpperCase(),"center",237)); this.add(new FlxBitmapText(30,187,Fonts.font(Fonts.OUTLINE_BLACK),"Control a lone blue tadpole as he swims his way through his venomous brethren.".toUpperCase(),"center",237)); tadpole = new ArcSprite(10,183); tadpole.loadGraphic(PlayerTadpole.sprite,true,false,16,16); tadpole.frame = 0; this.add(tadpole); this._buttonRun = new ArcButton(270,142,87,26,this.runUnlocked ? buttonPlaySprite : buttonLockedSprite).callback(function():void { if(runUnlocked) { SoundSystem.fadeOutMusic(); FlxG.fade(4278190080,0.25,function():void { FlxG.mouse.hide(); FlxG.switchState(new RunMode()); }); } }).selectable(false); this.add(this._buttonRun); heroicUnlocked = Data.boss[0] > 0; this._buttonTadpole = new ArcButton(270,179,87,26,this.tadpoleUnlocked ? buttonPlaySprite : buttonLockedSprite).callback(function():void { if(tadpoleUnlocked) { SoundSystem.fadeOutMusic(); FlxG.fade(4278190080,0.25,function():void { FlxG.mouse.hide(); FlxG.switchState(new TadpoleMode()); }); } }).selectable(false); this.add(this._buttonTadpole); this._buttonBack = new ArcButton(135,213,87,26,buttonBackSprite).callback(function():void { menu.switchScreen(menu.mainScreen); }).selectable(false); this.add(this._buttonBack); red = new ArcSprite(5,FlxG.height - 15); red.loadGraphic(StatisticsChapter.redDiamondObtained,true,false,10,10); red.addAnimation("glow",[0,1,2,3,4,5,4,3,2,1],5,true); red.play("glow"); this.add(red); this.add(new FlxBitmapText(17,FlxG.height - 15 + 2,Fonts.font(Fonts.OUTLINE_BLACK_S),Data.redDiamondCount.toString(),"left",237)); } override public function update() : void { super.update(); if(this._buttonRun.hover()) { if(menu.tooltip == null || menu.tooltip.source != this._buttonRun) { if(this.runUnlocked) { menu.tooltip = new MenuTooltip(this._buttonRun.x + this._buttonRun.width / 2,this._buttonRun.y,"Runner Mode","Max Distance: " + Data.maxRunDistance + "M\n\nJump and shoot while avoiding enemies. Be sure not to fall!"); } else { menu.tooltip = new MenuTooltip(this._buttonRun.x + this._buttonRun.width / 2,this._buttonRun.y,"Runner Mode","Requires 15 red diamonds to unlock"); } menu.tooltip.source = this._buttonRun; } menu.hovering = true; } else if(this._buttonTadpole.hover()) { if(menu.tooltip == null || menu.tooltip.source != this._buttonTadpole) { if(this.tadpoleUnlocked) { menu.tooltip = new MenuTooltip(this._buttonTadpole.x + this._buttonTadpole.width / 2,this._buttonTadpole.y - 1,"Tadpole Mode","Max Distance: " + Data.maxTadpoleDistance + "M\n\nClick or press space to swim up, release to swim down."); } else { menu.tooltip = new MenuTooltip(this._buttonTadpole.x + this._buttonTadpole.width / 2,this._buttonTadpole.y - 1,"Tadpole Mode","Requires 25 red diamonds to unlock"); } menu.tooltip.source = this._buttonTadpole; } menu.hovering = true; } if(FlxG.keys.justPressed("ESCAPE")) { menu.switchScreen(menu.mainScreen); } } override public function draw() : void { super.draw(); } } }