示例#1
0
    public override FXTextEffect clone(GameObject obj)
    {
        FXTextColor f = obj.AddComponent <FXTextColor>();

        f.color = color;
        return(f);
    }
示例#2
0
    IEnumerator startFloatTextCR(float x, float y, string text)
    {
        DialogueItem d_item = gameObject.AddComponent <DialogueItemAN>();

        transform.position = new Vector2(x, y);
        DialogueBox d_box = GetComponent <DialogueBox> ();

        d_box.is_floating  = true;
        d_box.talk_sfx     = false;
        d_box.scroll_delay = 0.07f;
        d_item.text        = text;
        d_box.d_item       = d_item;
        // parse effects and macros
        d_box.text = DialogueParser.main.parse(d_item, d_box);
        foreach (FXTextEffect text_effect in d_item.fx_text_effects)
        {
            d_box.fx_text.addEffect(text_effect);
        }
        // start text scroll
        d_box.dialogueBoxStart();
        // wait for dialogue to finish scrolling
        yield return(new WaitUntil(() => d_box.cr_scroll != null));

        yield return(new WaitWhile(() => d_box.cr_scroll != null));

        // wait for a little more and then fade out
        yield return(new WaitForSeconds(1f));

        FXTextColor fade = d_box.fx_text.gameObject.AddComponent <FXTextColor>();

        fade.color = d_box.fx_text.color;
        fade.chars = new int[2] {
            0, d_box.text.Length
        };
        d_box.fx_text.addEffect(fade);
        while (d_box.fx_text.color.a > 0)
        {
            fade.color.a -= 0.03f;
            yield return(null);
        }
        Destroy(gameObject);
    }
示例#3
0
    float text_pad;                               // Padding between text and dialogue box

    // Initializes dialogue box and starts text scroll
    public Coroutine dialogueBoxStart()
    {
        text_pad = fx_text.rectTransform.offsetMin.y - fx_text.rectTransform.offsetMax.y;
        // Initialize color effect to hide text
        set_color         = fx_text.gameObject.AddComponent <FXTextColor> ();
        set_color.color   = fx_text.color;
        set_color.color.a = 0;
        set_color.chars   = new int[2] {
            0, text.Length
        };
        fx_text.addEffect(set_color);
        if (d_item.GetType() == typeof(DialogueItemChat))
        {
            DialogueItemChat c_item = (DialogueItemChat)d_item;
            // Set icon
            left_icon.sprite  = c_item.left_icon;
            right_icon.sprite = c_item.right_icon;
            // Display appropriate icon
            if (c_item.icon_side == IconSide.LEFT || c_item.icon_side == IconSide.BOTH)
            {
                left_icon.enabled = true;
            }
            if (c_item.icon_side == IconSide.RIGHT || c_item.icon_side == IconSide.BOTH)
            {
                right_icon.enabled = true;
            }
            // Add text with speaker's name, and offset text display
            int offset = 0;
            if (d_item.speaker_name != null && d_item.speaker_name.Length != 0)
            {
                text    = d_item.speaker_name + "\n" + text;
                offset += d_item.speaker_name.Length + 1;
            }
            fx_text.text         = text;
            set_color.chars [0]  = offset;
            set_color.chars [1] += offset;
            // Set box height
            setBoxHeight();
        }
        else if (d_item.GetType() == typeof(DialogueItemVN))
        {
            DialogueItemVN v_item = (DialogueItemVN)d_item;
            // Display character sprites
            for (int i = 0; i < v_item.char_sprites.Length; ++i)
            {
                DialogueManager.main.displayCharacter(v_item.char_sprites [i], v_item.char_sprite_pos [i]);
            }
            fx_text.text = text;
        }
        else if (d_item.GetType() == typeof(DialogueItemAN))
        {
            fx_text.text = text;
            setBoxHeight();
        }
        else
        {
            fx_text.text = text;
        }
        // Set talking sfx
        if (talk_sfx)
        {
            AudioPlayer.main.setSFX(AudioPlayer.channel_voice, "speak_boop");
        }
        return(StartCoroutine(startTextScrollCR()));
    }