// removes most recent element
        public void RemoveLastItem()
        {
            if (operationInProgress)
            {
                return;
            }

            if (rollerCoasterController.IsRunning())
            {
                return;
            }

            if (rcItemList.Count == 0)
            {
                return;
            }

            rollerCoasterController.RemoveElement();

            rcItemList.RemoveAt(rcItemList.Count - 1);

            if (rcItemList.Count == 0)
            {
                cartHasBeenAdded = false;
            }

            RollerCoasterBuilderPreviewItem currentPreviewItem = previewItemsList[currentItemIndex].GetComponent <RollerCoasterBuilderPreviewItem>();
            RollerCoasterItem currentFullItem = currentPreviewItem.GetCurrentFullSize().GetComponent <RollerCoasterItem>();

            updateAddableList();

            updateItemAdditionalText(currentFullItem.ItemType);
        }
        // changes the size of the item if available
        public void ChangeItemSize(string direction)
        {
            GameObject item = previewItemsList[currentItemIndex];
            RollerCoasterBuilderPreviewItem currentPreviewItem = item.GetComponent <RollerCoasterBuilderPreviewItem>();
            int nextSizeIndex = currentPreviewItem.ChangeSize(direction);

            updateItemAdditionalText(bankedCurveSizes[nextSizeIndex]);
        }
        void Start()
        {
            startText        = "Start by adding a Hill. Select a size with the plus and minus buttons. Press the round button to add it.";
            currentItemIndex = 0;
            previewItemsList = new List <GameObject>();
            cartHasBeenAdded = false;

            modelPlayButton.SetActive(true);
            modelStopButton.SetActive(false);

            // get all preview items into list
            Transform previewParent = transform.Find("Previews");

            foreach (Transform child in previewParent)
            {
                previewItemsList.Add(child.gameObject);
            }

            // only display first item
            foreach (GameObject currentItem in previewItemsList)
            {
                currentItem.SetActive(false);
            }
            previewItemsList[0].SetActive(true);
            // set text name also
            RollerCoasterBuilderPreviewItem currentPreviewItem = previewItemsList[0].GetComponent <RollerCoasterBuilderPreviewItem>();

            SetItemNameTMP(currentPreviewItem.CurrentItemName);

            operationInProgress = false;
            trackIsComplete     = false;

            // assign the types to variables to keep them shorter
            itemTypeStartHill     = RollerCoasterItem.RCItemType.StartHill;
            itemTypeHill          = RollerCoasterItem.RCItemType.Hill;
            itemTypeBankedCurve10 = RollerCoasterItem.RCItemType.BankedCurve10;
            itemTypeBankedCurve15 = RollerCoasterItem.RCItemType.BankedCurve15;
            itemTypeBankedCurve20 = RollerCoasterItem.RCItemType.BankedCurve20;
            itemTypeLooping       = RollerCoasterItem.RCItemType.Looping;
            itemTypeCart          = RollerCoasterItem.RCItemType.Cart;

            rcItemList  = new List <RollerCoasterItem.RCItemType>();
            addableList = new List <RollerCoasterItem.RCItemType>();
            updateAddableList();

            bankedCurveSizes = new List <RollerCoasterItem.RCItemType>();
            bankedCurveSizes.Add(itemTypeBankedCurve10);
            bankedCurveSizes.Add(itemTypeBankedCurve15);
            bankedCurveSizes.Add(itemTypeBankedCurve20);

            // set start instructions
            additionalText.text = startText;

            // get gamecontroller
            gameController = GameObject.FindWithTag("GameController").GetComponent <GameController>();
        }
        private void fadeInItem(int index, string direction)
        {
            GameObject item = previewItemsList[index];
            RollerCoasterBuilderPreviewItem currentPreviewItem = item.GetComponent <RollerCoasterBuilderPreviewItem>();

            currentPreviewItem.FadeIn(direction);

            // check if current item is addable
            RollerCoasterItem currentFullItem = currentPreviewItem.GetCurrentFullSize().GetComponent <RollerCoasterItem>();

            updateItemAdditionalText(currentFullItem.ItemType);

            SetItemNameTMP(currentPreviewItem.CurrentItemName);
        }
        // places current item in scene
        public void PlaceCurrentItem()
        {
            if (operationInProgress)
            {
                return;
            }

            if (rollerCoasterController.IsRunning())
            {
                return;
            }

            RollerCoasterBuilderPreviewItem currentPreviewItem = previewItemsList[currentItemIndex].GetComponent <RollerCoasterBuilderPreviewItem>();
            RollerCoasterItem currentFullItem = currentPreviewItem.GetCurrentFullSize().GetComponent <RollerCoasterItem>();

            if (!isItemAddable(currentFullItem.ItemType))
            {
                var propsFail = new Value();
                propsFail["Scene Name"] = SceneManager.GetActiveScene().name;
                propsFail["Item Type"]  = currentFullItem.ItemType.ToString();
                propsFail["Success"]    = false;
                Mixpanel.Track("Placed Item", propsFail);

                return;
            }

            // special case: if it's the first item, make sure to add a start hill
            if (rcItemList.Count == 0)
            {
                currentPreviewItem.PlaceStartHill();
                rcItemList.Add(itemTypeStartHill);
                updateAddableList();
                // update text also
                additionalText.text = "Great! Now choose different parts with the left and right arrows.";
                return;
            }

            Transform mostRecentElement = rollerCoasterController.ElementList.Last();

            currentPreviewItem.PlaceFullsizedItem(mostRecentElement);

            // don't update rcItemList for cart, instead update bool
            if (currentFullItem.ItemType == itemTypeCart)
            {
                cartHasBeenAdded = true;
            }
            else
            {
                rcItemList.Add(currentFullItem.ItemType);
            }

            updateAddableList();

            updateItemAdditionalText(currentFullItem.ItemType);

            var propsSuccess = new Value();

            propsSuccess["Scene Name"] = SceneManager.GetActiveScene().name;
            propsSuccess["Item Type"]  = currentFullItem.ItemType.ToString();
            propsSuccess["Success"]    = true;
            Mixpanel.Track("Placed Item", propsSuccess);
        }