Пример #1
0
    public void playSound()
    {
        if (audioSource != null)
        {
            if (audioSource.volume > ManagesSound.getInstance().soundFXVolumeMax)
            {
                audioSource.volume = ManagesSound.getInstance().soundFXVolumeMax;
            }

            audioSource.clip   = ManagesSound.getInstance().soundFile(activationSound);
            audioSource.volume = activationSoundLevel;
            audioSource.Play();
        }
        else
        {
            ManagesSound.getInstance().playSound(
                activationSound,
                activationSoundLevel);
        }
    }
Пример #2
0
    public bool doBehavior(bool condition)
    {
        if (myBody == null)
        {
            myBody = this.gameObject.GetComponent <Rigidbody>();
        }

        if (entity == null)
        {
            entity = this.gameObject.GetComponent <AI_Entity>();
        }

        if (condition)
        {
            if (entity.useHackingPostProcessings &&
                !ManagesPostProcessing.getInstance().hackingEntities.Contains(this.gameObject))
            {
                ManagesPostProcessing.getInstance().hackingEntities.Add(this.gameObject);
            }

            if (!startedBehavior && entity.playActivationSound)
            {
                entity.playSound();
            }

            if (entity.playCombatMusic && !ManagesSound.getInstance().hackingEntities.Contains(this.gameObject))
            {
                ManagesSound.getInstance().hackingEntities.Add(this.gameObject);
            }

            if (entity.activationHint != null)
            {
                entity.activationHint.SetActive(true);
            }

            forceVector = contact.transform.position - this.transform.position;

            if (entity.flying != true)
            {
                forceVector.y = 0;
            }

            myBody.AddForce(forceVector.normalized * movementSpeed, ForceMode.Impulse);

            startedBehavior = true;
            return(condition);
        }

        if (entity.useHackingPostProcessings &&
            ManagesPostProcessing.getInstance().hackingEntities.Contains(this.gameObject))
        {
            ManagesPostProcessing.getInstance().hackingEntities.Remove(this.gameObject);
        }

        if (!entity.keepHintActive && entity.activationHint != null)
        {
            entity.activationHint.SetActive(false);
        }

        if (entity.playCombatMusic &&
            ManagesSound.getInstance().hackingEntities.Contains(this.gameObject))
        {
            ManagesSound.getInstance().hackingEntities.Remove(this.gameObject);
        }

        startedBehavior = false;
        return(condition);
    }