void spawnRabbit()
    {
        int        index       = Random.Range(0, spawnPoints.Length - 1);
        GameObject chosenSpawn = spawnPoints[index];

        Instantiate(prefab, chosenSpawn.transform.position, Quaternion.identity);

        currentQuestion = bank.getRandomQuestion(true);
        if (currentQuestion == null)
        {
            //all answered
        }
        TEXDraw text = questionDisplay.GetComponent <TEXDraw>();

        text.text = currentQuestion.question;



        popAnswers();
        answersSpawned = new GameObject[currentQuestion.answers.Length];

        int size = Screen.height / currentQuestion.answers.Length;

        for (int i = 0; i < currentQuestion.answers.Length; i++)
        {
            GameObject answer = Instantiate(questionPrefab, Vector2.zero, Quaternion.identity);
            answer.transform.SetParent(canvas.transform);
            RectTransform bounds = answer.GetComponent <RectTransform>();
            answer.transform.position                 = new Vector2(Screen.width - bounds.rect.width / 2, Screen.height - (i * size + size / 2));
            answer.GetComponent <TEXDraw>().text      = currentQuestion.answers[i];
            answer.GetComponent <Draggable>().manager = this;
            answersSpawned[i] = answer;
        }
        Debug.Log("answers" + currentQuestion.answers.Length);
    }
Exemple #2
0
 public void Init()
 {
     input      = transform.Find("InputField").GetComponent <InputField>();
     inputPanel = GameObject.Find("/UI/CanvasBack").transform.Find("InputPanel").GetComponent <InputPanel>();
     texdraw    = transform.Find("TEXDraw").GetComponent <TEXDraw>();
     Clear();
 }
Exemple #3
0
    public void getNodeByDiff(int diff)
    {
        Node newNOde = Assets.Scripts.Fonctions.Tree.getRandomNodeOfDepth(diff);

        currentNode      = newNOde;
        TEXDrawComponent = this.GetComponentInChildren <TEXDraw>();
        updateText(currentNode.value);
    }
Exemple #4
0
    private static float GetRotationAngle(TEXDraw tex)
    {
        var mtx = Quaternion.Inverse(tex.transform.rotation);

        if (tex.canvas)
        {
            mtx = tex.canvas.transform.rotation * mtx;
        }
        return(Quaternion.Angle(mtx, Quaternion.identity));
    }
Exemple #5
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        if (GUILayout.Button("Set text in editor from json"))
        {
            UpdateUIString();
        }

                        #if TEXDrawPlugin
        if (GUILayout.Button("Convert text to TEXDraw, can't undo !!"))
        {
            LangManager.Instance.ForAllLang(
                ( Lang pLang ) => {
                Text lText = pLang.GetComponent <Text>();
                if (lText != null)
                {
                    string lTxtContent   = lText.text;
                    int lFontSize        = lText.fontSize;
                    Color lColor         = lText.color;
                    bool lRayCast        = lText.raycastTarget;
                    TextAnchor lAlign    = lText.alignment;
                    Vector2 lVectorAlign = Text.GetTextAnchorPivot(lAlign);

                    GameObject lGameObject = pLang.GetComponent <Component>().gameObject;

                    DestroyImmediate(lText);

                    lGameObject.AddComponent <TEXDraw>();
                    TEXDraw lTexDraw = pLang.GetComponent <TEXDraw>();

                    lTexDraw.text          = lTxtContent;
                    lTexDraw.size          = lFontSize;
                    lTexDraw.color         = lColor;
                    lTexDraw.alignment     = lVectorAlign;
                    lTexDraw.autoFit       = TexDrawLib.Fitting.Off;
                    lTexDraw.autoWrap      = TexDrawLib.Wrapping.WordWrap;
                    lTexDraw.raycastTarget = lRayCast;

                    /*Debug.Log( pLang.name + " font size : " + lFontSize + " color : ( "+ lColor.r+","+ lColor.g +","+ lColor.b +","+ lColor.a +")" );
                     * Debug.Log( lTxtContent );*/
                    //Debug.Log( lAlign );
                    //Debug.Log( lVectorAlign );
                }
                else
                {
                    //TEXDraw lTexDraw = pLang.GetComponent<TEXDraw>();

                    //Debug.Log( lTexDraw.alignment );
                }
            }
                );
            UpdateUIString();
        }
                        #endif
    }
Exemple #6
0
    void Start()
    {
        chara = GameObject.FindGameObjectWithTag("Player").GetComponent <Character>();
        if (function != "")
        {
            currentNode = Assets.Scripts.Fonctions.Tree.getNodeFromString(function.Split(','));
        }
        enemy_animator  = GetComponent <Animator>();
        player_animator = chara.GetComponent <Animator>();
        doAttack        = false;

        TEXDrawComponent = this.GetComponentInChildren <TEXDraw>();
        updateText(currentNode.value);
    }
    void GUIDrawNode(TEXDraw tex)
    {
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.Space();
        var rBox = EditorGUILayout.BeginVertical();

        GUI.Box(rBox, GUIContent.none);
        EditorGUILayout.BeginHorizontal();
        {
            var r = EditorGUILayout.GetControlRect(GUILayout.Width(20f));
            if (GUI.Button(r, "+"))
            {
                OnAddInside = false;
                EditorUtility.DisplayCustomMenu(r, insertContext, -1, new EditorUtility.SelectMenuItemFunction(OnAddPopup), tex.gameObject);
            }
            if (GUI.Button(EditorGUILayout.GetControlRect(GUILayout.Width(20f)), "-"))
            {
                Undo.DestroyObjectImmediate(tex.gameObject);
            }
            if (GUI.Button(EditorGUILayout.GetControlRect(GUILayout.Width(30f)), "<>"))
            {
                Selection.activeGameObject = tex.gameObject;
            }
            tex.autoFit = (Fitting)EditorGUILayout.EnumPopup(tex.autoFit, GUILayout.ExpandWidth(true));
        }
        EditorGUILayout.EndHorizontal();
        if (!tex)
        {
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndVertical();
            EditorGUI.EndChangeCheck();
            return;
        }
        tex.text = TEXBoxHighlighting.DrawText(tex.text, 10, GUILayout.Width(90f), GUILayout.ExpandWidth(true));
        {
            if (tex.autoFit != Fitting.RectSize)
            {
                GUIHandleFitter(tex.gameObject);
            }
        }
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndVertical();
        if (EditorGUI.EndChangeCheck() && tex)
        {
            EditorUtility.SetDirty(tex);
        }
    }
        void SetMode(TEXInputChildMode modeNow)
        {
            if (modeNow == mode)
            {
                return;
            }
            if (child_0)
            {
                DestroyImmediate(child_0);
            }
            if (child_1)
            {
                DestroyImmediate(child_1);
            }
            if (child_2)
            {
                DestroyImmediate(child_2);
            }
            if (child_3)
            {
                DestroyImmediate(child_3);
            }
            switch (modeNow)
            {
            case TEXInputChildMode.Character:
                child_0 = gameObject.AddComponent <TEXDraw>();
                break;

            case TEXInputChildMode.BlockChar:
                child_1 = gameObject.AddComponent <Image>();
                break;

            case TEXInputChildMode.HorizontalBox:
                child_2 = gameObject.AddComponent <HorizontalLayoutGroup>();
                break;

            case TEXInputChildMode.VerticalBox:
                child_3 = gameObject.AddComponent <VerticalLayoutGroup>();
                break;
            }
        }
Exemple #9
0
    public void Init()
    {
        rectTransform = GetComponent <RectTransform>();

        btnToggleObject = transform.Find("ButtonToggle").gameObject;
        btnDeleteObject = transform.Find("ButtonDelete").gameObject;

        //btnToggle = btnToggleObject.GetComponent<DoubleClickButton>();
        btnToggle = btnToggleObject.GetComponent <Button>();
        btnDelete = btnDeleteObject.GetComponent <Button>();

        btnToggle.onClick.AddListener(ToggleButtonDoubleClicked);
        btnDelete.onClick.AddListener(DeleteButtonClicked);
        if (transform.Find("Text").GetComponent <TEXDraw>() != null)
        {
            text1 = transform.Find("Text").GetComponent <TEXDraw>();
        }
        else
        {
            text = transform.Find("Text").GetComponent <Text>();
        }
    }
Exemple #10
0
    public void UpdateUiString(bool pInPlayMode = true, string pLang = "", bool pUseEmptyString = false)
    {
        if ((textId != null) && (textId.Length > 0) || (pUseEmptyString))
        {
            if ((pLang == null) || (pLang.Length == 0))
            {
                pLang = LangManager.Instance.GetCurrentLanguage(user);
            }

            if (forceLang.Length > 0)
            {
                pLang = forceLang;
            }
            string lNewText = Get(textId, pLang);

            string lFontSizeString = Get(textId, "fontSize");
            string lFontFamily     = Get(textId, "fontFamily");
                        #if TEXDrawPlugin
            string lFontFamilyBold   = Get(textId, "fontFamilyBold");
            string lFontFamilyItalic = Get(textId, "fontFamilyItalic");
                        #endif

            int lFontSize = 0;
            if (lFontSizeString.Length > 0)
            {
                lFontSize = int.Parse(lFontSizeString);
            }

            if (forceCapitilize)
            {
                lNewText = lNewText.ToUpper();
            }


            Text lText = GetComponent <Text>();
            if (lText != null)
            {
                if (lText.text != lNewText)
                {
                    lText.text = lNewText;
                }
                if ((lFontSize > 0) && (lFontSize != lText.fontSize))
                {
                    lText.fontSize = lFontSize;
                }

                if (lFontFamily.Length > 0)
                {
                    Font lFont = LangManager.Instance.GetFontByShortName(lFontFamily);
                    if ((lFont != null) && (lText.font != lFont))
                    {
                        lText.font = lFont;
                    }
                }                // Have a font
            }
            else
            {
                                #if TEXDrawPlugin
                TEXDraw lTexDraw = GetComponent <TEXDraw>();
                if (lTexDraw != null)
                {
                    lNewText = GetPluginTxt(lNewText, lFontFamily, lFontFamilyBold, lFontFamilyItalic);
                    if (lTexDraw.text != lNewText)
                    {
                        lTexDraw.text = lNewText;
                    }
                    if ((lFontSize > 0) && (lFontSize != lTexDraw.size))
                    {
                        lTexDraw.size = lFontSize;
                    }
                }                // support texDraw plugin
                                #endif
            }

            //\gothambold{petit}

                        #if UNITY_EDITOR
            if (!pInPlayMode)
            {
                EditorUtility.SetDirty(this);
            }
                        #endif
        }
    }