Esempio n. 1
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.tag.Equals("Block"))
        {
            body.velocity = new Vector3(body.velocity.x * -1, body.velocity.y, body.velocity.z);

            if (collider.gameObject.GetComponent <BasicBlock>() is BasicBlock)
            {
                BasicBlock block = collider.gameObject.GetComponent <BasicBlock>();
                block.DecreaseToughness();

                if (block.getIsBreakable() && block.getToughness() == 0)
                {
                    PaddleController script = owner.GetComponent <PaddleController>();
                    script.IncreaseScore(block.getPoint());
                    Destroy(collider.gameObject);
                }
            }

            if (collider.gameObject.GetComponent <ToughBlock>() is ToughBlock)
            {
                ToughBlock block = collider.gameObject.GetComponent <ToughBlock>();
                block.DecreaseToughness();

                if (block.getIsBreakable() && block.getToughness() == 0)
                {
                    PaddleController script = owner.GetComponent <PaddleController>();
                    script.IncreaseScore(block.getPoint());
                    Destroy(collider.gameObject);
                }
            }
        }
    }