public void SetAppearance(BlossomData.BlossomGrowth pGrowth, string pColor)
        {
            Anim = GetComponent <Animator>();
            AnimatorOverrideController aoc = new AnimatorOverrideController(Anim.runtimeAnimatorController);

            aoc.name = "Blossom_Override";
            AnimationClip[] clips = Anim.runtimeAnimatorController.animationClips;

            //List<KeyValuePair<AnimationClip, AnimationClip>> overrides = new List<KeyValuePair<AnimationClip, AnimationClip>>();

            foreach (AnimationClip clip in clips)
            {
                string        path    = "BlossomColors/Blossom_" + pColor + "/" + pGrowth.ToString() + "/" + clip.name;
                AnimationClip newClip = Resources.Load(path) as AnimationClip;
                aoc[clip.name] = newClip;
                //                print(clip.name + newClip.name);
            }
            //   aoc.ApplyOverrides(overrides);
            Anim.runtimeAnimatorController = aoc;
        }
Exemple #2
0
        void CheckPregnancy()
        {
            if (Data.Growth != BlossomData.BlossomGrowth.Adult)
            {
                return;
            }
            if (Data.Pregnant == true)
            {
                return;
            }
            if (BlossomManager.Instance.HutAmount >= BlossomManager.Instance.MaxHuts)
            {
                return;
            }
            bool pregnantChance = false;

            int rand = Random.Range(0, 101);

            if (rand <= 15)
            {
                pregnantChance = true;
            }

            if (pregnantChance == true)
            {
                //CHECK COMPATIBLE BLOSSOMS
                List <string> compatibleBlossoms = new List <string>();
                string        match = string.Empty;
                foreach (string blossom in BlossomManager.Instance.OwnedBlossoms)
                {
                    if (Data.ID == blossom)
                    {
                        continue;
                    }
                    if (Data.Parent1 == blossom)
                    {
                        continue;
                    }
                    if (Data.Parent2 == blossom)
                    {
                        continue;
                    }
                    BlossomData.BlossomGrowth growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(blossom + "Growth").asString);
                    print(growth.ToString());
                    if (growth != BlossomData.BlossomGrowth.Adult)
                    {
                        continue;
                    }
                    if (DialogueLua.GetVariable(blossom + "Pregnant").asBool == true)
                    {
                        continue;
                    }
                    compatibleBlossoms.Add(blossom);
                }
                if (compatibleBlossoms.Count > 0)
                {
                    rand  = Random.Range(0, compatibleBlossoms.Count - 1);
                    match = compatibleBlossoms[rand];
                }
                else
                {
                    print("no compat");
                }
                //IF MATCH FOUND
                if (match != string.Empty)
                {
                    Data.BabyID = BlossomManager.Instance.CreateChildBlossom(Data.ID, match);
                    PixelCrushers.MessageSystem.SendMessage(this, "PregnantBlossom", Data.ID);
                    string babyHut = BlossomManager.Instance.GetEmptyHut();
                    DialogueLua.SetVariable(babyHut + "Blossom", Data.BabyID);
                    DialogueLua.SetVariable(Data.BabyID + "HutX", DialogueLua.GetVariable(babyHut + "X").asFloat);
                    DialogueLua.SetVariable(Data.BabyID + "HutY", DialogueLua.GetVariable(babyHut + "Y").asFloat);
                    DialogueLua.SetVariable(Data.BabyID + "HutName", babyHut);
                    Data.Pregnant     = true;
                    Data.DaysPregnant = 0;
                    GetComponent <BlossomDataSaver>().OnRecordPersistentData();
                }
            }
        }