Пример #1
0
        public override void SerializePokedex(Stream stream, PlayerData.Pokedex pokedex)
        {
            byte[] buffer;

            PlayerData.Pokedex.Entry[] entries = pokedex.GetAllSavedEntries();

            //Number of entries
            buffer = BitConverter.GetBytes(entries.Length);
            stream.Write(buffer, 0, 4);

            //Entries
            foreach (PlayerData.Pokedex.Entry entry in entries)
            {
                //Species id
                buffer = BitConverter.GetBytes(entry.speciesId);
                stream.Write(buffer, 0, 4);

                //Seen
                buffer = BitConverter.GetBytes(entry.seen);
                stream.Write(buffer, 0, 4);

                //Caught
                buffer = BitConverter.GetBytes(entry.caught);
                stream.Write(buffer, 0, 4);
            }
        }
Пример #2
0
        public void SetUp(PlayerData player = null)
        {
            if (player == null)
            {
                player = PlayerData.singleton;
            }

            playerPokedex = player.pokedex;

            buttonCry.onClick.RemoveAllListeners();
            buttonCry.onClick.AddListener(() => SoundFXController.singleton.PlayPokemonCry(currSpeciesId));
        }
Пример #3
0
        public override PlayerData.Pokedex DeserializePokedex(Stream stream)
        {
            byte[] buffer;

            PlayerData.Pokedex pokedex;
            int entryCount;

            PlayerData.Pokedex.Entry[] entries;

            //Number of entries
            buffer = new byte[4];
            stream.Read(buffer, 0, 4);
            entryCount = BitConverter.ToInt32(buffer, 0);

            entries = new PlayerData.Pokedex.Entry[entryCount];

            //Entries
            for (int i = 0; i < entryCount; i++)
            {
                int speciesId, seen, caught;

                //Species id
                buffer = new byte[4];
                stream.Read(buffer, 0, 4);
                speciesId = BitConverter.ToInt32(buffer, 0);

                //Seen
                buffer = new byte[4];
                stream.Read(buffer, 0, 4);
                seen = BitConverter.ToInt32(buffer, 0);

                //Caught
                buffer = new byte[4];
                stream.Read(buffer, 0, 4);
                caught = BitConverter.ToInt32(buffer, 0);

                //Add entry
                entries[i] = new PlayerData.Pokedex.Entry(speciesId, seen, caught);
            }

            pokedex = new PlayerData.Pokedex(entries);

            return(pokedex);
        }
Пример #4
0
 public abstract void SerializePokedex(Stream stream, PlayerData.Pokedex pokedex);