Пример #1
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            var clnTxt = CleanText;

            if (e.KeyChar == '-' && (!AllowNegative || SelectionStart != 0))
            {
                e.Handled = true;
            }
            lastValue = clnTxt == "-" || clnTxt == "." ||
                        string.IsNullOrWhiteSpace(clnTxt) ? 0 :
                        decimal.Parse(clnTxt);
            // Ignore all non-control and non-numeric key presses
            var hasDecimal = CleanText.Contains(".");

            if (!char.IsControl(e.KeyChar) &&
                !char.IsDigit(e.KeyChar) &&

                (e.KeyChar != '-' || !AllowNegative) &&
                (e.KeyChar != '.' || hasDecimal))
            {
                e.Handled = true;
            }

            //  to Call the implementation in the base TextBox class,
            // which raises the KeyPress event.
            base.OnKeyPress(e);
        }
Пример #2
0
    public void ReadNode(string Key)
    {
        HideChoiceButtons();

        GameManager.GetComponent <StatManager> ().ClearDebugUI();

        Node myNode;

        if (Suivant)
        {
            Suivant = false;
            Key     = Suivant_Node;
        }

        LastNode.GetNext().TryGetValue(Key, out myNode);

        UI_Text_Main.GetComponent <TypewritingScript> ().TypeWrite(myNode.content);
        int local = 0;

        LastNode = myNode;


        string Local_StatName;
        string TempStringDeux;
        int    Local_StatChangeValue;

        string[] TempArray;

        foreach (string LocalTag in myNode.Tags)
        {
            if (LocalTag.Length > 0)
            {
                TempArray      = LocalTag.Split(":" [0]);
                Local_StatName = TempArray [0];

                if (TempArray [1].Contains("="))
                {
                    TempStringDeux = TempArray [1].Replace("=", "");
                }
                else
                {
                    TempStringDeux = TempArray [1];
                }
                //Debug.Log (TempStringDeux);
                Local_StatChangeValue = int.Parse(TempStringDeux);
                StatManager.ins.ModifyStatValue(Local_StatName, Local_StatChangeValue);
            }
            else
            {
                GameManager.GetComponent <StatManager> ().ChangePersoName(0);
                //Debug.Log ("Empty Tags");
            }
        }
        foreach (Node n in myNode.GetNext().Values)
        {
            autoCondition = true;
            string CleanText;
            CleanText = n.choiceText;
            int tempBool = 0;
            if (n.choiceText.Contains("{"))
            {
                autoCondition = false;

                string output;
                output = n.choiceText.Split(new char[] { '{', '}' }) [1];

                string[]    conditions;
                string[]    TempArrayConditions_1;
                string[]    tempCleanText;
                List <bool> ListOfBool = new List <bool> ();
                conditions    = output.Split(";" [0]);
                tempCleanText = n.choiceText.Split("{" [0]);
                CleanText     = tempCleanText [0];

                foreach (string condition in conditions)
                {
                    string varName;
                    string TempString;
                    string signe;
                    string valueString;
                    int    value;
                    TempArrayConditions_1 = condition.Split(":" [0]);
                    varName     = TempArrayConditions_1 [0];
                    TempString  = TempArrayConditions_1 [1];
                    signe       = TempString.Substring(0, 1);
                    valueString = TempString.Substring(1, TempString.Length - 1);
                    value       = int.Parse(valueString);

                    ListOfBool.Add(GameManager.GetComponent <StatManager> ().CompareValue(varName, signe, value));
                    //Debug.Log ("Nom var: " + varName + " Signe: " + signe + " Valeur: " + value);
                }

                foreach (bool l in ListOfBool)
                {
                    if (l == false)
                    {
                        tempBool++;
                        //Debug.Log ("Something is false");
                    }
                }
            }
            if (tempBool != 0)
            {
                autoCondition = false;
            }
            else
            {
                autoCondition = true;
            }

            if (CleanText.Contains("("))
            {
                string[] TempArrayCleaner;
                TempArrayCleaner = CleanText.Split("(" [0]);
                CleanText        = TempArrayCleaner [0];
            }

            if (local == 4 && autoCondition)
            {
                UI_Text_Button5.transform.parent.gameObject.SetActive(true);
                UI_Text_Button5.GetComponent <TextRead> ().ShowText_External(CleanText);
                UI_Button5.GetComponent <ButtonTrigger> ().SetNextChoice(n.choiceText);
                //Debug.Log ("Max Choices Reached");
            }
            if (local == 3 && autoCondition)
            {
                UI_Text_Button4.transform.parent.gameObject.SetActive(true);
                UI_Text_Button4.GetComponent <TextRead> ().ShowText_External(CleanText);
                UI_Button4.GetComponent <ButtonTrigger> ().SetNextChoice(n.choiceText);
                local = 4;
            }
            if (local == 2 && autoCondition)
            {
                UI_Text_Button3.transform.parent.gameObject.SetActive(true);
                UI_Text_Button3.GetComponent <TextRead> ().ShowText_External(CleanText);
                UI_Button3.GetComponent <ButtonTrigger> ().SetNextChoice(n.choiceText);
                local = 3;
            }
            if (local == 1 && autoCondition)
            {
                UI_Text_Button2.transform.parent.gameObject.SetActive(true);
                UI_Text_Button2.GetComponent <TextRead> ().ShowText_External(CleanText);
                UI_Button2.GetComponent <ButtonTrigger> ().SetNextChoice(n.choiceText);
                local = 2;
            }

            if (local == 0 && autoCondition)
            {
                if (n.choiceText.Contains("Suivant") || n.choiceText.Contains("suivant"))
                {
                    Suivant      = true;
                    Suivant_Node = n.choiceText;
                    UI_Text_Button1.GetComponent <TextRead> ().ShowText_External("Suivant");
                }
                else
                {
                    UI_Text_Button1.GetComponent <TextRead> ().ShowText_External(CleanText);
                }
                UI_Text_Button1.transform.parent.gameObject.SetActive(true);
                UI_Button1.GetComponent <ButtonTrigger> ().SetNextChoice(n.choiceText);

                local = 1;
            }
        }
    }