コード例 #1
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;
        }
    }
コード例 #2
0
    private IEnumerator StunBehaviour(float duration)
    {
        Revision.Instance.ReviseCreatureFlashedByPlayer(agentCreature, this);

        agentCreature.Thinking.ActiveGoal = null;
        agentCreature.IsThinking          = false;

        currentEmotion = EmotionState.Stunned;
        FaceSwap.Swap(currentEmotion);

        GameObject stunnedParticle = ParticuleManager.Instance.CreateParticle(ParticleType.StunStars, transform.position + new Vector3(0, 0.5f, 0), transform.rotation * Quaternion.Euler(-90, 0, 0));

        stunnedParticle.transform.parent = transform;
        yield return(new WaitForSeconds(duration));

        ParticuleManager.Instance.DestroyParticle(ParticleType.StunStars, stunnedParticle);
        yield return(RecoverBehavior());
    }