initial commit, kind of working.
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
package com.arc.dh.menu
|
||||
{
|
||||
import com.arc.dh.state.BossMode;
|
||||
import com.arc.dh.state.HorizontalMode;
|
||||
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;
|
||||
|
||||
public class GameOver extends ArcGroup
|
||||
{
|
||||
|
||||
protected static const sprite:Class = GameOver_sprite;
|
||||
|
||||
protected static const spriteShort:Class = GameOver_spriteShort;
|
||||
|
||||
protected static const spriteComplete:Class = GameOver_spriteComplete;
|
||||
|
||||
protected static const spriteRetry:Class = GameOver_spriteRetry;
|
||||
|
||||
protected static const spriteMainMenu:Class = GameOver_spriteMainMenu;
|
||||
|
||||
private static const FADE_SPEED:Number = 4;
|
||||
|
||||
private var _window:ArcSprite;
|
||||
|
||||
private var _diamonds:ArcGroup;
|
||||
|
||||
private var _height:ArcGroup;
|
||||
|
||||
private var _time:ArcGroup;
|
||||
|
||||
private var _heart:ArcGroup;
|
||||
|
||||
private var _red:ArcGroup;
|
||||
|
||||
private var _continue:FlxBitmapText;
|
||||
|
||||
private var _complete:Boolean = false;
|
||||
|
||||
private var _fading:Boolean = false;
|
||||
|
||||
private var _buttonRetry:ArcButton;
|
||||
|
||||
private var _buttonMainMenu:ArcButton;
|
||||
|
||||
private var _tipText:FlxBitmapText;
|
||||
|
||||
private var _retryFunction:Function;
|
||||
|
||||
private var _menuFunction:Function;
|
||||
|
||||
public function GameOver(param1:String, param2:String, param3:String)
|
||||
{
|
||||
var buttonY:int;
|
||||
var message:String = null;
|
||||
var offset:int = 0;
|
||||
var diamonds:String = param1;
|
||||
var height:String = param2;
|
||||
var time:String = param3;
|
||||
this._diamonds = new ArcGroup();
|
||||
this._height = new ArcGroup();
|
||||
this._time = new ArcGroup();
|
||||
this._heart = new ArcGroup();
|
||||
this._red = new ArcGroup();
|
||||
super(71,89);
|
||||
if(diamonds == null && time == null)
|
||||
{
|
||||
this._window = new ArcSprite(0,0,spriteShort);
|
||||
}
|
||||
else if(diamonds == null)
|
||||
{
|
||||
this._window = new ArcSprite(0,0,spriteComplete);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._window = new ArcSprite(0,0,sprite);
|
||||
}
|
||||
this.add(this._window);
|
||||
if(diamonds != null && time != null)
|
||||
{
|
||||
this.addGroup(this._diamonds,21,26,60,"Diamonds",diamonds);
|
||||
this.addGroup(this._height,92,26,56,Data.state is HorizontalMode ? "Distance" : "Height",height);
|
||||
this.addGroup(this._time,148,26,72,"Total Time",time);
|
||||
}
|
||||
else if(time != null)
|
||||
{
|
||||
message = !(Data.state as BossMode).isPractice() ? "You have successfully completed " + ((Data.state as BossMode).isHeroic() ? "Heroic" : "Normal") + " Boss Mode!\nTime: " + time : "You\'ve successfully defeated a practice mode boss!";
|
||||
this._tipText = new FlxBitmapText(0,33,Fonts.font(Fonts.SMALL_WHITE),message.toUpperCase(),"center",218);
|
||||
this._tipText.y += (30 - this._tipText.height) / 2;
|
||||
this.add(this._tipText);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._tipText = new FlxBitmapText(0,23,Fonts.font(Fonts.SMALL_WHITE),Tip.random(),"center",218);
|
||||
offset = (30 - this._tipText.height) / 2;
|
||||
this._tipText.y += offset;
|
||||
this.add(this._tipText);
|
||||
}
|
||||
buttonY = diamonds == null && time == null ? 57 : (diamonds == null ? 64 : 50);
|
||||
this._buttonRetry = new ArcButton(22,buttonY,72,13,spriteRetry).callback(function():void
|
||||
{
|
||||
if(_complete && !_fading)
|
||||
{
|
||||
FlxG.camera.fade(4278190080,0.5,function():void
|
||||
{
|
||||
_retryFunction();
|
||||
});
|
||||
}
|
||||
}).selectable(false);
|
||||
this.add(this._buttonRetry);
|
||||
this._buttonMainMenu = new ArcButton(123,buttonY,72,13,spriteMainMenu).callback(function():void
|
||||
{
|
||||
if(_complete && !_fading)
|
||||
{
|
||||
FlxG.camera.fade(4278190080,0.5,function():void
|
||||
{
|
||||
_menuFunction();
|
||||
});
|
||||
}
|
||||
}).selectable(false);
|
||||
this.add(this._buttonMainMenu);
|
||||
setAll("scrollFactor",new FlxPoint(0,0));
|
||||
alpha = 0;
|
||||
}
|
||||
|
||||
public function setCallback(param1:Function, param2:Function) : GameOver
|
||||
{
|
||||
this._retryFunction = param1;
|
||||
this._menuFunction = param2;
|
||||
return this;
|
||||
}
|
||||
|
||||
private function addGroup(param1:ArcGroup, param2:int, param3:int, param4:int, param5:String, param6:String) : void
|
||||
{
|
||||
var _loc7_:FlxBitmapText = new FlxBitmapText(param2,param3,Fonts.font(Fonts.SMALL_WHITE),param5.toUpperCase(),"center",param4);
|
||||
param1.add(_loc7_);
|
||||
var _loc8_:FlxBitmapText = new FlxBitmapText(param2,param3 + 8,Fonts.font(Fonts.SMALL_WHITE),param6.toUpperCase(),"center",param4);
|
||||
_loc8_.alpha = 0.8;
|
||||
param1.add(_loc8_);
|
||||
this.add(param1);
|
||||
}
|
||||
|
||||
override public function update() : void
|
||||
{
|
||||
var order:Array = null;
|
||||
var o:* = undefined;
|
||||
if(!this._complete)
|
||||
{
|
||||
order = [this._window,this._diamonds,this._height,this._time,this._tipText];
|
||||
for each(o in order)
|
||||
{
|
||||
if(o != null)
|
||||
{
|
||||
if(o.alpha < 1)
|
||||
{
|
||||
o.alpha += FADE_SPEED * FlxG.elapsed;
|
||||
if(o.alpha > 1)
|
||||
{
|
||||
o.alpha = 1;
|
||||
}
|
||||
if(o == this._window)
|
||||
{
|
||||
this._buttonRetry.alpha = this._buttonMainMenu.alpha = o.alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._complete = true;
|
||||
}
|
||||
else if(FlxG.keys.justPressed("R"))
|
||||
{
|
||||
FlxG.camera.fade(4278190080,0.5,function():void
|
||||
{
|
||||
_retryFunction();
|
||||
});
|
||||
}
|
||||
else if(FlxG.keys.justPressed("M"))
|
||||
{
|
||||
FlxG.camera.fade(4278190080,0.5,function():void
|
||||
{
|
||||
_menuFunction();
|
||||
});
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user