package com.arc.dh.menu { import com.arc.dh.Gun; 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 GunComponentBar extends ArcGroup { private static const diamondsSprite:Class = GunComponentBar_diamondsSprite; private static const bgSprite:Class = GunComponentBar_bgSprite; private static const barSprite:Class = GunComponentBar_barSprite; private static const singleBarSprite:Class = GunComponentBar_singleBarSprite; private static const barSpriteUnobtained:Class = GunComponentBar_barSpriteUnobtained; private static const singleBarSpriteUnobtained:Class = GunComponentBar_singleBarSpriteUnobtained; private static const COSTS:Array = [100,150,200,300,450,600,800,1000,1200,1500]; private static const SPECIAL_COST:int = 2500; private var _bg:ArcSprite; private var _bar:ArcSprite; private var _skill:String; private var _offset:int; private var _type:int; private var _name:FlxBitmapText; private var _diamond:ArcSprite; private var _cost:FlxBitmapText; private var _obtained:Boolean; public function GunComponentBar(param1:Number, param2:Number, param3:String, param4:int, param5:String, param6:Boolean) { super(param1,param2); this._skill = param3; this._offset = param4; this._type = param4 >= 2 ? 1 : 10; this._obtained = param6; this._bg = new ArcSprite(-1,3); this.add(this._bg); this._bar = new ArcSprite(0,10); if(this._type == 1) { this._bar.loadGraphic(param6 ? singleBarSprite : singleBarSpriteUnobtained,true,false,83,7); } else if(this._type == 10) { this._bar.loadGraphic(param6 ? barSprite : barSpriteUnobtained,true,false,83,7); } this._bg.loadGraphic(bgSprite,false,false,85,15); this._bar.frame = Data[this._skill][this._offset]; this.add(this._bar); this._diamond = new ArcSprite(this._bar.width - 8,3); this._diamond.loadGraphic(diamondsSprite,true,false,8,8); this._diamond.frame = param6 ? 1 : 5; this._diamond.alpha = param6 ? 1 : 0.5; this.add(this._diamond); this._cost = new FlxBitmapText(this._diamond.x - 48,4,Fonts.font(Fonts.OUTLINE_BLUE_S),"","right",40,true); this.add(this._cost); var _loc7_:String = param6 ? this.getName(param3,param4) : "Unknown"; this._name = new FlxBitmapText(0,4,Fonts.font(param6 ? Fonts.OUTLINE_BLUE_S : Fonts.OUTLINE_BLACK_S),_loc7_.toUpperCase(),"left",100,true); if(!param6) { this._name.alpha = 0.5; } this.add(this._name); this.sync(); setAll("scrollFactor",new FlxPoint(0,0)); } public function sync() : void { var _loc1_:int = this.getCost(this._skill,this._offset); this._bar.frame = Data[this._skill][this._offset]; if(this._obtained) { this._cost.text = _loc1_ == -1 ? "" : _loc1_.toString(); } this._diamond.frame = !this._obtained ? 5 : (_loc1_ == -1 ? 4 : (_loc1_ > Data.diamonds ? 3 : 1)); } public function motherfuckingSync() : void { if(this._type == 1) { this._bar.loadGraphic(singleBarSprite,true,false,83,7); } else if(this._type == 10) { this._bar.loadGraphic(barSprite,true,false,83,7); } this._obtained = true; this._bar.frame = Data[this._skill][this._offset]; this._name.font = Fonts.font(Fonts.OUTLINE_BLUE_S); this._name.text = this.getName(this._skill,this._offset); this._name.alpha = 1; this.sync(); } override public function update() : void { var _loc1_:String = null; var _loc2_:Number = NaN; var _loc3_:Number = NaN; var _loc4_:String = null; var _loc5_:Array = null; if(this._bg.hover()) { this._bg.alpha = 0.4; if(FlxG.mouse.justPressed() && this._obtained) { if(Data[this._skill][this._offset] < this._type && Data.diamonds >= this.getCost(this._skill,this._offset)) { SoundSystem.play(Sound.BUY); Data.diamonds -= this.getCost(this._skill,this._offset); ++Data[this._skill][this._offset]; AchievementSystem.guns(); this.sync(); DataSerializer.save(); Menu.tooltip = null; } } if((Menu.tooltip == null || Menu.tooltip.source != this) && this._obtained) { _loc1_ = null; _loc2_ = 0; _loc3_ = 0; _loc4_ = this._skill.replace("gun","").toUpperCase(); if(this._offset == 0) { _loc1_ = "DAMAGE"; switch(this._skill) { case "primegun": _loc5_ = Gun.PRIME_DAMAGE; break; case "spreadergun": _loc5_ = Gun.SPREADER_DAMAGE; break; case "missilegun": _loc5_ = Gun.MISSILE_DAMAGE; break; case "reboundgun": _loc5_ = Gun.REBOUND_DAMAGE; } } else if(this._offset == 1) { _loc1_ = "DELAY"; switch(this._skill) { case "primegun": _loc5_ = Gun.PRIME_DELAY; break; case "spreadergun": _loc5_ = Gun.SPREADER_DELAY; break; case "missilegun": _loc5_ = Gun.MISSILE_DELAY; break; case "reboundgun": _loc5_ = Gun.REBOUND_DELAY; } } if(_loc1_ != null) { _loc2_ = Number(_loc5_[Data[this._skill][this._offset]]); _loc3_ = Data[this._skill][this._offset] < 10 ? Number(_loc5_[Data[this._skill][this._offset] + 1]) : Number(null); } Menu.tooltip = new MenuTooltip(this._bg.x + this._bg.width / 2,this._bg.y,this.getName(this._skill,this._offset),this.getDescription(this._skill,this._offset),_loc1_,_loc2_,_loc3_); Menu.tooltip.source = this; } Menu.hovering = true; } else { this._bg.alpha = 0.17; } super.update(); } private function getCost(param1:String, param2:int) : int { var _loc3_:int = int(Data[param1][param2]); if(param2 == 0) { return _loc3_ == 10 ? -1 : int(COSTS[_loc3_]); } if(param2 == 1) { return _loc3_ == 10 ? -1 : int(COSTS[_loc3_]); } if(param2 == 2) { return _loc3_ == 1 ? -1 : SPECIAL_COST; } if(param2 == 3) { return _loc3_ == 1 ? -1 : SPECIAL_COST; } return -1; } private function getDescription(param1:String, param2:int) : String { if(param2 == 0) { return "Increases damage done"; } if(param2 == 1) { return "Increases firing rate"; } if(param2 == 2) { switch(param1) { case "primegun": return "Adds a 30% chance of double damage"; case "spreadergun": return "Shoots 5 bullets instead of 3"; case "missilegun": return "Missiles obsorb enemy projectiles"; case "reboundgun": return "Rebound bullets bounce three times"; } } else if(param2 == 3) { switch(param1) { case "primegun": return "Shoots 2 bullets side by side"; case "spreadergun": return "Doubles the damage of your center spreader bullet"; case "missilegun": return "Missiles explode into 6 bullets on contact"; case "reboundgun": return "Rebound bullets bounce off enemies"; } } return "SHIT"; } private function getName(param1:String, param2:int) : String { if(param2 == 0) { return "POWER"; } if(param2 == 1) { return "SPEED"; } if(param2 == 2) { switch(param1) { case "primegun": return "CRITICAL"; case "spreadergun": return "SPREAD"; case "missilegun": return "ABSORB"; case "reboundgun": return "TRIPLE"; } } else if(param2 == 3) { switch(param1) { case "primegun": return "TWIN"; case "spreadergun": return "FOCUS"; case "missilegun": return "SHRAPNEL"; case "reboundgun": return "ENEMY"; } } return "FUCK"; } } }