예제 #1
0
    IEnumerator TransferLight(float loopValue, LightSource otherObject, bool extractSelf)
    {
        switch (extractSelf)
        {
        case true:
            ParticleSystem tempParticles = Instantiate(transferParticles, transform.position, Quaternion.LookRotation(Vector3.forward));
            tempParticles.GetComponent <particleAttractorMove>().target = otherObject.transform;
            tempParticles.Play();
            AudioManager.Instance.PlaySound(AudioManager.Instance.suckLight);
            for (int i = 0; i < loopValue; i++)
            {
                intensity--;
                otherObject.intensity++;
                otherObject.RefreshLight();
                RefreshLight();
                if (Input.GetMouseButton(transferToLightButton) && ShootTestRay(otherObject.gameObject))
                {
                    tempParticles.transform.position = transform.position;
                    tempParticles.GetComponent <particleAttractorMove>().target = otherObject.transform;
                    yield return(new WaitForSeconds(extractTime));
                }
                else
                {
                    break;
                }
            }
            AudioManager.Instance.StopSound(AudioManager.Instance.suckLight);
            tempParticles.Stop();
            break;

        case false:
            tempParticles = Instantiate(transferParticles, hit.point, Quaternion.LookRotation(Vector3.back));
            tempParticles.GetComponent <particleAttractorMove>().target = transform;
            tempParticles.Play();
            AudioManager.Instance.PlaySound(AudioManager.Instance.suckLight);
            for (int i = 0; i < loopValue; i++)
            {
                intensity++;
                otherObject.intensity--;
                otherObject.RefreshLight();
                RefreshLight();
                if (Input.GetMouseButton(transferFromLightButton) && ShootTestRay(otherObject.gameObject))
                {
                    tempParticles.transform.position = testHit.point;
                    tempParticles.GetComponent <particleAttractorMove>().target = transform;
                    yield return(new WaitForSeconds(extractTime));
                }
                else
                {
                    break;
                }
            }
            AudioManager.Instance.StopSound(AudioManager.Instance.suckLight);
            tempParticles.Stop();
            break;

        default:
            break;
        }
    }