예제 #1
0
    // Use this for initialization
    void Start()
    {
        PlayerIcon.GetComponent <SpriteRenderer>().enabled = true;
        A1.GetComponent <SpriteRenderer>().enabled         = false;
        A2.GetComponent <SpriteRenderer>().enabled         = false;
        A3.GetComponent <SpriteRenderer>().enabled         = false;
        A4.GetComponent <SpriteRenderer>().enabled         = false;
        A5.GetComponent <SpriteRenderer>().enabled         = false;
        A6.GetComponent <SpriteRenderer>().enabled         = false;
        A7.GetComponent <SpriteRenderer>().enabled         = false;
        A8.GetComponent <SpriteRenderer>().enabled         = false;
        A9.GetComponent <SpriteRenderer>().enabled         = false;
        A10.GetComponent <SpriteRenderer>().enabled        = false;
        A11.GetComponent <SpriteRenderer>().enabled        = false;
        B1.GetComponent <SpriteRenderer>().enabled         = false;
        B2.GetComponent <SpriteRenderer>().enabled         = false;
        B3.GetComponent <SpriteRenderer>().enabled         = false;
        B4.GetComponent <SpriteRenderer>().enabled         = false;
        B5.GetComponent <SpriteRenderer>().enabled         = false;
        B6.GetComponent <SpriteRenderer>().enabled         = false;
        B7.GetComponent <SpriteRenderer>().enabled         = false;
        B8.GetComponent <SpriteRenderer>().enabled         = false;
        B9.GetComponent <SpriteRenderer>().enabled         = false;
        B10.GetComponent <SpriteRenderer>().enabled        = false;
        B11.GetComponent <SpriteRenderer>().enabled        = false;
        C1.GetComponent <SpriteRenderer>().enabled         = false;
        C2.GetComponent <SpriteRenderer>().enabled         = false;
        C3.GetComponent <SpriteRenderer>().enabled         = false;
        C4.GetComponent <SpriteRenderer>().enabled         = false;
        C5.GetComponent <SpriteRenderer>().enabled         = false;
        C6.GetComponent <SpriteRenderer>().enabled         = false;
        C7.GetComponent <SpriteRenderer>().enabled         = false;
        C8.GetComponent <SpriteRenderer>().enabled         = false;
        C9.GetComponent <SpriteRenderer>().enabled         = false;
        C10.GetComponent <SpriteRenderer>().enabled        = false;
        C11.GetComponent <SpriteRenderer>().enabled        = false;
        D1.GetComponent <SpriteRenderer>().enabled         = false;
        D2.GetComponent <SpriteRenderer>().enabled         = false;
        D3.GetComponent <SpriteRenderer>().enabled         = false;
        D4.GetComponent <SpriteRenderer>().enabled         = false;
        D5.GetComponent <SpriteRenderer>().enabled         = false;
        D6.GetComponent <SpriteRenderer>().enabled         = false;
        D7.GetComponent <SpriteRenderer>().enabled         = false;
        D8.GetComponent <SpriteRenderer>().enabled         = false;
        D9.GetComponent <SpriteRenderer>().enabled         = false;
        D10.GetComponent <SpriteRenderer>().enabled        = false;
        D11.GetComponent <SpriteRenderer>().enabled        = false;
        E1.GetComponent <SpriteRenderer>().enabled         = false;
        E2.GetComponent <SpriteRenderer>().enabled         = false;
        E3.GetComponent <SpriteRenderer>().enabled         = false;
        E4.GetComponent <SpriteRenderer>().enabled         = false;
        E5.GetComponent <SpriteRenderer>().enabled         = false;
        E6.GetComponent <SpriteRenderer>().enabled         = false;
        E7.GetComponent <SpriteRenderer>().enabled         = false;
        E8.GetComponent <SpriteRenderer>().enabled         = false;
        E9.GetComponent <SpriteRenderer>().enabled         = false;
        E10.GetComponent <SpriteRenderer>().enabled        = false;
        E11.GetComponent <SpriteRenderer>().enabled        = false;
        F1.GetComponent <SpriteRenderer>().enabled         = false;
        F2.GetComponent <SpriteRenderer>().enabled         = false;
        F3.GetComponent <SpriteRenderer>().enabled         = false;
        F4.GetComponent <SpriteRenderer>().enabled         = false;
        F5.GetComponent <SpriteRenderer>().enabled         = false;
        F6.GetComponent <SpriteRenderer>().enabled         = false;
        F7.GetComponent <SpriteRenderer>().enabled         = false;
        F8.GetComponent <SpriteRenderer>().enabled         = false;
        F9.GetComponent <SpriteRenderer>().enabled         = false;
        F10.GetComponent <SpriteRenderer>().enabled        = false;
        F11.GetComponent <SpriteRenderer>().enabled        = false;
        G1.GetComponent <SpriteRenderer>().enabled         = false;
        G2.GetComponent <SpriteRenderer>().enabled         = false;
        G3.GetComponent <SpriteRenderer>().enabled         = false;
        G4.GetComponent <SpriteRenderer>().enabled         = false;
        G5.GetComponent <SpriteRenderer>().enabled         = false;
        G6.GetComponent <SpriteRenderer>().enabled         = false;
        G7.GetComponent <SpriteRenderer>().enabled         = false;
        G8.GetComponent <SpriteRenderer>().enabled         = false;
        G9.GetComponent <SpriteRenderer>().enabled         = false;
        G10.GetComponent <SpriteRenderer>().enabled        = false;
        G11.GetComponent <SpriteRenderer>().enabled        = false;
        H1.GetComponent <SpriteRenderer>().enabled         = false;
        H2.GetComponent <SpriteRenderer>().enabled         = false;
        H3.GetComponent <SpriteRenderer>().enabled         = false;
        H4.GetComponent <SpriteRenderer>().enabled         = false;
        H5.GetComponent <SpriteRenderer>().enabled         = false;
        H6.GetComponent <SpriteRenderer>().enabled         = false;
        H7.GetComponent <SpriteRenderer>().enabled         = false;
        H8.GetComponent <SpriteRenderer>().enabled         = false;
        H9.GetComponent <SpriteRenderer>().enabled         = false;
        H10.GetComponent <SpriteRenderer>().enabled        = false;
        H11.GetComponent <SpriteRenderer>().enabled        = false;
        I1.GetComponent <SpriteRenderer>().enabled         = false;
        I2.GetComponent <SpriteRenderer>().enabled         = false;
        I3.GetComponent <SpriteRenderer>().enabled         = false;
        I4.GetComponent <SpriteRenderer>().enabled         = false;
        I5.GetComponent <SpriteRenderer>().enabled         = false;
        I6.GetComponent <SpriteRenderer>().enabled         = false;
        I7.GetComponent <SpriteRenderer>().enabled         = false;
        I8.GetComponent <SpriteRenderer>().enabled         = false;
        I9.GetComponent <SpriteRenderer>().enabled         = false;
        I10.GetComponent <SpriteRenderer>().enabled        = false;
        I11.GetComponent <SpriteRenderer>().enabled        = false;
        J1.GetComponent <SpriteRenderer>().enabled         = false;
        J2.GetComponent <SpriteRenderer>().enabled         = false;
        J3.GetComponent <SpriteRenderer>().enabled         = false;
        J4.GetComponent <SpriteRenderer>().enabled         = false;
        J5.GetComponent <SpriteRenderer>().enabled         = false;
        J6.GetComponent <SpriteRenderer>().enabled         = false;
        J7.GetComponent <SpriteRenderer>().enabled         = false;
        J8.GetComponent <SpriteRenderer>().enabled         = false;
        J9.GetComponent <SpriteRenderer>().enabled         = false;
        J10.GetComponent <SpriteRenderer>().enabled        = false;
        J11.GetComponent <SpriteRenderer>().enabled        = false;
        K1.GetComponent <SpriteRenderer>().enabled         = false;
        K2.GetComponent <SpriteRenderer>().enabled         = false;
        K3.GetComponent <SpriteRenderer>().enabled         = false;
        K4.GetComponent <SpriteRenderer>().enabled         = false;
        K5.GetComponent <SpriteRenderer>().enabled         = false;
        K6.GetComponent <SpriteRenderer>().enabled         = false;
        K7.GetComponent <SpriteRenderer>().enabled         = false;
        K8.GetComponent <SpriteRenderer>().enabled         = false;
        K9.GetComponent <SpriteRenderer>().enabled         = false;
        K10.GetComponent <SpriteRenderer>().enabled        = false;
        K11.GetComponent <SpriteRenderer>().enabled        = false;
        float ratio = Screen.width / Screen.height;

        if (ratio < 2)
        {
            int screenx = 543;
            int screeny = 653;
        }
        else
        {
            int screenx = 743;
            int screeny = 853;
        }
    }
    // Update is called once per frame
    void Update()
    {
        po1 = O1.transform.position;
        po2 = O2.transform.position;
        po3 = O3.transform.position;
        pd1 = D1.transform.position;
        pd2 = D2.transform.position;
        pd3 = D3.transform.position;
        pb  = ball.transform.position;


        StartCoroutine(DelayMethod(23f, () => {
            SceneManager.LoadScene("3DLesson4-2");
        }));

        /*StartCoroutine(DelayMethod(10f, () =>
         *  {
         *      if (begin == 1)
         *      {
         *          begin = 0;
         *          O1.transform.position = so1;
         *          O2.transform.position = so2;
         *          O3.transform.position = so3;
         *          D1.transform.position = sd1;
         *          D2.transform.position = sd2;
         *          D3.transform.position = sd3;
         *          ball.transform.position = sb;
         *          // Debug.Log(begin);
         *          O1.transform.rotation = ro1;
         *          O2.transform.rotation = ro2;
         *          O3.transform.rotation = ro3;
         *          D1.transform.rotation = rd1;
         *          D2.transform.rotation = rd2;
         *          D3.transform.rotation = rd3;
         *          this.transform.parent = null;
         *          //ball.transform.parent = O1.transform;
         *          flag = 0; flag2 = 0;
         *          game();
         *      }
         *
         *
         *  }));*/

        StartCoroutine(DelayMethod(5f, () => {
            Debug.Log(true);
            //text1.text = "ずっと同じスピードで動いていると\n逆にディフェンスは付いて行きやすい";
            if (flag == 0)
            {
                iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po3.x - 0.3f, pb.y, po3.z - 0.3f), "Time", 2f));
                O1.transform.rotation = Quaternion.Euler(0, -10, 0);
                O1.GetComponent <Animator>().SetBool("runrun", true);
            }

            if (flag == 1)
            {
                O1.transform.rotation = Quaternion.Euler(0, 100, 0);
                O1.GetComponent <Animator>().SetBool("runrun", true);
            }

            if (flag == 2)
            {
                O1.transform.rotation = Quaternion.Euler(0, 120, 0);
                O1.GetComponent <Animator>().SetBool("runrun", true);
            }

            StartCoroutine(DelayMethod(0.3f, () =>
            {
                //Vector3 dir = po1 - pd1;
                if (flag2 == 0)
                {
                    Vector3 dir           = po1 - pd1;
                    D1.transform.position = (D1.transform.position + (dir.normalized * 1 * Time.deltaTime));
                    D1.transform.LookAt(O1.transform);
                    D1.GetComponent <Animator>().SetBool("runrun", true);
                }
            }));


            StartCoroutine(DelayMethod(2f, () =>
            {
                if (flag < 2)
                {
                    O2.transform.rotation = Quaternion.Euler(0, -130, 0);
                    O2.GetComponent <Animator>().SetBool("runrun", true);
                    O2.GetComponent <Animator>().speed = 1.2f;
                    D2.transform.rotation = Quaternion.Euler(0, -130, 0);
                    D2.GetComponent <Animator>().SetBool("runrun", true);
                    D2.GetComponent <Animator>().speed = 1.0f;
                }
            }));


            StartCoroutine(DelayMethod(7f, () =>
            {
                if (flag == 3)
                {
                    O1.transform.rotation = Quaternion.Euler(0, -60, 0);
                    O1.GetComponent <Animator>().SetBool("runrun", true);
                }
            }));

            StartCoroutine(DelayMethod(7.5f, () =>
            {
                if (flag == 3)
                {
                    D1.transform.rotation = Quaternion.Euler(0, -60, 0);
                    D1.GetComponent <Animator>().SetBool("runrun", true);
                }
            }));


            StartCoroutine(DelayMethod(11f, () =>
            {
                if (flag == 4)
                {
                    O1.transform.rotation = Quaternion.Euler(0, 120, 0);
                    O1.GetComponent <Animator>().SetBool("runrun", true);
                }
            }));

            StartCoroutine(DelayMethod(11.3f, () =>
            {
                if (flag == 4)
                {
                    D1.transform.rotation = Quaternion.Euler(0, 120, 0);
                    D1.GetComponent <Animator>().SetBool("runrun", true);
                }
            }));

            /* StartCoroutine(DelayMethod(11.3f, () =>
             * {
             *   SceneManager.LoadScene("3DLesson4-2");
             * }));*/
        }));


        /*---------------------------------------------------------------------------------*/

        if ((Mathf.Abs(pb.x - po3.x) <= 0.5f) && (Mathf.Abs(pb.z - po3.z) <= 0.5f))
        {
            this.transform.position = po3;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po3.z - 0.3f;
            this.transform.position = pospos;

            this.GetComponent <Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O3.transform;
        }

        if ((Mathf.Abs(pb.x - po2.x) <= 0.5f) && (Mathf.Abs(pb.z - po2.z) <= 0.5f))
        {
            this.transform.position = po2;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po2.z - 0.3f;
            this.transform.position = pospos;

            this.GetComponent <Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O2.transform;
        }


        if ((Mathf.Abs(pb.x - po1.x) <= 0.5f) && (Mathf.Abs(pb.z - po1.z) <= 0.5f))
        {
            this.transform.position = po1;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po1.z - 0.3f;
            this.transform.position = pospos;

            this.GetComponent <Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O1.transform;
        }
        /*---------------------------------------------------------------------------------*/

        if (flag == 0 && po1.z >= 11.5f)
        {
            flag = 1;
            O1.GetComponent <Animator> ().SetBool("runrun", false);
        }

        if (flag == 1 && po1.x >= 1.4f)
        {
            flag = 2;
            //flag2 = 1;
            //O1.GetComponent<Animator> ().SetBool ("runrun", false);
            //D1.GetComponent<Animator> ().SetBool ("runrun", false);
        }

        if (flag == 2 && flag2 == 0 && po1.x >= 4f)
        {
            flag  = 3;
            flag2 = 1;
            //Debug.Log(flag2);
            O1.transform.rotation = Quaternion.Euler(0, -120, 0);
            O1.GetComponent <Animator> ().SetBool("runrun", false);
            D1.transform.rotation = Quaternion.Euler(0, 160, 0);
            D1.GetComponent <Animator> ().SetBool("runrun", false);
        }

        if (po2.x <= 0f)
        {
//			flag = 2; flag2 = 1;
            O2.transform.rotation = Quaternion.Euler(0, -35, 0);
            O2.GetComponent <Animator> ().SetBool("runrun", false);
            D2.GetComponent <Animator> ().SetBool("runrun", false);
        }

        if (flag == 3 && po1.x <= 0.8f)
        {
            flag  = 4;
            flag2 = 2;
            // O1.transform.rotation = Quaternion.Euler(0, 120, 0);
            O1.GetComponent <Animator>().SetBool("runrun", false);
            D1.transform.rotation = Quaternion.Euler(0, 120, 0);
            D1.GetComponent <Animator>().SetBool("runrun", false);
        }

        if (flag == 4 && po1.x >= 4.0f)
        {
            flag  = 5;
            flag2 = 3;
            O1.transform.rotation = Quaternion.Euler(0, -120, 0);
            O1.GetComponent <Animator>().SetBool("runrun", false);
            D1.transform.rotation = Quaternion.Euler(0, 180, 0);
            D1.GetComponent <Animator>().SetBool("runrun", false);
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        po1 = O1.transform.position;
        po2 = O2.transform.position;
        po3 = O3.transform.position;
        pd1 = D1.transform.position;
        pd2 = D2.transform.position;
        pd3 = D3.transform.position;
        pb  = ball.transform.position;


        if (flag == 0)
        {
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x - 0.3f, pb.y, po2.z - 0.3f), "Time", 2f));
        }

        StartCoroutine(DelayMethod(1f, () => {
            if (flag == 0)
            {
                //O1.transform.rotation = Quaternion.Euler(0, 10, 0);
                O1.GetComponent <Animator>().SetBool("runrun", true);
                O1.transform.position += new Vector3(1.2f, O1.transform.position.y, 1.5f) * 0.001f;
            }
            /*--------------------------------------------------------------------------------*/
            StartCoroutine(DelayMethod(5f, () => {
                //flag=1;
                if (flag2 == 0)
                {
                    D1.transform.rotation = Quaternion.Euler(0, 15, 0);
                    D1.GetComponent <Animator>().SetBool("runrun", true);
                }
            }));

            /*--------------------------------------------------------------------------------*/
            StartCoroutine(DelayMethod(10f, () => {
                //flag=2;
                Debug.Log(flag);
                if (flag == 1)
                {
                }
            }));

            StartCoroutine(DelayMethod(15f, () => {
                if (flag == 1)
                {
                    O3.transform.rotation = Quaternion.Euler(0, 130, 0);
                    O3.GetComponent <Animator>().SetBool("runrun", true);
                    O3.GetComponent <Animator> ().speed = 1.3f;
                    D3.transform.rotation = Quaternion.Euler(0, 140, 0);
                    D3.GetComponent <Animator>().SetBool("runrun", true);
                    D3.GetComponent <Animator> ().speed = 1f;
                }
            }));
            /*--------------------------------------------------------------------------------*/

            StartCoroutine(DelayMethod(20f, () => {
                if (flag == 2)
                {
                }
            }));

            StartCoroutine(DelayMethod(25f, () => {
                if (flag == 2 && flag2 == 1)
                {
                    //O1.transform.Rotate(0, -3f, 0);
                    O1.transform.rotation = Quaternion.Euler(0, 260, 0);
                    O1.GetComponent <Animator>().SetBool("runrun", true);
                    //O1.GetComponent<Animator> ().speed = 1.3f;
                    O1.transform.position += new Vector3(-6.1f, O1.transform.position.y, 0.3f) * 0.001f;
                    D1.transform.rotation  = Quaternion.Euler(0, 260, 0);
                    D1.GetComponent <Animator>().SetBool("runrun", true);
                    D1.GetComponent <Animator> ().speed = 1.1f;
                }
            }));
            /*--------------------------------------------------------------------------------*/
            StartCoroutine(DelayMethod(30f, () => {
                if (flag == 3)
                {
                }
            }));

            StartCoroutine(DelayMethod(35f, () => {
                if (flag == 3)
                {
                    O3.transform.rotation = Quaternion.Euler(0, -10, 0);
                    O3.GetComponent <Animator>().SetBool("runrun", true);
                    O3.GetComponent <Animator> ().speed = 1.3f;
                }
            }));

            StartCoroutine(DelayMethod(35.5f, () => {
                if (flag == 3)
                {
                    D3.transform.rotation = Quaternion.Euler(0, -10, 0);
                    D3.GetComponent <Animator>().SetBool("runrun", true);
                    D3.GetComponent <Animator> ().speed = 1.1f;
                }
            }));
            /*--------------------------------------------------------------------------------*/
            StartCoroutine(DelayMethod(40.5f, () => {
                if (flag == 4)
                {
                }
            }));

            StartCoroutine(DelayMethod(45.5f, () => {
                if (flag == 4)
                {
                    //text1.text="そうするとはじめてスペースが空くので\nそのスペースにボールをもらいに行って\nスペースを埋める";
                    //GameObject.Find("/Marker/circle").GetComponent<Renderer>().enabled=true;
                    O2.transform.rotation = Quaternion.Euler(0, -125, 0);
                    O2.GetComponent <Animator>().SetBool("runrun", true);
                    O2.GetComponent <Animator> ().speed = 1.3f;
                    D2.transform.rotation = Quaternion.Euler(0, -120, 0);
                    D2.GetComponent <Animator>().SetBool("runrun", true);
                    D2.GetComponent <Animator> ().speed = 1f;
                }
            }));
            /*--------------------------------------------------------------------------------*/
            StartCoroutine(DelayMethod(50.5f, () => {
                if (flag == 5)
                {
                }
            }));

            StartCoroutine(DelayMethod(55.5f, () => {
                if (flag == 5)
                {
                    //text1.text="そうするとはじめてスペースが空くので\nそのスペースにボールをもらいに行って\nスペースを埋める";
                    //GameObject.Find("/Marker/circle").GetComponent<Renderer>().enabled=true;
                    O3.transform.rotation = Quaternion.Euler(0, 115, 0);
                    O3.GetComponent <Animator>().SetBool("runrun", true);
                    O3.GetComponent <Animator> ().speed = 1.3f;
                    D3.transform.rotation = Quaternion.Euler(0, 110, 0);
                    D3.GetComponent <Animator>().SetBool("runrun", true);
                    D3.GetComponent <Animator> ().speed = 1.0f;
                }
            }));
            /*--------------------------------------------------------------------------------*/
        }));



        if (flag == 0 && po1.z >= 11f)
        {
            flag = 1;
            //O1.transform.rotation = Quaternion.Euler(0, 90, 0);
            O1.GetComponent <Animator>().SetBool("runrun", false);
        }

        if (flag2 == 0 && pd1.z >= 10.3f)
        {
            flag2 = 1;
            D1.GetComponent <Animator>().SetBool("runrun", false);
        }

        if (flag == 1 && po3.x >= 0)
        {
            flag = 2;
            O3.transform.rotation = Quaternion.Euler(0, 30, 0);
            O3.GetComponent <Animator> ().SetBool("runrun", false);
            D3.GetComponent <Animator> ().SetBool("runrun", false);
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po3.x + 0.3f, pb.y, po3.z + 0.4f), "Time", 2f));
        }

        if (flag == 2 && flag2 == 1 && po1.x <= -4.5f)
        {
            //flag = 4;
            O1.GetComponent <Animator>().SetBool("runrun", false);

            O1.transform.rotation = Quaternion.Euler(0, 140, 0);
            O3.transform.rotation = Quaternion.Euler(0, -40, 0);
            flag = 3;
            D1.GetComponent <Animator>().SetBool("runrun", false);
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po1.x + 0.5f, pb.y, po1.z - 0.6f), "Time", 2f));
        }


        if (flag == 3 && po3.z >= 11f)
        {
            flag = 4;
            //O1.transform.rotation = Quaternion.Euler(0, 90, 0);
            O3.GetComponent <Animator>().SetBool("runrun", false);
            D3.GetComponent <Animator>().SetBool("runrun", false);
            O3.transform.rotation = Quaternion.Euler(0, -120, 0);
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po3.x - 0.5f, pb.y, po3.z - 0.3f), "Time", 2f));
        }

        if (flag == 4 && po2.x <= 0)
        {
            flag = 5;
            O2.GetComponent <Animator>().SetBool("runrun", false);
            D2.GetComponent <Animator>().SetBool("runrun", false);
            O2.transform.rotation = Quaternion.Euler(0, 0, 0);
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x - 0.2f, pb.y, po2.z + 0.3f), "Time", 2f));
        }

        if (flag == 5 && po3.x >= 4.3f)
        {
            flag = 6;
            O3.GetComponent <Animator>().SetBool("runrun", false);
            D3.GetComponent <Animator>().SetBool("runrun", false);
            O3.transform.rotation = Quaternion.Euler(0, -120, 0);
        }
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        po1 = O1.transform.position;
        po2 = O2.transform.position;
        po3 = O3.transform.position;
        pd1 = D1.transform.position;
        pd2 = D2.transform.position;
        pd3 = D3.transform.position;
        pb  = ball.transform.position;

        //if (!gestureListener)
        //return;

        StartCoroutine(DelayMethod(25f, () =>
        {
            SceneManager.LoadScene("3DLesson5-1");
        }));

        StartCoroutine(DelayMethod(8f, () => {
            if (flag == 0)
            {
                iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po3.x + 0f, pb.y, po3.z - 0.3f), "Time", 2f));
                O1.transform.rotation = Quaternion.Euler(0, -10, 0);


                O1.GetComponent <Animator>().SetBool("runrun", true);
                O1.GetComponent <Animator>().speed = 0.9f;

                StartCoroutine(DelayMethod(1f, () => {
                    Vector3 dir = po1 - pd1;
                    if (flag2 == 0)
                    {
                        D1.transform.position = (D1.transform.position + (dir.normalized * 1 * Time.deltaTime));
                        D1.transform.LookAt(O1.transform);
                        D1.GetComponent <Animator>().SetBool("runrun", true);
                    }
                }));
            }

            if (flag == 1)
            {
                O1.transform.rotation = Quaternion.Euler(0, 100, 0);
                O1.GetComponent <Animator>().SetBool("runrun", true);
                O1.GetComponent <Animator>().speed = 0.8f;

                Vector3 dir           = po1 - pd1;
                D1.transform.position = (D1.transform.position + (dir.normalized * 1 * Time.deltaTime));
                D1.transform.LookAt(O1.transform);
                D1.GetComponent <Animator>().SetBool("runrun", true);
                // iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x, pb.y, po2.z + 0.3f), "Time", 2f));
            }


            if (flag == 2 && flag3 == 0)
            {
                O2.transform.rotation = Quaternion.Euler(0, -120, 0);
                O2.GetComponent <Animator>().SetBool("runrun", true);
                O2.GetComponent <Animator>().speed = 1.0f;
                D2.transform.rotation = Quaternion.Euler(0, -120, 0);
                D2.GetComponent <Animator>().SetBool("runrun", true);
                D2.GetComponent <Animator>().speed = 1.0f;
            }

            if (flag3 == 1)
            {
                O2.transform.rotation = Quaternion.Euler(0, 190, 0);
                D2.transform.rotation = Quaternion.Euler(0, 170, 0);

                O2.GetComponent <Animator>().SetBool("runrun", true);
                O2.GetComponent <Animator>().speed = 1.3f;
                D2.GetComponent <Animator>().SetBool("runrun", true);
                D2.GetComponent <Animator>().speed = 0.9f;
            }


            if (flag3 == 2 && flag == 2 && flag2 == 1)
            {
                O1.transform.rotation = Quaternion.Euler(0, 150, 0);
                O1.GetComponent <Animator>().SetBool("runrun", true);
                O1.GetComponent <Animator>().speed = 1.2f;
                D1.transform.rotation = Quaternion.Euler(0, 150, 0);
                D1.GetComponent <Animator>().SetBool("runrun", true);
                D1.GetComponent <Animator>().speed = 1.0f;
            }

            if (flag == 3 && flag2 == 2)
            {
                O2.transform.rotation = Quaternion.Euler(0, 20, 0);
                O2.GetComponent <Animator>().SetBool("runrun", true);
                O2.GetComponent <Animator>().speed = 1.2f;
                D2.transform.rotation = Quaternion.Euler(0, 20, 0);
                D2.GetComponent <Animator>().SetBool("runrun", true);
                D2.GetComponent <Animator>().speed = 1.0f;
                //Vector3 dir = po2 - pd2;
                //D2.transform.position = (D2.transform.position + (dir.normalized * 1 * Time.deltaTime));
                //D2.transform.LookAt(O2.transform);
                //D2.GetComponent<Animator>().SetBool("runrun", true);
            }

            if (flag == 4)
            {
                O3.transform.rotation = Quaternion.Euler(0, 130, 0);
                O3.GetComponent <Animator>().SetBool("runrun", true);
                O3.GetComponent <Animator>().speed = 1.3f;
                D3.transform.rotation = Quaternion.Euler(0, 130, 0);
                D3.GetComponent <Animator>().SetBool("runrun", true);
                D3.GetComponent <Animator>().speed = 1.0f;
            }

            if (flag == 5 && flag2 == 4)
            {
                //StartCoroutine(DelayMethod(1.0f, () => {

                O2.transform.rotation = Quaternion.Euler(0, 230, 0);
                O2.GetComponent <Animator>().SetBool("runrun", true);
                O2.GetComponent <Animator>().speed = 1.1f;
                D2.transform.rotation = Quaternion.Euler(0, 230, 0);
                D2.GetComponent <Animator>().SetBool("runrun", true);
                D2.GetComponent <Animator>().speed = 1.1f;
                //}));
            }

            if (flag == 6 && flag2 == 5)
            {
                StartCoroutine(DelayMethod(0.2f, () =>
                {
                    O2.transform.rotation = Quaternion.Euler(0, 50, 0);
                    O2.GetComponent <Animator>().SetBool("runrun", true);
                    O2.GetComponent <Animator>().speed = 1.3f;
                    iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x + 0.3f, pb.y, po2.z + 0.3f), "Time", 1f));
                    //D2.transform.rotation = Quaternion.Euler(0, 50, 0);
                    //D2.GetComponent<Animator>().SetBool("runrun", true);
                    //D2.GetComponent<Animator>().speed = 1.1f;

                    StartCoroutine(DelayMethod(0.2f, () =>
                    {
                        if (flag2 == 5)
                        {
                            D2.transform.rotation = Quaternion.Euler(0, 50, 0);
                            D2.GetComponent <Animator>().SetBool("runrun", true);
                            D2.GetComponent <Animator>().speed = 1.2f;
                        }
                    }));
                }));
            }
        }));


        /*StartCoroutine (DelayMethod (10f, () => {
         *  //GameObject.Find("KinectController").GetComponent<KinectManager>().OnDestroy();
         *  SceneManager.LoadScene("3DLesson4-2");
         *      }));*/



        /*---------------------------------------------------------------------------------*/

        if ((Mathf.Abs(pb.x - po3.x) <= 0.5f) && (Mathf.Abs(pb.z - po3.z) <= 0.5f))
        {
            this.transform.position = po3;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po3.z + 0.3f;
            this.transform.position = pospos;

            //this.GetComponent<Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O3.transform;
        }

        if ((Mathf.Abs(pb.x - po2.x) <= 0.5f) && (Mathf.Abs(pb.z - po2.z) <= 0.5f))
        {
            this.transform.position = po2;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po2.z + 0.3f;
            this.transform.position = pospos;

            //this.GetComponent<Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O2.transform;
        }


        if ((Mathf.Abs(pb.x - po1.x) <= 0.5f) && (Mathf.Abs(pb.z - po1.z) <= 0.5f))
        {
            this.transform.position = po1;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.5f;
            pospos.z = po1.z - 0.2f;
            this.transform.position = pospos;

            this.GetComponent <Rigidbody>().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O1.transform;
        }
        /*---------------------------------------------------------------------------------*/

        if (flag == 0 && po1.z >= 11.5f)
        {
            flag = 1;
            O1.GetComponent <Animator>().SetBool("runrun", false);
            //D1.GetComponent<Animator> ().SetBool ("runrun", false);
        }

        if (flag == 1 && po1.x >= 1.4f)
        {
            flag  = 2;
            flag2 = 1;
            O1.transform.rotation = Quaternion.Euler(0, 180, 0);
            O1.GetComponent <Animator>().SetBool("runrun", false);
            D1.GetComponent <Animator>().SetBool("runrun", false);
        }

        if (flag3 == 0 && po2.x <= 1.0f)
        {
            flag3 = 1;
            //O2.transform.rotation = Quaternion.Euler(0, 190, 0);
            //D2.transform.rotation = Quaternion.Euler(0, 170, 0);
        }

        if (flag3 == 1 && po2.z <= 4f)
        {
            flag3 = 2;
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x + 0f, pb.y, po2.z - 0f), "Time", 2f));
            O2.transform.rotation = Quaternion.Euler(0, 0, 0);
            O2.GetComponent <Animator>().SetBool("runrun", false);
            D2.GetComponent <Animator>().SetBool("runrun", false);
        }

        /*if (flag3 == 1 && po2.x <= -2.5f)
         * {
         * // iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po3.x + 0f, pb.y, po3.z - 0.3f), "Time", 2f));
         *  flag3 = 10;
         *  O2.GetComponent<Animator>().SetBool("runrun", false);
         *  D2.GetComponent<Animator>().SetBool("runrun", false);
         * }*/

        if (flag == 2 && po1.x >= 4.0f)
        {
            flag  = 3;
            flag2 = 2;
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po1.x, pb.y, po1.z + 0f), "Time", 1.5f));
            O1.transform.rotation = Quaternion.Euler(0, -120, 0);
            O1.GetComponent <Animator> ().SetBool("runrun", false);
            D1.transform.rotation = Quaternion.Euler(0, 160, 0);
            D1.GetComponent <Animator> ().SetBool("runrun", false);
        }

        if (flag == 3 && po2.z >= 12f)
        {
            flag = 4; flag2 = 3;
            O2.transform.rotation = Quaternion.Euler(0, -100, 0);
            D2.transform.rotation = Quaternion.Euler(0, -100, 0);
        }

        if (flag == 4 && flag2 == 3 && po2.x <= -1.5f)
        {
            flag = 5; flag2 = 4;
            O2.transform.rotation = Quaternion.Euler(0, 190, 0);
            O2.GetComponent <Animator>().SetBool("runrun", false);
            D2.transform.rotation = Quaternion.Euler(0, 160, 0);
            D2.GetComponent <Animator>().SetBool("runrun", false);
        }

        if ((flag4 == 0) && po3.x >= -0.5f)
        {
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po3.x, pb.y, po3.z + 0f), "Time", 1.5f));
            O3.transform.rotation = Quaternion.Euler(0, -15, 0);
            O3.GetComponent <Animator>().SetBool("runrun", false);
            D3.transform.rotation = Quaternion.Euler(0, 170, 0);
            D3.GetComponent <Animator>().SetBool("runrun", false);
            flag4 = 1;
        }

        if (flag == 5 && flag2 == 4 && po2.x <= -3.5f)
        {
            flag = 6; flag2 = 5;
        }

        if (flag4 == 1 && po2.x >= -1.5f)
        {
            flag = 7; flag2 = 6;
            // iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x + 0f, pb.y, po2.z + 0f), "Time", 1f));
            //O2.transform.rotation = Quaternion.Euler(0, 50, 0);
            O2.GetComponent <Animator>().SetBool("runrun", false);
            //D2.transform.rotation = Quaternion.Euler(0, 50, 0);
            D2.GetComponent <Animator>().SetBool("runrun", false);
        }


        /* if (flag3 == 1 && po3.z >= 10f)
         * {
         *   flag3 = 2;
         *   O3.GetComponent<Animator>().SetBool("runrun", false);
         *   D3.GetComponent<Animator>().SetBool("runrun", false);
         * }*/

        /*---------------------------------------------------------------------------------*/
    }
    // Update is called once per frame
    void Update()
    {
        po1 = O1.transform.position;
        po2 = O2.transform.position;
        po3 = O3.transform.position;
        pd1 = D1.transform.position;
        pd2 = D2.transform.position;
        pd3 = D3.transform.position;
        pb  = ball.transform.position;

        // if (!gestureListener)
        //return;

        StartCoroutine(DelayMethod(23f, () =>
        {
            SceneManager.LoadScene("3DLesson4");
        }));


        StartCoroutine(DelayMethod(3f, () => {
            //text1.text = "";
            // delete_view();
            if (flag < 1)
            {
                //text1.text = "そこで動きに強弱をつけると\nディフェンスは付いて行きづらい";
            }
            if (flag == 0)
            {
                iTween.MoveUpdate(ball, iTween.Hash("position", new Vector3(po3.x - 0.3f, pb.y, po3.z - 0.3f), "Time", 2f));
                O1.transform.rotation = Quaternion.Euler(0, -10, 0);
                O1.GetComponent <Animator> ().SetBool("runrun", true);
                O1.GetComponent <Animator>().speed = 0.9f;
            }

            if (flag == 1)
            {
                O1.transform.rotation = Quaternion.Euler(0, 100, 0);
                O1.GetComponent <Animator> ().SetBool("runrun", true);
                O1.GetComponent <Animator>().speed = 0.8f;
                // iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x, pb.y, po2.z + 0.3f), "Time", 2f));
            }

            if (flag >= 1)
            {
                // text1.text = "具体的に言うと、<青矢印>までゆっくり動いて\nそこから<赤矢印>までを早くする、という具合に動きに緩急をつける";
                GameObject.Find("/Marker/RadarCursor_Blue/Cursor1").GetComponent <Renderer>().enabled = true;
                GameObject.Find("/Marker/RadarCursor_Blue/Cursor2").GetComponent <Renderer>().enabled = true;
                GameObject.Find("/Marker/RadarCursor_Blue/Cursor3").GetComponent <Renderer>().enabled = true;
                GameObject.Find("/Marker/RadarCursor_Red/Cursor1").GetComponent <Renderer>().enabled  = true;
                GameObject.Find("/Marker/RadarCursor_Red/Cursor2").GetComponent <Renderer>().enabled  = true;
                GameObject.Find("/Marker/RadarCursor_Red/Cursor3").GetComponent <Renderer>().enabled  = true;
            }

            /*-------------カッティングに強弱をつける-------------*/

            StartCoroutine(DelayMethod(5f, () => {
                //flag2=1;
                Vector3 dir = po1 - pd1;
                if (flag == 2 && flag2 == 1)
                {
                    iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x, pb.y, po2.z + 0.3f), "Time", 2f));
                    O1.transform.rotation = Quaternion.Euler(0, 190, 0);
                    O1.GetComponent <Animator>().SetBool("runrun", true);
                    O1.GetComponent <Animator>().speed = 0.8f;

                    D1.transform.rotation = Quaternion.Euler(0, 180, 0);
                    D1.GetComponent <Animator>().SetBool("runrun", true);
                    D1.GetComponent <Animator>().speed = 0.8f;
                }

                if (flag == 3)
                {
                    //ball.GetComponent<Rigidbody>().AddForce((new Vector3(po1.x+3f, pb.y, po1.z-1.5f) - pb) * 500);
                    O1.transform.rotation = Quaternion.Euler(0, 120, 0);
                    O1.GetComponent <Animator>().SetBool("runrun", true);
                    O1.GetComponent <Animator>().speed = 1.5f;

                    D1.transform.rotation = Quaternion.Euler(0, 120, 0);
                    D1.GetComponent <Animator>().SetBool("runrun", true);
                    D1.GetComponent <Animator>().speed = 1.0f;
                }

                /*if(flag2==1){
                 * if (gestureListener.IsMoveForward())
                 * {
                 * //					D1.transform.position = (D1.transform.position + (dir.normalized * 1 * Time.deltaTime));
                 * //					D1.transform.LookAt (O1.transform);
                 * D1.transform.rotation = Quaternion.Euler(0, 180, 0);
                 * D1.GetComponent<Animator>().SetBool("runrun", true);
                 * D1.GetComponent<Animator>().speed = 0.8f;
                 * }
                 * }*/
            }));
            /*-------------カッティングに強弱をつける-------------*/



            StartCoroutine(DelayMethod(1.5f, () => {
                Vector3 dir = po1 - pd1;
                if (flag2 == 0)
                {
                    D1.transform.position = (D1.transform.position + (dir.normalized * 1 * Time.deltaTime));
                    D1.transform.LookAt(O1.transform);
                    D1.GetComponent <Animator> ().SetBool("runrun", true);

                    if (flag2 == 1)
                    {
                    }
                }
            }));


            StartCoroutine(DelayMethod(2f, () => {
                if (flag < 2)
                {
                    O2.transform.rotation = Quaternion.Euler(0, -130, 0);
                    O2.GetComponent <Animator> ().SetBool("runrun", true);
                    O2.GetComponent <Animator> ().speed = 1.2f;
                    D2.transform.rotation = Quaternion.Euler(0, -130, 0);
                    D2.GetComponent <Animator> ().SetBool("runrun", true);
                    D2.GetComponent <Animator> ().speed = 1.0f;
                }
            }));
        }));


        /*StartCoroutine (DelayMethod (10f, () => {
         * //GameObject.Find("KinectController").GetComponent<KinectManager>().OnDestroy();
         * SceneManager.LoadScene("3DLesson4-2");
         * }));*/



        /*---------------------------------------------------------------------------------*/

        if ((Mathf.Abs(pb.x - po3.x) <= 0.5f) && (Mathf.Abs(pb.z - po3.z) <= 0.5f))
        {
            this.transform.position = po3;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po3.z + 0.3f;
            this.transform.position = pospos;

            //this.GetComponent<Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O3.transform;
        }

        if ((Mathf.Abs(pb.x - po2.x) <= 0.5f) && (Mathf.Abs(pb.z - po2.z) <= 0.5f))
        {
            this.transform.position = po2;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po2.z + 0.3f;
            this.transform.position = pospos;

            //this.GetComponent<Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O2.transform;
        }


        if ((Mathf.Abs(pb.x - po1.x) <= 0.5f) && (Mathf.Abs(pb.z - po1.z) <= 0.5f))
        {
            this.transform.position = po1;
            Vector3 pospos = this.transform.position;
            pospos.y = 1.4f;
            pospos.z = po1.z + 0.4f;
            this.transform.position = pospos;

            this.GetComponent <Rigidbody> ().velocity = Vector3.zero;
            //this.GetComponent<Rigidbody>().AddForce(Vector3.zero);
            //Debug.Log ("true");

            /*---shift relationship of parent and children from O1 to O3---*/
            //this.transform.parent = O1.transform;
            this.transform.parent = null;
            ball.transform.parent = O1.transform;
        }
        /*---------------------------------------------------------------------------------*/

        if (flag == 0 && po1.z >= 11.5f)
        {
            flag = 1;
            O1.GetComponent <Animator> ().SetBool("runrun", false);
            //D1.GetComponent<Animator> ().SetBool ("runrun", false);
        }

        if (flag == 1 && po1.x >= 1.4f)
        {
            flag  = 2;
            flag2 = 1;
            O1.transform.rotation = Quaternion.Euler(0, 180, 0);
            O1.GetComponent <Animator> ().SetBool("runrun", false);
            D1.GetComponent <Animator> ().SetBool("runrun", false);
        }

        if (flag == 2 && po1.z <= 9.0f)
        {
            flag  = 3;
            flag2 = 2;
            //O1.transform.rotation = Quaternion.Euler (0, -120, 0);
            O1.GetComponent <Animator> ().SetBool("runrun", false);
            //D1.transform.rotation = Quaternion.Euler (0, 160, 0);
            D1.GetComponent <Animator> ().SetBool("runrun", false);
        }

        if (flag == 3 && po1.x >= 4.5f)
        {
            flag = 4;
            O1.transform.rotation = Quaternion.Euler(0, -120, 0);
            O1.GetComponent <Animator> ().SetBool("runrun", false);
            D1.GetComponent <Animator>().SetBool("runrun", false);
            iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po1.x, pb.y, po1.z), "Time", 1.5f));
        }

        if (po2.x <= 0f)
        {
            //			flag = 2; flag2 = 1;
            O2.transform.rotation = Quaternion.Euler(0, 0, 0);
            O2.GetComponent <Animator> ().SetBool("runrun", false);
            D2.GetComponent <Animator> ().SetBool("runrun", false);
            //iTween.MoveTo(ball, iTween.Hash("position", new Vector3(po2.x, pb.y, po2.z + 0.3f), "Time", 2f));
        }

        /*---------------------------------------------------------------------------------*/
    }