Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown(fireInputAxis) && pointTracker.ShoootWorthy())
        {
            GameObject    ball         = Instantiate(pointBall, transform.position, Quaternion.identity);
            Ball_Activate bulletScript = ball.GetComponent <Ball_Activate>();

            bulletScript.startPosition = transform.position;
            bulletScript.direction     = transform.up;//gameObject.GetComponent<Player_Movement>().direction;
            bulletScript.player        = gameObject;
            bulletScript.pointTracker  = pointTracker;

            pointTracker.BullletCount++;
        }
    }
Esempio n. 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Bullet")
        {
            Ball_Activate bA = collision.gameObject.GetComponent <Ball_Activate>();

            if (bA)
            {
                // decrements players points
                Player_PointsTracker pointTracker = bA.player.GetComponent <Player_PointsTracker>();

                if (pointTracker)
                {
                    pointTracker.TotalPoints--;
                }
            }

            Destroy(collision.gameObject);
        }
    }