コード例 #1
0
    // Use this for initialization
    void Start()
    {
        GameDirector gameDirector = GameDirector.getInstance();

        gameDirector.currentSceneController = this;
        comFactory = ComFactory.GetInstance();
    }
コード例 #2
0
    private void Talk(Text talkText)
    {
        comFactory = ComFactory.GetInstance();
        reset();
        Vector3 position = talkText.rectTransform.localPosition;

        talkText.text = comFactory.com[current].content;
        if (comFactory.com[current].speaker == "left")
        {
            Animator leftAni = left.GetComponent <Animator>();
            leftAni.SetBool("big", true);
        }
        else
        {
            Animator rightAni = right.GetComponent <Animator>();
            rightAni.SetBool("big", true);
        }
        //产生对话

        if (time <= 0 && current < comFactory.com.Count)
        {
            if (comFactory.com[current].speaker == "left")
            {
                Animator leftAni = left.GetComponent <Animator>();
                leftAni.SetBool("big", false);
            }
            else
            {
                Animator rightAni = right.GetComponent <Animator>();
                rightAni.SetBool("big", false);
            }
            talkText.text = "";
            talkText.rectTransform.localPosition = position;
            if (current < comFactory.com.Count)
            {
                if (comFactory.com[current].content.Length * fontSize <= 10)
                {
                    time = 2;
                }
                else
                {
                    time = (comFactory.com[current].content.Length * fontSize - 50) * Time.deltaTime;
                }
            }
            //设置延迟
            if (talkText.text.Length * fontSize > 10)
            {
                position.x -= 1;
                talkText.rectTransform.localPosition = position;
            }
            //看看一句话的字长是否超过对话框
            time -= Time.deltaTime;
        }
    }