Ejemplo n.º 1
0
        /// <summary>
        /// 更新插槽容器所在的区域
        /// </summary>
        /// <param name="slotContainer">当前插槽容器</param>
        private void ChangeRegion(SlotContainer slotContainer)
        {
            bool added = false; // 是否已经添加到区域中

            foreach (RegionData regionData in regionDataList)
            {
                if (regionData.Contains(slotContainer) && !regionData.IsInRegion(slotContainer.InvalidRectangle))
                {
                    regionData.Remove(slotContainer);
                }

                if (!regionData.Contains(slotContainer) && regionData.IsInRegion(slotContainer.InvalidRectangle))
                {
                    regionData.Add(slotContainer);
                    added = true;
                }
            }

            if (!added)
            {
                backupRegionData.Add(slotContainer);
            }

            // 更新相关连接线所在的区域
            foreach (ConnectorContainer line in slotContainer.GetConnectedLine())
            {
                ChangeRegion(line);
            }
        }
Ejemplo n.º 2
0
        protected GraphSetting graphSetting; // 绘图参数配置对象

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="line">缩放控制点所属的插槽容器</param>
        /// <param name="location">缩放控制点的位置</param>
        /// <param name="size">缩放控制点的大小</param>
        public ResizeControler(SlotContainer slotContainer, Point location, Size size)
            : base(location)
        {
            this.slotContainer = slotContainer;
            this.location      = location;
            this.elementSize   = size;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 检查是否更新事件结点
        /// </summary>
        /// <param name="graphElement">当前图元</param>
        /// <param name="eventNode">事件结点</param>
        /// <returns>是否需要更新</returns>
        protected virtual bool CheckCanBindEventNode(GraphElement graphElement, EventGraphElement eventNode)
        {
            bool         avail        = true;
            GraphManager graphManager = data as GraphManager;
            DataManager  dataManager  = graphManager.CurrentFlowChartManager.CurrentDataManager;
            IComparable  com1;
            IComparable  com2;

            if (graphElement is SlotContainer) // 插槽容器
            {
                SlotContainer slotContainer = graphElement as SlotContainer;
                if (slotContainer.EventNode != null && slotContainer.EventNode != eventNode)
                {
                    com1  = dataManager.GetData(slotContainer.EventNode) as IComparable;
                    com2  = dataManager.GetData(eventNode) as IComparable;
                    avail = (com1.CompareTo(com2) == 0);
                }
            }
            else if (graphElement is ConnectorContainer) // 连接线
            {
                ConnectorContainer line = graphElement as ConnectorContainer;
                if (line.EventNode != null && line.EventNode != eventNode)
                {
                    com1  = dataManager.GetData(line.EventNode) as IComparable;
                    com2  = dataManager.GetData(eventNode) as IComparable;
                    avail = (com1.CompareTo(com2) == 0);
                }
            }

            return(avail);
        }
Ejemplo n.º 4
0
    /*  protected void SlotCraftTransfer(ItemInput droppedItem, SlotInput otherSlot, Dictionary<string, Item> InventoryAdd, int numSlots,
     * List<GameObject> slotsContainer, List<GameObject> itemsContainer, Dictionary<string, Item> InventoryRemove) {
     *  Item it = otherSlot.StoredItem;
     *  var type = it.GetType();
     *  var obj = (Item)Activator.CreateInstance(type, it);
     *  obj.ActiveContainer = null;
     *  obj.SetQuantity(1);
     *  Pd.AddItem(
     *      obj,
     *      InventoryAdd,
     *      numSlots,
     *      slotsContainer,
     *      itemsContainer,
     *      true
     *      );
     *  Pd.RemoveItem(it, 1, InventoryRemove);
     * }*/

    protected void SlotToSlot(ItemInput droppedItem, SlotContainer otherSlot)
    {
        //Transferring the item (if it exists) from this slot to the other
        if (this.CurrentItem != null)
        {
            Item       incomingItem          = otherSlot.CurrentItem;
            GameObject incomingItemContainer = otherSlot.ItemContainer;
            int        incomingItemSlot      = incomingItem.Slot;
            GameObject incomingSlotParent    = incomingItemContainer.GetComponent <ItemInput>().SlotParent;

            Item       thisItem          = CurrentItem;
            GameObject thisItemContainer = ItemContainer;
            int        thisSlot          = thisItem.Slot;
            GameObject thisSlotParent    = thisItemContainer.GetComponent <ItemInput>().SlotParent;

            otherSlot.CurrentItem      = thisItem;
            otherSlot.CurrentItem.Slot = thisSlot;
            thisItemContainer.GetComponent <ItemInput>().SlotParent     = incomingSlotParent;
            incomingItemContainer.GetComponent <ItemInput>().SlotParent = thisSlotParent;
            this.CurrentItem      = incomingItem;
            this.CurrentItem.Slot = incomingItemSlot;
        }
        else
        {
            otherSlot.CurrentItem.Slot = Pd.SlotContainers.IndexOf(this);
            this.CurrentItem           = otherSlot.CurrentItem;
            droppedItem.SlotParent     = this.gameObject;
            this.ItemContainer         = otherSlot.ItemContainer;
            otherSlot.CurrentItem      = null;
            otherSlot.ItemContainer    = null;
        }
    }
Ejemplo n.º 5
0
        public static List <Building> ReadBuildings()
        {
            if (!Directory.Exists(BuildingsDir))
            {
                Directory.CreateDirectory(BuildingsDir);
                return(new List <Building>());
            }
            var result = new List <Building>();

            foreach (var build_dir in Directory.GetDirectories(BuildingsDir))
            {
                if (!File.Exists(build_dir + @"\" + MaterialsFile))
                {
                    return(new List <Building>());
                }

                var           files         = Directory.GetFiles(build_dir);
                SlotContainer slotContainer = ParseBuildingMaterials(build_dir + @"\" + MaterialsFile);
                ObjImporter   importer      = new ObjImporter();
                List <Mesh>   meshes        = new List <Mesh>();
                for (int i = 0; i < files.Length - 1; i++)
                {
                    meshes.Add(importer.ImportFile(files[i]));
                }
                var building = new Building(Path.GetFileName(build_dir), slotContainer, meshes);

                result.Add(building);
            }
            return(result);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 添加插槽容器到区域
 /// </summary>
 /// <param name="slotContainer">插槽容器</param>
 public void Add(SlotContainer slotContainer)
 {
     if (!slotContainers.Contains(slotContainer))
     {
         slotContainers.Add(slotContainer);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes specifed container with a set
        /// </summary>
        /// <param name="setName"></param>
        /// <param name="container"></param>
        public void FillContainer(string setName, SlotContainer <ContainedSlot> container)
        {
            SlotContainer <BlueprintSlot> set;

            if (Config.ContainerSets.TryGetValue(setName, out set))
            {
                if (container.GridSize.X < set.GridSize.X || container.GridSize.Y < set.GridSize.Y)
                {
                    throw new InvalidOperationException("Destination container is smaller than the set");
                }

                container.Clear();

                foreach (var blueprintSlot in set)
                {
                    try
                    {
                        var item = (Item)CreateFromBluePrint(blueprintSlot.BlueprintId);
                        container.PutItem(item, blueprintSlot.GridPosition, blueprintSlot.ItemsCount);
                    }
                    catch (Exception x)
                    {
                        logger.Error("Unable to create the item from blueprint {0}: {1}", blueprintSlot.BlueprintId, x.Message);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 解除连接图元
        /// </summary>
        /// <param name="flowChartManager">绘图管理器</param>
        /// <param name="logicData">逻辑数据</param>
        /// <returns>是否操作成功</returns>
        protected override bool LogicDisconnect(FlowChartManager flowChartManager, object logicData)
        {
            DataManager dataManager = flowChartManager.CurrentDataManager;

            object[]              args          = logicData as object[];
            SlotGraphElement      slot          = args[0] as SlotGraphElement;
            ConnectorGraphElement connector     = args[1] as ConnectorGraphElement;
            ConnectorContainer    line          = connector.Line;
            SlotContainer         slotContainer = slot.SlotContainer;

            List <GraphElement> list = new List <GraphElement>();         // 记录遍历的图元的链表

            if (connector.IsHeadPoint)                                    // 移出连接线的头结点
            {
                ReBindEventNode(dataManager, list, slotContainer, false); // 重新绑定当前图元与其连出图元的事件结点
            }
            else // 移出连接线的尾结点
            {
                SlotContainer outSlotContainer = connector.Line.OutSlotContainer;

                if (outSlotContainer != null)
                {
                    ReBindEventNode(dataManager, list, connector.Line, false); // 重新绑定当前图元与其连出图元的事件结点
                }
            }

            return(true);
        }
Ejemplo n.º 9
0
        private bool RollbackItem(ItemTransferMessage itm, Slot slot)
        {
            if (slot != null)
            {
                var position = itm.SourceContainerSlot;
                SlotContainer <ContainedSlot> container = null;
                if (itm.SourceContainerEntityLink.IsPointsTo(this))
                {
                    if (itm.SourceContainerSlot.X == -1)
                    {
                        container = Equipment;

                        position.X = 0;
                    }
                    else
                    {
                        container = Inventory;
                    }
                }

                if (container != null)
                {
                    container.PutItem(slot.Item, position, slot.ItemsCount);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取连入的图元链表
        /// </summary>
        /// <param name="graphElement">当前图元</param>
        /// <returns>连入的图元链表</returns>
        public List <GraphElement> GetPreviousGraphElements(GraphElement graphElement)
        {
            List <GraphElement> list = new List <GraphElement>();

            if (graphElement is SlotContainer) // 当前图元是插槽容器
            {
                SlotContainer slotContaienr = graphElement as SlotContainer;

                foreach (SlotGraphElement slot in slotContaienr.GetInSlotList())
                {
                    if (slot.Binded)
                    {
                        list.Add(slot.BindingConnector.Line);
                    }
                }
            }
            else if (graphElement is ConnectorContainer) // 当前图元是连接线控制点容器
            {
                ConnectorContainer line = graphElement as ConnectorContainer;

                if (line.InSlotContainer != null)
                {
                    list.Add(line.InSlotContainer);
                }
            }

            return(list);
        }
Ejemplo n.º 11
0
 public Building(string Name, SlotContainer materials, List <Mesh> frames)
 {
     container      = materials;
     this.frames    = frames;
     stage          = 0;
     frame_iterator = 0;
     this.Name      = Name;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取连入的所有插槽容器的链表
        /// </summary>
        /// <param name="slotContainer">当前插槽容器</param>
        /// <returns>连入的所有插槽容器的链表</returns>
        public List <SlotContainer> GetAllPreviousSlotContainers(SlotContainer slotContainer)
        {
            List <SlotContainer> list = new List <SlotContainer>();

            GetAllPreviousSlotContainers(slotContainer, list);

            return(list);
        }
Ejemplo n.º 13
0
        void charInventory_CellMouseDown(object sender, InventoryWindowEventArgs e)
        {
            var keyboard = _inputManager.KeyboardManager.CurKeyboardState;

            if (_dragControl.Slot == null)
            {
                // taking item
                var slot = e.Container.PeekSlot(e.SlotPosition);

                if (slot != null)
                {
                    if (ContainerInventoryWindow != null && e.MouseState.RightButton == S33M3CoreComponents.Inputs.MouseHandler.ButtonState.Pressed && !keyboard.IsKeyDown(Keys.ShiftKey))
                    {
                        var targetContainer = e.Container != PlayerInventoryWindow.Content ? PlayerInventoryWindow.Content : ContainerInventoryWindow.Content;

                        // quick transfer
                        if (targetContainer == null)
                        {
                            targetContainer = PlayerManager.PlayerCharacter.Equipment;
                        }

                        if (targetContainer.CanPut(slot.Item, slot.ItemsCount) && e.Container.TakeItem(slot.GridPosition, slot.ItemsCount))
                        {
                            OnSlotTaken(slot);
                            targetContainer.PutItem(slot.Item, slot.ItemsCount);
                            OnSlotPut(slot);
                        }

                        return;
                    }

                    var itemsCount = slot.ItemsCount;

                    if (e.MouseState.RightButton == S33M3CoreComponents.Inputs.MouseHandler.ButtonState.Pressed)
                    {
                        itemsCount = 1;
                    }

                    if (keyboard.IsKeyDown(Keys.ShiftKey) && itemsCount > 1)
                    {
                        itemsCount = slot.ItemsCount / 2;
                    }

                    if (!e.Container.TakeItem(slot.GridPosition, itemsCount))
                    {
                        throw new InvalidOperationException();
                    }

                    slot.ItemsCount = itemsCount;

                    BeginDrag(slot);

                    _sourceContainer = e.Container;

                    OnSlotTaken(slot);
                }
            }
        }
    void OnDeviceDetached(InputDevice inputDevice)
    {
        SlotContainer slot = FindPlayersUsingGamePad(inputDevice);

        if (slot != null)
        {
            RemoveAssignedControls(slot);
        }
    }
Ejemplo n.º 15
0
        protected InventoryWindow(SlotContainer <ContainedSlot> container, IconFactory iconFactory, Point windowStartPosition, Point gridOffset, InputsManager inputManager)
        {
            _inputManager        = inputManager;
            GridOffset           = gridOffset;
            _iconFactory         = iconFactory;
            _windowStartPosition = windowStartPosition;

            Content = container;
        }
Ejemplo n.º 16
0
        public void AddNewBuilding()
        {
            SlotContainer slotContainer = new SlotContainer();
            var           tmp           = new List <Mesh>();

            tmp.Add(ExampleMesh);
            buildings.Add(new Building("New Building", slotContainer, tmp));
            Refresh();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 连接图元
        /// </summary>
        /// <param name="flowChartManager">绘图管理器</param>
        /// <param name="logicData">逻辑数据</param>
        /// <returns>是否操作成功</returns>
        protected override bool LogicConnect(FlowChartManager flowChartManager, object logicData)
        {
            bool        executeSuccess = true;
            DataManager dataManager    = flowChartManager.CurrentDataManager;

            object[]              data      = logicData as object[];
            SlotGraphElement      slot      = data[0] as SlotGraphElement;
            ConnectorGraphElement connector = data[1] as ConnectorGraphElement;
            bool enableConnect       = true;
            List <GraphElement> list = new List <GraphElement>(); // 记录遍历过的图元的链表

            if (connector.IsHeadPoint)                            // 连入插槽容器
            {
                SlotContainer inSlotContainer = connector.Line.InSlotContainer;

                if (inSlotContainer != null)
                {
                    List <DataElement> eventList = dataManager.GetEventList(connector.Line.OutSlotContainer);

                    // 检查事件结点互斥
                    enableConnect = LogicCheck.CheckEventExclusion(eventList);

                    if (enableConnect) // 允许连接事件结点
                    {
                        bool enable = dataManager.IsConnectEventNode(inSlotContainer);
                        ReBindEventNode(dataManager, list, slot.SlotContainer, enable); // 重新绑定当前图元与其连出图元的事件结点
                    }
                    else
                    {
                        slot.UnBind();
                        executeSuccess = false;
                    }
                }
            }
            else // 连出插槽容器
            {
                SlotContainer outSlotContainer = connector.Line.OutSlotContainer;

                if (outSlotContainer != null)
                {
                    List <DataElement> eventList = dataManager.GetEventList(outSlotContainer);

                    if (enableConnect) // 允许连接事件结点
                    {
                        bool enable = dataManager.IsConnectEventNode(slot.SlotContainer);
                        ReBindEventNode(dataManager, list, connector.Line, enable); // 重新绑定当前图元与其连出图元的事件结点
                    }
                    else
                    {
                        slot.UnBind();
                        executeSuccess = false;
                    }
                }
            }

            return(executeSuccess);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Creates new inventory cell and links it with some container
 /// </summary>
 /// <param name="container"></param>
 /// <param name="iconFactory"></param>
 /// <param name="position"></param>
 public InventoryCell(SlotContainer <ContainedSlot> container, IconFactory iconFactory, Vector2I position, InputsManager inputManager)
 {
     _inputManager       = inputManager;
     _container          = container;
     _iconFactory        = iconFactory;
     InventoryPosition   = position;
     DrawCellBackground  = true;
     DrawIconsGroupId    = 2;
     base.ToolTipEnabled = true;
 }
Ejemplo n.º 19
0
 public void Init(string Name, SlotContainer materials, List <Mesh> frames)
 {
     isFinished     = false;
     container      = materials;
     this.frames    = frames;
     stage          = 0;
     frame_iterator = 0;
     this.Name      = Name;
     ClosestPoint   = this.GetComponent <MeshRenderer>().bounds.ClosestPoint;
 }
 private SlotContainer FindPlayersUsingGamePad(InputDevice inputDevice)
 {
     for (int i = 0; i < playerCount; i++)
     {
         SlotContainer slot = slots[i];
         if (slot.InputDevice == inputDevice)
         {
             return(slot);
         }
     }
     return(null);
 }
Ejemplo n.º 21
0
        /// <summary>
        /// 初始化图结点
        /// </summary>
        /// <param name="graphElement">结点对象</param>
        /// <param name="id">结点ID</param>
        /// <param name="name">结点名称</param>
        private void InitSlotContainer(SlotContainer slotContainer, int id, string name)
        {
            slotContainer.ID   = id;
            slotContainer.Name = name;
            slotContainer.Init();
            graphManager.SlotContainerList.Add(slotContainer);

            description = "创建图元 " + slotContainer.Name;
            dataManager.AddDataElement(slotContainer);
            graphManager.SelectGraphElement(slotContainer, false);
            graphManager.ReconstructCanvasGraphElementList();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 将插槽容器从区域中删除
        /// </summary>
        /// <param name="slotContainer">当前插槽容器</param>
        private void DeleteFromRegion(SlotContainer slotContainer)
        {
            foreach (RegionData regionData in regionDataList)
            {
                regionData.Remove(slotContainer);
            }

            backupRegionData.Remove(slotContainer);

            // 更新网格数据
            ClearSlotContainerGrid(slotContainer);
        }
Ejemplo n.º 23
0
        public TaskStorage(Manager manager, Slot[] itemSlots, BlockItem storageItem, int slotsX, int slotsY)
            : base(manager)
        {
            imageCaption = new ImageBox(manager);
            imageCaption.Init();
            if (storageItem.RenderMode == BlockRenderMode.Single)
            {
                imageCaption.Image = ContentPack.Textures["spritesheets\\" + storageItem.Name];
            }
            else
            {
                imageCaption.Image = ContentPack.Textures["items\\" + storageItem.Name];
            }
            imageCaption.Left   = 8;
            imageCaption.Width  = imageCaption.Image.Width;
            imageCaption.Height = imageCaption.Image.Height;
            imageCaption.Top    = 4;
            Add(imageCaption);
            Caption.Left    = Description.Left = imageCaption.Left + imageCaption.Width + 8;
            TopPanel.Height = imageCaption.Image.Height + 12;
            Resizable       = false;

            Text             = storageItem.Name;
            TopPanel.Visible = true;
            Remove(BottomPanel);
            Caption.Text          = storageItem.Name;
            Description.Text      = storageItem.Description + " - " + storageItem.StorageSlots.X * storageItem.StorageSlots.Y + " Slots";
            Description.TextColor = Color.Gray;
            Caption.TextColor     = Color.LightGray;

            slotContainer = new SlotContainer(Manager, slotsX, slotsY);
            slotContainer.Init();
            slotContainer.ItemSlots        = itemSlots;
            slotContainer.Left             = 8;
            slotContainer.Top              = TopPanel.Height + TopPanel.Top + 8;
            slotContainer.ShiftClickItems += slotContainer_ShiftClickItems;
            Add(slotContainer);

            ClientWidth  = slotContainer.Left + slotContainer.ClientWidth;
            ClientHeight = slotContainer.Top + slotContainer.ClientHeight;
            Center();

            Top     = Interface.MainWindow.inventory.Top + Interface.MainWindow.InventoryOpenHeight + 48;
            Closed += TaskStorage_Closed;
            SendToBack();

            //For some reason Center() changes with width, this resets it to the correct amount.
            ClientWidth = slotContainer.Left + slotContainer.ClientWidth;

            //Open inventory
            Interface.MainWindow.hiding    = false;
            Interface.MainWindow.expanding = true;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 获取插槽容器对应的事件结点的数据
        /// </summary>
        /// <param name="slotContainer">当前插槽容器</param>
        /// <returns>事件结点的数据</returns>
        public object GetEventData(SlotContainer slotContainer)
        {
            object data = null;

            List <DataElement> eventList = GetEventList(slotContainer);

            if (eventList.Count > 0)
            {
                data = eventList[0].Data;
            }

            return(data);
        }
Ejemplo n.º 25
0
        private void AddButtons(Warehouse warehouse)
        {
            if (warehouse.container == null || warehouse.container.GetContent().IsEmpty)
            {
                SlotContainer new_container = new SlotContainer(MaterialsNeeded);
                warehouse.container = new_container;
            }

            materials_in_warehouse.ClearList();
            foreach (var material in warehouse.container.GetContent())
            {
                var amount_button = materials_in_warehouse.AddElement(material_amount_example);
                amount_button.Init(material.Key, material.Value);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取连出的插槽容器链表
        /// </summary>
        /// <param name="slotContainer">当前插槽容器</param>
        /// <returns>连出的插槽容器链表</returns>
        public List <SlotContainer> GetNextSlotContainers(SlotContainer slotContainer)
        {
            List <SlotContainer> list = new List <SlotContainer>();

            foreach (SlotGraphElement slot in slotContainer.GetOutSlotList())
            {
                if (slot.Binded && slot.BindingConnector.Line.OutSlotContainer != null &&
                    !list.Contains(slot.BindingConnector.Line.OutSlotContainer))
                {
                    list.Add(slot.BindingConnector.Line.OutSlotContainer);
                }
            }

            return(list);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 获取连入的所有插槽容器的链表(辅助函数)
        /// </summary>
        /// <param name="slotContainer">当前插槽容器</param>
        /// <param name="list">当前搜索的所有插槽容器的练表</param>
        public void GetAllPreviousSlotContainers(SlotContainer slotContainer, List <SlotContainer> list)
        {
            if (!list.Contains(slotContainer)) // 避免出现死循环
            {
                list.Add(slotContainer);

                foreach (SlotGraphElement slot in slotContainer.GetInSlotList())
                {
                    if (slot.Binded && slot.BindingConnector.Line.InSlotContainer != null)
                    {
                        GetAllPreviousSlotContainers(slot.BindingConnector.Line.InSlotContainer, list);
                    }
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 清除插槽容器对应的网格
        /// </summary>
        /// <param name="slotContainer">插槽容器</param>
        private void ClearSlotContainerGrid(SlotContainer slotContainer)
        {
            Rectangle    rectangle     = slotContainer.InvalidRectangle;
            List <Point> gridPointList = GetGridPointList(slotContainer, gridWidth);

            foreach (Point point in gridPointList)
            {
                int gridX = (int)(point.X / gridWidth);
                int gridY = (int)(point.Y / gridWidth);

                if (gridX >= 0 && gridX < gridBoardWidth && point.Y >= 0 && point.Y < gridBoardHeight)
                {
                    canvasGridBoard[gridX, gridY] = false;
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 设置图元是否可用
        /// </summary>
        /// <param name="list">遍历过的图元链表</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="eventNode">事件结点</param>
        /// <param name="enable">图元是否可用</param>
        protected virtual void ReBindEventNode(List <GraphElement> list, GraphElement graphElement, EventGraphElement eventNode, bool enable)
        {
            if (!list.Contains(graphElement)) // 还没有遍历过当前图元
            {
                GraphManager graphManager = data as GraphManager;
                DataManager  dataManager  = graphManager.CurrentFlowChartManager.CurrentDataManager;

                if (graphElement is SlotContainer) // 该图元是插槽容器
                {
                    SlotContainer slotContainer = graphElement as SlotContainer;

                    if (!enable && slotContainer.EventNode != null && dataManager.IsConnect(slotContainer.EventNode, slotContainer)) // 不需要更新当前图元的事件结点
                    {
                    }
                    else
                    {
                        list.Add(slotContainer);
                        slotContainer.Enable    = enable;
                        slotContainer.EventNode = eventNode;

                        foreach (GraphElement g in dataManager.GetNextGraphElements(graphElement))
                        {
                            ReBindEventNode(list, g, eventNode, enable);
                        }
                    }
                }
                else if (graphElement is ConnectorContainer) // 该图元是连接线控制点容器
                {
                    ConnectorContainer line = graphElement as ConnectorContainer;

                    if (!enable && line.EventNode != null && dataManager.IsConnect(line.EventNode, line)) // 不需要更新当前图元的事件结点
                    {
                    }
                    else
                    {
                        list.Add(line);
                        line.Enable    = enable;
                        line.EventNode = eventNode;

                        foreach (GraphElement g in dataManager.GetNextGraphElements(graphElement))
                        {
                            ReBindEventNode(list, g, eventNode, enable);
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
        private void Initialize()
        {
            Equipment = new CharacterEquipment(this);
            Inventory = new SlotContainer <ContainedSlot>(this, new Vector2I(7, 5));

            Equipment.ItemTaken     += EquipmentOnItemEvent;
            Equipment.ItemPut       += EquipmentOnItemEvent;
            Equipment.ItemExchanged += EquipmentOnItemEvent;

            Inventory.ItemTaken     += EquipmentOnItemEvent;
            Inventory.ItemPut       += EquipmentOnItemEvent;
            Inventory.ItemExchanged += EquipmentOnItemEvent;

            // we need to have single id scope with two of these containers
            Equipment.JoinIdScope(Inventory);
            Inventory.JoinIdScope(Equipment);
        }