Ejemplo n.º 1
0
    private IEnumerator destroySingleBranchAnimation(GameObject currentButton)
    {
        Vector3 targetPos       = currentButton.transform.position;
        Color   targetColor     = currentButton.GetComponent <Image>().color;
        Color   targetTextColor = currentButton.transform.Find("Text").GetComponent <Text>().color;

        for (float t = 0; t <= 1f; t += 0.05f)
        {
            currentButton.transform.position           = Vector3.Lerp(targetPos, targetPos + new Vector3(20f, 0, 0), EasingFuncs.QuartInOut(t));
            currentButton.GetComponent <Image>().color = Color.Lerp(targetColor, new Color(targetColor.r, targetColor.g, targetColor.b, 0), EasingFuncs.QuartInOut(t));
            currentButton.transform.Find("Text").GetComponent <Text>().color = Color.Lerp(targetTextColor, new Color(targetTextColor.r, targetTextColor.g, targetTextColor.b, 0), EasingFuncs.QuartInOut(t));
            yield return(null);

            yield return(new WaitForSeconds(0.006f));
        }
        Destroy(currentButton);
    }
Ejemplo n.º 2
0
    private IEnumerator nameAnimation(string name1, string name2)
    {
        GameObject replacedName = Instantiate(DialogBox.transform.Find("NamePanel").Find("NameText").gameObject) as GameObject;

        replacedName.transform.position         = DialogBox.transform.Find("NamePanel").Find("NameText").position - new Vector3(20f, 0, 0);
        replacedName.GetComponent <Text>().text = name2;
        Color c1 = DialogBox.transform.Find("NamePanel").Find("NameText").GetComponent <Text>().color;
        Color c2 = replacedName.GetComponent <Text>().color;

        c2 = new Color(c2.r, c2.g, c2.b, 0f);
        replacedName.GetComponent <Text>().color = c2;
        replacedName.transform.SetParent(DialogBox.transform.Find("NamePanel"));

        Vector3 targetNameTextPosition     = DialogBox.transform.Find("NamePanel").Find("NameText").position + new Vector3(20f, 0, 0);
        Vector3 targetReplacedNamePosition = DialogBox.transform.Find("NamePanel").Find("NameText").position;

        for (float t = 0; t <= 1f; t += 0.05f)
        {
            DialogBox.transform.Find("NamePanel").Find("NameText").transform.position = Vector3.Lerp(targetNameTextPosition - new Vector3(20f, 0, 0), targetNameTextPosition, EasingFuncs.QuartInOut(t));
            replacedName.transform.position = Vector3.Lerp(targetReplacedNamePosition - new Vector3(20f, 0, 0), targetReplacedNamePosition, EasingFuncs.QuartInOut(t));

            DialogBox.transform.Find("NamePanel").Find("NameText").GetComponent <Text>().color = Color.Lerp(c1, new Color(c1.r, c1.g, c1.b, 0f), EasingFuncs.QuartInOut(t));
            replacedName.GetComponent <Text>().color = Color.Lerp(c2, new Color(c2.r, c2.g, c2.b, 1f), EasingFuncs.QuartInOut(t));
            yield return(null);                       //下一帧继续执行for循环

            yield return(new WaitForSeconds(0.006f)); //0.006秒后继续执行for循环
        }
        DialogBox.transform.Find("NamePanel").Find("NameText").transform.position         -= new Vector3(20f, 0, 0);
        DialogBox.transform.Find("NamePanel").Find("NameText").GetComponent <Text>().color = new Color(c1.r, c1.g, c1.b, 1.0f);
        DialogBox.transform.Find("NamePanel").Find("NameText").GetComponent <Text>().text  = name2;
        Destroy(replacedName);
        animationLock = false;
    }
Ejemplo n.º 3
0
    private IEnumerator destroyAnimation()
    {
        Vector3 targetNamePanelPosition   = DialogBox.transform.Find("NamePanel").transform.position;
        Vector3 targetDialogPanelPosition = DialogBox.transform.Find("DialogPanel").transform.position;
        Color   targetNamePanelColor      = DialogBox.transform.Find("NamePanel").GetComponent <Image>().color;
        Color   targetDialogPanelColor    = DialogBox.transform.Find("DialogPanel").GetComponent <Image>().color;
        Vector3 targetCharacterPosition   = DialogBox.transform.Find("Character").transform.position;
        Color   targetCharacterColor      = DialogBox.transform.Find("Character").GetComponent <Image>().color;
        Vector3 targetNameTextPosition    = DialogBox.transform.Find("NamePanel").Find("NameText").transform.position;
        Color   targetNameTextColor       = DialogBox.transform.Find("NamePanel").Find("NameText").GetComponent <Text>().color;
        Vector3 targetDialogTextPosition  = DialogBox.transform.Find("DialogPanel").Find("DialogText").transform.position;
        Color   targetDialogTextColor     = DialogBox.transform.Find("DialogPanel").Find("DialogText").GetComponent <Text>().color;

        for (float t = 0; t <= 1f; t += 0.05f)
        {
            DialogBox.transform.Find("NamePanel").transform.position   = Vector3.Lerp(targetNamePanelPosition, targetNamePanelPosition - new Vector3(0, 20f, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("DialogPanel").transform.position = Vector3.Lerp(targetDialogPanelPosition, targetDialogPanelPosition - new Vector3(0, 20f, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("Character").transform.position   = Vector3.Lerp(targetCharacterPosition, targetCharacterPosition + new Vector3(40f, 0, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("NamePanel").Find("NameText").transform.position     = Vector3.Lerp(targetNameTextPosition, targetNameTextPosition - new Vector3(0, 20f, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("DialogPanel").Find("DialogText").transform.position = Vector3.Lerp(targetDialogTextPosition, targetDialogTextPosition - new Vector3(0, 20f, 0), EasingFuncs.QuartInOut(t));

            DialogBox.transform.Find("NamePanel").GetComponent <Image>().color   = Color.Lerp(targetNamePanelColor, new Color(targetNamePanelColor.r, targetNamePanelColor.g, targetNamePanelColor.b, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("DialogPanel").GetComponent <Image>().color = Color.Lerp(targetDialogPanelColor, new Color(targetDialogPanelColor.r, targetDialogPanelColor.g, targetDialogPanelColor.b, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("Character").GetComponent <Image>().color   = Color.Lerp(targetCharacterColor, new Color(targetCharacterColor.r, targetCharacterColor.g, targetCharacterColor.b, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("NamePanel").Find("NameText").GetComponent <Text>().color     = Color.Lerp(targetNameTextColor, new Color(targetNameTextColor.r, targetNameTextColor.g, targetNameTextColor.b, 0), EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("DialogPanel").Find("DialogText").GetComponent <Text>().color = Color.Lerp(targetDialogTextColor, new Color(targetDialogTextColor.r, targetDialogTextColor.g, targetDialogTextColor.b, 0), EasingFuncs.QuartInOut(t));

            yield return(null);

            yield return(new WaitForSeconds(0.03f));
        }

        Destroy(DialogBox);
        DialogBox = null;
    }
Ejemplo n.º 4
0
    private IEnumerator initializeAnimation()
    {
        Vector3 targetNamePanelPosition   = DialogBox.transform.Find("NamePanel").transform.position;
        Vector3 targetDialogPanelPosition = DialogBox.transform.Find("DialogPanel").transform.position;
        Color   targetNamePanelColor      = DialogBox.transform.Find("NamePanel").GetComponent <Image>().color;
        Color   targetDialogPanelColor    = DialogBox.transform.Find("DialogPanel").GetComponent <Image>().color;
        Vector3 targetCharacterPosition   = DialogBox.transform.Find("Character").transform.position;
        Color   targetCharacterColor      = DialogBox.transform.Find("Character").GetComponent <Image>().color;

        for (float t = 0; t <= 1f; t += 0.05f)
        {
            DialogBox.transform.Find("NamePanel").transform.position             = Vector3.Lerp(targetNamePanelPosition - new Vector3(0, 20f, 0), targetNamePanelPosition, EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("DialogPanel").transform.position           = Vector3.Lerp(targetDialogPanelPosition - new Vector3(0, 20f, 0), targetDialogPanelPosition, EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("Character").transform.position             = Vector3.Lerp(targetCharacterPosition - new Vector3(40f, 0, 0), targetCharacterPosition, EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("NamePanel").GetComponent <Image>().color   = Color.Lerp(new Color(targetNamePanelColor.r, targetNamePanelColor.g, targetNamePanelColor.b, 0), targetNamePanelColor, EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("DialogPanel").GetComponent <Image>().color = Color.Lerp(new Color(targetDialogPanelColor.r, targetDialogPanelColor.g, targetDialogPanelColor.b, 0), targetDialogPanelColor, EasingFuncs.QuartInOut(t));
            DialogBox.transform.Find("Character").GetComponent <Image>().color   = Color.Lerp(new Color(targetCharacterColor.r, targetCharacterColor.g, targetCharacterColor.b, 0), targetCharacterColor, EasingFuncs.QuartInOut(t));
            yield return(null);

            yield return(new WaitForSeconds(0.03f));
        }
        StartCoroutine(nameAnimation("", currentDialog.characterName));
        displayDialog(currentDialog);
    }