113 lines
3.3 KiB
ActionScript
113 lines
3.3 KiB
ActionScript
package com.arc.dh.state
|
|
{
|
|
import com.arc.dh.util.AchievementSystem;
|
|
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.ArcButtonGroup;
|
|
import com.arc.flixel.ArcGroup;
|
|
import com.arc.flixel.ArcSprite;
|
|
import org.flixel.FlxBitmapText;
|
|
|
|
public class EscapeButton extends ArcGroup
|
|
{
|
|
|
|
private static const buttonSprite:Class = EscapeButton_buttonSprite;
|
|
|
|
public static const lockSprite:Class = EscapeButton_lockSprite;
|
|
|
|
private var _height:int;
|
|
|
|
private var _button:ArcButton;
|
|
|
|
private var _text:FlxBitmapText;
|
|
|
|
private var _lock:ArcSprite;
|
|
|
|
private var _screen:EscapeScreen;
|
|
|
|
public function EscapeButton(param1:Number, param2:Number, param3:int, param4:ArcButtonGroup)
|
|
{
|
|
var index:int = 0;
|
|
var cost:int = 0;
|
|
var X:Number = param1;
|
|
var Y:Number = param2;
|
|
var H:int = param3;
|
|
var G:ArcButtonGroup = param4;
|
|
super();
|
|
this._height = H;
|
|
this._button = new ArcButton(X,Y,42,16,buttonSprite);
|
|
this.add(this._button);
|
|
G.addButton(this._button);
|
|
this._text = new FlxBitmapText(X,Y + 4,Fonts.font(Fonts.OUTLINE_BLACK_S),H + "M","right",37);
|
|
this.add(this._text);
|
|
index = H / 100;
|
|
cost = H * 5;
|
|
if(Data.escape[index] == 0)
|
|
{
|
|
this._lock = new ArcSprite(X + 4,Y + 3,lockSprite);
|
|
this._button.selectable(false).callback(function():void
|
|
{
|
|
if(Data.diamonds >= cost && Data.escape[index - 1] == 1)
|
|
{
|
|
Data.escape[index] = 1;
|
|
_lock = null;
|
|
_screen.tooltip = null;
|
|
_button.callback(null);
|
|
_button.selectable(true);
|
|
_button.select();
|
|
Data.diamonds -= cost;
|
|
AchievementSystem.checkpoints();
|
|
DataSerializer.save();
|
|
}
|
|
});
|
|
}
|
|
else
|
|
{
|
|
this._button.selectable(true);
|
|
this._button.select();
|
|
}
|
|
}
|
|
|
|
public function setScreen(param1:EscapeScreen) : void
|
|
{
|
|
this._screen = param1;
|
|
}
|
|
|
|
override public function update() : void
|
|
{
|
|
if(this._button.hover() && this._lock != null)
|
|
{
|
|
if(this._screen.tooltip == null || this._screen.tooltip.source != this)
|
|
{
|
|
this._screen.tooltip = new EscapeTooltip(this._button.x + 21,this._button.y,this._height);
|
|
this._screen.tooltip.source = this;
|
|
}
|
|
this._screen.hovering = true;
|
|
}
|
|
super.update();
|
|
}
|
|
|
|
override public function draw() : void
|
|
{
|
|
super.draw();
|
|
if(this._lock != null)
|
|
{
|
|
this._lock.draw();
|
|
}
|
|
}
|
|
|
|
public function get selected() : Boolean
|
|
{
|
|
return this._button.selected;
|
|
}
|
|
|
|
public function get start() : int
|
|
{
|
|
return this._height;
|
|
}
|
|
}
|
|
}
|
|
|