Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //フラグが立っているなら、指定のアニメーションを起動する。
        dd2_flag = !(Drag.GetComponentInChildren <Drag>().SetAnimation());

        dd1_flag = Drag.GetComponentInChildren <Drag>().SetAnimation();

        if (dd2_flag)
        {
            frame_animator.SetBool("DD1", true);
            frame_animator.SetBool("DD2", false);
            dd1_flag = false;
        }
        else if (dd1_flag)
        {
            frame_animator.SetBool("DD2", true);
            frame_animator.SetBool("DD1", false);
            dd2_flag = false;
        }
    }
Exemplo n.º 2
0
    public void OnDrop(PointerEventData eventData)
    {
        Drag d = eventData.pointerDrag.GetComponent <Drag>();

        if (d != null && d.active)
        {
            if (d.cardType == Drag.CardType.Number && (this.transform.gameObject.name == "Answer2" || this.transform.gameObject.name == "Answer4"))
            {
                d.gameObject.GetComponent <CanvasGroup>().alpha = 1f;
            }
            else if (d.cardType == Drag.CardType.Operator && (this.transform.gameObject.name == "Answer1" || this.transform.gameObject.name == "Answer3" ||
                                                              this.transform.gameObject.name == "Answer5"))
            {
            }
            else if (d.cardType == Drag.CardType.Answer && d.GetComponentInChildren <Text>().text == "")
            {
            }
            else if ((this.gameObject.name == "Answer1" &&
                      (d.gameObject.name == "Answer2" || d.gameObject.name == "Answer4")) ||
                     (this.gameObject.name == "Answer3" &&
                      (d.gameObject.name == "Answer2" || d.gameObject.name == "Answer4")) ||
                     (this.gameObject.name == "Answer5" &&
                      (d.gameObject.name == "Answer2" || d.gameObject.name == "Answer4")) ||
                     (this.gameObject.name == "Answer2" &&
                      (d.gameObject.name == "Answer1" || d.gameObject.name == "Answer3" || d.gameObject.name == "Answer5")) ||
                     (this.gameObject.name == "Answer4" &&
                      (d.gameObject.name == "Answer1" || d.gameObject.name == "Answer3" || d.gameObject.name == "Answer5")))
            {
            }
            else if (d.cardType == Drag.CardType.Answer)
            {
                string text = this.transform.gameObject.GetComponentInChildren <Text>().text;
                UnityEngine.FontStyle fontStyle = this.transform.gameObject.GetComponentInChildren <Text>().fontStyle;
                int fontSize = this.transform.gameObject.GetComponentInChildren <Text>().fontSize;
                UnityEngine.TextAnchor align = this.transform.gameObject.GetComponentInChildren <Text>().alignment;

                this.transform.gameObject.GetComponentInChildren <Text>().text      = d.transform.gameObject.GetComponentInChildren <Text>().text;
                this.transform.gameObject.GetComponentInChildren <Text>().fontStyle = d.transform.gameObject.GetComponentInChildren <Text>().fontStyle;
                this.transform.gameObject.GetComponentInChildren <Text>().fontSize  = d.transform.gameObject.GetComponentInChildren <Text>().fontSize;
                this.transform.gameObject.GetComponentInChildren <Text>().alignment = d.transform.gameObject.GetComponentInChildren <Text>().alignment;
                this.gameObject.GetComponent <CanvasGroup>().alpha = 1f;

                d.transform.gameObject.GetComponentInChildren <Text>().text      = text;
                d.transform.gameObject.GetComponentInChildren <Text>().fontStyle = fontStyle;
                d.transform.gameObject.GetComponentInChildren <Text>().fontSize  = fontSize;
                d.transform.gameObject.GetComponentInChildren <Text>().alignment = align;
                d.gameObject.GetComponent <CanvasGroup>().alpha = 1f;

                d.active            = true;
                d.droppedToLocation = true;
            }
            else
            {
                string num = this.transform.gameObject.GetComponentInChildren <Text>().text;

                this.transform.gameObject.GetComponentInChildren <Text>().text      = d.transform.gameObject.GetComponentInChildren <Text>().text;
                this.transform.gameObject.GetComponentInChildren <Text>().fontStyle = d.transform.gameObject.GetComponentInChildren <Text>().fontStyle;
                this.transform.gameObject.GetComponentInChildren <Text>().fontSize  = d.transform.gameObject.GetComponentInChildren <Text>().fontSize;
                this.transform.gameObject.GetComponentInChildren <Text>().alignment = d.transform.gameObject.GetComponentInChildren <Text>().alignment;
                this.transform.gameObject.GetComponent <CanvasGroup>().alpha        = 1f;

                if (d.cardType == Drag.CardType.Number)
                {
                    d.gameObject.GetComponent <CanvasGroup>().alpha = 0.6f;
                    d.active            = false;
                    d.droppedToLocation = true;

                    if (game.numberOne.GetComponentInChildren <Text>().text == num && !game.numberOne.GetComponent <Drag>().active)
                    {
                        game.numberOne.GetComponent <Drag>().active = true;
                        game.numberOne.GetComponent <Drag>().GetComponent <CanvasGroup>().alpha = 1f;
                    }
                    else if (game.numberTwo.GetComponentInChildren <Text>().text == num && !game.numberTwo.GetComponent <Drag>().active)
                    {
                        game.numberTwo.GetComponent <Drag>().active = true;
                        game.numberTwo.GetComponent <Drag>().GetComponent <CanvasGroup>().alpha = 1f;
                    }
                    else if (game.numberThree.GetComponentInChildren <Text>().text == num && !game.numberThree.GetComponent <Drag>().active)
                    {
                        game.numberThree.GetComponent <Drag>().active = true;
                        game.numberThree.GetComponent <Drag>().GetComponent <CanvasGroup>().alpha = 1f;
                    }
                }
                else
                {
                    d.gameObject.GetComponent <CanvasGroup>().alpha = 1f;
                    d.active = true;
                }
            }
        }
    }