void OnGUI()
    {
        if (!_showing)
        {
            return;
        }
        if (!_windowShowing)
        {
            return;
        }

        GUI.depth = 10;

        Rect dialogueBoxRect = new Rect((Screen.width * 0.5f) - (WIDTH * 0.5f), Screen.height - HEIGHT - 100, WIDTH, HEIGHT);

        Rect dialogueBackBoxRect = new Rect(dialogueBoxRect.x, dialogueBoxRect.y, dialogueBoxRect.width, dialogueBoxRect.height - (45 * _choices.Length));

        GUI.Box(dialogueBackBoxRect, string.Empty);
        GUI.Label(new Rect(dialogueBackBoxRect.x + 10, dialogueBackBoxRect.y + 10, dialogueBackBoxRect.width - 20, dialogueBackBoxRect.height - 20), _windowText);

        if (_selectionClicked)
        {
            return;
        }

        for (int i = 0; i < _choices.Length; i += 1)
        {
            Rect buttonRect = new Rect(dialogueBoxRect.x, dialogueBoxRect.yMax - (45 * (_choices.Length - i)) + 5, dialogueBoxRect.width, 40);
            if (GUI.Button(buttonRect, _choices[i]))
            {
                _selectionClicked = true;
                Dialoguer.ContinueDialogue(i);
            }
        }
    }
 void onClick(GameObject button)
 {
     if (button == choice1)
     {
         Debug.Log("Choice1");
         Dialoguer.ContinueDialogue(0);
     }
     if (button == choice2)
     {
         Debug.Log("Choice2");
         Dialoguer.ContinueDialogue(1);
     }
     if (button == choice3)
     {
         Debug.Log("Choice3");
         Dialoguer.ContinueDialogue(2);
     }
     if (button == choice4)
     {
         Debug.Log("Choice4");
         Dialoguer.ContinueDialogue(3);
     }
     if (button == choice5)
     {
         Debug.Log("Choice5");
         Dialoguer.ContinueDialogue(4);
     }
     if (button == choice6)
     {
         Debug.Log("Choice6");
         Dialoguer.ContinueDialogue(5);
     }
 }
Beispiel #3
0
 void ContinueDialogue(int option)
 {
     if (isTextNode)
     {
         OnTextPhaseEnd();
     }
     Dialoguer.ContinueDialogue(option);
 }
Beispiel #4
0
 void ContinueDialogue()
 {
     if (isTextNode)
     {
         OnTextPhaseEnd();
     }
     Dialoguer.ContinueDialogue();
 }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        Dialoguer.events.onStarted   += onStarted;
        Dialoguer.events.onEnded     += onEnded;
        Dialoguer.events.onTextPhase += onTextPhase;

        continueButton.GetComponent <Button>().onClick.AddListener(() => Dialoguer.ContinueDialogue());
        choiceOne.GetComponent <Button>().onClick.AddListener(() => Dialoguer.ContinueDialogue(0));
        choiceTwo.GetComponent <Button>().onClick.AddListener(() => Dialoguer.ContinueDialogue(1));
    }
 // Update is called once per frame
 void Update()
 {
     if (_showWindow)
     {
         if (Input.GetMouseButtonDown(0))
         {
             if (_choices != null)
             {
                 audioSelect.Play();
             }
             Dialoguer.ContinueDialogue(_currentChoice);
         }
     }
 }
    void Start()
    {
        Dialoguer.Initialize();

//		DialoguerEvents
        Dialoguer.events.ClearAll();
        //observe text init
        gCon          = GameController.instance;
        obsTextPrefab = gCon.gameSettings.observeText;
        obsTextObj    = Instantiate(obsTextPrefab, Vector3.zero, Quaternion.identity) as GameObject;
        obsTextObj.transform.SetParent(gCon.dialogueHolder.transform);
        obsTextObj.GetComponent <RectTransform> ().localPosition = obsTextPrefab.transform.position;
        obsTextObj.GetComponent <RectTransform> ().localScale    = Vector3.one;
        obsTextC = obsTextObj.GetComponentInChildren <Text> ();

        obsTextObj.SetActive(false);


        //continue button init
        continueButtonPrefab = gCon.gameSettings.continueButton;
        continueButton       = Instantiate(continueButtonPrefab, Vector3.zero, Quaternion.identity) as GameObject;
        continueButton.transform.SetParent(gCon.dialogueHolder.transform);
        continueButton.GetComponent <RectTransform> ().localPosition = continueButtonPrefab.transform.position;
        continueButton.GetComponent <RectTransform> ().localScale    = Vector3.one;
        continueButton.SetActive(false);
        continueButton.GetComponent <Button> ().onClick.AddListener(() => Dialoguer.ContinueDialogue());

        //endButton init
        endButtonPrefab = gCon.gameSettings.endButton;
        endButton       = Instantiate(endButtonPrefab, Vector3.zero, Quaternion.identity) as GameObject;
        endButton.transform.SetParent(gCon.dialogueHolder.transform);
        endButton.GetComponent <RectTransform> ().localPosition = endButtonPrefab.transform.position;
        endButton.GetComponent <RectTransform> ().localScale    = Vector3.one;
        endButton.SetActive(false);
        endButton.GetComponent <Button> ().onClick.AddListener(() => Dialoguer.EndDialogue());


        Dialoguer.events.onStarted   += OnStarted;
        Dialoguer.events.onEnded     += OnEnded;
        Dialoguer.events.onTextPhase += OnTextPhase;
    }
Beispiel #8
0
    // Update is called once per frame
    void Update()
    {
        if(!_dialogue) return;

        if(_windowReady) calculateText();

        if(!_dialogue || _ending) return;

        if(!_isBranchedText){
            if(Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.X) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return)){
                if(_windowCurrentText == _windowTargetText){
                    Dialoguer.ContinueDialogue(0);
                }else{
                    _windowCurrentText = _windowTargetText;
                    audioTextEnd.Play();
                }
            }
        }else{
            if(Input.GetKeyDown(KeyCode.DownArrow)){
                _currentChoice = (int)Mathf.Repeat(_currentChoice + 1, _branchedTextChoices.Length);
                audioText.Play();
            }
            if(Input.GetKeyDown(KeyCode.UpArrow)){
                _currentChoice = (int)Mathf.Repeat(_currentChoice - 1, _branchedTextChoices.Length);
                audioText.Play();
            }
            if(Input.GetMouseButtonDown(0) && _windowCurrentText != _windowTargetText){
                _windowCurrentText = _windowTargetText;
            }
            if(Input.GetKeyDown(KeyCode.X) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return)){
                if(_windowCurrentText == _windowTargetText){
                    Dialoguer.ContinueDialogue(_currentChoice);
                }else{
                    _windowCurrentText = _windowTargetText;
                    audioTextEnd.Play();
                }
            }
        }
    }
    void OnGUI()
    {
        if (!_showDialogueBox)
        {
            return;
        }

        // Set GUI Skin
        GUI.skin  = skin;
        GUI.depth = 10;

        float rectX      = (!_usingPositionRect) ? Screen.width * 0.5f : _positionRect.x;
        float rectY      = (!_usingPositionRect) ? Screen.height - 200 : _positionRect.y;
        float rectWidth  = (!_usingPositionRect) ? 512 : _positionRect.width;
        float rectHeight = (!_usingPositionRect) ? 190 : _positionRect.height;

        Rect dialogueBoxRect = centerRect(new Rect(rectX, rectY, rectWidth * _windowTweenValue, rectHeight * _windowTweenValue));

        // Clamp values so they can be no smaller than 32px X 32px
        dialogueBoxRect.width  = Mathf.Clamp(dialogueBoxRect.width, 32, 2000);
        dialogueBoxRect.height = Mathf.Clamp(dialogueBoxRect.height, 32, 2000);

        // Draw dialogue box
        if (_theme == "good")
        {
            drawDialogueBox(dialogueBoxRect, new Color(0.2f, 0.8f, 0.4f));
        }
        else if (_theme == "bad")
        {
            drawDialogueBox(dialogueBoxRect, new Color(0.8f, 0.2f, 0.2f));
        }
        else
        {
            drawDialogueBox(dialogueBoxRect);
        }

        /*// Draw name box
         * if(_nameText != string.Empty){
         *      Rect nameBoxRect = new Rect(dialogueBoxRect.x, dialogueBoxRect.y - 60, 150 * _windowTweenValue, 50 * _windowTweenValue);
         *      nameBoxRect.width = Mathf.Clamp(nameBoxRect.width, 32, 2000);
         *      nameBoxRect.height = Mathf.Clamp(nameBoxRect.height, 32, 2000);
         *      drawDialogueBox(nameBoxRect);
         *      drawShadowedText(new Rect(nameBoxRect.x + (15 * _windowTweenValue) - (5 * (1 - _windowTweenValue)), nameBoxRect.y + (5 * _windowTweenValue)  - (10 * (1 - _windowTweenValue)), nameBoxRect.width - (30 * _windowTweenValue), nameBoxRect.height - (5 * _windowTweenValue)), _nameText);
         * }*/

        Rect textLabelRect = new Rect(dialogueBoxRect.x + (20 * _windowTweenValue), dialogueBoxRect.y + (10 * _windowTweenValue), dialogueBoxRect.width - (40 * _windowTweenValue), dialogueBoxRect.height - (20 * _windowTweenValue));

        //_windowCurrentText = "This is a lot of text that I'm using as a test. Lorem ipsum! This is a lot of text that I'm using as a test. Lorem ipsum! This is a lot of text that I'm using as a test. Lorem ipsum!";
        drawShadowedText(textLabelRect, _windowCurrentText);

        if (_isBranchedText && _windowCurrentText == _windowTargetText && _branchedTextChoices != null)
        {
            for (int i = 0; i < _branchedTextChoices.Length; i += 1)
            {
                float choiceRectY = (dialogueBoxRect.yMax - (((38) * _branchedTextChoices.Length) - (38 * i))) - 20;
                Rect  choiceRect  = new Rect(dialogueBoxRect.x + 60, choiceRectY, dialogueBoxRect.width - 80, 38);
                drawShadowedText(choiceRect, _branchedTextChoices[i]);
                if (choiceRect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)))
                {
                    if (_currentChoice != i)
                    {
                        audioText.Play();
                        _currentChoice = i;
                    }
                    if (Input.GetMouseButtonDown(0))
                    {
                        Dialoguer.ContinueDialogue(_currentChoice);
                        break;
                    }
                }
                if (_currentChoice == i)
                {
                    GUI.Box(new Rect(choiceRect.x - 64, choiceRect.y, 64, 64), string.Empty, GUI.skin.GetStyle("box_cursor"));
                }
            }
        }
    }
Beispiel #10
0
        void OnGUI()
        {
            //定义GUI皮肤
            GUI.skin.box.normal.textColor  = new Vector4(1, 1, 1, 1);
            GUI.skin.box.padding           = new RectOffset(15, 15, 15, 15);
            GUI.skin.box.fontSize          = scaleGUI(18);
            GUI.skin.box.alignment         = TextAnchor.UpperLeft;
            GUI.skin.box.normal.background = dialogboxbg;
            GUI.skin.button.fontSize       = scaleGUI(18);
            switch (state)
            {
            case "nodata":
                player.canMove         = false;
                dialogbox              = new Rect(Screen.width / 2 - scaleGUI(110), Screen.height / 2 - scaleGUI(150), scaleGUI(220), scaleGUI(250));
                GUI.skin.box.alignment = TextAnchor.UpperCenter;
                GUI.Box(dialogbox, "当前没有存档\n...无法读取...\n是否重新开始?");
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(20), scaleGUI(180), scaleGUI(45)), "确定"))
                {
                    Application.LoadLevel(1);
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 + scaleGUI(35), scaleGUI(180), scaleGUI(45)), "取消"))
                {
                    player.canMove = true;
                    state          = "";
                }
                break;

            case "dabuguo":
                player.canMove = false;
                GUI.Box(new Rect(Screen.width / 2 - scaleGUI(72), Screen.height / 2 - scaleGUI(120), scaleGUI(144), scaleGUI(240)), infoDabuguo);
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(60), Screen.height / 2 + scaleGUI(75), scaleGUI(120), scaleGUI(35)), "知道了"))
                {
                    state          = "";
                    player.canMove = true;
                }
                break;

            case "floorchange":
                if (dialogTime > 0)
                {
                    player.canMove = false;
                    dialogTime    -= Time.deltaTime;
                    GUI.skin.box.normal.textColor  = new Vector4(1, 1, 1, 1);
                    GUI.skin.box.padding           = new RectOffset(15, 15, 15, 15);
                    GUI.skin.box.fontSize          = scaleGUI(24);
                    GUI.skin.box.alignment         = TextAnchor.MiddleCenter;
                    GUI.skin.box.normal.background = dialogboxbg;
                    dialogbox = new Rect(Screen.width / 2 - scaleGUI(100), Screen.height / 2 - scaleGUI(30), scaleGUI(200), scaleGUI(60));
                    GUI.Box(dialogbox, "当前第 " + GM.CurrentFloor.Value + " 层");
                }
                else
                {
                    player.canMove = true;
                    dialogTime     = 0;
                    state          = "";
                }
                break;

            case "menu":
                player.canMove = false;
                dialogbox      = new Rect(Screen.width / 2 - scaleGUI(110), Screen.height / 2 - scaleGUI(150), scaleGUI(220), scaleGUI(250));
                GUI.Box(dialogbox, "");
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(130), scaleGUI(180), scaleGUI(45)), "保存进度"))
                {
                    GDM.SaveGame();
                    player.canMove = true;
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(75), scaleGUI(180), scaleGUI(45)), "读取进度"))
                {
                    if (GDM.checkGameData())
                    {
                        PlayerPrefs.SetInt("loadgame", 1);
                        Application.LoadLevel(1);
                    }
                    else
                    {
                        state = "nodata";
                    }
                    player.canMove = true;
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(20), scaleGUI(180), scaleGUI(45)), "退出游戏"))
                {
                    Application.Quit();
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 + scaleGUI(35), scaleGUI(180), scaleGUI(45)), "取消"))
                {
                    state          = "";
                    player.canMove = true;
                }
                break;

            case "tujian":
                if (Input.GetMouseButton(0))
                {
                    GameObject mycamera = GameObject.Find("Camera");
                    Vector3    position = mycamera.GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition);
                    TileIndex  ti       = TM.tileSystem.ClosestTileIndexFromWorld(position);
                    TileData   tile     = TM.tileSystem.GetTile(ti);
                    if (tile != null && tile.GetUserFlag(3))
                    {
                        AuM.playAudio("talk");
                        Guaiwu guaiwu = tile.gameObject.GetComponent <Guaiwu>();
                        string info   = "";
                        if (!tile.GetUserFlag(10))
                        {
                            if (PlayerInfo.Instance.Data.Attack.Value <= guaiwu.fangyu)
                            {
                                info = "你破不了它的防御。\n";
                            }
                            else
                            {
                                int   shanghai     = PlayerInfo.Instance.Data.Attack.Value - guaiwu.fangyu;
                                float cishu        = Mathf.Ceil(guaiwu.shengming / shanghai);
                                float zongshanghai = 0;
                                if (guaiwu.gongji > PlayerInfo.Instance.Data.Defence.Value)
                                {
                                    float shoushang = guaiwu.gongji - PlayerInfo.Instance.Data.Defence.Value;
                                    zongshanghai = shoushang * cishu;
                                }
                                info = "战胜它你将损失:" + zongshanghai + "生命。\n";
                            }
                        }
                        info += "生命:" + guaiwu.shengming + "  /  ";
                        info += "攻击:" + guaiwu.gongji + "  /  ";
                        info += "防御:" + guaiwu.fangyu + "\n";
                        info += "金币:" + guaiwu.jinbi + "  /  ";
                        info += "经验:" + guaiwu.jingyan;
                        if (position.y > -5)
                        {
                            //显示在下面
                            GUI.Box(new Rect(0, Screen.height / 2 + scaleGUI(63), Screen.width, scaleGUI(100)), info);
                        }
                        else
                        {
                            //显示在上面
                            GUI.Box(new Rect(0, Screen.height / 2 - scaleGUI(237), Screen.width, scaleGUI(100)), info);
                        }
                    }
                }
                break;

            case "feixing":
                player.canMove = false;
                for (int i = 1; i < GM.MaxFloor.Value + 1; i++)
                {
                    int y = i % 3;
                    if (y == 0)
                    {
                        y = -1;
                    }
                    else if (y == 2)
                    {
                        y = 0;
                    }
                    int z = (i - 1) / 3;
                    if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(120 * y + 50), Screen.height / 2 - scaleGUI(220) + scaleGUI(50 * z), scaleGUI(100), scaleGUI(40)), "第 " + i + " 层"))
                    {
                        AuM.playAudio("feixing");
                        GM.changeFloor(i);
                        state          = "";
                        player.canMove = true;
                    }
                }
                break;

            case "dialog":
                player.canMove = false;
                if (_text != "")
                {
                    dialogbox = new Rect(Screen.width / 2 - scaleGUI(150), Screen.height / 2 - scaleGUI(150), scaleGUI(300), scaleGUI(300));
                    GUI.Box(dialogbox, _text);
                }
                if (_choices == null)
                {
                    if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(135), Screen.height / 2 + scaleGUI(95), scaleGUI(270), scaleGUI(40)), "继续"))
                    {
                        Dialoguer.ContinueDialogue();
                    }
                }
                else
                {
                    pressed = false;
                    for (int i = _choices.Length - 1; i > -1; i--)
                    {
                        if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(135), Screen.height / 2 + scaleGUI(40 + (i - _choices.Length + 2) * 45), scaleGUI(270), scaleGUI(40)), _choices[i]))
                        {
                            Dialoguer.ContinueDialogue(i);
                        }
                    }
                }
                break;

            default:
                break;
            }
            if (tipTime > 0 && tipContent != "")
            {
                GUI.skin.box.alignment = TextAnchor.MiddleCenter;
                GUI.Box(new Rect(Screen.width / 2 - scaleGUI(200), Screen.height / 2 + scaleGUI(115), scaleGUI(400), scaleGUI(50)), tipContent);
                tipTime -= Time.deltaTime;
            }
            else
            {
                tipTime    = 0;
                tipContent = "";
            }
            if (state == "")
            {
                player.canMove = true;
            }
        }
Beispiel #11
0
 public void ClickedContinueButton()
 {
     Dialoguer.ContinueDialogue();
 }
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        if (!_dialogue || !_showDialogueBox)
        {
            setScaleZero();
            return;
        }

        // Set position of conversation bubble
        if (convoBubble != null)
        {
            uiroot = GameObject.Find("UI Root").GetComponent <UIRoot>();

            if (uiroot != null)
            {
                Transform convo = uiroot.transform.Find("Conversation Bubble");
                uiroot.scalingStyle        = UIRoot.Scaling.FixedSize;
                uiroot.manualHeight        = 600;
                convo.transform.localScale = new Vector3(0.6f, 0.6f, 1f);

                // For determining whether convo displays top or bottom of screen
                if (runOnce == false)
                {
                    genericSceneObj = FindObjectsOfType(typeof(genericScene)) as genericScene[];
                }
                Vector3 top          = new Vector3(0f, 100f, 1f);
                Vector3 bottom       = new Vector3(0f, -800f, 1f);
                Vector3 centertop    = new Vector3(-200f, -100f, 1f);
                Vector3 centerbottom = new Vector3(-200f, -800f, 1f);

                if (genericSceneObj != null && genericSceneObj.Length >= 1)
                {
                    foreach (genericScene scene in genericSceneObj)
                    {
                        string sprName = convo.GetComponent <UISprite>().spriteName;
                        // If want to place on top of screen, else...
                        if (scene.getPlaceTop())
                        {
                            if (sprName == "conversation-template-new")
                            {
                                convo.transform.localPosition = Vector3.Lerp(convo.transform.localPosition, top, Time.deltaTime * 8f);
                            }
                            else if (sprName == "regulartext")
                            {
                                convo.transform.localPosition = Vector3.Lerp(convo.transform.localPosition, centertop, Time.deltaTime * 8f);
                            }
                        }
                        else
                        {
                            if (sprName == "conversation-template-new")
                            {
                                convo.transform.localPosition = Vector3.Lerp(convo.transform.localPosition, bottom, Time.deltaTime * 8f);
                            }
                            else if (sprName == "regulartext")
                            {
                                convo.transform.localPosition = Vector3.Lerp(convo.transform.localPosition, centerbottom, Time.deltaTime * 8f);
                            }
                        }

                        Color col = convo.GetComponent <UIWidget>().color;
                        col.a = Mathf.Lerp(col.a, 1f, Time.deltaTime * 4f);
                        convo.GetComponent <UIWidget>().color = col;

                        // Used for switching between conversation template backgrounds
                        // For text where there is no character speaking,
                        // display a different background
                        // HARD CODE LOLOL
                        Transform convoText = convo.Find("Conversation Text");
                        if ((Application.loadedLevelName == "chapter1intronarration" ||
                             Application.loadedLevelName == "chapter1introfinbalcony") &&
                            _nameText == "")
                        {
                            convo.GetComponent <UISprite>().spriteName = "regulartext";
                            convo.GetComponent <UIWidget>().width      = 8000;
                            convoText.GetComponent <UIWidget>().pivot  = UIWidget.Pivot.Top;
                            convo.GetComponent <UISprite>().MarkAsChanged();
                        }
                        else
                        {
                            convo.GetComponent <UISprite>().spriteName = "conversation-template-new";
                            convo.GetComponent <UIWidget>().width      = 4618;
                            convoText.GetComponent <UIWidget>().pivot  = UIWidget.Pivot.TopLeft;
                            convo.GetComponent <UISprite>().MarkAsChanged();
                        }
                    }
                    runOnce = true;
                }
                else
                {
                    // If there is no generic scene in the scene
                    convo.transform.localPosition = Vector3.Lerp(convo.transform.localPosition, bottom, Time.deltaTime * 8f);

                    Color col = convo.GetComponent <UIWidget>().color;
                    col.a = Mathf.Lerp(col.a, 1f, Time.deltaTime * 4f);
                    convo.GetComponent <UIWidget>().color = col;
                }


                if (_nameText == "")
                {
                    runOnce = false;
                }

                convo.GetComponent <UISprite> ().enabled = true;
            }
        }

        // Setup
        if (!GameObject.Find("Conversation Bubble"))
        {
            setup();
            leftChar  = GameObject.Find("LeftCharacter").GetComponent <UISprite>();
            nameLabel = GameObject.Find("Name").GetComponent <UILabel>();
        }

        // Mouse click interval delay
        time += Time.deltaTime;

        // Branched Text
        if (_isBranchedText && _windowCurrentText == _windowTargetText && _branchedTextChoices != null)
        {
            enableColliders();
            repopulateChoices();
            label.text = "";                    // Clear conversation text field
            if (_metadata == "")
            {
                for (int i = 0; i < _branchedTextChoices.Length; ++i)
                {
                    choices[i].text = "- " + _branchedTextChoices[i];
                }
            }
            else
            {
                /// For parsing metadata
                List <int> mylist  = new List <int>();
                List <int> newlist = new List <int>();
                for (int i = 1; i <= _branchedTextChoices.Length; ++i)
                {
                    mylist.Add(i);
                    newlist.Add(i);
                }
                List <int> metalist = new List <int>();
                List <int> varlist  = new List <int>();
                foreach (string[] ele in _parsedmetadata)
                {
                    metalist.Add(int.Parse(ele[0].Trim(',')));
                    varlist.Add(int.Parse(ele[2].Trim(',')));
                }
                foreach (int i in mylist)
                {
                    foreach (int j in metalist)
                    {
                        if (i == j)
                        {
                            newlist.Remove(i);
                        }
                    }
                }
                foreach (int i in newlist)
                {
                    choices[i - 1].text = "- " + _branchedTextChoices[i - 1];
                    enableCollider(choices[i - 1]);
                }
                int itor = 0;
                foreach (int i in metalist)
                {
                    if (Dialoguer.GetGlobalBoolean(varlist[itor]))
                    {
                        choices[i - 1].text = "- " + _branchedTextChoices[i - 1];
                        enableCollider(choices[i - 1]);
                    }
                    else
                    {
                        choices[i - 1].text = "";
                        disableCollider(choices[i - 1]);
                    }
                    ++itor;
                }
            }
        }
        // Regular text
        else
        {
            clearBranchedText();
            label.text = _windowTargetText;
        }

        // Regular text progression
        if (!_isBranchedText)
        {
            disableColliders();
            if (Input.GetMouseButtonUp(0) && time > delay)
            {
                time = 0;
                Dialoguer.ContinueDialogue(0);
            }
        }

        updatePortraits();

        # region test things
        if (Input.GetKeyUp(KeyCode.F))
Beispiel #13
0
    void OnGUI()
    {
        GUI.skin.box.normal.textColor  = new Vector4(1, 1, 1, 1);
        GUI.skin.box.padding           = new RectOffset(15, 15, 15, 15);
        GUI.skin.box.fontSize          = scaleGUI(8);
        GUI.skin.box.alignment         = TextAnchor.UpperLeft;
        GUI.skin.box.normal.background = dialogboxbg;
        GUI.skin.button.fontSize       = scaleGUI(8);
        switch (state)
        {
        case "dialog":
        {
            player.canMove = false;
            if (!string.IsNullOrEmpty(_text))
            {
                dialogbox = new Rect(
                    Screen.width / 2 - scaleGUI(95),
                    Screen.height / 2 - scaleGUI(113),
                    scaleGUI(190),
                    scaleGUI(190));
                GUI.Box(dialogbox, _text);
            }
            if (_choices == null)
            {
                if (GUI.Button(new Rect(
                                   Screen.width / 2 - scaleGUI(95),
                                   Screen.height / 2 + scaleGUI(50),
                                   scaleGUI(190),
                                   scaleGUI(30)),
                               "继续"))
                {
                    Dialoguer.ContinueDialogue();
                }
            }
            else
            {
                pressed = false;
                for (int i = _choices.Length - 1; i >= 0; i--)
                {
                    if (GUI.Button(new Rect(
                                       Screen.width / 2 - scaleGUI(95),
                                       Screen.height / 2 + scaleGUI((i - _choices.Length + 2) * 35),
                                       scaleGUI(190),
                                       scaleGUI(30)),
                                   _choices[i]))
                    {
                        Dialoguer.ContinueDialogue(i);
                    }
                }
            }
        }
        break;

        case "dabuguo":
        {
            player.canMove = false;
            GUI.Box(new Rect(
                        Screen.width / 2 - scaleGUI(72),
                        Screen.height / 2 - scaleGUI(120),
                        scaleGUI(144),
                        scaleGUI(220)),
                    infoDabuguo);
            if (GUI.Button(new Rect(
                               Screen.width / 2 - scaleGUI(60),
                               Screen.height / 2 + scaleGUI(45),
                               scaleGUI(120),
                               scaleGUI(35)),
                           "知道了"))
            {
                state          = string.Empty;
                player.canMove = true;
            }
        }
        break;

        case "floorchange":
        {
            if (dialogTime > 0)
            {
                dialogTime -= Time.deltaTime;
                GUI.Box(new Rect(
                            Screen.width / 2 - scaleGUI(72),
                            Screen.height / 2 - scaleGUI(20),
                            scaleGUI(144),
                            scaleGUI(40)),
                        "当前第 " + _GM.CurrentFloor + " 层");
            }
            else
            {
                dialogTime = 0;
                state      = string.Empty;
            }
        }
        break;

        case "tujian":
            if (Input.GetMouseButton(0))
            {
                GameObject mycamera = GameObject.Find("Camera");
                Vector3    position = mycamera.GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition);
                TileIndex  ti       = _TM._TileSystem.ClosestTileIndexFromWorld(position);
                TileData   tile     = _TM._TileSystem.GetTile(ti);
                if (tile != null && tile.GetUserFlag(3))
                {
                    Guaiwu guaiwu = tile.gameObject.GetComponent <Guaiwu>();
                    string info   = "";
                    if (!tile.GetUserFlag(10))
                    {
                        if (_PA._gongji <= guaiwu.fangyu)
                        {
                            info = "你破不了它的防御。\n";
                        }
                        else
                        {
                            int   shanghai     = _PA._gongji - guaiwu.fangyu;
                            float cishu        = Mathf.Ceil(guaiwu.shengming / shanghai);
                            float zongshanghai = 0;
                            if (guaiwu.gongji > _PA._fangyu)
                            {
                                float shoushang = guaiwu.gongji - _PA._fangyu;
                                zongshanghai = shoushang * cishu;
                            }
                            info = "战胜它你将损失:" + zongshanghai + "生命。\n";
                        }
                    }
                    info += "生命:" + guaiwu.shengming + "  /  ";
                    info += "攻击:" + guaiwu.gongji + "  /  ";
                    info += "防御:" + guaiwu.fangyu + "\n";
                    info += "金币:" + guaiwu.jinbi + "  /  ";
                    info += "经验:" + guaiwu.jingyan;
                    if (position.y > -5)
                    {
                        //显示在下面
                        GUI.Box(new Rect(
                                    Screen.width / 2 - scaleGUI(95),
                                    Screen.height / 2 + scaleGUI(30),
                                    scaleGUI(190),
                                    scaleGUI(50)),
                                info);
                    }
                    else
                    {
                        //显示在上面
                        GUI.Box(new Rect(
                                    Screen.width / 2 - scaleGUI(95),
                                    Screen.height / 2 - scaleGUI(113),
                                    scaleGUI(190),
                                    scaleGUI(50)),
                                info);
                    }
                }
            }
            break;

        case "feixing":
            player.canMove = false;
            for (int i = 1; i < _GM.maxFloor + 1; i++)
            {
                int y = i % 3;
                if (y == 0)
                {
                    y = -1;
                }
                else if (y == 2)
                {
                    y = 0;
                }
                int z = (i - 1) / 3;
                if (GUI.Button(
                        new Rect(Screen.width / 2 - scaleGUI(60 * y + 35),
                                 Screen.height / 2 - scaleGUI(113) + scaleGUI(25 * z),
                                 scaleGUI(50),
                                 scaleGUI(20)),
                        "第 " + i + " 层"))
                {
                    _GM.changeFloor(i);
                    state          = "";
                    player.canMove = true;
                }
            }
            break;
        }
        if (tipTime > 0 && !string.IsNullOrEmpty(tipContent))
        {
            GUI.skin.box.alignment = TextAnchor.MiddleCenter;
            GUI.Box(new Rect(
                        Screen.width / 2 - scaleGUI(95),
                        Screen.height / 2 + scaleGUI(50),
                        scaleGUI(190),
                        scaleGUI(30)),
                    tipContent);
            tipTime -= Time.deltaTime;
        }
        else
        {
            tipTime    = 0;
            tipContent = string.Empty;
        }
        if (string.IsNullOrEmpty(state))
        {
            player.canMove = true;
        }
    }