// 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); }
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); }