예제 #1
0
    // Update is called once per frame
    void Update()
    {
        // Find photons in range
        Collider[] photonsInRange = FindPhotonsInRange();
        if (photonsInRange.Length > 0)
        {
            // Play force attractor sound for as long as there is a photon in range
            AudioManager.Instance.Play("ForceAttractor");
            // Apply attraction force to all photons in range
            foreach (Collider photon in photonsInRange)
            {
                Rigidbody photonRB = photon.GetComponent <Rigidbody>();
                Attraction(photonRB);
                DeltaPhotonTimer photonTimer = photon.GetComponent <DeltaPhotonTimer>();

                // If the photon has never been in range, and therefore, had its max time increased, increase the max photon time
                if (!photonTimer.HasMaxPhotonTimeIncreased)
                {
                    photonTimer.HasMaxPhotonTimeIncreased = true;
                    photonTimer.AddTime(_photonAddTime);
                }

                // If the photon is within a certain distance of the force attractor, destroy it >:)
                float distance = Vector3.Distance(transform.position, photon.transform.position);
                if (distance <= 0.7f)
                {
                    // Play a particle effect
                    //
                    Destroy(photon.gameObject);
                }
            }
        }
    }
예제 #2
0
    private void AddTimeToPhoton(Collider photon)
    {
        Rigidbody        photonRB    = photon.GetComponent <Rigidbody>();
        DeltaPhotonTimer photonTimer = photon.GetComponent <DeltaPhotonTimer>();

        // If the photon has never been in range, and therefore, had its max time increased, increase the max photon time
        if (!photonTimer.HasMaxPhotonTimeIncreased)
        {
            photonTimer.HasMaxPhotonTimeIncreased = true;
            photonTimer.AddTime(_photonAddTime);
        }
    }