예제 #1
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.GetComponent <Player>()) // If we collide with a player, disable the warning system if neccessary and destroy the block.
        {
            if (collider.gameObject.GetComponent <Player>().warningSystem.incomingBlock == this)
            {
                collider.gameObject.GetComponent <Player>().warningSystem.incomingBlock = null;
                collider.gameObject.GetComponent <Player>().warningSystem.warnings.gameObject.SetActive(false);
            }
            Destroy(this.gameObject);
        }
        else if (collider.gameObject.layer == LayerMask.NameToLayer("Warnings"))
        {
            Warnings warningSystem = collider.gameObject.GetComponent <Warnings>();

            if (!warningSystem)
            {
                return;
            }

            warningSystem.ActivateWarning(this);

            this.speed = speed / 2.0f;
        }
        else if (collider.gameObject.layer == LayerMask.NameToLayer("Game Boundaries")) // Destroy this block if it goes out of bounds.
        {
            Destroy(this.gameObject);
        }
    }