Пример #1
0
 public void Train(string pBlossomID)
 {
     if (BlossomManager.Instance.GetSpawnedBlossom(pBlossomID) != null)
     {
         BlossomController blossom = BlossomManager.Instance.GetSpawnedBlossom(pBlossomID).GetComponent <BlossomController>();
         blossom.Train(this);
     }
 }
Пример #2
0
        public void Open(string pBlossom, int pFee)
        {
            BlossomController blossom = BlossomManager.Instance.GetSpawnedBlossom(pBlossom).GetComponent <BlossomController>();

            float AgilityPotential     = blossom.GetTruePotential(Stat.StatName.Agility);         // DialogueLua.GetVariable(pBlossom + "AgilityPotential").asFloat;
            float AgilityLearningSpeed = blossom.GetTrueLearningSpeed(Stat.StatName.Agility);     //DialogueLua.GetVariable(pBlossom + "AgilityLearningSpeed").asFloat;

            float StrengthPotential     = blossom.GetTruePotential(Stat.StatName.Strength);       //DialogueLua.GetVariable(pBlossom + "StrengthPotential").asFloat;
            float StrengthLearningSpeed = blossom.GetTrueLearningSpeed(Stat.StatName.Strength);   //DialogueLua.GetVariable(pBlossom + "StrengthLearningSpeed").asFloat;

            float IntellectPotential     = blossom.GetTruePotential(Stat.StatName.Intellect);     //DialogueLua.GetVariable(pBlossom + "IntellectPotential").asFloat;
            float IntellectLearningSpeed = blossom.GetTrueLearningSpeed(Stat.StatName.Intellect); // DialogueLua.GetVariable(pBlossom + "IntellectLearningSpeed").asFloat;

            float CharmPotential     = blossom.GetTruePotential(Stat.StatName.Charm);             //DialogueLua.GetVariable(pBlossom + "CharmPotential").asFloat;
            float CharmLearningSpeed = blossom.GetTrueLearningSpeed(Stat.StatName.Charm);         //DialogueLua.GetVariable(pBlossom + "CharmLearningSpeed").asFloat;

            AgilityText.text   = "Agility: Potential: " + AgilityPotential.ToString("F2") + " Learning Speed: " + AgilityLearningSpeed.ToString("F2");
            StrengthText.text  = "Strength: Potential: " + StrengthPotential.ToString("F2") + " Learning Speed: " + StrengthLearningSpeed.ToString("F2");
            IntellectText.text = "Intellect: Potential: " + IntellectPotential.ToString("F2") + " Learning Speed: " + IntellectLearningSpeed.ToString("F2");
            CharmText.text     = "Charm: Potential: " + CharmPotential.ToString("F2") + " Learning Speed: " + CharmLearningSpeed.ToString("F2");

            FeeText.text = "Adoption Fee: " + pFee.ToString("F2");

            FeeText.color             = new Color(0, 0.5f, 0);
            AcceptButton.interactable = true;

            if (GameManager.Instance.Player.GetComponent <PlayerInventory>().Gold < pFee)
            {
                FeeText.color             = Color.red;
                AcceptButton.interactable = false;
            }
            if (BlossomManager.Instance.GetEmptyHut() == null)
            {
                DialogueManager.ShowAlert("No empty hut");
                AcceptButton.interactable = false;
            }



            Window.Open();
        }
        public void Open(Stat.StatName pStat, TrainingProp pProp)
        {
            TitleText.text = pStat.ToString() + " Training: Select a Blossom";
            BlossomDataSaver[] spawnedBlossoms = FindObjectsOfType <BlossomDataSaver>();
            foreach (BlossomDataSaver spawnedBlossom in spawnedBlossoms)
            {
                spawnedBlossom.OnRecordPersistentData();
            }

            BlossomSelectionUI[] children = BlossomContainer.GetComponentsInChildren <BlossomSelectionUI>();
            foreach (BlossomSelectionUI child in children)
            {
                Destroy(child.gameObject);
            }

            ChosenProp = pProp;


            foreach (string blossom in BlossomManager.Instance.OwnedBlossoms)
            {
                BlossomController selectedBlossom = BlossomManager.Instance.GetSpawnedBlossom(blossom).GetComponent <BlossomController>();

                float agility          = DialogueLua.GetVariable(blossom + "AgilityValue").asFloat;
                float agilityPotential = selectedBlossom.GetTruePotential(Stat.StatName.Agility);


                float strength          = DialogueLua.GetVariable(blossom + "StrengthValue").asFloat;
                float strengthPotential = selectedBlossom.GetTruePotential(Stat.StatName.Strength);

                float intellect          = DialogueLua.GetVariable(blossom + "IntellectValue").asFloat;
                float intellectPotential = selectedBlossom.GetTruePotential(Stat.StatName.Intellect);

                float charm          = DialogueLua.GetVariable(blossom + "CharmValue").asFloat;
                float charmPotential = selectedBlossom.GetTruePotential(Stat.StatName.Charm);


                bool pregnant = DialogueLua.GetVariable(blossom + "Pregnant").asBool;
                bool hungry   = DialogueLua.GetVariable(blossom + "Hungry").asBool;

                float energy   = DialogueLua.GetVariable(blossom + "Energy").asFloat;
                bool  fatigued = energy <= 0 ? true : false;

                string name = DialogueLua.GetVariable(blossom + "Name").asString;

                BlossomData.BlossomGrowth growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(blossom + "Growth").asString);
                string color = DialogueLua.GetVariable(blossom + "Color").asString;
                Sprite portrait;
                if (growth == BlossomData.BlossomGrowth.Adult)
                {
                    portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).AdultPortrait;
                    print("BlossomColors/" + color);
                }
                else
                {
                    portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).BabyPortrait;
                }

                BlossomSelectionUI ui = Instantiate(BlossomUIPrefab, BlossomContainer);

                ui.SelectBtn.enabled = true;

                ui.BlossomNameText.text   = name;
                ui.BlossomPortrait.sprite = portrait;


                switch (pStat)
                {
                case Stat.StatName.Null:
                    Debug.LogError("No Stat Specified for this prop");
                    return;

                case Stat.StatName.Agility:
                    if (agility >= agilityPotential)
                    {
                        ui.SelectBtn.enabled    = false;
                        ui.AgilityAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.AgilityAmtText.color = Color.blue;
                    }
                    break;

                case Stat.StatName.Strength:
                    if (strength >= strengthPotential)
                    {
                        ui.SelectBtn.enabled     = false;
                        ui.StrengthAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.StrengthAmtText.color = Color.blue;
                    }
                    break;

                case Stat.StatName.Charm:
                    if (charm >= charmPotential)
                    {
                        ui.SelectBtn.enabled  = false;
                        ui.CharmAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.CharmAmtText.color = Color.blue;
                    }
                    break;

                case Stat.StatName.Intellect:
                    if (intellect >= intellectPotential)
                    {
                        ui.SelectBtn.enabled  = false;
                        ui.CharmAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.IntellectAmtText.color = Color.blue;
                    }
                    break;
                }

                ui.AgilityAmtText.text   = agility.ToString("F2") + " / " + agilityPotential.ToString("F2");
                ui.StrengthAmtText.text  = strength.ToString("F2") + " / " + strengthPotential.ToString("F2");
                ui.IntellectAmtText.text = intellect.ToString("F2") + " / " + intellectPotential.ToString("F2");
                ui.CharmAmtText.text     = charm.ToString("F2") + " / " + charmPotential.ToString("F2");

                if (pregnant)
                {
                    ui.SelectBtn.enabled = false;

                    ui.PregnantIcon.enabled = true;
                }
                else
                {
                    ui.PregnantIcon.enabled = false;
                }

                if (hungry)
                {
                    ui.SelectBtn.enabled  = false;
                    ui.HungryIcon.enabled = true;
                }
                else
                {
                    ui.HungryIcon.enabled = false;
                }

                if (fatigued)
                {
                    ui.SelectBtn.enabled    = false;
                    ui.FatiguedIcon.enabled = true;
                }
                else
                {
                    ui.FatiguedIcon.enabled = false;
                }

                ui.SelectBtn.onClick.AddListener(
                    delegate()
                {
                    ChosenBlossom = blossom;
                    ShowConfirmationWindow();
                }
                    );
            }

            GetComponent <WindowToggle>().Open();
        }