Esempio n. 1
0
    public void kickMe(Vector2 tappos)
    {
        Rigidbody2D rb2 = Ball.GetInstance().gameObject.GetComponent <Rigidbody2D>();

        //ignore if ball travelling upwards
        if (rb2.velocity.y >= 0)
        {
            return;
        }

        //tap too far
//		Debug.Log ("rb2 position: "+rb2.position);
//		Debug.Log ("distance bwtn tap and rb2: "+Lib.pythag(tappos,rb2.position));
        if (Lib.pythag(tappos, rb2.position) >= 0.8f * tapTolerance)
        {
            return;
        }

        float dx = -(tappos.x - rb2.position.x) * 100f;

        rb2.AddForce(new Vector2(dx * xForceDirection, yForceDirection * 1f));

        screen_game game = screen_game.GetInstance();

        game.doCollision(tappos);
        var score = game.increaseScore(1);

        //if (score % 10 == 0 && xForceDirection <= 5)
        //{
        //    xForceDirection ++;
        //}

        playSound(kick);
    }
Esempio n. 2
0
    public void kickMe(Vector2 tappos)
    {
        Rigidbody2D rb2 = Ball.GetInstance().gameObject.GetComponent <Rigidbody2D>();

        //ignore if ball travelling upwards
        if (rb2.velocity.y >= 0)
        {
            return;
        }

        //tap too far
        if (Lib.pythag(tappos, rb2.position) >= 0.8f)
        {
            return;
        }

        float dx = -(tappos.x - rb2.position.x) * 500f;

        rb2.AddForce(new Vector2(dx, 1500f));

        screen_game game = screen_game.GetInstance();

        game.doCollision(tappos);
        game.increaseScore(1);
        playSound(kick);
    }
Esempio n. 3
0
    void Start()
    {
        var screenGameGameObjects = GameObject.FindGameObjectsWithTag("screen_game");
        var sg = screenGameGameObjects[0];

        screenGame = sg.GetComponent <screen_game> ();
        timeLeft   = visibleTime;
    }
Esempio n. 4
0
 void Awake()
 {
     pthis = this;
 }