127 lines
4.1 KiB
ActionScript
127 lines
4.1 KiB
ActionScript
package com.arc.dh.menu
|
|
{
|
|
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.dh.util.Sound;
|
|
import com.arc.dh.util.SoundSystem;
|
|
import com.arc.flixel.ArcGroup;
|
|
import com.arc.flixel.ArcSprite;
|
|
import org.flixel.FlxBitmapText;
|
|
import org.flixel.FlxG;
|
|
import org.flixel.FlxPoint;
|
|
|
|
public class SkillMeter extends ArcGroup
|
|
{
|
|
|
|
private static const barSprite:Class = SkillMeter_barSprite;
|
|
|
|
private static const diamondSprite:Class = SkillMeter_diamondSprite;
|
|
|
|
private static const COSTS:Array = [50,100,175,250,350,450,600,800,1200,1500,-1];
|
|
|
|
private var _bg:ArcSprite;
|
|
|
|
private var _bar:ArcSprite;
|
|
|
|
private var _skill:String;
|
|
|
|
private var _name:FlxBitmapText;
|
|
|
|
private var _diamond:ArcSprite;
|
|
|
|
private var _cost:FlxBitmapText;
|
|
|
|
public function SkillMeter(param1:Number, param2:Number, param3:String)
|
|
{
|
|
super(param1,param2);
|
|
this._skill = param3;
|
|
this._bg = new ArcSprite(-2,0);
|
|
this._bg.makeGraphic(127,7,4294967295);
|
|
this._bg.alpha = 0.1;
|
|
this.add(this._bg);
|
|
this._bar = new ArcSprite(36,0);
|
|
this._bar.loadGraphic(barSprite,true,false,53,7);
|
|
this._bar.frame = Math.random() * 10;
|
|
this.add(this._bar);
|
|
this._name = new FlxBitmapText(0,1,Fonts.font(Fonts.SMALL_WHITE),param3.toUpperCase(),"left",1000);
|
|
this._name.alpha = 0.9;
|
|
this.add(this._name);
|
|
this._diamond = new ArcSprite(115,-1);
|
|
this._diamond.loadGraphic(diamondSprite,true,false,8,8);
|
|
this.add(this._diamond);
|
|
this._cost = new FlxBitmapText(13,1,Fonts.font(Fonts.SMALL_WHITE),param3,"right",100);
|
|
this.add(this._cost);
|
|
setAll("scrollFactor",new FlxPoint(0,0));
|
|
this.sync();
|
|
}
|
|
|
|
private function getDescription() : String
|
|
{
|
|
switch(this._skill)
|
|
{
|
|
case "agility":
|
|
return "Increases movement speed";
|
|
case "jump":
|
|
return "Increases jump height";
|
|
case "attract":
|
|
return "Increases diamond attraction";
|
|
case "recover":
|
|
return "Increases speed of recover after knockback";
|
|
case "aegis":
|
|
return "Increases invulnerability time after being hit";
|
|
case "defense":
|
|
return "Decreases damage from higher level enemies";
|
|
default:
|
|
return "THE FUCK!?";
|
|
}
|
|
}
|
|
|
|
override public function update() : void
|
|
{
|
|
if(this._bg.hover())
|
|
{
|
|
this._bg.alpha = 0.4;
|
|
if(FlxG.mouse.justPressed())
|
|
{
|
|
if(Data[this._skill] < 10 && Data.diamonds >= this.cost())
|
|
{
|
|
SoundSystem.play(Sound.BUY);
|
|
Data.diamonds -= this.cost();
|
|
++Data[this._skill];
|
|
this.sync();
|
|
AchievementSystem.skills();
|
|
DataSerializer.save();
|
|
}
|
|
}
|
|
if(Menu.tooltip == null || Menu.tooltip.source != this)
|
|
{
|
|
Menu.tooltip = new MenuTooltip(this._bg.x + this._bg.width / 2,this._bg.y - 1,this._skill.toUpperCase(),this.getDescription().toUpperCase());
|
|
Menu.tooltip.source = this;
|
|
}
|
|
Menu.hovering = true;
|
|
}
|
|
else
|
|
{
|
|
this._bg.alpha = 0.1;
|
|
}
|
|
super.update();
|
|
}
|
|
|
|
public function sync() : void
|
|
{
|
|
this._bar.frame = Data[this._skill];
|
|
var _loc1_:int = this.cost();
|
|
this._cost.text = _loc1_ == -1 ? "" : _loc1_.toString();
|
|
this._diamond.frame = _loc1_ == -1 ? 4 : (_loc1_ > Data.diamonds ? 3 : 1);
|
|
}
|
|
|
|
private function cost() : int
|
|
{
|
|
return COSTS[Data[this._skill]];
|
|
}
|
|
}
|
|
}
|
|
|