Beispiel #1
0
        /// <summary>
        ///     Jump to an item of the station
        /// </summary>
        /// <param name="index">The index of the item</param>
        public void SkipToItem(int index)
        {
            // Make sure the index is in the bounds
            index = Mathf.Clamp(index, 0, _itemList.Count - 1);

            // Update the control visibility
            previousButton.Enable(index > 0);
            nextButton.Enable(index < _itemList.Count - 1);
            skipFirstButton.Enable(index > 0);
            skipLastButton.Enable(index < _itemList.Count - 1);

            // Hide old items and switch to the next
            HideActiveItem();
            for (var i = _itemList.Count - 1; i > index; i--)
            {
                SetItemVisibility(i, false);
            }
            for (var i = 0; i <= index; i++)
            {
                SetItemVisibility(i, true);
            }
            _currentIndex = index;
            if (_itemList.Count > 0)
            {
                _activeItem = _itemList[_currentIndex];
            }
            else
            {
                _currentIndex = -1;
            }

            // Show the new item
            SetActiveHierarchyItem(_currentIndex, true);
            UpdateItemIndexText();
        }
Beispiel #2
0
        /// <summary>
        ///     Close the station view
        /// </summary>
        public void CloseStation()
        {
            gameObject.SetActive(false);
            station = null;
            Utility.ToggleVisibility(hierarchyView, true);

            // Close the SequenceView
            sequenceController.HideActiveItem();
        }
Beispiel #3
0
        /// <summary>
        ///     Create an item state snapshot from a list item
        /// </summary>
        /// <param name="item">The item of the hierarchy view</param>
        /// <returns>The created item state</returns>
        public ItemState(HierarchyItemController item)
        {
            var gameItem = item.item;
            var itemInfo = gameItem.GetComponent <ItemInfoController>().ItemInfo;

            ID          = gameItem.name;
            Name        = itemInfo.displayName;
            ParentID    = gameItem.transform.parent.name;
            NeighbourID = Utility.GetNeighbourID(gameItem.transform);
        }
Beispiel #4
0
        /// <summary>
        ///     Open the station view
        /// </summary>
        /// <param name="shownStation">The station to be shown</param>
        public void ShowStation(HierarchyItemController shownStation)
        {
            // Show the station view
            station = shownStation;
            gameObject.SetActive(true);

            // Set the name of the station
            title.text = shownStation.itemInfo.ItemInfo.displayName;

            // Update the station view
            UpdateStation(null);
        }
Beispiel #5
0
        /// <summary>
        ///     Returns index of passed component inside the specified station
        /// </summary>
        /// <param name="station">Input station</param>
        /// <param name="indexedObject">Component which should be searched in passed station</param>
        /// <returns>Returns index of passed component in station</returns>
        /// <exception cref="ComponentNotFoundException">Throws exception when component not existent</exception>
        public static int GetIndexForStation(HierarchyItemController station, GameObject indexedObject)
        {
            // Get all components of the current station
            var itemList = GetAllComponents(station.childrenContainer);

            // Search for the indexed object in the station
            for (var i = 0; i < itemList.Count; i++)
            {
                if (itemList[i].item.name == indexedObject.name)
                {
                    return(i);
                }
            }

            throw new ComponentNotFoundException();
        }
Beispiel #6
0
        /// <summary>
        ///     Method to react on changing stations
        /// </summary>
        public void ActionStationUpdate(HierarchyItemController station, Command command)
        {
            // Load the updated children container of the station into the item list
            _itemList = Utility.GetAllComponents(station.childrenContainer);

            // No command executed. Init/switch station occured --> Init StationView!
            if (command == null)
            {
                // Reset item dot indicator
                HideActiveItem();

                // Get the hierarchy item controller reference
                _station = station;

                // Jump to the end of the current station
                _currentIndex = _itemList.Count - 1;
                SkipToItem(_currentIndex);
            }
            // Action has been performed --> Update StationView!
            else
            {
                var commandType = command.GetType();

                // Find out the right command and react to it
                if (commandType == typeof(FuseCommand))
                {
                    ReactToFuse((FuseCommand)command);
                }
                else if (commandType == typeof(MoveCommand))
                {
                    ReactToMove((MoveCommand)command);
                }
                else
                {
                    SkipToActiveItem();
                }
            }
        }