Example #1
0
 public static void LogWarning(LocalizedString message, Object context, bool showPlayer)
 {
     if (Debug.isDebugBuild || showPlayer)
     {
     Debug.LogWarning(message, context);
     }
 }
 public LocalizedString(LocalizedString[] components)
 {
     foreach (LocalizedString lString in components)
     {
         _Text += lString.Text;
     }
 }
Example #3
0
 public static void LogWarning(LocalizedString message, bool showPlayer)
 {
     if (Debug.isDebugBuild || showPlayer)
     {
     Debug.LogWarning(message);
     DebugConsole.LogWarning(message);
     }
 }
        public static ClickableText AddResponse(LocalizedString text, System.Type type)
        {
            if (!typeof(ClickableText).IsAssignableFrom(type))
            {
                return null;
            }
            if (messageBox != null && !messageBox.activeSelf)
            {
                messageBox.SetActive(true);
            }
            ClickableText output = null;
            if (responses != null)
            {
                foreach (ClickableText cText in responses)
                {
                    MonoBehaviour.Destroy(cText.gameObject);
                }
            }
            if (defaultResponses)
            {
                ClearResponses();
            }
            responseStrings.Add(text);
            responses = new ClickableText[responseStrings.Count];
            // Determine the number of columns
            int responseCount = responses.Length;
            int responseColumns = 1; // Start at 1
            if (responseCount % 2 == 0) // If it's divisible by 2, we should have either 2 or 4 columns.
            {
                if (responseCount <= 4)
                {
                    responseColumns = 2;
                }
                else
                {
                    responseColumns = 4;
                }
            }
            else if (responseCount % 3 == 0) // If it's divisible by 3, we should have 3 columns.
            {
                responseColumns = 3;
            }

            // Figure out how many responses will be in each column
            int responsesPerColumn = Mathf.CeilToInt(responseCount / responseColumns);

            DisplayText lastText = messagePrompt;

            // Determine box X positions
            float[] responseXs = new float[responseColumns];
            float boxWidth = GetBackgroundWidth();
            float minXPos = boxWidth / -2.0f;
            float responseMaxWidth = boxWidth / responseColumns;
            for (int i = 0; i < responseColumns; i++)
            {
                float responseX = minXPos;
                responseX += (responseMaxWidth * i) + (responseMaxWidth / 2.0f);
                responseXs[i] = responseX;
            }
            responseMaxWidth -= GlobalConsts.RESPONSE_SPACING;

            // Determine box Y positions
            float[] responseYs = new float[responsesPerColumn];
            float boxHeight = GetBackgroundHeight();
            float minYPos = boxHeight / -2.0f;
            float responseMaxHeight = boxHeight / responsesPerColumn;
            for (int i = 0; i < responsesPerColumn; i++)
            {
                float responseY = minYPos;
                responseY += (responseMaxHeight * i) + (responseMaxHeight / 2.0f);
                responseYs[i] = responseY;
            }
            responseMaxHeight -= GlobalConsts.RESPONSE_SPACING;

            int count = 0;
            for (int x = 0; x < responseColumns; x++)
            {
                Vector3 position = new Vector3(responseXs[x], 0.0f, -0.1f);
                bool allResponsesDone = false;
                for (int y = 0; y < responsesPerColumn; y++)
                {
                    if (count >= responses.Length)
                    {
                        allResponsesDone = true;
                        break;
                    }
                    position.y = responseYs[y];
                    // Load GameObject
                    GameObject responseGO = MonoHelper.Load(lastText.transform.parent, position, "Prefabs/Response Text") as GameObject;
                    ClickableText response = responseGO.GetComponentInChildren(type) as ClickableText;
                    // Set maximum bounds
                    response.SetMaxWidth(responseMaxWidth);
                    response.SetMaxHeight(responseMaxHeight);
                    output = response;

                    // Set visuals
                    response.SetTextString(responseStrings[count]);
                    response.SetDisplayParent(messageBox);

                    // Make the instantiated object clickable if it isn't already
                    if (responseGO.GetComponent<BoxCollider2D>() == null)
                    {
                        responseGO.AddComponent<BoxCollider2D>();
                    }
                    // Reset lastText to the most recent text.
                    lastText = response.GetDisplayText();
                    responses[count] = response;
                    // Keep it alive on scene change
                    Globals.DontDestroy(responseGO);
                    count++;
                }
                if (allResponsesDone)
                {
                    break;
                }
            }
            if (text.ID != "OK")
            {
                defaultResponses = false;
            }
            return output;
        }
 public static ClickableText AddResponse(LocalizedString text)
 {
     return AddResponse(text, typeof(ClickableText));
 }
 public static void ChangeBoxPrompt(LocalizedString newPrompt, bool open)
 {
     boxPrompt = newPrompt;
     CheckPrompt();
     messagePrompt.SetTextString(boxPrompt);
     if (responses == null)
     {
         AddResponse(new LocalizedString(GlobalConsts.ID_OKAY, "Okay"));
     }
     InitLua();
     DisplayBox(open);
 }
 public static void ChangeBoxPrompt(LocalizedString newPrompt)
 {
     ChangeBoxPrompt(newPrompt, false);
 }
Example #8
0
 public static void LogError(LocalizedString message, Object context)
 {
     Debug.LogError(message, context);
     DebugConsole.IsOpen = true;
 }
Example #9
0
 public static void LogError(LocalizedString message)
 {
     Debug.LogError(message);
     DebugConsole.LogError(message);
     DebugConsole.IsOpen = true;
 }