private void ToggleFlash(InputAction.CallbackContext _context)
 {
     if (!EcodexManager.Instance.EcodexIsOpen && !Player.Instance.IsDie)
     {
         audio.PlayOneShot(flashIsActive ? SoundOneShot.FlashUI_DOWN : SoundOneShot.FlashUI_UP);
         changeFlash(!flashIsActive);
     }
 }
Beispiel #2
0
    private void PlayFearSound()
    {
        bool chased = false;

        IReadOnlyCollection <DataCreature> creatures = agentCreature.Memory.Creatures.Read();

        foreach (DataCreature data in creatures)
        {
            Agent agent = data.creature?.agentCreature;
            if (!agent || !agent.gameObject.activeSelf || data.RegistrationDate < Time.time - 5f)
            {
                continue;
            }

            bool isHostil = GoalEvade.CreatureIsHostil(agentCreature, agent.Creature);
            if (isHostil && agent.Steering.Target == agentCreature)
            {
                chased = true;
                break;
            }
        }

        //Ajout de son
        if (chased)
        {
            AudioBox.PlayOneShot(SoundOneShot.CreatureFear);
        }
        else
        {
            if (UnityEngine.Random.value > 0.2f)
            {
                AudioBox.PlayOneShot(SoundOneShot.CreatureAlert);
            }
        }
    }
Beispiel #3
0
    void Update()
    {
        if (MetabolismActive)
        {
            Age += GrowSpeed * Time.deltaTime;
            AudioBox.SetOneShotPitch(1 + 0.5f * Age - 0.25f);
        }

        if (agentCreature != null)
        {
            EmotionState deductedEmotion = Emotion.Instance.GetEmotion(agentCreature);
            if (deductedEmotion != currentEmotion && Time.time - lastTime > 1f)
            {
                currentEmotion = deductedEmotion;
                FaceSwap.Swap(deductedEmotion);
                lastTime = Time.time;

                switch (currentEmotion)
                {
                //case EmotionState.Happy : AudioBox.PlayOneShot(SoundOneShot.CreatureHappy); break;
                case EmotionState.Hungry: AudioBox.PlayOneShot(SoundOneShot.CreatureHungry); break;

                case EmotionState.Scared: PlayFearSound(); break;

                case EmotionState.Suspicious: if (UnityEngine.Random.value > 0.5f)
                    {
                        AudioBox.PlayOneShot(SoundOneShot.CreatureSuspicious);
                    }
                    break;

                case EmotionState.Agressive: AudioBox.PlayOneShot(SoundOneShot.CreatureSpotPrey); break;

                case EmotionState.Curious: AudioBox.PlayOneShot(SoundOneShot.CreatureCurious); break;

                case EmotionState.Love: AudioBox.PlayOneShot(SoundOneShot.CreatureLove); break;

                case EmotionState.Tired: AudioBox.PlayOneShot(SoundOneShot.CreatureTired); break;
                }
            }
        }

        DNADistortion.Update();

        //TODO les delegué des gauges fonctionne pas
        if (MetabolismActive)
        {
            _gauges.UpdateGauges(Time.deltaTime);
        }
        if (_gauges.Life <= 0 || _gauges.Hunger <= 0 || Age > 1)
        {
            Die();
        }

        if (UpdateSize)
        {
            transform.localScale = Vector3.one * SizeForAge;
        }
    }
Beispiel #4
0
    void Update()
    {
        if (!player.IsOnGround)
        {
            return;
        }

        float velocity = player.Velocity.magnitude;
        float freq     = FreqWithVelocity / player.Velocity.magnitude;

        if (Time.time - lastFootTime > freq)
        {
            if (velocity > velocityWalkDelimiter)
            {
                audioBox.PlayOneShot(soundRun);
            }
            else
            {
                audioBox.PlayOneShot(soundWalk, velocity / velocityWalkDelimiter);
            }

            lastFootTime = Time.time;
        }
    }
    private void TurnOnAndTurnOffLight(InputAction.CallbackContext _context)
    {
        audioBox.PlayOneShot(soundFlashlight, 1);

        if (!FlashlightIsTurnOn)
        {
            FlashlightIsTurnOn = true;
            Flashlight.enabled = true;
        }
        else
        {
            FlashlightIsTurnOn = false;
            Flashlight.enabled = false;
        }
    }