Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.utils.ByteArray;
- import flash.net.SharedObject;
- public class SaveManager {
- public var parentClass:Main;
- public var saveData:SharedObject = SharedObject.getLocal("nutter666/webbyHD")
- // awards
- var flySnack:Boolean = false; // collect 50 black flies
- var flyMeal:Boolean = false; // collect 100 black flies
- var flyFeast:Boolean = false; // collect 250 black flies
- var flyBuffet:Boolean = false; // collect 500 black flies
- var flyGluttony:Boolean = false; // collect 1000 black flies
- var freeze:Boolean = false; // collect 1 freeze flies
- var deepFreeze:Boolean = false; // collect 5 freeze flies
- var winterIsComing:Boolean = false; // collect 25 freeze flies
- var winterHasArrived:Boolean = false // collect 50 freeze flies
- var iceAge:Boolean = false; // collect 100 freeze flies
- var bigRedBlast:Boolean = false; // collect 1 super blast flies
- var seeingRed:Boolean = false; // collect 5 super blast flies
- var radioactiveRed:Boolean = false // collect 25 super blast flies
- var redStorm:Boolean = false; // collect 50 super blast flies
- var theRedDeath:Boolean = false; // collect 100 super blast flies
- var extraLife:Boolean = false; // collect 1 extra life flies
- var extraLife2:Boolean = false; // collect 5 extra life flies
- var longLiving:Boolean = false; // collect 25 extra life flies
- var eternal:Boolean = false; // collect 50 extra life flies
- var immortality:Boolean = false; // collect 100 extra life flies
- var sprinter:Boolean = false; // collect 25 speedy flies
- var sprinter2:Boolean = false; // collect 50 speedy flies
- var sprinter3:Boolean = false; // collect 100 speedy flies
- //--------------- [STATS] ----------------
- // Fly stats
- var blackFliesCollected:int = 0;
- var glowFliesCollected:int = 0;
- var greenFliesCollected:int = 0;
- var blueFliesCollected:int = 0;
- var redFliesCollected:int = 0;
- var purpleFliesCollected:int = 0;
- var pinkFliesCollected:int = 0;
- var goldFliesCollected:int = 0;
- // enemy stats
- var widowsEaten:int = 0;
- var pyrosEaten:int = 0;
- var spinnersEaten:int = 0;
- var huntersEaten:int = 0;
- var feedersEaten:int = 0;
- var bossBeaten:int = 0;
- // chapter stats
- var chapter1Complete:Boolean = false;
- var chapter2Complete:Boolean = false;
- var chapter3Complete:Boolean = false;
- var chapter4Complete:Boolean = false;
- var chapter5Complete:Boolean = false;
- public function SaveManager(pClass) {
- // constructor code
- parentClass = pClass
- }
- public function checkUnlockCondition(charName:String){
- // chapter unlock characters
- if(charName == "widow"){
- if(this.chapter1Complete){
- return true;
- }
- else{
- return false;
- }
- }
- else if(charName == "pyro"){
- if(this.chapter2Complete){
- return true;
- }
- else{
- return false;
- }
- }
- else if(charName == "silky"){
- if(this.chapter3Complete){
- return true;
- }
- else{
- return false;
- }
- }
- else if(charName == "hunter"){
- if(this.chapter4Complete){
- return true;
- }
- else{
- return false;
- }
- }
- // powerup unlocks
- // blue fly powerup
- else if(charName == "frosty"){
- if(this.deepFreeze){
- return true;
- }
- else{
- return false
- }
- }
- // red fly powerup
- else if(charName == "midget"){
- if(this.radioactiveRed){
- return true;
- }
- else{
- return true;
- //return false;
- }
- }
- else {
- trace(charName+" needs unlock requiremnt")
- return true;
- }
- }
- function submitStat(statName:String,statNum:Number){
- if(parentClass.debugMode){
- trace("Submit Stat["+statName+":"+statNum+"]")
- }
- // flies eaten
- if(statName == "blackFlyEaten"){
- this.blackFliesCollected += statNum;
- }
- else if(statName == "blueFlyEaten"){
- this.blueFliesCollected += statNum;
- }
- else if(statName == "redFlyEaten"){
- this.redFliesCollected += statNum;
- }
- else if(statName == "greenFlyEaten"){
- this.greenFliesCollected += statNum;
- }
- else if(statName == "purpleFlyEaten"){
- this.purpleFliesCollected += statNum;
- }
- else if(statName == "pinkFlyEaten"){
- this.pinkFliesCollected += statNum;
- }
- else if(statName == "goldFlyEaten"){
- this.goldFliesCollected += statNum;
- }
- else if(statName == "glowFlyEaten"){
- this.glowFliesCollected += statNum;
- }
- // super mode / enemies eaten
- else if(statName == "blackEnemyEaten"){
- this.widowsEaten += statNum;
- }
- else if(statName == "redEnemyEaten"){
- this.pyrosEaten += statNum;
- }
- else if(statName == "whiteEnemyEaten"){
- this.spinnersEaten += statNum;
- }
- else if(statName == "greenEnemyEaten"){
- this.huntersEaten += statNum;
- }
- else if(statName == "purpleEnemyEaten"){
- this.feedersEaten += statNum;
- }
- updateAwards();
- // update awards should check if an award has been unlocked and spawn a popup if it has
- }
- function updateAwards(){
- // black flies awards
- if(this.blackFliesCollected >= 50 && !flySnack){
- this.flySnack = true;
- spawnAwardPopup("Fly Snack","blackFly")
- }
- if(this.blackFliesCollected >= 100 && !flyMeal){
- this.flyMeal= true;
- spawnAwardPopup("Fly Meal","blackFly")
- }
- if(this.blackFliesCollected >= 250 && !flyFeast){
- this.flyFeast= true;
- spawnAwardPopup("Fly Feast","blackFly")
- }
- if(this.blackFliesCollected >= 500 && !flyBuffet){
- this.flyBuffet = true;
- spawnAwardPopup("Fly Buffet","blackFly")
- }
- if(this.blackFliesCollected >= 1000 && !flyGluttony){
- this.flyGluttony = true;
- spawnAwardPopup("Fly Gluttony","blackFly")
- }
- // blue flies awards
- if(this.blueFliesCollected >= 1 && !freeze){
- this.freeze = true;
- spawnAwardPopup("Freeze!","blueFly")
- }
- if(this.blueFliesCollected >= 5 && !deepFreeze){
- this.deepFreeze = true;
- spawnAwardPopup("Deep Freeze","blueFly")
- }
- if(this.blueFliesCollected >= 25 && !winterIsComing){
- this.winterIsComing = true;
- spawnAwardPopup("Winter is Coming","blueFly")
- }
- if(this.blueFliesCollected >= 50 && !winterHasArrived){
- this.winterHasArrived = true;
- spawnAwardPopup("Winter is Here","blueFly")
- }
- if(this.blueFliesCollected >= 100 && !iceAge){
- this.iceAge = true;
- spawnAwardPopup("Ice Age!","blueFly")
- }
- // glow flies awards
- if(this.glowFliesCollected >= 1 && !extraLife){
- this.extraLife = true;
- spawnAwardPopup("1Up!","glowFly")
- }
- if(this.glowFliesCollected >= 5 && !extraLife2){
- this.extraLife2 = true;
- spawnAwardPopup("Extra Lives","glowFly")
- }
- if(this.glowFliesCollected >= 25 && !longLiving){
- this.longLiving = true;
- spawnAwardPopup("Long Living","glowFly")
- }
- if(this.glowFliesCollected >= 50 && !eternal){
- this.eternal = true;
- spawnAwardPopup("Eternal","glowFly")
- }
- if(this.glowFliesCollected >= 100 && !immortality){
- this.immortality = true;
- spawnAwardPopup("Immortality","glowFly")
- }
- // red flies awards
- if(this.redFliesCollected >= 1 && !bigRedBlast){
- this.bigRedBlast = true;
- spawnAwardPopup("Big Red Blast!","redFly")
- }
- if(this.redFliesCollected >= 5 && !seeingRed){
- this.seeingRed = true;
- spawnAwardPopup("Seeing Red","redFly")
- }
- if(this.redFliesCollected >= 25 && !radioactiveRed){
- this.radioactiveRed = true;
- spawnAwardPopup("Radioactive","redFly")
- }
- }
- function saveGameData(){
- saveData.data.saveExists = true;
- // save character used and options first
- saveData.data.currentChar = parentClass.settingsMan.selectedCharacter
- saveData.data.soundOn = parentClass.settingsMan.soundsOn;
- saveData.data.musicOn = parentClass.settingsMan.musicOn;
- saveData.data.vFxOn = parentClass.settingsMan.visualEffectsOn;
- saveData.data.fullControl = parentClass.settingsMan.fullControlMode;
- if(parentClass.debugMode){
- trace("saving data")
- }
- saveData.flush();
- }
- function loadSavedData(){
- if(saveData.data.saveExists){
- if(parentClass.debugMode){
- trace("loading data")
- }
- parentClass.settingsMan.selectedCharacter = saveData.data.currentChar
- parentClass.settingsMan.soundsOn = saveData.data.soundOn ;
- parentClass.settingsMan.musicOn = saveData.data.musicOn ;
- parentClass.settingsMan.visualEffectsOn = saveData.data.vFxOn ;
- parentClass.settingsMan.fullControlMode = saveData.data.fullControl ;
- }
- }
- function spawnAwardPopup(awardName:String,iGraphic:String){
- var a:AwardPopup = new AwardPopup();
- a.x = 800
- a.y = 0
- a.setInfo(awardName,iGraphic)
- parentClass.addChild(a)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement