Ejemplo n.º 1
0
    private void DoEating()
    {
        //Check if enemy is still alive
        if (stateVariables.eatTargetEnemy.activeSelf)
        {
            IEatable eatable = stateVariables.eatTargetEnemy.GetComponent <IEatable>();
            if (!eatable.IsNull())
            {
                int health;
                eatable.Eat(out health);
                stateVariables.statsManager.TakeHealth(health);
                Stats stats = GetComponent <Stats>();

                EventSystem.Instance.TriggerEvent(Strings.Events.UPDATE_HEALTH, stats.GetHealthFraction());
                EventSystem.Instance.TriggerEvent(Strings.Events.ENEMY_DEATH_BY_EATING);

                GameObject skinningEffect = ObjectPool.Instance.GetObject(PoolObjectType.VFXMallCopExplosion);
                playerFaceController.SetTemporaryEmotion(Turing.VFX.PlayerFaceController.Emotion.Happy, happyTimeAfterEating);

                if (skinningEffect && clawTransform)
                {
                    skinningEffect.transform.position = clawTransform.position;
                }


                GameObject healthJuice = ObjectPool.Instance.GetObject(PoolObjectType.VFXHealthGain);
                if (healthJuice)
                {
                    healthJuice.FollowAndDeActivate(3f, transform, Vector3.up * 3.2f, CoroutineName);
                }
                SFXManager.Instance.Play(stateVariables.EatSFX, transform.position);
            }
        }
    }
Ejemplo n.º 2
0
 public void Eat(IEatable food)
 {
     StarvePoint += food.Satiety;
     if (StarvePoint > 100f)
     {
         StarvePoint = 100f;
     }
     food.Eat();
 }
Ejemplo n.º 3
0
        public bool Eat(IEatable eatable)
        {
            if (IsInReach(eatable))
            {
                eatable.Eat().ApplyOn(transform.parent.gameObject);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
    public void EatFood(IEatable food)
    {
        //SALE EL LOGO DE COMIENDO///
        /////////////////////////////
        float maxEnergyToGet = genes.genesData.maxEnergy - currentEnergy;

        float energyEarned = food.Eat(maxEnergyToGet);

        currentEnergy += energyEarned;
    }
Ejemplo n.º 5
0
        private void DoSuck(GameObject obj)
        {
            ISuckable suckable = obj.GetComponent <ISuckable>();
            IEatable  eatable  = obj.GetComponent <IEatable>();

            var tempDistance = Vector3.Distance(transform.position, obj.transform.position);

            if (eatable != null)
            {
                if (tempDistance < eatDistance)
                {
                    GameObject tempObj = eatable.Eat();

                    if (tempObj != null)
                    {
                        _eatenObjects.Add(tempObj);
                        tempObj.SetActive(false);
                        _audioComponent?.Play(4); // Play eat sound
                        eatEvent?.Invoke();       // Invoke eat event
                        return;
                    }
                }
            }

            if (suckable != null)
            {
                if (InRangeCheck(gameObject, obj))
                {
                    var tempSuckForce = vacuumPowerLevel - tempDistance;

                    if (tempSuckForce < minimumPower)
                    {
                        tempSuckForce = minimumPower;
                    }

                    suckable.Suck(transform.position, tempSuckForce);
                }
            }
        }
Ejemplo n.º 6
0
    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Hydrator"))
        {
            if (drinkRef == null)
            {
                return;
            }
            if (Input.GetButton("Interact"))
            {
                ModifyHydration(drinkRef.Drink());
            }
        }
        if (other.CompareTag("Feeder"))
        {
            if (foodRef == null)
            {
                return;
            }
            if (Input.GetButton("Interact"))
            {
                ModifyHunger(foodRef.Eat());
                foodRef = null;
            }
        }

        var hint = other.GetComponent <IHintable>();

        if (Input.GetButton("Interact"))
        {
            var success = hint?.CollectHint();
            if (success != null && (bool)success)
            {
                InteractionText.gameObject.SetActive(false);
            } //Tell the player they messed up?
        }
    }
Ejemplo n.º 7
0
 public void Consume(IEatable food)
 {
     calories += food.Eat();
     Debug.Log("Now " + gameObject.name + " has " + calories + " calories!");
 }
Ejemplo n.º 8
0
 public void Eat()
 {
     eatBehaviour.Eat();
 }
Ejemplo n.º 9
0
 public void Eat(IEatable food, CreatureList.Creature creature)
 {
     food.Eat(creature);
 }