// Start is called before the first frame update
    void Start()
    {
        cageAnim = prisonCage.GetComponent <Animator>();

        cageParent       = prisonCage.parent;
        cageInitialPos   = prisonCage.localPosition;
        cageSkin.enabled = false;

        //if (cells.Count > 0) {
        //    foreach (PrisonCell room in cells) {
        //        room.arrivalLocationOffset = room.cell.position + room.arrivalLocationOffset;
        //    }
        //}

        Color lowAlphaCageColor = new Color(cageSkin.material.color.r, cageSkin.material.color.g, cageSkin.material.color.b, cageInitialAlpha);

        cageSkin.material.color = lowAlphaCageColor;

        stateOfCage     = CageState.Inactive;
        cageStepRefTime = Time.time;

        cageActivated = false;
    }
    // Update is called once per frame
    void Update()
    {
        // This manages the behavior of the cage when capturing an individual
        switch (stateOfCage)
        {
        case CageState.Inactive:

            if (cageActivated && currentSuspect != null)
            {
                cageActivated = false;

                prisonCage.SetParent(null);
                prisonCage.position = currentSuspect.GetSelf().position + currentSuspect.OffsetForPrisonCage;
                cageSkin.enabled    = true;

                currentSuspect.GetSelf().SetParent(prisonCage);
                if (currentSuspect.GetSelf().GetComponent <CyclopsAI>() != null)
                {
                    currentSuspect.GetSelf().GetComponent <CyclopsAI>().GotPinched();
                }
                if (currentSuspect.GetSelf().GetComponent <Collider>() != null)
                {
                    currentSuspect.GetSelf().GetComponent <Collider>().enabled = false;
                }
                if (currentSuspect.GetSelf().GetComponent <Rigidbody>() != null)
                {
                    currentSuspect.GetSelf().GetComponent <Rigidbody>().isKinematic = true;
                }

                cageAnim.SetTrigger(cageFoldTriggerString);

                stateOfCage     = CageState.FoldingAtSuspectPosition;
                cageStepRefTime = Time.time;
            }
            break;

        case CageState.FoldingAtSuspectPosition:
            if (Time.time - cageStepRefTime > cageFoldTime)
            {
                cageAnim.SetTrigger(cageStayFoldedTriggerString);

                stateOfCage     = CageState.FoldedAndHoldingAtSuspectPosition;
                cageStepRefTime = Time.time;
            }
            break;

        case CageState.FoldedAndHoldingAtSuspectPosition:

            IncreaseCageAlpha();

            if (Time.time - cageStepRefTime > cageStillTime)
            {
                TransportSuspectToOpenCell();

                stateOfCage     = CageState.FoldedAndHoldingAtCellPosition;
                cageStepRefTime = Time.time;
            }
            break;

        case CageState.FoldedAndHoldingAtCellPosition:

            DecreaseCageAlpha();

            if (Time.time - cageStepRefTime > cageStillTime)
            {
                cageAnim.SetTrigger(cageUnfoldTriggerString);

                stateOfCage     = CageState.UnfoldingInCell;
                cageStepRefTime = Time.time;
            }

            break;

        case CageState.UnfoldingInCell:
            if (Time.time - cageStepRefTime > cageUnfoldTime)
            {
                cageSkin.enabled = false;
                currentSuspect.GetSelf().SetParent(null);
                prisonCage.SetParent(cageParent);
                prisonCage.position = cageInitialPos;

                cageAnim.SetTrigger(cageStayUnfoldedTriggerString);

                stateOfCage     = CageState.Inactive;
                cageStepRefTime = Time.time;
            }
            break;
        }
    }