92 lines
2.7 KiB
ActionScript
92 lines
2.7 KiB
ActionScript
package com.arc.dh.state
|
|
{
|
|
import com.arc.dh.menu.Menu;
|
|
import com.arc.dh.menu.MenuTooltip;
|
|
import com.arc.dh.util.Achievement;
|
|
import com.arc.dh.util.AchievementSystem;
|
|
import com.arc.dh.util.Data;
|
|
import com.arc.flixel.ArcGroup;
|
|
import com.arc.flixel.ArcSprite;
|
|
import org.flixel.FlxPoint;
|
|
|
|
public class Trophy extends ArcGroup
|
|
{
|
|
|
|
private static const sprite:Class = Trophy_sprite;
|
|
|
|
public static const BRONZE:int = 0;
|
|
|
|
public static const SILVER:int = 1;
|
|
|
|
public static const GOLD:int = 2;
|
|
|
|
public static const PLATINUM:int = 3;
|
|
|
|
private var _type:int;
|
|
|
|
private var _achievement:Achievement;
|
|
|
|
private var _sprite:ArcSprite;
|
|
|
|
private var _bg:ArcSprite;
|
|
|
|
public function Trophy(param1:Number, param2:Number, param3:int)
|
|
{
|
|
super(param1,param2);
|
|
this._sprite = new ArcSprite(0,0);
|
|
this._sprite.loadGraphic(sprite,true,false,16,16);
|
|
this._achievement = AchievementSystem.get(param3);
|
|
this._type = this._achievement.type;
|
|
this._sprite.addAnimation("trophy",[this._type]);
|
|
this._sprite.play("trophy");
|
|
this._bg = new ArcSprite(-1,-1);
|
|
this._bg.makeGraphic(18,18,4294967295);
|
|
this._bg.alpha = 0.1;
|
|
this.add(this._bg);
|
|
this.add(this._sprite);
|
|
setAll("scrollFactor",new FlxPoint(0,0));
|
|
this.sync();
|
|
}
|
|
|
|
override public function update() : void
|
|
{
|
|
if(this._sprite.hover())
|
|
{
|
|
this._bg.alpha = 0.3;
|
|
if(Menu.tooltip == null || Menu.tooltip.source != this)
|
|
{
|
|
Menu.tooltip = new MenuTooltip(this._bg.x + this._bg.width / 2,this._bg.y,this._achievement.name.toUpperCase(),this._achievement.description.toUpperCase());
|
|
Menu.tooltip.source = this;
|
|
}
|
|
Menu.hovering = true;
|
|
}
|
|
else
|
|
{
|
|
this._bg.alpha = Data.achievements[this._achievement.id] == 1 ? 0.1 : 0.05;
|
|
}
|
|
this.sync();
|
|
super.update();
|
|
}
|
|
|
|
public function achieved() : Boolean
|
|
{
|
|
return Data.achievements[this._achievement.id] != 0;
|
|
}
|
|
|
|
public function sync() : void
|
|
{
|
|
if(Data.achievements[this._achievement.id] == 1)
|
|
{
|
|
this._sprite.alpha = 1 * _alpha;
|
|
this._bg.alpha = 0.1 * _alpha;
|
|
}
|
|
else
|
|
{
|
|
this._sprite.alpha = 0.2 * _alpha;
|
|
this._bg.alpha = 0.05 * _alpha;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|