Beispiel #1
0
        void Update()
        {
            // Don't do anything if no Stat name is defined
            if (string.IsNullOrEmpty(name_of_stat_to_retrieve))
            {
                return;
            }


            string stat = "";

            // Retrieve the correct stat
            switch (type_of_stat_to_retrieve)
            {
            case Type_of_Stat.Numbered_Stat:
                // Check if we should display nothing if the stat does not exist
                if (display_nothing_if_stat_not_present && !StatsManager.Numbered_Stat_Exists(name_of_stat_to_retrieve))
                {
                    text_element.text = "";
                    return;
                }

                stat = "" + StatsManager.Get_Numbered_Stat(name_of_stat_to_retrieve);
                break;

            case Type_of_Stat.String_Stat:
                if (display_nothing_if_stat_not_present && !StatsManager.String_Stat_Exists(name_of_stat_to_retrieve))
                {
                    text_element.text = "";
                    return;
                }

                stat = StatsManager.Get_String_Stat(name_of_stat_to_retrieve);
                break;

            case Type_of_Stat.Boolean_Stat:
                if (display_nothing_if_stat_not_present && !StatsManager.Boolean_Stat_Exists(name_of_stat_to_retrieve))
                {
                    text_element.text = "";
                    return;
                }

                stat = "" + StatsManager.Get_Boolean_Stat(name_of_stat_to_retrieve);
                break;
            }

            // Construct the actual string
            text_element.text = message_before_stat + stat + message_after_stat;
        }
        public override void Run_Node()
        {
            sceneName      = String.Empty;
            activityNumber = StatsManager.Get_Numbered_Stat("intActivity");
            activityName   = StatsManager.Get_String_Stat("strActivity");
            //EX: conversation_to_start = GameObject.Find("ArtActivityManager").GetComponent<ConversationManager>();

            switch (activityName)
            {
            case "study":
                sceneName += "s_";
                break;

            case "workout":
                sceneName      += "w_";
                activityNumber += 600;
                break;

            case "art":
                sceneName      += "a_";
                activityNumber += 1200;
                break;

            case "talk":
                sceneName      += "t_";
                activityNumber += 1800;
                break;

            case "play":
                sceneName      += "p_";
                activityNumber += 2400;
                break;
            }

            IsNewScene();
            seenScenes.Add(activityNumber);

            //sceneName += activityNumber;
            sceneName += 1;

            conversation_to_start = GameObject.Find(sceneName).GetComponent <ConversationManager>();

            StartCoroutine(Check_If_Actors_Have_Exited());

            Finish_Node();
        }
Beispiel #3
0
        public string Insert_Stats_into_Text(string in_text)
        {
            // Find any [ ] characters
            string[] splits = in_text.Split('[', ']');

            // Now check each split if it's legitimate
            foreach (string original_s in splits)
            {
                bool   is_variable = false;
                string new_s       = "";
                string modified_s;
                if (original_s.StartsWith("b:"))
                {
                    is_variable = true;
                    modified_s  = original_s.Replace("b:", "");
                    new_s       = StatsManager.Get_Boolean_Stat(modified_s).ToString();
                }
                else if (original_s.StartsWith("f:"))
                {
                    is_variable = true;
                    modified_s  = original_s.Replace("f:", "");
                    new_s       = StatsManager.Get_Numbered_Stat(modified_s) + "";
                }
                else if (original_s.StartsWith("s:"))
                {
                    is_variable = true;
                    modified_s  = original_s.Replace("s:", "");
                    new_s       = StatsManager.Get_String_Stat(modified_s);
                }

                if (is_variable)
                {
                    in_text = in_text.Replace("[" + original_s + "]", new_s);
                }
            }

            return(in_text);
        }
        public override void Run_Node()
        {
            if (string.IsNullOrEmpty(Stat_To_Save_To))
            {
                Debug.LogError("Stat_To_Save_To is empty. Please specify the name of a Stat to save to for this GenerateRandomNumberNode", this.gameObject);
                Finish_Node();
                return;
            }

            float value_from_stat = 0;
            float randomly_generated_num;

            if (use_whole_numbers)
            {
                randomly_generated_num = (float)Random.Range((int)minimum_random_number, (int)maximum_random_number + 1);
            }
            else
            {
                randomly_generated_num = Random.Range(minimum_random_number, maximum_random_number);
            }

            if (!string.IsNullOrEmpty(Stat_To_Add_To_Random_Number))
            {
                value_from_stat = StatsManager.Get_Numbered_Stat(Stat_To_Add_To_Random_Number);
            }

            float result = randomly_generated_num + value_from_stat;

            StatsManager.Set_Numbered_Stat(Stat_To_Save_To, result);

            if (print_result_to_console)
            {
                Debug.Log("Rolled " + randomly_generated_num + ", added to value from Stat " + value_from_stat + " gives total: " + result + " saved in " + Stat_To_Save_To, this.gameObject);
            }

            Finish_Node();
        }
Beispiel #5
0
        // Checks if the given stat is > or < the value. Returns true/false.
        // If no stat of that name is found, 0 is given as the stat's value
        public static bool Compare_Float_Stat(string stat_name, Float_Stat_Comparator than, float value)
        {
            // Check if the stat exists
            if (!StatsManager.Numbered_Stat_Exists(stat_name))
            {
                Debug.Log(stat_name + " Numbered Stat does not exist. Returning default value for stat: 0");
            }

            bool result = false;
            // Check if it meets the requirements
            float stat = StatsManager.Get_Numbered_Stat(stat_name);

            switch (than)
            {
            case Float_Stat_Comparator.Greater_than:
                result = stat > value;
                break;

            case Float_Stat_Comparator.Less_than:
                result = stat < value;
                break;
            }
            return(result);
        }