コード例 #1
0
 public void ChangeValue (int target, int maxValue, PetObject pet)
 {
     m_Amount = (float)target - m_Slider.value;
     m_CurrentAmount = 0;
     m_CachedPet = pet;
     StartCoroutine(ChangeValueToTarget());
     //m_Slider.
 }
コード例 #2
0
 IEnumerator ChangeValueToTarget ()
 {
     while (m_CurrentAmount < m_Amount)
     {
         m_CurrentAmount += m_DeltaAmount;
         m_Slider.value = m_Slider.value + m_DeltaAmount;
         yield return null;
     }
     m_CurrentAmount = 0;
     m_Amount = 0;
     m_CachedPet.CabllbackForHealthBar();
     m_CachedPet = null;
     
 }
コード例 #3
0
 //Will always load from "SavedFile"
 public void Load(List <PetObject> Pets)
 {
     //Gets a filestream to open and access the savefile
     using (FileStream fsInput = new FileStream(SavedFile, FileMode.Open, FileAccess.Read))
     {
         //Decrypts the encrypted file
         using (DESCryptoServiceProvider DES = new DESCryptoServiceProvider())
         {
             //Forces the Key and IV
             DES.Key = DefaultKey;
             DES.IV  = DefaultKey;
             //the decryptor
             ICryptoTransform desencrypt = DES.CreateDecryptor();
             //now opens a stream wrapped in a filestream to read and decode the file
             using (CryptoStream cryptostream = new CryptoStream(fsInput, desencrypt, CryptoStreamMode.Read))
             {
                 //creates a stream reader to read the actual data
                 using (StreamReader STRead = new StreamReader(cryptostream))
                 {
                     //makes a string out of the current line
                     string line;
                     while ((line = STRead.ReadLine()) != null)
                     {
                         //splits the line by
                         string[]  spLines = line.Split(",".ToCharArray());
                         PetObject NewPet  = new PetObject();
                         NewPet.Name   = spLines[0].ToString();
                         NewPet.Energy = int.Parse(spLines[1]);
                         NewPet.Hunger = int.Parse(spLines[2]);
                         NewPet.Mood   = int.Parse(spLines[3]);
                         NewPet.Health = int.Parse(spLines[4]);
                         NewPet.Attack = int.Parse(spLines[5]);
                         NewPet.Speed  = int.Parse(spLines[6]);
                         line          = STRead.ReadLine();
                         string[] PetRelationships = line.Split(",".ToCharArray());
                         for (int i = 0; i < PetRelationships.Length - 1; i++)
                         {
                             string[] relationship = PetRelationships[i].Split(":".ToCharArray());
                             NewPet.Relationships.Add(relationship[0], int.Parse(relationship[1]));
                         }
                         Pets.Add(NewPet);
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: PetList.cs プロジェクト: duongxuanlong/examples
    void OnLoadPet()
    {
        #region Fake loading
        if (m_Pets.Count == 0)
        {
            for (int i = 0; i < Constant.PETS; ++i)
            {
                GameObject obj = Instantiate(m_PrefabPets[i]) as GameObject;
                if (obj != null)
                {
                    obj.transform.SetParent(gameObject.transform);
                    GameObject newobj = Instantiate(m_PrefabPet) as GameObject;
                    newobj.transform.SetParent(gameObject.transform);
                    PetObject pet  = newobj.GetComponent <PetObject>();
                    PetStat   stat = new PetStat();

                    if (i == 0)
                    {
                        stat.m_PetType = PetIconController.PetType.Pet01;
                    }
                    else if (i == 1)
                    {
                        stat.m_PetType = PetIconController.PetType.Pet02;
                    }
                    else if (i == 2)
                    {
                        stat.m_PetType = PetIconController.PetType.Pet03;
                    }

                    PetController controller = obj.GetComponent <PetController>();
                    pet.SetUpPet(stat, controller);
                    m_Pets.Add(pet);
                }
            }
        }

        DelegateManager.UpdateMaxLevel(FindMaxLevel());

        if (Constant.IsDebug)
        {
            Debug.Log("Pets: " + m_Pets.Count);
        }
        #endregion
    }
コード例 #5
0
    //Will always Load from "NewFile"
    public void StartNewFile(List <PetObject> Pets)
    {
        print(NewFile);
        using (FileStream fsInput = new FileStream(NewFile, FileMode.Open, FileAccess.Read))
        {
            using (DESCryptoServiceProvider DES = new DESCryptoServiceProvider())
            {
                DES.Key = DefaultKey;
                DES.IV  = DefaultKey;
                ICryptoTransform desencrypt = DES.CreateDecryptor();
                using (CryptoStream cryptostream = new CryptoStream(fsInput, desencrypt, CryptoStreamMode.Read))
                {
                    using (StreamReader STRead = new StreamReader(cryptostream))
                    {
                        //makes a string out of the current line
                        string line;
                        while ((line = STRead.ReadLine()) != null)
                        {
                            string[]  spLines = line.Split(",".ToCharArray());
                            PetObject NewPet  = new PetObject();
                            NewPet.Name   = spLines[0].ToString();
                            NewPet.Energy = int.Parse(spLines[1]);
                            NewPet.Hunger = int.Parse(spLines[2]);
                            NewPet.Mood   = int.Parse(spLines[3]);
                            NewPet.Health = int.Parse(spLines[4]);
                            NewPet.Attack = int.Parse(spLines[5]);
                            NewPet.Speed  = int.Parse(spLines[6]);

                            line = STRead.ReadLine();
                            string[] PetRelationships = line.Split(",".ToCharArray());
                            for (int i = 0; i < PetRelationships.Length - 1; i++)
                            {
                                string[] relationship = PetRelationships[i].Split(":".ToCharArray());
                                NewPet.Relationships.Add(relationship[0], int.Parse(relationship[1]));
                            }
                            Pets.Add(NewPet);
                        }
                    }
                }
            }
        }
    }
コード例 #6
0
    //this is being used to read the new unencrypted save file. Should probably be saved for later
    public void CreateNewSave()
    {
        print(UnENFile);
        List <PetObject> Pets = new List <PetObject>();

        using (FileStream fsInput = new FileStream(UnENFile, FileMode.Open, FileAccess.Read))
        {
            using (StreamReader STRead = new StreamReader(fsInput))
            {
                //makes a string out of the current line
                string line;
                while ((line = STRead.ReadLine()) != null)
                {
                    //splits the line by
                    string[]  spLines = line.Split(",".ToCharArray());
                    PetObject NewPet  = new PetObject();
                    NewPet.Name   = spLines[0].ToString();
                    NewPet.Energy = int.Parse(spLines[1]);
                    NewPet.Hunger = int.Parse(spLines[2]);
                    NewPet.Mood   = int.Parse(spLines[3]);
                    NewPet.Health = int.Parse(spLines[4]);
                    NewPet.Attack = int.Parse(spLines[5]);
                    NewPet.Speed  = int.Parse(spLines[6]);

                    line = STRead.ReadLine();
                    string[] PetRelationships = line.Split(",".ToCharArray());
                    for (int i = 0; i < PetRelationships.Length - 1; i++)
                    {
                        string[] relationship = PetRelationships[i].Split(":".ToCharArray());
                        print(relationship[0] + " " + relationship[1]);
                        NewPet.Relationships.Add(relationship[0], int.Parse(relationship[1]));
                    }
                    Pets.Add(NewPet);
                }
                Save(Pets);
                SaveToNew(Pets);
            }
        }
    }
コード例 #7
0
ファイル: PetSkill.cs プロジェクト: OlegGelezcov/neb
 public PetSkill(PetSkillInfo skillInfo, NebulaObject source)
 {
     m_SkillInfo = skillInfo;
     m_Source    = source;
     m_Pet       = source.GetComponent <PetObject>();
 }
コード例 #8
0
 public PassivePetBonus(PetPassiveBonusInfo data, NebulaObject source)
 {
     m_Data   = data;
     m_Source = source;
     m_Pet    = source.GetComponent <PetObject>();
 }