예제 #1
0
        private void onPetRefresh(object sender, RoutedEventArgs e)
        {
            petComboBox.Items.Clear();

            var blob = loadSaveFile();

            List <PetProperties> temp = new List <PetProperties>();

            {
                int           offset = 0;
                PetProperties p      = null;
                while (true)
                {
                    offset = Utils.IndexOf(blob, petNameTag, offset, petNameTagMask);
                    if (offset == -1)
                    {
                        offset = 0;
                        break;
                    }

                    if (p != null)
                    {
                        p.offsetOfNext = offset;
                    }

                    offset += petNameTag.Length;
                    var pet = readTillNull(blob, offset);

                    if (p == null)
                    {
                        PetProperties.PlayerName = pet;
                    }

                    p        = new PetProperties();
                    p.name   = pet;
                    p.offset = offset;
                    p.blob   = blob;
                    temp.Add(p);
                }
            }

            foreach (var entry in temp)
            {
                var item = new ComboBoxItem();
                item.Content = entry.name;
                item.Tag     = entry;

                if (Utils.IndexOf(entry.blob, breederTag, entry.offset, null, entry.offsetOfNext) != -1 ||
                    PetProperties.PlayerName == entry.name)
                {
                    continue;
                }
                petComboBox.Items.Add(item);
            }
        }
예제 #2
0
    private static PetProperties ClonePet(PetProperties pet)
    {
        PetProperties temPet = new PetProperties()
        {
            TargetName = pet.TargetName,
            name       = pet.name,
            Level      = pet.Level,
            Experience = pet.Experience,
            Life       = pet.Life,
            Hungry     = pet.Hungry,
            Happiness  = pet.Happiness,
            Cleanness  = pet.Cleanness,
        };

        return(temPet);
    }
예제 #3
0
    private static PetProperties LoadPetInfo(string key)
    {
        List <string> petInfo = PlayerPrefsX.GetStringList(key);
        PetProperties loadPet = new PetProperties()
        {
            TargetName = petInfo[0],
            name       = petInfo[1],
            Level      = int.Parse(petInfo[2]),
            Experience = int.Parse(petInfo[3]),
            Life       = int.Parse(petInfo[4]),
            Hungry     = int.Parse(petInfo[5]),
            Happiness  = int.Parse(petInfo[6]),
            Cleanness  = int.Parse(petInfo[7]),
        };

        return(loadPet);
    }
예제 #4
0
    public static void SavePetInfo(PetProperties pet)
    {
        string        key     = pet.TargetName;
        List <string> petInfo = new List <string>()
        {
            pet.TargetName,
            pet.name,
            pet.Level.ToString(),
            pet.Experience.ToString(),
            pet.Life.ToString(),
            pet.Hungry.ToString(),
            pet.Happiness.ToString(),
            pet.Cleanness.ToString(),
        };

        PlayerPrefsX.SetStringList(key, petInfo);
    }
예제 #5
0
    public static PetProperties GetPetByTargetName(string targetName)
    {
        PetProperties loadPet = new PetProperties();

        if (PlayerPrefs.HasKey(targetName) == true)
        {
            loadPet = LoadPetInfo(targetName);
        }
        else
        {
            foreach (var t in pets)
            {
                if (t.TargetName != targetName)
                {
                    continue;
                }
                loadPet = ClonePet(t);
                break;
            }
        }
        return(loadPet);
    }
예제 #6
0
 private void comboBoxUpdated(object sender, SelectionChangedEventArgs e)
 {
     selectedPet = (((sender as ComboBox).SelectedItem as ComboBoxItem).Tag as PetProperties);
 }