Example #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);
        }
Example #2
0
        private void HandleTextChanged()
        {
            lines.Clear();
            if (Mode == LabelRenderMode.ManualSizing)
            {
                lines.Add(CleanText.ToList());
            }
            else if (Mode == LabelRenderMode.SingleLineAutoSize)
            {
                Height = 1;

                if (MaxWidth.HasValue)
                {
                    Width = Math.Min(MaxWidth.Value, CleanText.Length);
                }
                else
                {
                    Width = CleanText.Length;
                }

                lines.Add(CleanText.ToList());
            }
            else
            {
                DoSmartWrap();
            }
        }
Example #3
0
        public void i_get_the_help_text()
        {
            using (var gameObjects = new GameObjects())
            {
                //prepare
                var expectedMessage = "You feel your sanity returning to you. You quickly " +
                                      "find your way out of the cave and get back to your life as a farmer.";

                var commandOutput = Command.Get(gameObjects, "quit");

                //assert
                Assert.Equal(expectedMessage, CleanText.Run(commandOutput.Output));
            }
        }
Example #4
0
        public void i_get_the_help_text()
        {
            using (var gameObjects = new GameObjects())
            {
                //prepare
                var expectedMessage = "Commands: search, status, pickup <item>, drop <item>, help, quit";

                //execute
                var commandOutput = Command.Get(gameObjects, "help");

                //assert
                Assert.Equal(expectedMessage, CleanText.Run(commandOutput.Output));
            }
        }
Example #5
0
        public void i_get_the_location_weapon_and_inventory_items()
        {
            using (var gameObjects = new GameObjects())
            {
                //prepare
                var expectedMessage = "You are in the EntranceThis is the entrance of the cave." +
                                      "You entered from the door to the south. There is an entrance to the north" +
                                      "You have no weapon equippedYou have nothing in your inventory";

                //execute
                var commandOutput = Command.Get(gameObjects, "status");

                //assert
                Assert.Equal(expectedMessage, CleanText.Run(commandOutput.Output));
            }
        }
Example #6
0
        public void i_get_the_items_back()
        {
            using (var gameObjects = new GameObjects())
            {
                //prepare
                var expectedMessage = "After searching the room you find:potion, rusty sword";

                gameObjects.Player.GetCurrentRoom().RemoveAllItems();
                gameObjects.Player.GetCurrentRoom().AddItem(new Potion());
                gameObjects.Player.GetCurrentRoom().AddItem(new RustySword());

                //execute
                var commandOutput = Command.Get(gameObjects, "search");

                //assert
                Assert.Equal(expectedMessage, CleanText.Run(commandOutput.Output));
            }
        }
Example #7
0
        public void i_get_the_location_weapon_and_inventory_items()
        {
            using (var gameObjects = new GameObjects())
            {
                //prepare
                var expectedMessage = "You are in the EntranceThis is the entrance of the cave." +
                                      "You entered from the door to the south. There is an entrance to the north" +
                                      "You have a rusty sword equippedYou carry in your inventory:potion";

                gameObjects.Player.EquipWeapon <RustySword>();
                gameObjects.Player.PickupItem <Potion>();

                //execute
                var commandOutput = Command.Get(gameObjects, "status");

                //assert
                Assert.Equal(expectedMessage, CleanText.Run(commandOutput.Output));
            }
        }
Example #8
0
        private void HandleTextChanged()
        {
            lines.Clear();
            if (Mode == LabelRenderMode.ManualSizing)
            {
                lines.Add(new List <ConsoleCharacter>());
                foreach (var c in CleanText)
                {
                    if (c.Value == '\n')
                    {
                        lines.Add(new List <ConsoleCharacter>());
                    }
                    else
                    {
                        lines.Last().Add(c);
                    }
                }
            }
            else if (Mode == LabelRenderMode.SingleLineAutoSize)
            {
                Height = 1;

                if (MaxWidth.HasValue)
                {
                    Width = Math.Min(MaxWidth.Value, CleanText.Length);
                }
                else
                {
                    Width = CleanText.Length;
                }

                lines.Add(CleanText.ToList());
            }
            else
            {
                DoSmartWrap();
            }
        }
Example #9
0
 public bool HasText(string text)
 {
     return(CleanText.ToLower().Contains(text.ToLower()));
 }
Example #10
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;
            }
        }
    }