Ejemplo n.º 1
0
 protected override void Update()
 {
     base.Update();
     this.m_SelectedNode = -1;
     if (this.m_NodesVisible)
     {
         for (int i = 0; i < this.m_UINodeDatas.Count; i++)
         {
             UISelectDialogNodeData uiselectDialogNodeData = this.m_UINodeDatas[i];
             if (RectTransformUtility.RectangleContainsScreenPoint(uiselectDialogNodeData.m_BG.rectTransform, Input.mousePosition))
             {
                 this.m_SelectedNode = i;
                 break;
             }
         }
         for (int j = 0; j < this.m_UINodeDatas.Count; j++)
         {
             this.m_UINodeDatas[j].m_BG.enabled = (j == this.m_SelectedNode);
         }
         if (!InputsManager.Get().IsActionActive(InputsManager.InputAction.ShowSelectDialogNode))
         {
             this.OnSelect(this.m_SelectedNode);
         }
     }
     CursorManager.Get().SetCursor((this.m_SelectedNode < 0) ? CursorManager.TYPE.Normal : CursorManager.TYPE.MouseOver);
     if (this.m_TimerBelt && this.m_TimerBelt.gameObject.activeSelf)
     {
         float   b          = Time.time - this.m_ShowTime;
         Vector3 localScale = this.m_TimerBelt.rectTransform.localScale;
         localScale.x = CJTools.Math.GetProportionalClamp(1f, 0f, b, 0f, this.m_Duration);
         this.m_TimerBelt.rectTransform.localScale = localScale;
     }
     if (this.m_Reply.gameObject.activeSelf)
     {
         if (this.m_ReplyCanvasGroup.alpha < 1f)
         {
             this.m_ReplyCanvasGroup.alpha += Time.deltaTime * 3f;
         }
         this.m_ReplyCanvasGroup.alpha = Mathf.Min(this.m_ReplyCanvasGroup.alpha, 1f);
         float num = Mathf.Sin(Time.time);
         if (num > 0f)
         {
             if (!this.m_WasSound)
             {
                 Player.Get().m_AudioModule.PlayDialogSound(1f, false);
                 this.m_WasSound = true;
             }
             Quaternion identity = Quaternion.identity;
             identity.z = Mathf.Sin(Time.time * 100f) * num * 0.1f;
             this.m_Icon.rectTransform.localRotation = identity;
         }
         else
         {
             this.m_Icon.rectTransform.localRotation = Quaternion.identity;
             this.m_WasSound = false;
         }
     }
 }
Ejemplo n.º 2
0
    private void AddNode(DialogNode node, int index)
    {
        UISelectDialogNodeData uiselectDialogNodeData = new UISelectDialogNodeData();

        uiselectDialogNodeData.m_Object = UnityEngine.Object.Instantiate <GameObject>(this.m_NodePrefab, base.transform);
        Text   component = uiselectDialogNodeData.m_Object.transform.Find("Text").gameObject.GetComponent <Text>();
        string text      = node.m_Name + "_Short";

        if (GreenHellGame.Instance.GetLocalization().Contains(text))
        {
            component.text = GreenHellGame.Instance.GetLocalization().Get(text, true);
        }
        else
        {
            component.text = GreenHellGame.Instance.GetLocalization().Get(node.m_Name, true);
        }
        component.fontSize = ((GreenHellGame.Instance.m_Settings.m_Subtitles == SubtitlesSetting.Large) ? HUDDialog.FONT_SIZE_LARGE : HUDDialog.FONT_SIZE);
        if (node.m_Locked)
        {
            Color grey = Color.grey;
            grey.r          = 0.65f;
            grey.g          = 0.65f;
            grey.b          = 0.65f;
            component.color = grey;
        }
        TextGenerationSettings generationSettings = component.GetGenerationSettings(component.rectTransform.rect.size);

        generationSettings.scaleFactor = 1f;
        float preferredWidth  = this.m_TextGen.GetPreferredWidth(component.text, generationSettings);
        float preferredHeight = this.m_TextGen.GetPreferredHeight(component.text, generationSettings);

        uiselectDialogNodeData.m_BG         = uiselectDialogNodeData.m_Object.FindChild("BG").GetComponent <RawImage>();
        uiselectDialogNodeData.m_BG.enabled = false;
        this.m_MaxBGWidth = Mathf.Max(preferredWidth, this.m_MaxBGWidth);
        uiselectDialogNodeData.m_Object.GetComponent <Button>().onClick.AddListener(delegate
        {
            this.OnSelect(index);
        });
        Vector3 position = uiselectDialogNodeData.m_Object.transform.position;

        position.x = 0f;
        position.y = this.m_PosY;
        position.z = 0f;
        uiselectDialogNodeData.m_Object.transform.localPosition = position;
        this.m_PosY -= preferredHeight + this.m_Margin;
        uiselectDialogNodeData.m_Object.transform.localScale = Vector3.one;
        uiselectDialogNodeData.m_PadIcon = uiselectDialogNodeData.m_Object.FindChild("PadIcon").GetComponent <Image>();
        uiselectDialogNodeData.m_Node    = node;
        uiselectDialogNodeData.m_Object.SetActive(this.m_NodesVisible);
        this.m_UINodeDatas.Add(uiselectDialogNodeData);
    }
Ejemplo n.º 3
0
    private void AddNode(string text, int index)
    {
        UISelectDialogNodeData uiselectDialogNodeData = new UISelectDialogNodeData();

        uiselectDialogNodeData.m_Object = UnityEngine.Object.Instantiate <GameObject>(this.m_NodePrefab, base.transform);
        Text   component = uiselectDialogNodeData.m_Object.transform.Find("Text").gameObject.GetComponent <Text>();
        string text2     = text + "_Short";

        if (GreenHellGame.Instance.GetLocalization().Contains(text2))
        {
            component.text = GreenHellGame.Instance.GetLocalization().Get(text2);
        }
        else
        {
            component.text = GreenHellGame.Instance.GetLocalization().Get(text);
        }
        TextGenerationSettings generationSettings = component.GetGenerationSettings(component.rectTransform.rect.size);

        generationSettings.scaleFactor = 1f;
        float preferredWidth  = this.m_TextGen.GetPreferredWidth(component.text, generationSettings);
        float preferredHeight = this.m_TextGen.GetPreferredHeight(component.text, generationSettings);

        uiselectDialogNodeData.m_BG = uiselectDialogNodeData.m_Object.FindChild("BG").GetComponent <RawImage>();
        this.m_MaxBGWidth           = Mathf.Max(preferredWidth, this.m_MaxBGWidth);
        Button component2 = uiselectDialogNodeData.m_Object.GetComponent <Button>();

        component2.onClick.AddListener(delegate
        {
            this.OnSelect(index);
        });
        Vector3 position = uiselectDialogNodeData.m_Object.transform.position;

        position.x = 0f;
        position.y = this.m_PosY;
        position.z = 0f;
        uiselectDialogNodeData.m_Object.transform.localPosition = position;
        this.m_PosY -= preferredHeight + this.m_Margin;
        uiselectDialogNodeData.m_Object.transform.localScale = Vector3.one;
        uiselectDialogNodeData.m_Object.SetActive(this.m_NodesVisible);
        this.m_UINodeDatas.Add(uiselectDialogNodeData);
    }
Ejemplo n.º 4
0
    protected override void Update()
    {
        base.Update();
        this.m_SelectedNode = -1;
        if (this.m_NodesVisible)
        {
            for (int i = 0; i < this.m_UINodeDatas.Count; i++)
            {
                UISelectDialogNodeData uiselectDialogNodeData = this.m_UINodeDatas[i];
                if (GreenHellGame.IsPCControllerActive())
                {
                    if (!uiselectDialogNodeData.m_Node.m_Locked && RectTransformUtility.RectangleContainsScreenPoint(uiselectDialogNodeData.m_BG.rectTransform, Input.mousePosition))
                    {
                        this.m_SelectedNode = i;
                        break;
                    }
                }
                else
                {
                    this.m_SelectedNode = this.m_PadNodeIndex;
                }
            }
            for (int j = 0; j < this.m_UINodeDatas.Count; j++)
            {
                this.m_UINodeDatas[j].m_BG.enabled = (j == this.m_SelectedNode);
                this.m_UINodeDatas[j].m_PadIcon.gameObject.SetActive(GreenHellGame.IsPadControllerActive() && j == this.m_SelectedNode);
            }
            if (GreenHellGame.IsPCControllerActive())
            {
                if (!InputsManager.Get().IsActionActive(InputsManager.InputAction.ShowSelectDialogNode))
                {
                    this.OnSelect(this.m_SelectedNode);
                }
            }
            else if (Input.GetKeyDown(InputHelpers.PadButton.Button_X.KeyFromPad()))
            {
                this.OnSelect(this.m_SelectedNode);
            }
            else if (Input.GetKeyDown(InputHelpers.PadButton.Button_B.KeyFromPad()))
            {
                this.OnSelect(-1);
            }
        }
        CursorManager.Get().SetCursor((this.m_SelectedNode >= 0) ? CursorManager.TYPE.MouseOver : CursorManager.TYPE.Normal);
        if (this.m_TimerBelt[GreenHellGame.IsPCControllerActive() ? 0 : 1] && this.m_TimerBelt[GreenHellGame.IsPCControllerActive() ? 0 : 1].gameObject.activeSelf)
        {
            float   b          = Time.time - this.m_ShowTime;
            Vector3 localScale = this.m_TimerBelt[GreenHellGame.IsPCControllerActive() ? 0 : 1].rectTransform.localScale;
            localScale.x = CJTools.Math.GetProportionalClamp(1f, 0f, b, 0f, this.m_Duration);
            this.m_TimerBelt[GreenHellGame.IsPCControllerActive() ? 0 : 1].rectTransform.localScale = localScale;
        }
        GameObject  gameObject  = GreenHellGame.IsPCControllerActive() ? this.m_Reply : this.m_ReplyPad;
        CanvasGroup canvasGroup = GreenHellGame.IsPCControllerActive() ? this.m_ReplyCanvasGroup : this.m_ReplyPadCanvasGroup;

        if (gameObject.gameObject.activeSelf)
        {
            if (canvasGroup.alpha < 1f)
            {
                canvasGroup.alpha += Time.deltaTime * 3f;
            }
            canvasGroup.alpha = Mathf.Min(canvasGroup.alpha, 1f);
            float num = Mathf.Sin(Time.time);
            if (num > 0f)
            {
                if (!this.m_WasSound)
                {
                    Player.Get().m_AudioModule.PlayDialogSound(1f, false);
                    this.m_WasSound = true;
                }
                Quaternion identity = Quaternion.identity;
                identity.z = Mathf.Sin(Time.time * 100f) * num * 0.1f;
                this.m_Icon.rectTransform.localRotation = identity;
                return;
            }
            this.m_Icon.rectTransform.localRotation = Quaternion.identity;
            this.m_WasSound = false;
        }
    }