private void ExecuteItemBehaviour(Item item) { item.Hide(); switch (item.Kind) { case ItemKind.Number: m_numberItem = item as NumberItem; break; case ItemKind.Bonus: SlowdownSpeedTemporarily(); break; case ItemKind.Reverse: m_isReversing = true; break; } }
private IEnumerator Move() { var sfxMove = new string[] { "Move1 Blip", "Move2 Blip" }; while (true) { yield return(new WaitForSeconds(m_moveSpeed)); if (m_isReversing) { ReverseSnakeHead(); m_isReversing = false; } else { var currentPosition = transform.localPosition; SoundManager.Instance.PlaySoundEffect(sfxMove [Random.Range(0, sfxMove.Length)]); transform.Translate(m_direction); if (m_numberItem != null) { IncreaseTailAndSpeed(currentPosition); m_numberItem = null; } else if (m_tail.Count > 0) { m_tail.Last().localPosition = currentPosition; m_tail.Insert(0, m_tail.Last()); m_tail.RemoveAt(m_tail.Count - 1); } } } }