Example #1
0
        public void DoLoadGame()
        {
            // Open a storage container.
            StorageContainer container = Device.OpenContainer("Savegames");

            // Get the path of the save game.
            string filename = Path.Combine(container.Path, "savegame.sav");

            // Open the file, creating it if necessary.
            FileStream stream = File.Open(filename, FileMode.OpenOrCreate);

            // Convert the object to XML data and put it in the stream.
            XmlSerializer reader = new XmlSerializer(typeof(SaveGameData));
            while (stream.Position < stream.Length)
            {
                try
                {
                    SaveGameData data = (SaveGameData)reader.Deserialize(stream);
                    LivingEntity.PlayerEntity temp = new LivingEntity.PlayerEntity();
                    temp.Health = data.Health;
                    temp.Level = data.Level;
                    temp.XP = data.XP;
                    temp.Pos = data.Pos;
                    temp.Strength = data.Strength;
                    temp.Speed = data.Speed;
                    temp.Dexterity = data.Dexterity;
                    PlayersLoaded.Add(temp);
                }
                catch (Exception e)
                {
                    e.ToString();
                }
            }

            // Close the file.
            stream.Close();

            // Dispose the container, to commit changes.
            container.Dispose();
        }
Example #2
0
        protected override void Initialize()
        {
            base.Initialize();
            MusicOn = false;
            RandomQuest = new RandomQuest(this);
            RandomQuest.RandomQuestFlag = -1;
            SCREEN_WIDTH = graphics.GraphicsDevice.Viewport.Width;
            SCREEN_HEIGHT = graphics.GraphicsDevice.Viewport.Height;
            GameMap = new Map();
            Player = new LivingEntity.PlayerEntity();
            Player.Speed = Player.Strength = Player.Dexterity = Player.Health = 10;
            Player.Pos = LocationBHamHam;
            StorageUnit = new Storage();

            FontPos = new Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
            Network = new Network(this);
            rand = new Random(DateTime.UtcNow.Millisecond);

            enemy = new LivingEntity.EnemyEntity[MAX_ENEMIES];
            for (int i = 0; i < MAX_ENEMIES; ++i)
                enemy[i] = new LivingEntity.EnemyEntity(1);
            for (int i = 0; i < MAX_ENEMIES; ++i)
                SpawnEnemy(i);

            treasureGotten = 0;

            //MAX_PUZZLE_GARGOYLES
            gargoyleActivated = new bool[MAX_PUZZLE_GARGOYLES];
            gargoyleActivationOrder = new int[MAX_PUZZLE_GARGOYLES];
            for (int i = 0; i < MAX_PUZZLE_GARGOYLES; ++i)
            {
                gargoyleActivated[i] = false;
                gargoyleActivationOrder[i] = 0;
            }
            numGargoylesActivated = 0;
            //gargoyleActivated[];

            NPC = new LivingEntity.NPCEntity[MAX_NPCS];
            for (int i = 0; i < MAX_NPCS; ++i)
            {
                switch (i)
                {
                    case 0://Shaniqua
                        NPC[i] = new LivingEntity.NPCEntity(PenguinTexture);
                        NPC[i].Pos = new Vector2(256f, 500f);
                        break;
                    case 1://Amulet
                        NPC[i] = new LivingEntity.NPCEntity(AmuletTexture);
                        NPC[i].Pos = new Vector2(236f, 500f);
                        break;
                    case 2://Sword
                        NPC[i] = new LivingEntity.NPCEntity(SwordTexture);
                        NPC[i].Pos = new Vector2(32, 32);
                        break;
                    case 3://Blacksmith in JRoberton
                        NPC[i] = new LivingEntity.NPCEntity(PlayerFrontTexture);
                        NPC[i].Pos = new Vector2(35, 31);
                        break;
                    case 4://Gargoyle to East of JRoberton
                        NPC[i] = new LivingEntity.NPCEntity(GargoyleTexture);
                        NPC[i].Pos = new Vector2(275, 498);
                        break;
                    case 5://Gargoyle 1 in group in center
                        NPC[i] = new LivingEntity.NPCEntity(GargoyleTexture);
                        NPC[i].Pos = LocationGargoyle + new Vector2(-4, 0);
                        break;
                    case 6://Gargoyle 2 in group in center
                        NPC[i] = new LivingEntity.NPCEntity(GargoyleTexture);
                        NPC[i].Pos = LocationGargoyle + new Vector2(1, 0);
                        break;
                    case 7://Gargoyle 3 in group in center
                        NPC[i] = new LivingEntity.NPCEntity(GargoyleTexture);
                        NPC[i].Pos = LocationGargoyle + new Vector2(-4, 5);
                        break;
                    case 8://Gargoyle 4 in group in center
                        NPC[i] = new LivingEntity.NPCEntity(GargoyleTexture);
                        NPC[i].Pos = LocationGargoyle + new Vector2(1, 5);
                        break;
                    case 9://Battle Axe gotten for beating Gargoyle puzzle
                        NPC[i] = new LivingEntity.NPCEntity(BattleAxeTexture);
                        NPC[i].Pos = LocationGargoyle + new Vector2(0, 3);
                        NPC[i].alive = false;
                        break;
                    case 20://Birminghamham Town Sage
                        NPC[i] = new LivingEntity.NPCEntity(SageTexture);
                        NPC[i].Pos = LocationBHamHam;
                        NPC[i].Pos.Y -= 7.0f;
                        break;
                    case 21://Dickinsongrad Town Sage
                        NPC[i] = new LivingEntity.NPCEntity(SageTexture);
                        NPC[i].Pos = LocationDickinsongrad + new Vector2(5, 0);
                        break;
                    case 22://JRoberton Town Sage
                        NPC[i] = new LivingEntity.NPCEntity(SageTexture);
                        NPC[i].Pos = LocationJRoberton;// +new Vector2(2, 0); ;
                        break;
                    case 25://Santa 
                        NPC[i] = new LivingEntity.NPCEntity(SantaTexture);
                        NPC[i].Pos = LocationDickinsongrad + new Vector2(1, -2);
                        break;
                    case 26://Catapult
                        NPC[i] = new LivingEntity.NPCEntity(CatapultTexture);
                        NPC[i].Pos = LocationGargoyle + new Vector2(2, -8);
                        NPC[i].alive = false;
                        break;
                    case 27://Jester
                        NPC[i] = new LivingEntity.NPCEntity(JesterTexture);
                        //NPC[i].Pos = LocationBHamHam + new Vector2(-5, 4);
                        NPC[i].Pos = LocationDickinsongrad + new Vector2(0, 4);
                        NPC[i].alive = false;
                        break;
                    default:
                        
                        if (i >= 10 && i <= 19)
                        {
                            NPC[i] = new LivingEntity.NPCEntity(TreasureChestTexture);
                            //NPC[i].Pos = new Vector2((float)(Map.MapSize / 2 + rand.Next() % 10), (float)(Map.MapSize - Map.MapSize / 32 + rand.Next() % 10));
                            NPC[i].Pos = new Vector2((float)(rand.Next() % 512), (float)(rand.Next() % 512));
                            //NPC[i].Pos = new Vector2((float)(LocationBHamHam.X + rand.Next() % 10 - 5), (float)(LocationBHamHam.Y + rand.Next() % 10 - 5));
                            //Map.MapSize / 2, Map.MapSize - Map.MapSize / 32
                        }
                        else
                        {
                            NPC[i] = new LivingEntity.NPCEntity(PenguinTexture);
                            NPC[i].Pos = new Vector2(275, 498);
                        }

                    break;
                }

                // 0 Shaniqua
                // 1 Amulet
                // 2 Sword
                // 3 Blacksmith in Jroberton
                // 4 Gargoyle to East of Jroberton
            }

            storyMessage = new string[MAX_MESSAGES];
            for (int i = 0; i < MAX_MESSAGES; i++)
            {
                switch (i)
                {
                    case 0: storyMessage[i] = "Find Shaniqua the penguin.\nShe is somewhere around here.";
                        break;
                    case 1: storyMessage[i] = "You must head west and\n retrieve the Amulet of Ages.";
                        break;
                    case 2: storyMessage[i] = "Head northwest and take\n the path to Jroberton.";
                        break;
                    case 3: storyMessage[i] = "Talk to the blacksmith,\nwho will give guidance.";
                        break;
                    case 4: storyMessage[i] = "Find the lone gargoyle to\nthe east of Birminghamham.";
                        break;
                    case 5: storyMessage[i] = "Take the northern road to\nthe four gargoyles.";
                        break;
                    case 6: storyMessage[i] = "Sir Mark is Dickinsongrad,\nto the East. Kill him.";
                        break;
                    case 7: storyMessage[i] = "You have defeated Sir Mark.\nA jester laughs to the south.";
                        break;
                    case 8: storyMessage[i] = "You must find the magical\n axe to defeat Sir Mark.";
                        break;
                    case 9: storyMessage[i] = "Above the gargoyles lies\nthe machine of the apocalypse.";
                        break;
                    case 10: storyMessage[i] = "You swing the axe,destroy-\ning the machine. You win.";
                        break;
                    case 11: storyMessage[i] = "You pick up the key to the castle of Dickinsongrad in the city of the same name.  Shaniqua tells you to go to the evil lair of Sir Mark in the north.";
                        break;
                    case 12: storyMessage[i] = "You must now defeat Sir Mark.  Short in stature, Sir Mark is nevertheless a force to be reckoned with.";
                        break;
                    case 13: storyMessage[i] = "Swinging your sword one last time, you hew off the head of the one who killed your best friend.  As it bounces to the earth, you realize that your quest is at an end.";
                        break;
                    case 100: storyMessage[i] = "Treasure: " + treasureGotten + "/10";
                        break;                   
                    default: storyMessage[i] = "DEFAULT MESSAGE";
                        break;

                    
                }
            }
            displayMessage(0, 90);
            //currentMessage = 0;
            //messagetime = 120;

            /*
            You remember little of your past. The hoops of fire, tigers, and freaks of a past life accentuate
                the grit and grime of futuristic Birminghamham life. The one you loved… lost forever. Since the
            day your heart was ripped to pieces, you swore to die to his old self and bring new life. Wallowing
            in the blacksmithery of Jew in the town of Jroberton outside Birminghamham, you realize the goal
            of your life must be to avenge the death of your love. You still have nightmares, perhaps telling
             * the future. You still have nightmares of the past - the slaying of your one hope of a happy life, 
             * your pearl of great price, your penguin, Shaniqua. On occasion she whispers to you that she will help.
             Tonight is a night of nightmares. Every night is a night of nightmares. Every night is a night of future nightmares 
             * of night. Tonight your Shaniqua whispers demands for revenge; you feel propelled to escape and exact 
             * revenge on the evil one, Sir Mark in Dickinsongrad, also outside of Birminghamham. Your ragtag crew of 
             * you and your old dead penguin ghost show no fear, ready to eventually bring down the ever-rotating 
             * machine of the apocalypse, pain harbinger sense-offender extraordinaire, Sir Mark.
            Your sword shop offers little help to begin. What could you use to fight the enemy? Use your circus-born 
             * ingenuity to take hold of the situation and fight it with a light, quick, sharp, and pointy attack. 
             * May your blade of justice shine the way, and may the voice of Shaniqua be your guide.
            */
            /*
                The voice of Shaniqua calls out to you, 'Return to the blacksmithery in Jroberton, where you will find the Amulet of the Ages.'
                Entering the town of JRoberton, you are overcome with grief, hunger, and the urge to avenge the shameless slaughter of the beautiful pengiun named Shaniqua.
                You pick up the amulet and Shaniqua speaks to you again:  “Go to the four ends of the earth and retrieve the shards of the sword Awesome, and then return here to forge anew the sword that was shattered.”
                You have retrieved the first fragment of the sword.
                You have retrieved the second fragment of the sword.
                You have retrieved the third fragment of the sword.
                You have retrieved the last fragment of the sword and do a little dance to celebrate.  You also sing a silly song, but we didn’t want to overload the Zune with such mindless foolishness.  Return to the blacksmithery with the pieces of the sword.
                Throwing the shards on the Anvil of Justice, you reforge the blade and name it DyKnow the Destroyer.  Shaniqua tells you to head to the eastern hills to recover the lost key into Birminghamham. 
                Hewing your way through the last of the enemies that guard the lost key, the ghost of Shaniqua guides you to the key.  Picking it up, you somehow know that traveling to Birminghamham will shed more light on where to find Sir Mark, the evil one of old who stole your life’s shining joy from you.
                You enter the town of Birminghamham.  Steeped in tradition, the old city is a monolithic tribute to the times of old.
                You pick up the key to the castle of Dickinsongrad in the city of the same name.  Shaniqua tells you to go to the evil lair of Sir Mark in the north.
                You must now defeat Sir Mark.
                Swinging your sword one last time, you hew off the head of the one who killed your best friend.  As it bounces to the earth, you realize that your quest is at an end.
            */

            library = new MediaLibrary();
            songs = library.Songs;
            MediaPlayer.State.Equals(MediaState.Stopped);
            TimeLastMenuChange = TimeLastScreenModeChange = Environment.TickCount;
            CurrentScreenMode = CurrentMenuOption = lastButtonPressed = 0;
        }