public void Load()
        {
            IGameSave newsave = GameSaveManager.m_Instance.GetLoadedInfo(this.GetType());

            m_LoadedSuccessfully = false;

            if (newsave != null)
            {
                FieldInfo[] fields = this.GetType().GetFields(BindingFlags.Public |
                                                              BindingFlags.NonPublic |
                                                              BindingFlags.Instance);

                FieldInfo[] newfields = newsave.GetType().GetFields(BindingFlags.Public |
                                                                    BindingFlags.NonPublic |
                                                                    BindingFlags.Instance);


                for (int i = 0; i < fields.Length; i++)
                {
                    fields[i] = newfields[i];
                    fields[i].SetValue(this, newfields[i].GetValue(newsave));// = newfields[i];
                }

                m_LoadedSuccessfully = true;
            }
        }
        public SecretBaseSendToWindow(int gameIndex)
        {
            InitializeComponent();

            loaded = false;

            for (int i = -1; i < PokeManager.NumGameSaves; i++)
            {
                if (i == gameIndex)
                {
                    comboBoxGame.SetGameSaveVisible(i, false);
                    continue;
                }

                IGameSave game = PokeManager.GetGameSaveAt(i);
                if (game.GameType != GameTypes.Ruby && game.GameType != GameTypes.Sapphire && game.GameType != GameTypes.Emerald && game.GameType != GameTypes.Any)
                {
                    comboBoxGame.SetGameSaveVisible(i, false);
                }
            }

            this.gameIndex = PokeManager.LastGameInDialogIndex;
            if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex))
            {
                this.gameIndex = comboBoxGame.SelectedGameIndex;
            }
            else
            {
                comboBoxGame.SelectedGameIndex = this.gameIndex;
            }

            loaded = true;
            GameChanged(null, null);
        }
        public EditGameTrainerWindow(IGameSave gameSave)
        {
            InitializeComponent();
            this.gameSave         = gameSave;
            this.trainerName      = gameSave.TrainerName;
            this.trainerGender    = gameSave.TrainerGender;
            this.textBoxName.Text = trainerName;

            UpdateTrainerImage();

            this.labelTrainerID.Content = gameSave.TrainerID.ToString("00000");
            this.labelSecretID.Content  = gameSave.SecretID.ToString("00000");

            radioButtonMale.IsChecked   = gameSave.TrainerGender == Genders.Male;
            radioButtonFemale.IsChecked = gameSave.TrainerGender == Genders.Female;

            if (gameSave.IsJapanese)
            {
                this.textBoxName.MaxLength = 5;
            }

            this.textBoxName.Focus();
            this.textBoxName.SelectAll();

            if (gameSave.GameType == GameTypes.Colosseum || gameSave.GameType == GameTypes.XD)
            {
                radioButtonMale.IsEnabled   = false;
                radioButtonFemale.IsEnabled = false;
            }

            this.Title = "Edit " + gameSave.GameType.ToString() + " Trainer";
        }
Exemple #4
0
 public override void GiveReward(IGameSave gameSave)
 {
     gameSave.Money -= Cost;
     gameSave.PokePC.PlacePokemonInNextAvailableSlot(0, 0, reward);
     PokeManager.ManagerWindow.GotoPokemon(reward);
     PokeManager.RefreshUI();
 }
        public void Load(int profile)
        {
            if (this.onLoad != null)
            {
                this.onLoad.Invoke(profile);
            }
            if (this.storage == null)
            {
                this.storage = new List <IGameSave>();
            }
            this.data = new Dictionary <string, object>();

            for (int i = this.storage.Count - 1; i >= 0; --i)
            {
                IGameSave item = this.storage[i];
                if (item == null)
                {
                    this.storage.RemoveAt(i);
                    continue;
                }

                item.ResetData();
                this.LoadItem(item, profile);
            }

            SaveLoadManager.PROFILE_LOADED = true;
        }
        public static bool?ShowDialog(Window owner, IGameSave gameSave)
        {
            EditGameTrainerWindow window = new EditGameTrainerWindow(gameSave);

            window.Owner = owner;
            return(window.ShowDialog());
        }
 public NationalPokedexBAndCBlockData(IGameSave gameSave, byte[] data, BlockDataCollection parent)
     : base(gameSave, data, parent)
 {
     if (parent.GameCode == GameCodes.RubySapphire) {
         if (parent.Inventory.Decorations == null)
             parent.Inventory.AddDecorationInventory();
         for (int i = 0; i < 16; i++) {
             byte id = raw[2714 + i];
             if (id != 0) {
                 byte x = ByteHelper.BitsToByte(raw, 2714 + 16 + i, 4, 4);
                 byte y = ByteHelper.BitsToByte(raw, 2714 + 16 + i, 0, 4);
                 parent.Inventory.Decorations.SecretBaseDecorations.Add(new PlacedDecoration(id, x, y));
             }
         }
     }
     else if (parent.GameCode == GameCodes.Emerald) {
         if (parent.Inventory.Decorations == null)
             parent.Inventory.AddDecorationInventory();
         for (int i = 0; i < 16; i++) {
             byte id = raw[2862 + i];
             if (id != 0) {
                 byte x = ByteHelper.BitsToByte(raw, 2862 + 16 + i, 4, 4);
                 byte y = ByteHelper.BitsToByte(raw, 2862 + 16 + i, 0, 4);
                 parent.Inventory.Decorations.SecretBaseDecorations.Add(new PlacedDecoration(id, x, y));
             }
         }
     }
 }
 public override void GiveReward(IGameSave gameSave)
 {
     gameSave.Money -= Cost;
     gameSave.PokePC.PlacePokemonInNextAvailableSlot(0, 0, reward);
     PokeManager.ManagerWindow.GotoPokemon(reward);
     PokeManager.RefreshUI();
 }
 public override bool IsRequirementsFulfilled(IGameSave gameSave)
 {
     GBAGameSave gbaSave = gameSave as GBAGameSave;
     GameTypes gameType = gameSave.GameType;
     int count = GetRegiEventsCompleted(gameSave);
     if (count == 0) {
         if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire)
             return gbaSave.GetGameFlag((int)RubySapphireGameFlags.HasBadge4);
         else if (gameType == GameTypes.Emerald)
             return gbaSave.GetGameFlag((int)EmeraldGameFlags.HasBadge4);
     }
     else if (count == 1) {
         if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire)
             return gbaSave.GetGameFlag((int)RubySapphireGameFlags.HasBadge5);
         else if (gameType == GameTypes.Emerald)
             return gbaSave.GetGameFlag((int)EmeraldGameFlags.HasBadge5);
     }
     else if (count == 2) {
         if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire)
             return gbaSave.GetGameFlag((int)RubySapphireGameFlags.HasBadge6);
         else if (gameType == GameTypes.Emerald)
             return gbaSave.GetGameFlag((int)EmeraldGameFlags.HasBadge6);
     }
     return false;
 }
        public GiveItemWindow(IGameSave gameSave)
        {
            InitializeComponent();
            selectedIndex  = -1;
            selectedItem   = null;
            this.gameIndex = gameSave.GameIndex;

            for (int i = -1; i < PokeManager.NumGameSaves; i++)
            {
                IGameSave game = PokeManager.GetGameSaveAt(i);
                if (game.GameType == GameTypes.PokemonBox)
                {
                    comboBoxGame.SetGameSaveVisible(i, false);
                }
            }

            if (gameSave.GameType != GameTypes.PokemonBox)
            {
                comboBoxGame.SelectedGameIndex = gameIndex;
            }
            else
            {
                comboBoxGame.SelectedGameIndex = -1;
            }

            loaded = true;
            OnGameSelectionChanged(null, null);
        }
 public ColosseumPokePC(IGameSave gameSave)
 {
     this.gameSave = gameSave;
     this.raw = null;
     this.boxes = new ColosseumPokeBox[3];
     this.currentBox = 0; // Not stored in Colosseum saves, let's start at 0
 }
Exemple #12
0
        public SelectItemWindow(ushort[] validItemIDs, ItemTypes[] pocketTypes, string windowName, string buttonName, bool pcDefault)
        {
            InitializeComponent();
            selectedIndex         = -1;
            selectedItem          = null;
            this.validItemIDs     = validItemIDs;
            this.pocketTypes      = pocketTypes;
            this.Title            = windowName;
            this.buttonOK.Content = buttonName;
            this.pcDefault        = pcDefault;

            for (int i = -1; i < PokeManager.NumGameSaves; i++)
            {
                IGameSave game = PokeManager.GetGameSaveAt(i);
                if (game.GameType == GameTypes.PokemonBox)
                {
                    comboBoxGame.SetGameSaveVisible(i, false);
                }
            }

            comboBoxGame.SelectedGameIndex = -1;

            //comboBoxPocket.Items.Add("Items");
            //comboBoxPocket.SelectedIndex = 0;
            loaded = true;

            OnGameSelectionChanged(null, null);
        }
        public DecorationBlockData(IGameSave gameSave, byte[] data, BlockDataCollection parent)
            : base(gameSave, data, parent)
        {
            if (parent.GameCode == GameCodes.RubySapphire) {
                if (parent.Inventory.Decorations == null)
                    parent.Inventory.AddDecorationInventory();
                AddDecorationContainer(DecorationTypes.Desk, 1952, 10);
                AddDecorationContainer(DecorationTypes.Chair, 1962, 10);
                AddDecorationContainer(DecorationTypes.Plant, 1972, 10);
                AddDecorationContainer(DecorationTypes.Ornament, 1982, 30);
                AddDecorationContainer(DecorationTypes.Mat, 2012, 30);
                AddDecorationContainer(DecorationTypes.Poster, 2042, 10);
                AddDecorationContainer(DecorationTypes.Doll, 2052, 40);
                AddDecorationContainer(DecorationTypes.Cushion, 2092, 10);
                // TODO: Find where the XY values actually are stored.
                for (int i = 0; i < 12; i++) {
                    byte id = raw[1928 + i];
                    if (id != 0) {
                        byte x = ByteHelper.BitsToByte(raw, 1928 + 12 + i, 4, 4);
                        byte y = ByteHelper.BitsToByte(raw, 1928 + 12 + i, 0, 4);
                        parent.Inventory.Decorations.BedroomDecorations.Add(new PlacedDecoration(id, x, y));
                    }
                }

                parent.Mailbox.Load(ByteHelper.SubByteArray(3148, raw, 16 * 36));
            }
            else if (parent.GameCode == GameCodes.Emerald) {
                if (parent.Inventory.Decorations == null)
                    parent.Inventory.AddDecorationInventory();
                AddDecorationContainer(DecorationTypes.Desk, 2100, 10);
                AddDecorationContainer(DecorationTypes.Chair, 2110, 10);
                AddDecorationContainer(DecorationTypes.Plant, 2120, 10);
                AddDecorationContainer(DecorationTypes.Ornament, 2130, 30);
                AddDecorationContainer(DecorationTypes.Mat, 2160, 30);
                AddDecorationContainer(DecorationTypes.Poster, 2190, 10);
                AddDecorationContainer(DecorationTypes.Doll, 2200, 40);
                AddDecorationContainer(DecorationTypes.Cushion, 2240, 10);
                // TODO: Find where the XY values actually are stored.
                for (int i = 0; i < 12; i++) {
                    byte id = raw[2076 + i];
                    if (id != 0) {
                        byte x = ByteHelper.BitsToByte(raw, 2076 + 12 + i, 4, 4);
                        byte y = ByteHelper.BitsToByte(raw, 2076 + 12 + i, 0, 4);
                        parent.Inventory.Decorations.BedroomDecorations.Add(new PlacedDecoration(id, x, y));
                    }
                }

                parent.Mailbox.Load(ByteHelper.SubByteArray(3296, raw, 16 * 36));

                /*sharedSecretBases = new List<SharedSecretBase>();
                for (int i = 0; i < 3; i++) {
                    byte locationID = raw[1596 + i * 160];
                    if (SecretBaseDatabase.GetLocationFromID(locationID) != null)
                        sharedSecretBases.Add(new SharedSecretBase(ByteHelper.SubByteArray(1596 + i * 160, data, 160)));
                }*/
            }
            else if (parent.GameCode == GameCodes.FireRedLeafGreen) {
                parent.Mailbox.LoadPart1(ByteHelper.SubByteArray(3536, raw, 12 * 36));
            }
        }
Exemple #14
0
        public ReplaceBallWindow(IPokemon pokemon)
        {
            InitializeComponent();
            ballID        = 0;
            selectedIndex = -1;
            selectedItem  = null;
            this.pokemon  = pokemon;


            for (int i = 0; i < PokeManager.NumGameSaves; i++)
            {
                IGameSave game = (IGameSave)PokeManager.GetGameSaveAt(i);
                if (game.GameType == GameTypes.PokemonBox)
                {
                    comboBoxGame.SetGameSaveVisible(i, false);
                }
            }

            this.gameIndex = PokeManager.LastGameInDialogIndex;
            if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex))
            {
                comboBoxGame.SelectedIndex = 0;
                this.gameIndex             = comboBoxGame.SelectedGameIndex;
            }
            else
            {
                comboBoxGame.SelectedGameIndex = this.gameIndex;
            }

            loaded = true;
            OnGameSelectionChanged(null, null);
        }
Exemple #15
0
        //private XDPurifier purifier;

        #endregion

        public XDPokePC(IGameSave gameSave)
        {
            this.gameSave   = gameSave;
            this.raw        = null;
            this.boxes      = new XDPokeBox[8];
            this.currentBox = 0;
        }
 public override void GiveReward(IGameSave gameSave)
 {
     GBAGameSave gbaSave = gameSave as GBAGameSave;
     GameTypes gameType = gameSave.GameType;
     if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire) {
         if (TicketType == TicketTypes.EonTicket)
             gbaSave.SetGameFlag((int)RubySapphireGameFlags.EonTicketActivated, true);
     }
     else if (gameType == GameTypes.FireRed || gameType == GameTypes.LeafGreen) {
         if (TicketType == TicketTypes.MysticTicket)
             gbaSave.SetGameFlag((int)FireRedLeafGreenGameFlags.MysticTicketActivated, true);
         else if (TicketType == TicketTypes.AuroraTicket)
             gbaSave.SetGameFlag((int)FireRedLeafGreenGameFlags.AuroraTicketActivated, true);
     }
     else if (gameType == GameTypes.Emerald) {
         if (TicketType == TicketTypes.EonTicket)
             gbaSave.SetGameFlag((int)EmeraldGameFlags.EonTicketActivated, true);
         else if (TicketType == TicketTypes.MysticTicket)
             gbaSave.SetGameFlag((int)EmeraldGameFlags.MysticTicketActivated, true);
         else if (TicketType == TicketTypes.AuroraTicket)
             gbaSave.SetGameFlag((int)EmeraldGameFlags.AuroraTicketActivated, true);
         else if (TicketType == TicketTypes.OldSeaMap)
             gbaSave.SetGameFlag((int)EmeraldGameFlags.OldSeaMapActivated, true);
     }
     if (gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(TicketItemID) == 0)
         gameSave.Inventory.Items[ItemTypes.KeyItems].AddItem(TicketItemID, 1);
     PokeManager.ManagerWindow.GotoItem(gameSave.GameIndex, ItemTypes.KeyItems, TicketItemID);
 }
Exemple #17
0
 public BoxPokePC(IGameSave gameSave)
 {
     this.gameSave   = gameSave;
     this.raw        = null;
     this.boxes      = null;
     this.currentBox = 0;
 }
Exemple #18
0
        public override bool IsRequirementsFulfilled(IGameSave gameSave)
        {
            GBAGameSave gbaSave  = gameSave as GBAGameSave;
            GameTypes   gameType = gameSave.GameType;

            for (int i = 0; i < 40; i++)
            {
                if (gameSave.Inventory.Items[ItemTypes.Berries].GetCountOfID((ushort)(i + 133)) == 0 && gameSave.Inventory.Items[ItemTypes.PC].GetCountOfID((ushort)(i + 133)) == 0)
                {
                    return(false);
                }
            }
            if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire)
            {
                return(gbaSave.GetGameFlag((int)RubySapphireGameFlags.HasBeatenEliteFour));
            }
            else if (gameType == GameTypes.FireRed || gameType == GameTypes.LeafGreen)
            {
                return(gbaSave.GetGameFlag((int)FireRedLeafGreenGameFlags.HasBeatenEliteFour));
            }
            else if (gameType == GameTypes.Emerald)
            {
                return(gbaSave.GetGameFlag((int)EmeraldGameFlags.HasBeatenEliteFour));
            }
            return(false);
        }
Exemple #19
0
 public Inventory(IGameSave gameSave)
 {
     this.gameSave            = gameSave;
     this.itemInventory       = null;
     this.decorationInventory = null;
     this.pokeblockCase       = null;
 }
Exemple #20
0
 public XDPokePC(IGameSave gameSave)
 {
     this.gameSave = gameSave;
     this.raw = null;
     this.boxes = new XDPokeBox[8];
     this.currentBox = 0;
 }
 public override void GiveReward(IGameSave gameSave)
 {
     ushort bikeID = GetBikeItemID(gameSave);
     if (gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(bikeID) == 0) {
         gameSave.Inventory.Items[ItemTypes.KeyItems].AddItem(bikeID, 1);
         PokeManager.ManagerWindow.GotoItem(gameSave.GameIndex, ItemTypes.KeyItems, bikeID);
     }
 }
        public SendItemToWindow(int gameIndex, ushort id, uint maxCount)
        {
            InitializeComponent();
            upDownItemCount.Minimum = 0;
            upDownItemCount.Value   = 1;
            upDownItemCount.Maximum = (int)maxCount;
            itemID      = id;
            pocketTypes = new List <ItemTypes>();
            loaded      = false;
            count       = 1;

            for (int i = -1; i < PokeManager.NumGameSaves; i++)
            {
                if (i == gameIndex)
                {
                    comboBoxGame.SetGameSaveVisible(i, false);
                    continue;
                }

                IGameSave game = PokeManager.GetGameSaveAt(i);
                if (game.GameType != GameTypes.Any && !ItemDatabase.GetItemFromID(id).Exclusives.HasFlag((GameTypeFlags)(1 << ((int)game.GameType - 1))))
                {
                    comboBoxGame.SetGameSaveVisible(i, false);
                }
            }

            pocketTypes.Clear();
            comboBoxPocket.Items.Clear();

            /*if (this.gameIndex == -1) {
             *      pocketTypes.Add(ItemDatabase.GetItemFromID(itemID).PocketType);
             *      comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemDatabase.GetItemFromID(itemID).PocketType));
             *      comboBoxPocket.SelectedIndex = 0;
             * }
             * else {
             *      pocketTypes.Add(ItemTypes.PC);
             *      pocketTypes.Add(ItemDatabase.GetItemFromID(itemID).PocketType);
             *      comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemTypes.PC));
             *      comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemDatabase.GetItemFromID(itemID).PocketType));
             *      comboBoxPocket.SelectedIndex = 1;
             * }*/

            this.gameIndex = PokeManager.LastGameInDialogIndex;
            if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex))
            {
                //comboBoxGame.SelectedIndex = 0;
                this.gameIndex = comboBoxGame.SelectedGameIndex;
            }
            else
            {
                comboBoxGame.SelectedGameIndex = this.gameIndex;
            }

            loaded = true;

            GameChanged(null, null);
        }
 public override string GetRequirements(IGameSave gameSave)
 {
     int count = GetRegiEventsCompleted(gameSave);
     if (count == 0)
         return "You must obtain the Heat Badge from Flannery in order to receive this Doll.";
     else if (count == 1)
         return "You must obtain the Balance Badge from Norman in order to receive this Doll.";
     else
         return "You must obtain the Feather Badge from Winona in order to receive this Doll.";
 }
 public BlockData(IGameSave gameSave, byte[] data, BlockDataCollection parent)
 {
     if (data.Length != 4096)
     {
         throw new Exception("Block size not equal to 4096 bytes");
     }
     this.raw      = data;
     this.parent   = parent;
     this.gameSave = gameSave;
 }
Exemple #25
0
        public Mailbox(IGameSave gameSave, uint mailboxSize)
        {
            this.gameSave    = gameSave;
            this.raw         = null;
            this.partyMail   = new List <Mail>();
            this.boxMail     = new List <Mail>();
            this.mailboxSize = mailboxSize;

            this.listViewItems = new ObservableCollection <ListViewItem>();
        }
Exemple #26
0
        public Mailbox(IGameSave gameSave, uint mailboxSize)
        {
            this.gameSave		= gameSave;
            this.raw			= null;
            this.partyMail		= new List<Mail>();
            this.boxMail		= new List<Mail>();
            this.mailboxSize	= mailboxSize;

            this.listViewItems	= new ObservableCollection<ListViewItem>();
        }
Exemple #27
0
        public int GetNumRows(PokemonBoxViewer viewer)
        {
            IGameSave gameSave = PokeManager.GetGameSaveAt(GetGameIndex(viewer));

            if (gameSave is ManagerGameSave)
            {
                return((gameSave as ManagerGameSave).NumPokePCRows);
            }
            return(1);
        }
 public GamePokemonSearchResults GetMirageResults(IGameSave gameSave)
 {
     foreach (GamePokemonSearchResults results in mirageIslandResults)
     {
         if (results.GameSave == gameSave)
         {
             return(results);
         }
     }
     return(null);
 }
        private void FillListViewItem(GameSaveFileInfo gameSaveFile, ListViewItem listViewItem)
        {
            IGameSave gameSave = gameSaveFile.GameSave;

            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Horizontal;

            /*Image gameImage = new Image();
             * BitmapImage bitmap = ResourceDatabase.GetImageFromName(gameSaveFile.GameType.ToString() + "Physical");
             * gameImage.Source = bitmap;
             * if (bitmap == null)
             *      gameImage.Width = 20;
             * else
             *      gameImage.Width = bitmap.PixelWidth * (20.0 / bitmap.PixelHeight);
             * gameImage.Height = 20;
             * gameImage.VerticalAlignment = VerticalAlignment.Center;*/

            TextBlock gameName     = new TextBlock();
            string    gameTypeName = (gameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : gameSave.GameType.ToString());

            if (gameSaveFile.Nickname != "")
            {
                gameName.Text = gameSaveFile.Nickname + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : "");
            }
            else
            {
                gameName.Text = gameTypeName + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : "");
            }
            gameName.VerticalAlignment = VerticalAlignment.Center;
            //gameName.Margin = new Thickness(5, 0, 0, 0);

            TextBlock trainerName = new TextBlock();

            trainerName.Text              = gameSave.TrainerName;
            trainerName.Foreground        = new SolidColorBrush(gameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (gameSave.TrainerGender == Genders.Female ? Color.FromRgb(248, 24, 168) : Color.FromRgb(0, 0, 0)));
            trainerName.VerticalAlignment = VerticalAlignment.Center;

            TextBlock ending = new TextBlock();

            ending.Text = "]";
            ending.VerticalAlignment = VerticalAlignment.Center;

            //stackPanel.Children.Add(gameImage);
            stackPanel.Children.Add(gameName);
            if (gameSaveFile.GameType != GameTypes.PokemonBox)
            {
                stackPanel.Children.Add(trainerName);
                stackPanel.Children.Add(ending);
            }

            listViewItem.Content = stackPanel;
            listViewItem.Tag     = gameSaveFile;
        }
 public override bool IsRequirementsFulfilled(IGameSave gameSave)
 {
     GBAGameSave gbaSave = gameSave as GBAGameSave;
     GameTypes gameType = gameSave.GameType;
     bool hasOneBike = gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(259) != 0 || gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(272) != 0;
     if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire)
         return gbaSave.GetGameFlag((int)RubySapphireGameFlags.HasBeatenEliteFour) && hasOneBike;
     else if (gameType == GameTypes.Emerald)
         return gbaSave.GetGameFlag((int)EmeraldGameFlags.HasBeatenEliteFour) && hasOneBike;
     return false;
 }
        public void OnDestroyIGameSave(IGameSave gameSave)
        {
            #if UNITY_EDITOR
            if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode &&
                UnityEditor.EditorApplication.isPlaying)
            {
                return;
            }
            #endif

            this.data[gameSave.GetUniqueName()] = gameSave.GetSaveData();
        }
Exemple #32
0
 public void LoadEvents(IGameSave gameSave)
 {
     this.gameSave                   = gameSave;
     this.selectedIndex              = -1;
     this.labelTitle.Content         = "";
     this.textBlockDescription.Text  = "";
     this.textBlockRequirements.Text = "";
     this.imageSprite.Source         = null;
     this.buttonActivate.IsEnabled   = false;
     UpdateDetails();
     PopulateEvents();
 }
        public static Item ShowDialog(Window owner, IGameSave gameSave)
        {
            GiveItemWindow window = new GiveItemWindow(gameSave);

            window.Owner = owner;
            var result = window.ShowDialog();

            if (result != null && result.Value)
            {
                return(window.selectedItem);
            }
            return(null);
        }
        public void LoadGame(IGameSave gameSave)
        {
            this.gameSave = gameSave;

            AddListViewItems();
            roomDisplay.UnloadSecretBase();
            locationDisplay.UnloadLocation();
            labelOwner.Content = "";
            labelTrainerID.Content = "";
            labelSecretID.Content = "";
            labelRequires.Content = "";
            gridTeam.Visibility = Visibility.Hidden;
            OnSecretBaseSelected(null, null);

            /*this.buttonSend.Visibility		= (IsGBAGame ? Visibility.Visible : Visibility.Hidden);
            this.buttonRegister.Visibility	= (IsGBAGame ? Visibility.Visible : Visibility.Hidden);
            this.buttonImport.Visibility	= (IsGBAGame ? Visibility.Hidden : Visibility.Visible);
            this.buttonExport.Visibility	= (IsGBAGame ? Visibility.Hidden : Visibility.Visible);*/
        }
 public override bool HasRoomForReward(IGameSave gameSave)
 {
     return gameSave.Inventory.Items[ItemTypes.KeyItems].HasRoomForItem(GetBikeItemID(gameSave), 1);
 }
 public override bool HasRoomForReward(IGameSave gameSave)
 {
     return gameSave.PokePC.HasRoomForPokemon(1);
 }
 public override void GenerateReward(IGameSave gameSave)
 {
 }
 public override bool IsCompleted(IGameSave gameSave)
 {
     if (gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(TicketItemID) == 0)
         return false;
     GBAGameSave gbaSave = gameSave as GBAGameSave;
     GameTypes gameType = gameSave.GameType;
     if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire) {
         if (TicketType == TicketTypes.EonTicket)
             return gbaSave.GetGameFlag((int)RubySapphireGameFlags.EonTicketActivated);
     }
     else if (gameType == GameTypes.FireRed || gameType == GameTypes.LeafGreen) {
         if (TicketType == TicketTypes.MysticTicket)
             return gbaSave.GetGameFlag((int)FireRedLeafGreenGameFlags.MysticTicketActivated);
         else if (TicketType == TicketTypes.AuroraTicket)
             return gbaSave.GetGameFlag((int)FireRedLeafGreenGameFlags.AuroraTicketActivated);
     }
     else if (gameType == GameTypes.Emerald) {
         if (TicketType == TicketTypes.EonTicket)
             return gbaSave.GetGameFlag((int)EmeraldGameFlags.EonTicketActivated);
         else if (TicketType == TicketTypes.MysticTicket)
             return gbaSave.GetGameFlag((int)EmeraldGameFlags.MysticTicketActivated);
         else if (TicketType == TicketTypes.AuroraTicket)
             return gbaSave.GetGameFlag((int)EmeraldGameFlags.AuroraTicketActivated);
         else if (TicketType == TicketTypes.OldSeaMap)
             return gbaSave.GetGameFlag((int)EmeraldGameFlags.OldSeaMapActivated);
     }
     return false;
 }
 public GamePokemonSearchResults(IGameSave gameSave)
 {
     GameSave = gameSave;
     ValidPokemon = new List<IPokemon>();
 }
 public GamePokemonSearchResults GetMirageResults(IGameSave gameSave)
 {
     foreach (GamePokemonSearchResults results in mirageIslandResults) {
         if (results.GameSave == gameSave)
             return results;
     }
     return null;
 }
 public void LoadGameSave(IGameSave gameSave)
 {
     this.gameSave = gameSave;
     RefreshUI();
 }
 private int GetRegiEventsCompleted(IGameSave gameSave)
 {
     int count = 0;
     if (PokeManager.IsEventSoftCompletedBy("REGIROCK DOLL [RSE]", gameSave)) count++;
     if (PokeManager.IsEventSoftCompletedBy("REGICE DOLL [RSE]", gameSave)) count++;
     if (PokeManager.IsEventSoftCompletedBy("REGISTEEL DOLL [RSE]", gameSave)) count++;
     return count;
 }
 public override void GiveReward(IGameSave gameSave)
 {
     gameSave.Inventory.Decorations[DecorationTypes.Doll].AddDecoration(DollID, 1);
     PokeManager.ManagerWindow.GotoDecoration(gameSave.GameIndex, DecorationTypes.Doll, DollID);
 }
 public override bool IsCompleted(IGameSave gameSave)
 {
     return false;
 }
 private ushort GetBikeItemID(IGameSave gameSave)
 {
     return (ushort)(gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(259) != 0 ? 272 : 259);
 }
        public override void GenerateReward(IGameSave gameSave)
        {
            Random random = new Random((int)DateTime.Now.Ticks);
            PokemonData pokemonData = PokemonDatabase.GetPokemonFromDexID(DexID);
            GBAPokemon pkm = new GBAPokemon();

            pkm.DexID = DexID;
            pkm.Personality = (Personality.HasValue ? Personality.Value : (uint)random.Next());
            pkm.Experience = PokemonDatabase.GetExperienceFromLevel(pokemonData.ExperienceGroup, (IsEgg ? (byte)5 : Level));
            pkm.IsSecondAbility2 = (IsSecondAbility.HasValue ? IsSecondAbility.Value : (!pokemonData.CanOnlyHaveFirstAbility && random.Next(2) == 1));
            pkm.Nickname = (Nickname != null ? Nickname : pokemonData.Name.ToUpper());
            pkm.BallCaughtID = 4;
            pkm.MetLocationID = 255;
            if (DexID == 151 || DexID == 386)
                pkm.IsFatefulEncounter = true;
            pkm.LevelMet = (IsEgg ? (byte)0 : Level);
            pkm.Language = Languages.English;
            pkm.Friendship = (byte)(IsEgg ? 10 : 70);

            // Ownership
            pkm.TrainerName = (TrainerName != null ? TrainerName : PokeManager.ManagerGameSave.TrainerName);
            pkm.TrainerGender = (TrainerGender.HasValue ? TrainerGender.Value : PokeManager.ManagerGameSave.TrainerGender);
            pkm.TrainerID = (TrainerID.HasValue ? TrainerID.Value : PokeManager.ManagerGameSave.TrainerID);
            pkm.SecretID = (SecretID.HasValue ? SecretID.Value : PokeManager.ManagerGameSave.SecretID);
            if (TrainerGender.HasValue && TrainerGender.Value == Genders.Genderless)
                pkm.TrainerGender = (random.Next(2) == 1 ? Genders.Female : Genders.Male);

            if (!Personality.HasValue)
                GeneratePID(pkm, random);

            if (HeldItem != null) pkm.HeldItemID = HeldItem[random.Next(HeldItem.Length)];

            if (Conditions != null) {
                pkm.Coolness	= Conditions[0];
                pkm.Beauty		= Conditions[1];
                pkm.Cuteness	= Conditions[2];
                pkm.Smartness	= Conditions[3];
                pkm.Toughness	= Conditions[4];
                pkm.Feel		= Conditions[5];
            }

            pkm.HPIV		= (IVs != null ? IVs[0] : (byte)random.Next(32));
            pkm.AttackIV	= (IVs != null ? IVs[1] : (byte)random.Next(32));
            pkm.DefenseIV	= (IVs != null ? IVs[2] : (byte)random.Next(32));
            pkm.SpAttackIV	= (IVs != null ? IVs[3] : (byte)random.Next(32));
            pkm.SpDefenseIV	= (IVs != null ? IVs[4] : (byte)random.Next(32));
            pkm.SpeedIV		= (IVs != null ? IVs[5] : (byte)random.Next(32));

            if (HiddenPowerDamage.HasValue)	pkm.SetHiddenPowerDamage(HiddenPowerDamage.Value);
            if (HiddenPowerType.HasValue) pkm.SetHiddenPowerType(HiddenPowerType.Value);

            // Teach the Pokemon all of it's default moves
            ushort[] moves = PokemonDatabase.GetMovesLearnedAtLevelRange(pkm, 1, (IsEgg ? (byte)5 : Level));
            foreach (ushort moveID in moves) {
                if (!PokemonDatabase.PokemonHasMove(pkm, moveID)) {
                    if (pkm.NumMoves < 4) {
                        pkm.SetMoveAt(pkm.NumMoves, new Move(moveID));
                    }
                    else {
                        for (int i = 0; i < 3; i++) {
                            pkm.SetMoveAt(i, pkm.GetMoveAt(i + 1));
                        }
                        pkm.SetMoveAt(3, new Move(moveID));
                    }
                }
            }
            if (Move1ID.HasValue) pkm.SetMoveAt(0, new Move(Move1ID.Value));
            if (Move2ID.HasValue) pkm.SetMoveAt(1, new Move(Move2ID.Value));
            if (Move3ID.HasValue) pkm.SetMoveAt(2, new Move(Move3ID.Value));
            if (Move4ID.HasValue) pkm.SetMoveAt(3, new Move(Move4ID.Value));

            GameTypes gameType = gameSave.GameType;
            if (gameType == GameTypes.Ruby)				pkm.GameOrigin = GameOrigins.Ruby;
            else if (gameType == GameTypes.Sapphire)	pkm.GameOrigin = GameOrigins.Sapphire;
            else if (gameType == GameTypes.Emerald)		pkm.GameOrigin = GameOrigins.Emerald;
            else if (gameType == GameTypes.FireRed)		pkm.GameOrigin = GameOrigins.FireRed;
            else if (gameType == GameTypes.LeafGreen)	pkm.GameOrigin = GameOrigins.LeafGreen;
            else if (gameType == GameTypes.Colosseum ||
                     gameType == GameTypes.XD)			pkm.GameOrigin = GameOrigins.ColosseumXD;
            else										pkm.GameOrigin = GameOrigins.Emerald;

            pkm.GameType = gameType;
            pkm.Checksum = pkm.CalculateChecksum();
            pkm.RecalculateStats();
            reward = pkm;
        }
        public void LoadGame(int gameIndex)
        {
            try {
                PokeManager.DropSelection();
                PokeManager.DropPokemon();
                PokeManager.ClearSelectedPokemon();
                comboBoxGameSaves.SelectedIndex = gameIndex + 1;
                gameSave = PokeManager.GetGameSaveAt(gameIndex);

                this.gameIndex = gameIndex;

                BitmapSource trainerImage = ResourceDatabase.GetImageFromName("WorldRubySapphireMale");
                if (gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire)
                    trainerImage = ResourceDatabase.GetImageFromName("WorldRubySapphire" + gameSave.TrainerGender.ToString());
                else if (gameSave.GameType == GameTypes.Emerald)
                    trainerImage = ResourceDatabase.GetImageFromName("WorldEmerald" + gameSave.TrainerGender.ToString());
                else if (gameSave.GameType == GameTypes.FireRed || gameSave.GameType == GameTypes.LeafGreen)
                    trainerImage = ResourceDatabase.GetImageFromName("WorldFireRedLeafGreen" + gameSave.TrainerGender.ToString());
                else if (gameSave.GameType == GameTypes.Colosseum)
                    trainerImage = ResourceDatabase.GetImageFromName("WorldColosseumMale");
                else if (gameSave.GameType == GameTypes.XD)
                    trainerImage = ResourceDatabase.GetImageFromName("WorldXDMale");
                else if (gameSave.GameType == GameTypes.Any)
                    trainerImage = ResourceDatabase.GetImageFromName("WorldManager" + gameSave.TrainerGender.ToString());
                (menuItemEditTrainer.Icon as Image).Source = trainerImage;

                int eventCount = 0;
                for (int i = 0; i < PokeManager.NumEvents && gameSave.GameType != GameTypes.Any; i++) {
                    EventDistribution eventDist = PokeManager.GetEventAt(i);
                    if (eventDist.AllowedGames.HasFlag((GameTypeFlags)(1 << ((int)gameSave.GameType - 1))))
                        eventCount++;
                }
                this.tabEventViewer.Visibility = (eventCount > 0 ? Visibility.Visible : Visibility.Collapsed);

                if (gameSave.GameType == GameTypes.PokemonBox) {
                    this.tabPokemon.Visibility = Visibility.Visible;
                    this.tabTrainerInfo.Visibility = Visibility.Collapsed;
                    this.tabItems.Visibility = Visibility.Collapsed;
                    this.tabDexViewer.Visibility = Visibility.Collapsed;
                    this.tabMailbox.Visibility = Visibility.Collapsed;
                    this.tabDecorations.Visibility = Visibility.Collapsed;
                    this.tabSecretBases.Visibility = Visibility.Collapsed;
                    this.eventViewer.LoadEvents(gameSave);
                    if (tabControl.SelectedItem != null && ((TabItem)tabControl.SelectedItem).Visibility != Visibility.Visible || (tabControl.SelectedIndex == 7 && eventCount == 0))
                        Dispatcher.BeginInvoke((Action)(() => tabControl.SelectedIndex = 1));

                    pokemonViewer.LoadGame(gameSave);
                    menuItemEditTrainer.IsEnabled = false;
                }
                else {
                    //this.tabSecretBases.Visibility = Visibility.Collapsed;
                    if (gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire || gameSave.GameType == GameTypes.Emerald || gameSave.GameType == GameTypes.Any) {
                        this.tabSecretBases.Visibility = Visibility.Visible;
                        this.secretBaseManager.LoadGame(gameSave);
                    }
                    else {
                        this.tabSecretBases.Visibility = Visibility.Collapsed;
                    }
                    menuItemEditTrainer.IsEnabled = true;
                    this.tabTrainerInfo.Visibility = Visibility.Visible;
                    this.tabItems.Visibility = Visibility.Visible;
                    this.tabDexViewer.Visibility = Visibility.Visible;
                    this.eventViewer.LoadEvents(gameSave);
                    inventoryViewer.LoadInventory(gameSave.Inventory);
                    pokemonViewer.LoadGame(gameSave);
                    trainerInfo.LoadGameSave(gameSave);
                    if (gameSave.Inventory.Decorations != null)
                        decorationInventoryViewer.LoadInventory(gameSave.Inventory);
                    if (gameSave.Mailbox != null)
                        mailViewer.LoadMailbox(gameSave.Mailbox);
                    else
                        mailViewer.UnloadMailbox();
                    dexViewer.LoadGameSave(gameSave);
                    if (gameSave.GameType == GameTypes.Colosseum || gameSave.GameType == GameTypes.XD)
                        tabDexViewer.Header = "Strategy Memo";
                    else
                        tabDexViewer.Header = "Pokédex";
                    tabMailbox.Visibility = (gameSave.Mailbox != null ? Visibility.Visible : Visibility.Collapsed);
                    tabDecorations.Visibility = (gameSave.Inventory.Decorations != null ? Visibility.Visible : Visibility.Collapsed);
                    if (tabControl.SelectedItem != null && ((TabItem)tabControl.SelectedItem).Visibility != Visibility.Visible || (tabControl.SelectedIndex == 7 && eventCount == 0))
                        Dispatcher.BeginInvoke((Action)(() => tabControl.SelectedIndex = 0));
                    if (tabControl.SelectedIndex == 6)
                        dexViewer.RefreshUI();
                }
            }
            catch (Exception ex) {
                if (gameIndex == -1) {
                    ErrorMessageBox.Show(ex);
                }
                else {
                    MessageBoxResult result = TriggerMessageBox.Show(this, "An error occured while displaying this game save. The save may be corrupted or this may have been an error on Trigger's PC's end. Would you like to see the error?", "Load Error", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                        ErrorMessageBox.Show(ex);
                    LoadGame(-1);
                }
            }
        }
 public override bool IsCompleted(IGameSave gameSave)
 {
     return gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(259) != 0 && gameSave.Inventory.Items[ItemTypes.KeyItems].GetCountOfID(272) != 0;
 }
 public override bool IsRequirementsFulfilled(IGameSave gameSave)
 {
     GBAGameSave gbaSave = gameSave as GBAGameSave;
     GameTypes gameType = gameSave.GameType;
     if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire)
         return gbaSave.GetGameFlag((int)RubySapphireGameFlags.HasBeatenEliteFour);
     else if (gameType == GameTypes.FireRed || gameType == GameTypes.LeafGreen)
         return gbaSave.GetGameFlag((int)FireRedLeafGreenGameFlags.HasBeatenEliteFour);
     else if (gameType == GameTypes.Emerald)
         return gbaSave.GetGameFlag((int)EmeraldGameFlags.HasBeatenEliteFour);
     return false;
 }
        public PokeManagerWindow()
        {
            this.UseLayoutRounding = true;
            PokeManager.Initialize(this);

            this.gameIndex = 0;
            this.loaded = false;
            this.gameSave = null;
            this.gen = Generations.Gen3;
            this.selectedTab = 0;

            this.timer = new DispatcherTimer();
            this.timer.Interval = TimeSpan.FromSeconds(5);
            this.timer.Tick += OnTick;
            this.timer.Start();

            #region Stuff

            /*Gen3GBAGameSave rbySave = new Gen3GBAGameSave(System.IO.Path.Combine("Saves", "Ruby Hack.sav"));

            foreach (IBlockData blockData in rbySave.MostRecentSave.BlockDataCollection) {

                if (blockData.SectionID >= SectionTypes.PCBufferA)
                    continue;
                for (int i = 0; i < SectionIDTable.GetContents(blockData.SectionID); i++) {

                    if (blockData.Raw[i] == 0x55 && blockData.Raw[i + 1] == 0x55) {
                        Console.WriteLine(i);
                        //804 NatPokedexBC (0x420)
                    }
                }
            }

            Gen3GBAGameSave frSave = new Gen3GBAGameSave(System.IO.Path.Combine("Saves", "FireRed Hack.sav"));

            foreach (IBlockData blockData in frSave.MostRecentSave.BlockDataCollection) {

                if (blockData.SectionID >= SectionTypes.PCBufferA)
                    continue;
                for (int i = 0; i < SectionIDTable.GetContents(blockData.SectionID); i++) {

                    if (blockData.Raw[i] == 0x55 && blockData.Raw[i + 1] == 0x55) {
                        Console.WriteLine(i);
                        //100 NatPokedexBC
                        //3940 TeamAndItems (Save == 3968) 3940-132=3808
                    }
                }
            }*/

            /*Dictionary<SectionTypes, List<DifferenceData>> differenceData = new Dictionary<SectionTypes, List<DifferenceData>>();

            foreach (SectionTypes sectionType in Enum.GetValues(typeof(SectionTypes))) {
                IBlockData least = emSave.LeastRecentSave.BlockDataCollection.GetBlockData(sectionType);
                IBlockData most = emSave.MostRecentSave.BlockDataCollection.GetBlockData(sectionType);
                differenceData.Add(sectionType, new List<DifferenceData>());

                DifferenceData difference = null;
                for (int i = 0; i < SectionIDTable.GetContents(sectionType); i++) {
                    if (least.Raw[i] != most.Raw[i]) {
                        if (difference == null)
                            difference = new DifferenceData(i);
                        else
                            difference.Length++;
                    }
                    else if (difference != null) {
                        differenceData[sectionType].Add(difference);
                        difference = null;
                    }
                }
            }*/

            /*int saveIndex = 0;
            while (saveIndex != -1) {
                BlockDataCollection bdcLeast = emSave.LeastRecentSave.BlockDataCollection;
                BlockDataCollection bdcMost = emSave.MostRecentSave.BlockDataCollection;
                Console.WriteLine(saveIndex);
                emSave.Save(System.IO.Path.Combine("Saves", "Tests", saveIndex.ToString() + ".sav"));
                saveIndex++;
                emSave = new Gen3GBAGameSave(System.IO.Path.Combine("Saves", "POKEMON EMER-7b058a7aea5bfbb352026727ebd87e17.sav"));
            }*/

            /*Dictionary<string, GameTypes> gameTypeTable = new Dictionary<string, GameTypes>() {
                {"RUBY", GameTypes.Ruby},
                {"SAPP", GameTypes.Sapphire},
                {"EMER", GameTypes.Emerald},
                {"FIRE", GameTypes.FireRed},
                {"LEAF", GameTypes.LeafGreen}
            };
            string[] files = Directory.GetFiles("Saves");
            foreach (string file in files) {
                foreach (KeyValuePair<string, GameTypes> pair in gameTypeTable) {
                    if (System.IO.Path.GetFileName(file).Contains(pair.Key) && System.IO.Path.GetExtension(file) == ".sav") {
                        PokeManager.AddGameSave(file, pair.Value);
                    }
                }
            }*/
            /*PokeManager.AddGameSave(System.IO.Path.Combine("Saves", "01-GC6E-pokemon_colosseum.gci"));
            PokeManager.AddGameSave(System.IO.Path.Combine("Saves", "01-GC6E-pokemon_colosseum1.gci"));
            PokeManager.AddGameSave(System.IO.Path.Combine("Saves", "01-GC6E-pokemon_colosseum2.gci"));
            PokeManager.AddGameSave(System.IO.Path.Combine("Saves", "01-GC6E-pokemon_colosseum3.gci"));*/

            #endregion

            InitializeComponent();

            UpdateSettingsMenuItems();

            this.loaded = true;

            if (PokeManager.Settings.DefaultStartupSize.Width != 0 && PokeManager.Settings.DefaultStartupSize.Height != 0) {
                this.Width = PokeManager.Settings.DefaultStartupSize.Width;
                this.Height = PokeManager.Settings.DefaultStartupSize.Height;
            }

            PokeManager.IsReloading = true;
            LoadGame(PokeManager.Settings.IsValidDefaultGame ? PokeManager.Settings.DefaultGame : -1);
            PokeManager.IsReloading = false;

            if (((TabItem)tabControl.Items[PokeManager.Settings.DefaultStartupTab]).Visibility == Visibility.Visible)
                Dispatcher.BeginInvoke((Action)(() => tabControl.SelectedIndex = PokeManager.Settings.DefaultStartupTab));

            if (!PokeManager.IsAprilFoolsDay)
                menuItemAprilFoolsMode.Visibility = Visibility.Collapsed;
        }
 public override bool HasRoomForReward(IGameSave gameSave)
 {
     return gameSave.Inventory.Decorations[DecorationTypes.Doll].HasRoomForDecoration(DollID, 1);
 }
 public override bool IsRequirementsFulfilled(IGameSave gameSave)
 {
     return CheckRequirements(gameSave);
 }