Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        //interval
        cnt++;
        if (cnt > 0)
        {
            cnt = 0;

            //ball stop time  at start
            if (stopcnt >= 1)
            {
                stopcnt--;
                return;
            }
            else if (stopcnt == 0)
            {
                //collider at start
                r2.bodyType = RigidbodyType2D.Dynamic;
            }

            //ball move
            if (mc.resetsw == false)                    //reset中は移動停止
//l				cashTransform.Translate (xx, yy, 0);
            {
                if (doadf == false)
                {
                    doadf = true;
                    r2.AddForce(new Vector2(xx, yy));
                }
            }

//l

/*
 *                      //反転
 *                      bool rvs = false;
 *
 *                      //x反転
 *                      if (( (cashTransform.position.x + ballxs) > (cashTransformWall_r.position.x - wall_rxs) ) ||
 *                              ( (cashTransform.position.x - ballxs) < (cashTransformWall_l.position.x + wall_lxs) ) ) {
 *                              xx = xx - (xx * 2);
 *                              se.Play();
 *                              rvs = true;
 *                      }
 *
 *                      //y反転
 *                      if (( (cashTransform.position.y + ballys) > (cashTransformWall_u.position.y - wall_uys) ) ||
 *                              ( (cashTransform.position.y - ballys) < (cashTransformWall_d.position.y + wall_dys) ) ){
 *                              yy = yy - (yy * 2);
 *                              se.Play();
 *                              rvs = true;
 *                      }
 *
 *                      //反転animation
 *                      if (rvs == true) {
 *                              animt.speed = 3.5f;
 *                              animt.SetTrigger ("bound");
 *                      }
 */

            //色変化
            colR = colR + colRR;
            if ((colR > 2.4f) || (colR < 0.6f))
            {
                colRR = colRR - (colRR * 2);
            }
            colG = colG + colGG;
            if ((colG > 2.4f) || (colG < 0.6f))
            {
                colGG = colGG - (colGG * 2);
            }
            colB = colB + colBB;
            if ((colB > 2.4f) || (colB < 0.6f))
            {
                colBB = colBB - (colBB * 2);
            }
            colA = colA + colAA;
            if ((colA > 2.4f) || (colA < 0.6f))
            {
                colAA = colAA - (colAA * 2);
            }
            sr.color = new Color(colR, colG, colB, colA);

            //scale (reset時)
            if (mc.resetsw == true)
            {
                r2.velocity = Vector2.zero;
                cashTransform.localScale = new Vector3(scl, scl, 1);
                scl = scl - 0.015f;
                if (scl < 0.2f)
                {
                    mc.decBall();                               //ball dec
                    Destroy(gameObject);                        //this Destroy
                }
            }
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        //interval
        cnt++;
        if (cnt > 0)
        {
            cnt = 0;

            //ball stop time  at start
            if (stopcnt >= 1)
            {
                stopcnt--;
                return;
            }

            //ball move
            if (mc.resetsw == false)                    //reset中は移動停止
            {
                cashTransform.Translate(xx, yy, 0);
            }

            //反転
            bool rvs = false;

            //x反転
            if (((cashTransform.position.x + ballxs) > (cashTransformWall_r.position.x - wall_rxs)) ||
                ((cashTransform.position.x - ballxs) < (cashTransformWall_l.position.x + wall_lxs)))
            {
                xx = xx - (xx * 2);
                se.Play();
                rvs = true;
            }

            //y反転
            if (((cashTransform.position.y + ballys) > (cashTransformWall_u.position.y - wall_uys)) ||
                ((cashTransform.position.y - ballys) < (cashTransformWall_d.position.y + wall_dys)))
            {
                yy = yy - (yy * 2);
                se.Play();
                rvs = true;
            }

            //反転animation
            if (rvs == true)
            {
                animt.speed = 3.5f;
                animt.SetTrigger("bound");
            }

            //色変化
            colR = colR + colRR;
            if ((colR > 2.4f) || (colR < 0.6f))
            {
                colRR = colRR - (colRR * 2);
            }
            colG = colG + colGG;
            if ((colG > 2.4f) || (colG < 0.6f))
            {
                colGG = colGG - (colGG * 2);
            }
            colB = colB + colBB;
            if ((colB > 2.4f) || (colB < 0.6f))
            {
                colBB = colBB - (colBB * 2);
            }
            colA = colA + colAA;
            if ((colA > 2.4f) || (colA < 0.6f))
            {
                colAA = colAA - (colAA * 2);
            }
            sr.color = new Color(colR, colG, colB, colA);

            //scale (reset時)
            if (mc.resetsw == true)
            {
                cashTransform.localScale = new Vector3(scl, scl, 1);
                scl = scl - 0.015f;
                if (scl < 0.2f)
                {
                    mc.decBall();                               //ball dec
                    Destroy(gameObject);                        //this Destroy
                }
            }
        }
    }