Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sponsored
- {
- import com.newgrounds.API;
- import com.newgrounds.components.MedalPopup;
- import misc.Items;
- import net.flashpunk.FP;
- import net.flashpunk.Sfx;
- public class NewgroundsAPI
- {
- private var medal_popup:MedalPopup;
- private var _unlocked_coins_medal:Boolean = false;
- private var _unlock_box_break_medal:Boolean = false;
- public function NewgroundsAPI()
- {
- super();
- this.medal_popup = new MedalPopup();
- this.medal_popup.x = 20;
- this.medal_popup.y = 580 - this.medal_popup.height;
- FP.stage.addChild(this.medal_popup);
- }
- public function CheckAllMedals() : void
- {
- this.MaxHPPlusPlus();
- this.MoonStoneGet();
- this.InventoryCheckForMedals(3);
- this._SaveIndexCheckMedalsBackup();
- this.InnSleepMedalCheck();
- this.CoinAddCheckMedal(0);
- this.BoxBreakCheckMedal(0);
- this.EatFoodCheckMedal(21,true);
- this._BestiaryMedalCheckBackup();
- this._BeatGameBackupCheck();
- }
- public function MaxHPPlusPlus() : void
- {
- if(FP.game_world.player.max_hp >= 99)
- {
- API.unlockMedal("Diamond Skin");
- }
- if(FP.game_world.player.max_hp >= 40)
- {
- API.unlockMedal("Iron Skin");
- }
- }
- public function MoonStoneGet() : void
- {
- var _loc1_:int = FP.game_world.local_save.space_rocks;
- if(_loc1_ >= 42)
- {
- API.unlockMedal("Number 42");
- }
- if(_loc1_ >= 40)
- {
- API.unlockMedal("Master Moon Stone Hunter");
- }
- if(_loc1_ >= 20)
- {
- API.unlockMedal("Experienced Moon Stone Hunter");
- }
- if(_loc1_ >= 5)
- {
- API.unlockMedal("Novice Moon Stone Hunter");
- }
- }
- public function InventoryCheckForMedals(param1:int) : void
- {
- var _loc2_:Items = FP.game_world.player.items;
- if(!_loc2_.Contains(1))
- {
- API.unlockMedal("Big Bag");
- }
- if(_loc2_.Contains(11))
- {
- API.unlockMedal("It\'s dangerous to go alone!");
- }
- if(_loc2_.Contains(61) && _loc2_.Contains(42) && _loc2_.Contains(60) && _loc2_.Contains(59) && _loc2_.Contains(13) && _loc2_.Contains(12) && _loc2_.Contains(23))
- {
- API.unlockMedal("Most Dangerous Arsenal");
- }
- }
- private function _SaveIndexCheckMedalsBackup() : void
- {
- if(FP.saver.CheckGeneralArray(316))
- {
- API.unlockMedal("Repentance");
- }
- if(FP.saver.CheckGeneralArray(122))
- {
- API.unlockMedal("Robin Hood?");
- }
- if(FP.saver.CheckGeneralArray(310))
- {
- API.unlockMedal("Bearer of Bad News");
- }
- if(FP.saver.CheckGeneralArray(311))
- {
- API.unlockMedal("Good Friend");
- }
- if(FP.saver.CheckGeneralArray(345))
- {
- API.unlockMedal("Explorer");
- }
- if(FP.saver.CheckGeneralArray(313))
- {
- API.unlockMedal("Exterminator");
- }
- if(FP.saver.CheckGeneralArray(390))
- {
- API.unlockMedal("Last Song of Earth");
- }
- }
- public function SaveIndexCheckMedals(param1:int) : void
- {
- if(param1 == 316)
- {
- API.unlockMedal("Repentance");
- }
- else if(param1 == 122)
- {
- API.unlockMedal("Robin Hood?");
- }
- else if(param1 == 310)
- {
- API.unlockMedal("Bearer of Bad News");
- }
- else if(param1 == 311)
- {
- API.unlockMedal("Good Friend");
- }
- else if(param1 == 345)
- {
- API.unlockMedal("Explorer");
- }
- else if(param1 == 313)
- {
- API.unlockMedal("Exterminator");
- }
- else if(param1 == 390)
- {
- API.unlockMedal("Last Song of Earth");
- }
- }
- public function InnSleepMedalCheck() : void
- {
- var _loc1_:Array = FP.game_world.local_save.general;
- var _loc2_:int = 391;
- while(_loc2_ < 400)
- {
- if(!_loc1_[_loc2_])
- {
- return;
- }
- _loc2_++;
- }
- API.unlockMedal("A Connoisseur of Fluffy Pillows");
- }
- private function _BestiaryMedalCheckBackup() : void
- {
- if(FP.game_world.local_save.game_time >= 4)
- {
- API.unlockMedal("Bully to Toads");
- }
- if(FP.game_world.local_save.game_time >= 10)
- {
- API.unlockMedal("Slayer of Dragons");
- }
- if(FP.saver.CheckGeneralArray(108))
- {
- API.unlockMedal("Breaker of Robots");
- }
- if(FP.game_world.local_save.game_time >= 22)
- {
- API.unlockMedal("Enemy to Kobolds");
- }
- }
- public function UnlockBestiaryMedal(param1:int) : void
- {
- switch(param1)
- {
- case 0:
- API.unlockMedal("Never knew what hit him");
- break;
- case 1:
- API.unlockMedal("Harpy Backfire");
- break;
- case 2:
- API.unlockMedal("Bully to Toads");
- break;
- case 3:
- API.unlockMedal("Slayer of Dragons");
- break;
- case 4:
- API.unlockMedal("Breaker of Robots");
- break;
- case 5:
- API.unlockMedal("Enemy to Kobolds");
- }
- }
- public function CoinAddCheckMedal(param1:int) : void
- {
- if(this._unlocked_coins_medal)
- {
- return;
- }
- FP.game_world.local_save.coins_collected_total = FP.game_world.local_save.coins_collected_total + param1;
- if(FP.game_world.local_save.coins_collected_total >= 1000)
- {
- API.unlockMedal("Treasure Hunter");
- this._unlocked_coins_medal = true;
- }
- }
- public function BoxBreakCheckMedal(param1:int = 1) : void
- {
- if(this._unlock_box_break_medal)
- {
- return;
- }
- FP.game_world.local_save.boxes_broken_count = FP.game_world.local_save.boxes_broken_count + param1;
- if(FP.game_world.local_save.boxes_broken_count >= 100)
- {
- this._unlock_box_break_medal = true;
- API.unlockMedal("Property Destruction");
- }
- }
- public function EatFoodCheckMedal(param1:int, param2:Boolean = false) : void
- {
- if(!param2)
- {
- FP.game_world.local_save.good_food_consumed = FP.game_world.local_save.good_food_consumed + 1;
- if(param1 == 21 || param1 == 39 || param1 == 49 || param1 == 58 || param1 == 75)
- {
- FP.game_world.local_save.bad_food_consumed = FP.game_world.local_save.bad_food_consumed + 1;
- }
- }
- if(FP.game_world.local_save.good_food_consumed >= 30)
- {
- API.unlockMedal("Big Eater");
- }
- if(FP.game_world.local_save.bad_food_consumed >= 5)
- {
- API.unlockMedal("Never waste food");
- }
- }
- private function _BeatGameBackupCheck() : void
- {
- if(FP.saver.CheckGeneralArray(351))
- {
- API.unlockMedal("The End");
- }
- }
- public function BeatGameMedalsCheck() : void
- {
- Sfx.setVolume("m",1);
- Sfx.setVolume(null,1);
- API.unlockMedal("The End");
- var _loc1_:SaveFileX = FP.game_world.local_save;
- var _loc2_:int = _loc1_.accumulated_time_played + 0.001 * (FP.game_world.GetTime() - _loc1_.time_started_playing);
- if(_loc2_ <= 3870)
- {
- if(_loc2_ >= 1200)
- {
- API.unlockMedal("Speed Runner!");
- }
- }
- if(_loc1_.times_died == 0)
- {
- API.unlockMedal("Indomitable!");
- }
- }
- public function NGPrint(param1:String) : void
- {
- API.logCustomEvent(param1);
- }
- public function DisplayUnlockedMedals() : void
- {
- var _loc4_:String = null;
- var _loc5_:uint = 0;
- var _loc1_:Array = API.medals;
- var _loc2_:uint = 0;
- var _loc3_:uint = 0;
- while(_loc3_ < _loc1_.length)
- {
- _loc4_ = _loc1_[_loc3_].name;
- _loc5_ = _loc1_[_loc3_].value;
- if(_loc1_[_loc3_].unlocked)
- {
- _loc2_ = _loc2_ + _loc5_;
- }
- _loc3_++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement