package com.arc.dh.state { import com.arc.dh.menu.MenuTooltip; import com.arc.dh.util.Config; import com.arc.dh.util.Data; import com.arc.dh.util.DataSerializer; import com.arc.dh.util.Fonts; import com.arc.flixel.ArcButton; import com.arc.flixel.ArcSprite; import flash.events.MouseEvent; import org.flixel.FlxBitmapText; import org.flixel.FlxG; import org.flixel.FlxU; public class MainScreen extends MenuScreen { private static const buttonStorySprite:Class = MainScreen_buttonStorySprite; private static const buttonBossSprite:Class = MainScreen_buttonBossSprite; private static const buttonEscapeSprite:Class = MainScreen_buttonEscapeSprite; private static const buttonHelpSprite:Class = MainScreen_buttonHelpSprite; private static const buttonCreditsSprite:Class = MainScreen_buttonCreditsSprite; private static const buttonMinigameSprite:Class = MainScreen_buttonMinigameSprite; private static const buttonUnlockSprite:Class = MainScreen_buttonUnlockSprite; private static const buttonMoreGames:Class = MainScreen_buttonMoreGames; public static const buttonPegas:Class = MainScreen_buttonPegas; public static const buttonHost:Class = MainScreen_buttonHost; public static const buttonAG:Class = MainScreen_buttonAG; public static const buttonLikeAG:Class = MainScreen_buttonLikeAG; public static const buttonMG:Class = MainScreen_buttonMG; private static const buttonBossLockedSprite:Class = MainScreen_buttonBossLockedSprite; private static const buttonEscapeLockedSprite:Class = MainScreen_buttonEscapeLockedSprite; private static const buttonOptionsSprite:Class = MainScreen_buttonOptionsSprite; private var _buttonStory:ArcButton; private var _buttonBoss:ArcButton; private var _buttonEscape:ArcButton; private var _buttonHelp:ArcButton; private var _buttonCredits:ArcButton; private var _buttonMinigames:ArcButton; private var _buttonUnlock:ArcButton; private var _buttonPegas:ArcButton; private var _buttonMoreGames:ArcButton; private var _buttonHost:ArcButton; private var _minigamesBox:ArcSprite; private var _minigamesText:FlxBitmapText; private var _optionsButton:ArcButton; private var _bottomBar:ArcSprite; private var _createdText:FlxBitmapText; private var _versionText:FlxBitmapText; private var bossUnlocked:Boolean; private var escapeUnlocked:Boolean; public function MainScreen(param1:MainMenu) { var agOffset:int = 0; var M:MainMenu = param1; super(M); this._buttonStory = new ArcButton(43,103,87,26,buttonStorySprite).callback(function():void { menu.switchScreen(menu.storyScreen); }).selectable(false); this.add(this._buttonStory); this.escapeUnlocked = Data.chapters[1][0] > 0; this._buttonEscape = new ArcButton(134,103,87,26,this.escapeUnlocked ? buttonEscapeSprite : buttonEscapeLockedSprite).callback(function():void { if(escapeUnlocked) { menu.switchScreen(menu.escapeScreen); } }).selectable(false); this.add(this._buttonEscape); this.bossUnlocked = Data.chapters[6][0] > 0; this._buttonBoss = new ArcButton(43,136,87,26,this.bossUnlocked ? buttonBossSprite : buttonBossLockedSprite).callback(function():void { if(bossUnlocked) { menu.switchScreen(menu.bossScreen); } }).selectable(false); this.add(this._buttonBoss); this._buttonMinigames = new ArcButton(134,136,87,26,buttonMinigameSprite).callback(function():void { menu.switchScreen(menu.minigamesScreen); }).selectable(false); this.add(this._buttonMinigames); this._buttonHelp = new ArcButton(43,169,87,26,buttonHelpSprite).callback(function():void { menu.switchScreen(menu.helpScreen); }).selectable(false); this.add(this._buttonHelp); this._buttonCredits = new ArcButton(134,169,87,26,buttonCreditsSprite).callback(function():void { menu.switchScreen(menu.creditsScreen); }).selectable(false); this.add(this._buttonCredits); if(Config.RELEASE == Config.PEGAS) { this._buttonPegas = new ArcButton(230,100,106,46,buttonPegas).callback(function():void { }).selectable(false); this.add(this._buttonPegas); this._buttonMoreGames = new ArcButton(240,145,87,26,buttonMoreGames).callback(function():void { }).selectable(false); this.add(this._buttonMoreGames); this._buttonHost = new ArcButton(240,170,87,26,buttonHost).callback(function():void { }).selectable(false); this.add(this._buttonHost); } else if(Config.RELEASE == Config.ARMORGAMES) { this._buttonPegas = new ArcButton(215,100,133,39,buttonAG).callback(function():void { FlxU.openURL("http://armorgames.com"); }).selectable(false); this.add(this._buttonPegas); this._buttonMoreGames = new ArcButton(240,144,87,26,buttonMoreGames).callback(function():void { FlxU.openURL("http://armorgames.com"); }).selectable(false); this.add(this._buttonMoreGames); this._buttonHost = new ArcButton(240,169,87,26,buttonLikeAG).callback(function():void { FlxU.openURL("http://facebook.com/armorgames"); }).selectable(false); this.add(this._buttonHost); agOffset = 20; this._buttonStory.x -= agOffset; this._buttonEscape.x -= agOffset; this._buttonBoss.x -= agOffset; this._buttonMinigames.x -= agOffset; this._buttonHelp.x -= agOffset; this._buttonCredits.x -= agOffset; } else if(Config.RELEASE == Config.MAXGAMES) { this._buttonPegas = new ArcButton(222,130,139,37,buttonMG).callback(function():void { FlxU.openURL("http://maxgames.com"); }).selectable(false); this.add(this._buttonPegas); } this._bottomBar = new ArcSprite(0,228); this._bottomBar.makeGraphic(Config.WIDTH,9,2566914048); this.add(this._bottomBar); this._createdText = new FlxBitmapText(4,230,Fonts.font(Fonts.SMALL_WHITE),"CREATED BY ARKEUS","left",200); this._createdText.alpha = 0.6; this.add(this._createdText); this._versionText = new FlxBitmapText(Config.WIDTH - 200 - 4,230,Fonts.font(Fonts.SMALL_WHITE),"VERSION " + Config.VERSION + " - " + Config.RELEASE.toUpperCase(),"right",200); this._versionText.alpha = 0.6; this.add(this._versionText); this._optionsButton = new ArcButton(160,213,34,29,buttonOptionsSprite).callback(function():void { M.inOptions = true; }).selectable(false); this.add(this._optionsButton); if(Config.RELEASE == Config.FLASHGAMELICENSE || Config.DEBUG) { this._buttonUnlock = new ArcButton(134,212,87,26,buttonUnlockSprite).callback(function():void { Data.diamonds = 105000; Data.chapters = [[1,1000000],[1,1000000],[1,1000000],[1,1000000],[1,1000000],[1,1000000],[1,1000000]]; Data.redDiamonds = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; Data.moonboots = 1; Data.skyboots = 1; Data.autofirer = 1; Data.xrayscope = 1; Data.lasersight = 1; Data.moltensuit = 1; Data.spreader = 1; Data.rebound = 1; Data.missile = 1; Data.prime = 1; Data.escape = [1,1,1,1,1,1]; Data.heartcrystals = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; Data.vitality = 17; Data.achievements = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; Data.boss = [1,1000000,1,1000000]; DataSerializer.save(); FlxG.fade(4278190080,0.25,function():void { FlxG.mouse.hide(); FlxG.switchState(new MainMenu()); }); }).selectable(false); this.add(this._buttonUnlock); } } public function bindPegas() : void { if(Config.RELEASE != Config.PEGAS) { return; } FlxG.stage.addEventListener(MouseEvent.CLICK,this.pegas); } public function unbindPegas() : void { if(Config.RELEASE != Config.PEGAS) { return; } FlxG.stage.removeEventListener(MouseEvent.CLICK,this.pegas); } private function pegas(param1:*) : void { if(Config.RELEASE != Config.PEGAS) { return; } if(menu.inOptions) { return; } if(this._buttonPegas.hover() || this._buttonMoreGames.hover()) { FlxU.openURL("http://www.pegasgames.com/"); } if(this._buttonHost.hover()) { FlxU.openURL("http://games.mochiads.com/c/g/diamond-hollow-ii/DiamondHollowII.swf"); } } override public function update() : void { if(this._buttonBoss.hover() && !this.bossUnlocked) { if(menu.tooltip == null || menu.tooltip.source != this._buttonBoss) { menu.tooltip = new MenuTooltip(this._buttonBoss.x + this._buttonBoss.width / 2,this._buttonBoss.y,"Boss Rush Locked","You must complete chapter 7 of story mode to unlock Boss Rush"); menu.tooltip.source = this._buttonBoss; } menu.hovering = true; } else if(this._buttonEscape.hover() && !this.escapeUnlocked) { if(menu.tooltip == null || menu.tooltip.source != this._buttonEscape) { menu.tooltip = new MenuTooltip(this._buttonEscape.x + this._buttonEscape.width / 2,this._buttonEscape.y,"Escape Mode Locked","You must complete chapter 2 of story mode to unlock Escape Mode"); menu.tooltip.source = this._buttonEscape; } menu.hovering = true; } if(FlxG.keys.justPressed("L")) { FlxG.log("FlxG.stage.root.loaderInfo.loaderURL: " + FlxG.stage.root.loaderInfo.loaderURL); FlxG.log("FlxG.stage.loaderInfo.loaderURL: " + FlxG.stage.loaderInfo.loaderURL); FlxG.log("FlxG.root.loaderInfo.loaderURL: " + FlxG.root.loaderInfo.loaderURL); } super.update(); } } }