Ejemplo n.º 1
0
    /// <summary>
    /// Takes care of the eating for the player
    /// </summary>
    /// <param name="eatObject"></param>
    private void Eat(GameObject go)
    {
        FoodBaseClass eatObject = go.GetComponent <FoodBaseClass>();

        if (eatObject == null || eatObject.AmountOfFood <= 0)
        {
            eating = false;
        }
        else
        {
            if (Input.GetButton("Fire1"))
            {
                eating      = true;
                Experience += eatObject.GetAmount();
                if (isServer)
                {
                    RpcEat(go);
                }
                else
                {
                    CmdEat(go);
                }


                //  Update Carnivore Compass
                Carnivore carnivore = GameObject.FindObjectOfType <Carnivore>();

                if (carnivore)                    //  If carnivore in game
                {
                    if (canSetNewCompassPosition) //  If Compass Timer Ready
                    {
                        if (isServer)
                        {
                            RpcCompassPos(transform.position);
                        }
                        else
                        {
                            CmdCompassPos(transform.position);
                        }
                    }
                    //  Reset Compass Timer
                    canSetNewCompassPosition = false;
                    currentCompassTime       = 0f;
                }
            }
            else
            {
                eating = false;
                EventManager.SoundBroadcast(EVENT.StopSound, eatObject.Source(), 0);
                eatObject.Eaten = eating;
            }
        }
    }
Ejemplo n.º 2
0
    private void CmdEat(GameObject go)
    {
        if (go != null)
        {
            FoodBaseClass eatObject = go.GetComponent <FoodBaseClass>();
            eatObject.Eaten = eating;
            eatObject.DecreaseFood(eatObject.FoodPerSecond * Time.deltaTime);
            StartCoroutine(eatObject.EatChecker());
            eatObject.CoolDownTime = 5.0f;

            if (!eatObject.Source().isPlaying)
            {
                EventManager.SoundBroadcast(EVENT.PlaySFX, eatObject.Source(), (int)SFXEvent.Eat);
            }
        }
    }