コード例 #1
0
        private void OnContainerCreated(int containerId, ObservableList <ItemInstance> items)
        {
            String containerName;

            if (containerId == GameState.Instance.InventoryContainerId)
            {
                Toolbar.SetItems(new ObservableList <ItemInstance>(items.GetRange(0, NumItemsInToolbar)));
                Toolbar.ContainerId = containerId;
                containerName       = "Inventory";
            }
            else if (containerId == GameState.Instance.EquipmentContainerId)
            {
                containerName = "Equipment";
            }
            else
            {
                containerName = "Container " + containerId;
            }

            ContainerView containerView = ContainerViews.Find(cv => cv.ContainerId == containerId);

            if (!containerView)
            {
                containerView = ContainerGroup.CreateView <ContainerView>();
                containerView.Alignment.Value = ElementAlignment.Right;
                containerView.ContainerName   = containerName;
                containerView.SetItems(items);
                containerView.ContainerId = containerId;

                containerView.InitializeViews();

                ContainerViews.Add(containerView);
            }
            else
            {
                containerView.SetItems(items);
            }

            if (ContainerViews.Count() > _maxContainerViewsAllowed)
            {
                // index 0 is the inventory
                ContainerViews[1].Destroy();
                ContainerViews.RemoveAt(1);
            }
        }