private void HandleTutorial(AssemblyLineItem poppedItem, bool correct)       //TODO: Refactor this and HandleNormal into one clean method
 {
     lastPress = 0;
     if (multipleFinger != null)
     {
         StopCoroutine(multipleFinger);
         multipleFinger = null;
     }
     if (tutorialZone == 3)
     {
         finger.StopShake(GetCorrectTransform().position);
     }
     else
     {
         finger.StopShake(GetButtonTransform(tutorialZone).position);
     }
     if (correct)
     {
         assemblyLineController.PopFirstItem();
         poppedItem.Activate();
         assemblyLineController.MoveUpLine(false);
         if (assemblyLineController.LineComplete)
         {
             doctorMatchTutorial.Advance();
         }
         else if (tutorialZone == 3)
         {
             finger.transform.position = GetCorrectTransform().position;                //GetButtonTransform((int)assemblyLineController.PeekFirstItem().ItemType).transform.position;
         }
     }
     else
     {
         StartCoroutine(finger.Shake(new Vector3(0, 10), .25f));
     }
 }
    // Input coming from button scripts
    public void OnZoneClicked(DoctorMatchButtonTypes buttonType)
    {
        AssemblyLineItem peakedItem = assemblyLineController.PeekFirstItem();
        bool             correct    = peakedItem.ItemType == buttonType;
        float            comboMod   = comboController.ComboMod;

        if (correct)          //The same feedback is provided whether or not the game is in tutorial
        {
            StartCoroutine(particleController.SpawnFirework(comboMod, assemblyLineController.StartPosition.position));
            numOfCorrectDiagnose++;
            UpdateScore(2);
            ComboBonus();
            PlaySoundCorrect();
            comboController.IncrementCombo();
        }
        else
        {
            comboController.ResetCombo();
            UpdateScore(-1);
            BloodPanelManager.Instance.PlayBlood();
            AudioManager.Instance.PlayClip("minigameError");
        }

        if (isTutorial)          //But line movement and populating is different in each mode
        {
            HandleTutorial(peakedItem, correct);
        }
        else
        {
            HandleNormal(peakedItem);
        }
    }
 public void SpawnTutorialSet(int stage)
 {
     for (int i = 1; i < AssemblyLineItem.SPRITE_COUNT; i++)
     {
         GameObject item = GameObjectUtils.AddChild(itemParent, itemPrefab);
         item.transform.position = GetPosition(index: i, indexOffset: -1);            //StartPosition.position + (i - 1) * new Vector3(distanceBetween, 0);
         AssemblyLineItem newItemScript = item.GetComponent <AssemblyLineItem>();
         newItemScript.Init(i - 1, stage, i);
         itemQueue.Enqueue(newItemScript);
         newItemScript.CompareVisible(visibleCount, false);
     }
 }
    public void ShiftAndAddNewItem()
    {
        MoveUpLine();
        // Add new item
        GameObject item         = GameObjectUtils.AddChild(itemParent, itemPrefab);
        int        newItemIndex = itemQueue.Count;

        item.transform.position = GetPosition(index: newItemIndex);        //StartPosition.position + newItemIndex * new Vector3(distanceBetween, 0);
        AssemblyLineItem newItemScript = item.GetComponent <AssemblyLineItem>();

        newItemScript.Init(newItemIndex);
        itemQueue.Enqueue(newItemScript);
        newItemScript.CompareVisible(visibleCount, true);
    }
    public void PopulateQueue(bool compare = false, int count = -1, int indexOffset = 0)
    {
        UpdateVisibleCount();
        int toSpawn = (count == -1) ? startingCount + 1 : count;

        for (int i = 0; i < toSpawn; i++)
        {
            GameObject item = GameObjectUtils.AddChild(itemParent, itemPrefab);
            item.transform.position = GetPosition(index: i, indexOffset: indexOffset);
            AssemblyLineItem itemScript = item.GetComponent <AssemblyLineItem>();
            itemScript.Init((i + indexOffset));
            itemQueue.Enqueue(itemScript);
            itemScript.CompareVisible(visibleCount, compare);
        }
    }
    private void HandleNormal(AssemblyLineItem poppedItem)
    {
        assemblyLineController.PopFirstItem();
        poppedItem.Activate();
        int toClear = assemblyLineController.Count + bonusStack;

        lifeBarController.UpdateCount(toClear);
        if (!lifeBarController.IsEmpty || bonusStack > 0)
        {
            assemblyLineController.ShiftAndAddNewItem();
            if (lifeBarController.IsEmpty && bonusStack > 0)
            {
                bonusStack--;
            }
        }
        else if (!assemblyLineController.LineComplete)
        {
            assemblyLineController.MoveUpLine();
        }
        else
        {
            GameOver();
        }
    }
    private Transform GetCorrectTransform()
    {
        AssemblyLineItem item = assemblyLineController.PeekFirstItem();

        return(GetButtonTransform((int)item.ItemType - 1));
    }