示例#1
0
    private void Eat()
    {
        if (!_eatingAllowed)
        {
            return;
        }

        var eatSushi = new HashSet <Sushi>();

        foreach (var sushi in _sushiPool.ActiveSushi)
        {
            if (_horizontalRange.x <= sushi.transform.position.x &&
                _horizontalRange.y >= sushi.transform.position.x &&
                !_stomach.IsDigesting(sushi))
            //!sushi.transform.IsChildOf(_stomach.transform))
            {
                eatSushi.Add(sushi);
            }
        }

        var couldEat = false;

        foreach (var sushi in eatSushi)
        {
            couldEat = couldEat || _stomach.Eat(sushi);
        }

        if (couldEat)
        {
            _audioSource.PlayOneShot(_nomSound);
        }

        eatSushi.Clear();
    }
示例#2
0
 private void CombosEffect(Combos combos)
 {
     // 加饱腹值 得分
     Stomach.Eat(combos.Bonus);
     // 发送弹幕
     BulletCommenter.Shoot(combos.BulletComment);
     // 播放音频
     CombosAudio.clip = combos.Clip;
     CombosAudio.Play();
     StartCoroutine(TurnDownOtherAudios());
 }
示例#3
0
    private void EatFood(Food food)
    {
        // 队列操作
        if (Foods.Count == MaxFoodCount)
        {
            Foods.Dequeue();
        }
        Foods.Enqueue(food);
        CombosPanel.Show(Foods.ToArray());

        // Audio 报食物名
        FoodAudio.clip = food.Clip;
        FoodAudio.Play();

        /// 检查是否包含组合技
        if (CombosManager.CheckCombo(Foods))
        {
            // 队列清空
            Foods.Clear();
            CombosPanel.Show(Foods.ToArray());

            // 人物动画
        }
        else
        {
            // 人物动画

            // UI 反馈 -> 加饱腹值
            Stomach.Eat(food.Energy);

            // 声音反馈 -> 播放音效
            if (EatVomitAudio.clip != EatClip || !EatVomitAudio.isPlaying)
            {
                EatVomitAudio.clip = EatClip;
                EatVomitAudio.Play();
            }
        }
    }