void OnTriggerEnter(Collider co)
    {
        colliders.Add(co);

        if (!open)
        {
            open = true;
            aud.PlayOneShot(openSound);

            foreach (var anim in anims)
            {
                anim.SetTrigger("open");
            }
        }
    }
Example #2
0
    void OnCollisionEnter(Collision co)
    {
        if (Time.time < lastCollisiontime + minTime)
        {
            return;
        }

        lastCollisiontime = Time.time;
        var relativeSpeed = co.relativeVelocity.magnitude;

        if (relativeSpeed > minHitSpeed)
        {
            if (source != null && collisionSound != null)
            {
                // sound
                source.source.volume = relativeSpeed / normalizedHitSpeed;
                source.PlayOneShot(collisionSound);
            }

            if (collisionFx != null)
            {
                // fx
                var contact = co.contacts[0];
                Instantiate(collisionFx, contact.point, Quaternion.LookRotation(contact.normal, transform.up));
            }
        }
    }
Example #3
0
    void SwitchTo(int slotNumber)
    {
        var slotToSwitchTo = GetSlot(slotNumber);

        if (!slotToSwitchTo.obtained)
        {
            // weapon is not yet obtained, don't switch
            return;
        }

        currentSlot = slotNumber;

        // enable weapon
        slotToSwitchTo.weaponInterface.Equip(true);
        aud.PlayOneShot(slotToSwitchTo.equipSound);

        // disable other weapons
        foreach (var weaponSlot in weaponSlots)
        {
            if (weaponSlot.slot != slotNumber)
            {
                weaponSlot.weaponInterface.Equip(false);
            }
        }
    }
Example #4
0
    void FixedUpdate()
    {
        distance   += (transform.position - oldPosition).magnitude;
        oldPosition = transform.position;

        if (distance > stepDistance)
        {
            distance = 0;
            source.RandomizePitch(randomPitchRange);
            source.PlayOneShot(stepSound);
        }
    }
    void OnTriggerEnter(Collider co)
    {
        if (locked)
        {
            // enter log
            UiLog.Log(pickupLog);
            aud.PlayOneShot(lockedSound);
            return;
        }

        colliders.Add(co);

        if (!open)
        {
            open = true;
            aud.PlayOneShot(openSound);

            foreach (var anim in anims)
            {
                anim.SetTrigger("open");
            }
        }
    }
    protected override void Break()
    {
        transform.parent          = null;
        rb.isKinematic            = false;
        rb.useGravity             = true;
        rb.collisionDetectionMode = CollisionDetectionMode.Continuous;
        gameObject.layer          = brokenLayer;
        StartCoroutine(ApplyBreakMovement());

        if (source != null)
        {
            source.RandomizePitch(randomPitchRadius);
            source.PlayOneShot(breakSound);
        }

        Destroy(this);
    }
 public void Fire()
 {
     source.RandomizePitch(randomPitchRange);
     source.PlayOneShot(fireClip);
 }