Exemplo n.º 1
0
    /**
     * When hit triggers the behaviour.
     */
    public void trigger()
    {
        if (active)
        {
            return;
        }

        pillarPuzzle leftPillar  = (pillarPuzzle)left.GetComponent(typeof(pillarPuzzle));
        pillarPuzzle rightPillar = (pillarPuzzle)right.GetComponent(typeof(pillarPuzzle));

        leftPillar.active  = !leftPillar.active;
        rightPillar.active = !rightPillar.active;
        active             = true;

        _checker.check();
    }
    bool IsHitValid(RaycastHit hit)
    {
        ///////////////////////////////////////////////
        /// Removes a target and it's link when hit ///
        ///////////////////////////////////////////////
        if (hit.collider.CompareTag("TARGET"))
        {
            target z = (target)hit.collider.gameObject.GetComponent(typeof(target));
            Destroy(z.removeable);
            Destroy(hit.collider.gameObject);
        }

        /////////////////////////////////
        /// Pillar shooter detection ////
        /////////////////////////////////
        if (hit.collider.CompareTag("PILLAR"))
        {
            pillarPuzzle p = (pillarPuzzle)hit.collider.gameObject.GetComponent(typeof(pillarPuzzle));
            p.trigger();
        }

        //////////////////////////////////
        /// Next Stage Waypoint Shoot ////
        //////////////////////////////////
        if (hit.collider.CompareTag("END_LEVEL_WP"))
        {
            NextLevelTP nextLevelTp = (NextLevelTP)hit.collider.gameObject.GetComponent(typeof(NextLevelTP));
            nextLevelTp.activate();
        }

        //////////////////////
        /// M3 projectile ////
        //////////////////////
        if (hit.collider.CompareTag("M3"))
        {
            M3Value     value = (M3Value)hit.collider.gameObject.GetComponent(typeof(M3Value));
            Match3Level m3    = (Match3Level)value.m3Level.GetComponent(typeof(Match3Level));
            m3.playerSelection(value.value);
        }
        ///////////////////////////////////////////

        // ignore hits with an ignore component
        if (hit.collider.GetComponent <IgnoreHitDetection>())
        {
            return(false);
        }

        // ignore hits with triggers that don't have a Damageable component
        if (hit.collider.isTrigger && hit.collider.GetComponent <Damageable>() == null)
        {
            return(false);
        }

        // ignore hits with specific ignored colliders (self colliders, by default)
        if (m_IgnoredColliders != null && m_IgnoredColliders.Contains(hit.collider))
        {
            return(false);
        }

        return(true);
    }