public void Load()
    {
        if (File.Exists (Application.persistentDataPath + "/playerInfo.dat")) {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
            GameData data = (GameData) bf.Deserialize(file);
            file.Close();

            #region Luke Persistent Stat Data
            LukeStats = data.LukeStats;
        //			LukeStats.MaxHP = data.LukeMaxHP;
        //			LukeStats.CurrentHP = data.LukeCurrentHP;
        //			LukeStats.MaxStamina = data.LukeMaxStamina;
        //			LukeStats.CurrentStamina = data.LukeCurrentStamina;
        //			LukeStats.AttackModifier = data.LukeAttackModifier;
        //			LukeStats.DefenseModifier = data.LukeDefenseModifier;
            #endregion

            #region Izzy Persistent Stat Data
            IzzyStats = data.IzzyStats;
        //			IzzyStats.MaxHP = data.IzzyMaxHP;
        //			IzzyCurrentHP = data.IzzyCurrentHP;
        //			IzzyMaxStamina = data.IzzyMaxStamina;
        //			IzzyCurrentStamina = data.IzzyCurrentStamina;
        //			IzzyAttackModifier = data.IzzyAttackModifier;
        //			IzzyDefenseModifier = data.IzzyDefenseModifier;
            #endregion

            #region Yogurt Persistent Stat Data
            YogurtStats = data.YogurtStats;
        //			YogurtMaxHP = data.YogurtMaxHP;
        //			YogurtCurrentHP = data.YogurtCurrentHP;
        //			YogurtMaxStamina = data.YogurtMaxStamina;
        //			YogurtCurrentStamina = data.YogurtCurrentStamina;
        //			YogurtAttackModifier = data.YogurtAttackModifier;
        //			YogurtDefenseModifier = data.YogurtDefenseModifier;
            #endregion

            #region Key Item Dirty Flags
            hasBasketball = data.hasBasketball;
            hasBaseball = data.hasBaseball;
            hasFoamFinger = data.hasFoamFinger;
            hasFootball = data.hasFootball;
            hasSmartphone = data.hasSmartphone;
            hasSpeakers = data.hasSpeakers;
            hasTablet = data.hasTablet;
            hasVoucher = data.hasVoucher;
            hasCollar = data.hasCollar;
            hasChewToy = data.hasChewToy;
            hasOldTreat = data.hasOldTreat;
            hasHydrantPic = data.hasHydrantPic;
            #endregion

            #region Quest Dirty Flags
            #endregion

            #region Other Persistent Data
            experience = data.experience;
            currentLevel = data.currentLevel;
            money = data.money;
            inventory = data.inventory;
            currentAreaName = data.currentAreaName;
            #endregion

            Application.LoadLevel(currentLevel);
        }
    }
示例#2
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
            GameData        data = (GameData)bf.Deserialize(file);
            file.Close();

            #region Luke Persistent Stat Data
            LukeStats = data.LukeStats;
//			LukeStats.MaxHP = data.LukeMaxHP;
//			LukeStats.CurrentHP = data.LukeCurrentHP;
//			LukeStats.MaxStamina = data.LukeMaxStamina;
//			LukeStats.CurrentStamina = data.LukeCurrentStamina;
//			LukeStats.AttackModifier = data.LukeAttackModifier;
//			LukeStats.DefenseModifier = data.LukeDefenseModifier;
            #endregion

            #region Izzy Persistent Stat Data
            IzzyStats = data.IzzyStats;
//			IzzyStats.MaxHP = data.IzzyMaxHP;
//			IzzyCurrentHP = data.IzzyCurrentHP;
//			IzzyMaxStamina = data.IzzyMaxStamina;
//			IzzyCurrentStamina = data.IzzyCurrentStamina;
//			IzzyAttackModifier = data.IzzyAttackModifier;
//			IzzyDefenseModifier = data.IzzyDefenseModifier;
            #endregion

            #region Yogurt Persistent Stat Data
            YogurtStats = data.YogurtStats;
//			YogurtMaxHP = data.YogurtMaxHP;
//			YogurtCurrentHP = data.YogurtCurrentHP;
//			YogurtMaxStamina = data.YogurtMaxStamina;
//			YogurtCurrentStamina = data.YogurtCurrentStamina;
//			YogurtAttackModifier = data.YogurtAttackModifier;
//			YogurtDefenseModifier = data.YogurtDefenseModifier;
            #endregion

            #region Key Item Dirty Flags
            hasBasketball = data.hasBasketball;
            hasBaseball   = data.hasBaseball;
            hasFoamFinger = data.hasFoamFinger;
            hasFootball   = data.hasFootball;
            hasSmartphone = data.hasSmartphone;
            hasSpeakers   = data.hasSpeakers;
            hasTablet     = data.hasTablet;
            hasVoucher    = data.hasVoucher;
            hasCollar     = data.hasCollar;
            hasChewToy    = data.hasChewToy;
            hasOldTreat   = data.hasOldTreat;
            hasHydrantPic = data.hasHydrantPic;
            #endregion

            #region Quest Dirty Flags
            #endregion

            #region Other Persistent Data
            experience      = data.experience;
            currentLevel    = data.currentLevel;
            money           = data.money;
            inventory       = data.inventory;
            currentAreaName = data.currentAreaName;
            #endregion

            Application.LoadLevel(currentLevel);
        }
    }
        public ViewResult RecruitForm(ThePlayer newWarrior)
        {
            // check user input
            if (ModelState.IsValid)
            {
                // Set up a game log of Fight Events
                AttackRecorder gameLog = new AttackRecorder();

                gameLog.FightEvents = new List <string>()
                {
                    "..the game log was the only book in town that the Evil Emperor wanted to read."
                };

                // Set up a Jedi Warrior object - using the data entered in the form
                ThePlayer myWarrior = new ThePlayer();
                myWarrior.Name  = newWarrior.Name;
                myWarrior.Email = newWarrior.Email;

                ThePlayer.playerMail = myWarrior.Email;

                myWarrior.LightSaberColor    = newWarrior.LightSaberColor;
                myWarrior.CurrentDamageLevel = JediKnight.DamageLevel.Healthy;
                myWarrior.DarkSide           = newWarrior.DarkSide;
                myWarrior.Deceased           = false;
                myWarrior.FightLog           = new AttackRecorder();

                // Init the personal fight log
                myWarrior.FightLog.FightEvents = new List <string>()
                {
                    myWarrior.Name + " loosens his tie",
                    myWarrior.Name + " unstraps his lightsaber and admires it's wonderfully " + myWarrior.LightSaberColor + " sheen.",
                    myWarrior.Name + " quotes Caesar: 'Jacta Alea Est', dude!",
                    myWarrior.Name + " shuffles his feet and looks a bit shyly at the other guys.. quite imposing figures, actually.."
                };
                // start up first knight in game log
                gameLog.FightEvents.AddRange(myWarrior.FightLog.FightEvents);

                // Set up some more Jedi objects
                Darth DarthV = new Darth();
                // start up second knight in game log
                gameLog.FightEvents.AddRange(DarthV.FightLog.FightEvents);

                Luke LukeS = new Luke();
                // start up third knight in game log
                gameLog.FightEvents.AddRange(LukeS.FightLog.FightEvents);

                Obi_Wan obiWan = new Obi_Wan();
                // start up fourth knejt' in game log

                EvilEmperor evilEmperor = new EvilEmperor();
                // let the 'pror get in on the log

                List <JediKnight> myJedis = new List <JediKnight>();
                myJedis.Add(myWarrior);
                myJedis.Add(DarthV);
                myJedis.Add(LukeS);



                // Now, let's run a battle scenario umpteen times over, based on the logic in the model for each Knight.
                // That ought to be enough to kill one of our protagonists outright a few times over..
                for (int i = 1; i < 18; i++)
                {
                    // Pick a random Jedi Knight to kick into action courtesy of our Helper class
                    int        randomInt = RandomGenerator.Rand.Next(0, myJedis.Count);
                    JediKnight warrior   = myJedis[randomInt];
                    // Empty the individual fight log before next batch recording of events
                    warrior.FightLog.FightEvents.Clear();
                    warrior.FightLog.FightEvents.Add("The Evil Emperor randomly points a bony finger at " + warrior.Name + " and says: 'do some nasty work for me - now!'");

                    //boost the darkside!
                    evilEmperor.DarkSideBoost(myJedis);

                    //saveLuke
                    if (LukeS.CurrentDamageLevel < JediKnight.DamageLevel.Challenged)
                    {
                        obiWan.SaveLuke(LukeS);
                    }

                    //saveLuke(again) and add obiWan to the battle
                    if (LukeS.CurrentDamageLevel <= JediKnight.DamageLevel.Critical && myJedis.Contains(obiWan) == false)
                    {
                        myJedis.Add(obiWan);
                        warrior.FightLog.FightEvents.Add(obiWan.Name + " has joined the battle ck. ");
                        obiWan.SecondWind(LukeS);
                    }

                    //saveDarth and add Palpetine to the battle
                    if (DarthV.CurrentDamageLevel <= JediKnight.DamageLevel.Critical && myJedis.Contains(evilEmperor) == false)
                    {
                        myJedis.Add(evilEmperor);
                        warrior.FightLog.FightEvents.Add(evilEmperor.Name + " has joined the battle mk. ");
                        evilEmperor.SecondWind(DarthV);
                    }

                    // Attack opponents, but only if they are on the opposing side, and only if you aren't dead yourself..yet.
                    switch (warrior.Name)
                    {
                    case "Darth Vader":
                        if (!warrior.Deceased)
                        {
                            warrior.AttackEnemy(warrior, LukeS);
                            if (myWarrior.DarkSide == false)
                            {
                                warrior.AttackEnemy(warrior, myWarrior);
                            }
                        }
                        else     // this happens if the Emperor points a bony finger at a dead Jedi Knight
                        {
                            //increment number of deaths
                            warrior.numOfDeaths++;

                            warrior.FightLog.FightEvents.Add(warrior.Name + " unfortunately feels a bit out of it right now, and is rather actively knockin' on the Force's Door.");
                            // Darth is a mean ole bean, so we'll re-life him with a lousy medicare allowance of 'Hurting'
                            warrior.Deceased           = false;
                            warrior.CurrentDamageLevel = JediKnight.DamageLevel.Hurting;
                            warrior.FightLog.FightEvents.Add("Wow, that door-mojo worked... " + warrior.Name + " is in a rather hurt condition, but still bouncing back for some mean ole revenge!");
                        }
                        // add player fight events to game log
                        gameLog.FightEvents.AddRange(warrior.FightLog.FightEvents);
                        break;

                    case "Luke Skywalker":
                        if (!warrior.Deceased)
                        {
                            warrior.AttackEnemy(warrior, DarthV);
                            if (myWarrior.DarkSide == true)
                            {
                                warrior.AttackEnemy(warrior, myWarrior);
                            }
                        }
                        else
                        {
                            //increment number of deaths
                            warrior.numOfDeaths++;

                            warrior.FightLog.FightEvents.Add(warrior.Name + " unfortunately feels a bit out of it right now, and is feebly knockin' on the Force's Door, in a Lukey way.");
                            // give Luke an advantage when killed, by rescusiating him and by setting his health to max
                            warrior.Deceased           = false;
                            warrior.CurrentDamageLevel = JediKnight.DamageLevel.Healthy;
                            warrior.FightLog.FightEvents.Add(warrior.Name + " apparently has mucho clout with the Force's Door and is now bouncing back for some swashbuckling revenge!");
                        }
                        // add player fight events to game log
                        gameLog.FightEvents.AddRange(warrior.FightLog.FightEvents);
                        break;

                    // default case will be our guy on the dance floor wanting a serious piece of the action
                    default:
                        if (!warrior.Deceased)
                        {
                            if (warrior.DarkSide == false)
                            {
                                warrior.AttackEnemy(warrior, DarthV);
                            }
                            if (warrior.DarkSide == true)
                            {
                                warrior.AttackEnemy(warrior, LukeS);
                            }
                        }
                        else
                        {
                            warrior.FightLog.FightEvents.Add(warrior.Name + " unfortunately feels a bit out of it right now, and is knockin' on the Force's Door.");
                            warrior.Deceased           = false;
                            warrior.CurrentDamageLevel = JediKnight.DamageLevel.Challenged;
                            warrior.FightLog.FightEvents.Add(warrior.Name + " apparently has some clout with the Force's Door and is now bent on some challenged-level revenge!");
                        }
                        // add player fight events to game log
                        gameLog.FightEvents.AddRange(warrior.FightLog.FightEvents);
                        break;
                    }
                }

                // Conclude fight at this point - check who's still vital, and do the victory roll
                foreach (JediKnight warrior in myJedis)
                {
                    if (!warrior.Deceased)
                    {
                        gameLog.FightEvents.Add("Ho ho ho! " + warrior.Name + "'s still around, with a rude health of: " + warrior.CurrentDamageLevel);
                    }
                    else
                    {
                        gameLog.FightEvents.Add("Awww, " + warrior.Name + " is sleeping with the fishes!");
                    }
                }

                //output number of deaths
                gameLog.FightEvents.Add("\n## Death Statistics ##");
                foreach (JediKnight warrior in myJedis)
                {
                    gameLog.FightEvents.Add(warrior.Name + " has died " + warrior.numOfDeaths + " time(s).");
                }

                // Set up viewbag list of event strings
                ViewBag.FightDescription = new List <string> {
                    "A long time ago in a galaxy far, far away...."
                };


                // put the game log contents into the ViewBag
                foreach (string FightEvent in gameLog.FightEvents)
                {
                    ViewBag.FightDescription.Add(FightEvent);

                    //errorlog
                    //if (FightEvent.Contains("points"))
                    //{
                    //    ErrorLogger.SaveMsg(FightEvent);
                    //}
                }

                //MailMethod
                foreach (string FightEvent in gameLog.FightEvents)
                {
                    EmailSender.MailThis.Add(FightEvent);
                }

                return(View("Jedi_Vs_Sith", myWarrior));
            }
            else
            {
                // validation error - redisplay form with error messages
                return(View());
            }
        }