コード例 #1
0
ファイル: MapData.cs プロジェクト: pingwiniasty/BlueSheep
 /// <summary>
 /// Parse the interactive elements array from MapComplementaryInformationsDataMessage.
 /// </summary>
 public void ParseInteractiveElements(BlueSheep.Common.Protocol.Types.InteractiveElement[] interactiveElements)
 {
     foreach (BlueSheep.Common.Protocol.Types.InteractiveElement element in interactiveElements)
     {
         if (element.elementTypeId == 85)
         {
             m_Account.Safe = element;
         }
         Elements.InteractiveElement Ielement = new Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills));
         InteractiveElements.Add(Ielement, -1);
         if (Ielement.EnabledSkills.Count > 0)
         {
             foreach (var layer in this.Data.Layers)
             {
                 foreach (var cell in layer.Cells)
                 {
                     foreach (var layerElement in cell.Elements)
                     {
                         if (layerElement is GraphicalElement)
                         {
                             GraphicalElement graphicalElement = (GraphicalElement)layerElement;
                             if (graphicalElement.Identifier == Ielement.Id)
                             {
                                 InteractiveElements[Ielement] = cell.CellId;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: EditorGraphics.cs プロジェクト: VaLiuM09/Creator
        public void BringToTop(GraphicalElement rootElement)
        {
            int elementIndex = rootElements.IndexOf(rootElement);

            rootElements.Insert(rootElements.Count, rootElement);
            rootElements.RemoveAt(elementIndex);
        }
コード例 #3
0
ファイル: EditorGraphics.cs プロジェクト: vued/Creator
        /// <summary>
        /// Registers graphical element to enable UI events and drawing for it.
        /// </summary>
        public void Register(GraphicalElement element)
        {
            if (elements.Contains(element))
            {
                return;
            }

            elements.Add(element);

            elements.Sort((e1, e2) =>
            {
                if (e2.Layer > e1.Layer)
                {
                    return(1);
                }

                if (e2.Layer < e1.Layer)
                {
                    return(-1);
                }

                return(0);
            });

            element.HandleRegistration();

            foreach (GraphicalElement child in element.Children)
            {
                Register(child);
            }
        }
コード例 #4
0
        private bool TryGetStepForTransitionDrag(Vector2 pointerPosition, out IStep step)
        {
            step = null;

            GraphicalElement elementUnderCursor = Graphics.GetGraphicalElementWithHandlerAtPoint(pointerPosition).FirstOrDefault();

            if (elementUnderCursor is EntryJoint endJoint)
            {
                if (endJoint.Parent is StepNode stepNode)
                {
                    step = stepNode.Step;
                }

                return(true);
            }
            else if (elementUnderCursor is StepNode stepNode)
            {
                step = stepNode.Step;
                return(true);
            }
            else
            {
                return(elementUnderCursor == null);
            }
        }
コード例 #5
0
ファイル: EditorGraphics.cs プロジェクト: VaLiuM09/Creator
        private void LayoutRecursive(GraphicalElement element)
        {
            element.Layout();

            foreach (GraphicalElement child in element.Children)
            {
                LayoutRecursive(child);
            }
        }
コード例 #6
0
ファイル: EditorGraphics.cs プロジェクト: VaLiuM09/Creator
        private void CollectElementsRecursively(GraphicalElement element, ref IList <IList <GraphicalElement> > collection)
        {
            InsertElement(element, ref collection);

            foreach (GraphicalElement child in element.Children)
            {
                CollectElementsRecursively(child, ref collection);
            }
        }
コード例 #7
0
ファイル: EditorGraphics.cs プロジェクト: vued/Creator
        /// <summary>
        /// Process current event.
        /// </summary>
        /// <param name="currentEvent">Event that is currently being processed.</param>
        /// <param name="window">Current window rect. Elements outside the window rect are ignored.</param>
        public void HandleEvent(Event currentEvent, Rect window)
        {
            if (currentEvent.type == EventType.Layout)
            {
                Layout();
                return;
            }

            if (currentEvent.isMouse)
            {
                if (window.Contains(currentEvent.mousePosition) == false)
                {
                    if (initiallyPressedHandler != null)
                    {
                        // Initially pressed element recieves the event in any case,
                        initiallyPressedHandler.InvokePointerUp(currentEvent.mousePosition);
                    }

                    Selected = null;
                    initiallyPressedHandler = null;
                    return;
                }

                GraphicalElement element = GetGraphicalElementWithHandlerAtPoint(currentEvent.mousePosition).FirstOrDefault();

                GraphicalEventHandler handler = Canvas;

                if (element != null)
                {
                    handler = element.GraphicalEventHandler;
                }

                if (currentEvent.type == EventType.MouseDrag)
                {
                    if (ResolvePointerDrag(currentEvent))
                    {
                        Event.current.Use();
                    }
                }
                else if (ResolvePointerHover(currentEvent, handler)
                         // | is on purpose.
                         | ResolveContextPointerUpAndClick(currentEvent, handler)
                         | ResolvePointerUpAndClick(currentEvent, handler)
                         | ResolveContextPointerDown(currentEvent, handler)
                         | ResolvePointerDown(currentEvent, handler))
                {
                    Event.current.Use();
                }
            }

            if (currentEvent.type == EventType.Repaint)
            {
                Draw(window);
            }
        }
コード例 #8
0
ファイル: EditorGraphics.cs プロジェクト: VaLiuM09/Creator
        /// <summary>
        /// Deregisters graphical element.
        /// </summary>
        public void Deregister(GraphicalElement element)
        {
            rootElements.Remove(element);

            element.HandleDeregistration();

            foreach (GraphicalElement child in element.Children.ToList())
            {
                Deregister(child);
            }
        }
コード例 #9
0
ファイル: EditorGraphics.cs プロジェクト: vued/Creator
        /// <summary>
        /// Deregisters graphical element.
        /// </summary>
        public void Deregister(GraphicalElement element)
        {
            // Don't execute callback if element wasn't registered in a first place (or if Remove(element) was called twice).
            if (elements.Remove(element))
            {
                element.HandleDeregistration();
            }

            foreach (GraphicalElement child in element.Children.ToList())
            {
                Deregister(child);
            }
        }
コード例 #10
0
ファイル: EditorGraphics.cs プロジェクト: vued/Creator
        private void LayoutRecursive(GraphicalElement element, ref HashSet <GraphicalElement> updated)
        {
            if (updated.Contains(element) == false)
            {
                element.Layout();

                updated.Add(element);

                foreach (GraphicalElement child in element.Children)
                {
                    LayoutRecursive(child, ref updated);
                }
            }
        }
コード例 #11
0
ファイル: EditorGraphics.cs プロジェクト: VaLiuM09/Creator
        /// <summary>
        /// Registers graphical element to enable UI events and drawing for it.
        /// </summary>
        public void Register(GraphicalElement element)
        {
            if (element.Parent == null)
            {
                rootElements.Add(element);
            }

            element.HandleRegistration();

            foreach (GraphicalElement child in element.Children)
            {
                Register(child);
            }
        }
コード例 #12
0
ファイル: EditorGraphics.cs プロジェクト: VaLiuM09/Creator
        private static GraphicalElement CompareElementsByOutlyingness(GraphicalElement firstElement, GraphicalElement secondElement, Edge edge)
        {
            Rect first = firstElement.BoundingBox;

            Rect second = secondElement.BoundingBox;

            switch (edge)
            {
            case Edge.Left:
                if (first.xMin <= second.xMin)
                {
                    return(firstElement);
                }

                break;

            case Edge.Right:
                if (first.xMax >= second.xMax)
                {
                    return(firstElement);
                }

                break;

            case Edge.Top:
                if (first.yMin <= second.yMin)
                {
                    return(firstElement);
                }

                break;

            case Edge.Bottom:
                if (first.yMax >= second.yMax)
                {
                    return(firstElement);
                }

                break;
            }

            return(secondElement);
        }
コード例 #13
0
ファイル: EditorGraphics.cs プロジェクト: VaLiuM09/Creator
        private void InsertElement(GraphicalElement element, ref IList <IList <GraphicalElement> > collection)
        {
            for (int i = 0; i < collection.Count; i++)
            {
                if (collection[i][0].Layer < element.Layer)
                {
                    collection.Insert(i, new List <GraphicalElement> {
                        element
                    });
                    return;
                }

                if (collection[i][0].Layer == element.Layer)
                {
                    collection[i].Add(element);
                    return;
                }
            }

            collection.Add(new List <GraphicalElement> {
                element
            });
        }
コード例 #14
0
ファイル: ContextHandler.cs プロジェクト: P4sh/BlueSheep
        public static void MapComplementaryInformationsWithCoordsMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            MapComplementaryInformationsWithCoordsMessage msg = (MapComplementaryInformationsWithCoordsMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            account.Map.SubAreaId = msg.subAreaId;
            account.Map.Data      = MapsManager.FromId(msg.mapId);
            DataClass subArea     = GameData.GetDataObject(D2oFileEnum.SubAreas, (int)msg.subAreaId);
            string    mapName     = I18N.GetText((int)GameData.GetDataObject(D2oFileEnum.Areas, (int)subArea.Fields["areaId"]).Fields["nameId"]);
            string    subAreaName = I18N.GetText((int)subArea.Fields["nameId"]);

            account.ModifBar(5, 0, 0, "[" + msg.worldX + ";" + msg.worldY + "]" + " " + mapName + " (" + subAreaName + ")");
            account.Map.Entities.Clear();
            account.Map.List.Clear();
            account.Enable(true);
            foreach (GameRolePlayActorInformations actor in msg.actors)
            {
                account.Map.Entities.Add(new BlueSheep.Core.Fight.Entity(actor.contextualId, actor.disposition.cellId));
                if (actor is GameRolePlayGroupMonsterInformations)
                {
                    GameRolePlayGroupMonsterInformations a = (GameRolePlayGroupMonsterInformations)actor;
                    account.Map.List.Add(new MonsterGroup(a.staticInfos, a.disposition.cellId, a.contextualId));
                }
            }
            account.Map.StatedElements.Clear();
            foreach (var statedElementDofus in msg.statedElements)
            {
                if (!(account.Map.StatedElements.ContainsKey(statedElementDofus.elementId)))
                {
                    account.Map.StatedElements.Add(statedElementDofus.elementId, new BlueSheep.Core.Map.Elements.StatedElement((uint)statedElementDofus.elementCellId, (uint)statedElementDofus.elementId, (uint)statedElementDofus.elementState));
                }
            }
            account.Map.InteractiveElements.Clear();
            account.Map.Doors.Clear();
            foreach (var element in msg.interactiveElements)
            {
                account.Map.InteractiveElements.Add(element.elementId, new BlueSheep.Core.Map.Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills)));
                InteractiveElement interactiveElement = element;
                List <int>         listDoorSkillId    = new List <int>(new[] { 184, 183, 187, 198, 114 });
                List <int>         listDoorTypeId     = new List <int>(new[] { -1, 128, 168, 16 });
                if (listDoorTypeId.Contains(interactiveElement.elementTypeId) && (interactiveElement.enabledSkills.Length > 0) && (listDoorSkillId.Contains(interactiveElement.enabledSkills[0].skillId)))
                {
                    foreach (var layer in ((BlueSheep.Data.D2p.Map)account.Map.Data).Layers)
                    {
                        foreach (var cell in layer.Cells)
                        {
                            foreach (var layerElement in cell.Elements)
                            {
                                if (layerElement is GraphicalElement)
                                {
                                    GraphicalElement graphicalElement = (GraphicalElement)layerElement;
                                    if ((graphicalElement.Identifier == interactiveElement.elementId) && !(account.Map.Doors.ContainsKey(cell.CellId)))
                                    {
                                        account.Map.Doors.Add(cell.CellId, new BlueSheep.Core.Map.Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills)));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            account.Npc.Npcs.Clear();
            foreach (GameRolePlayActorInformations a in msg.actors)
            {
                if (a is GameRolePlayNpcInformations)
                {
                    account.Npc.Npcs.Add(a.contextualId, ((GameRolePlayNpcInformations)a).npcId);
                }
            }
            if (account.Path != null)
            {
                if (account.Path.Current_Flag == "<Fight>" && account.state != Enums.Status.Fighting && account.Path.Current_Map == account.Map.X.ToString() + "," + account.Map.Y.ToString())
                {
                    if (account.Fight.SearchFight() == false)
                    {
                        account.Path.PerformActionsStack();
                    }
                }
                else if (account.Path != null & account.state != Enums.Status.Fighting && account.Path.Current_Map == account.Map.X.ToString() + "," + account.Map.Y.ToString())
                {
                    account.Path.PerformActionsStack();
                }
                else if (account.Path != null & account.Path.Current_Map != account.Map.X.ToString() + "," + account.Map.Y.ToString() || account.Map.Id != account.Map.LastMapId)
                {
                    //account.Path.Stop = false;
                    account.Path.Start();
                }
            }
        }
コード例 #15
0
ファイル: ChapterRepresentation.cs プロジェクト: vued/Creator
        private void SetupTransitions(IChapter chapter, EntryNode entryNode, IDictionary <IStep, StepNode> stepNodes)
        {
            if (chapter.Data.FirstStep != null)
            {
                CreateNewTransition(entryNode.ExitJoints.First(), stepNodes[chapter.Data.FirstStep].EntryJoints.First());
            }

            foreach (IStep step in stepNodes.Keys)
            {
                foreach (ITransition transition in step.Data.Transitions.Data.Transitions)
                {
                    ExitJoint joint = stepNodes[step].AddExitJoint();
                    if (transition.Data.TargetStep != null)
                    {
                        StepNode target = stepNodes[transition.Data.TargetStep];
                        CreateNewTransition(joint, target.EntryJoints.First());
                    }

                    IStep       closuredStep       = step;
                    ITransition closuredTransition = transition;
                    int         transitionIndex    = step.Data.Transitions.Data.Transitions.IndexOf(closuredTransition);

                    joint.GraphicalEventHandler.PointerDrag += (sender, args) =>
                    {
                        joint.DragDelta = args.PointerPosition - joint.Position;
                    };

                    joint.GraphicalEventHandler.PointerUp += (sender, args) =>
                    {
                        GraphicalElement elementUnderCursor = Graphics.GetGraphicalElementWithHandlerAtPoint(args.PointerPosition).FirstOrDefault();

                        EntryJoint endJoint = elementUnderCursor as EntryJoint;

                        if (endJoint == null)
                        {
                            joint.DragDelta = Vector2.zero;

                            if (elementUnderCursor != null)
                            {
                                return;
                            }
                        }

                        StepNode endJointStepNode = endJoint == null ? null : endJoint.Parent as StepNode;

                        IStep targetStep = null;
                        IStep oldStep    = closuredTransition.Data.TargetStep;

                        if (endJointStepNode != null)
                        {
                            targetStep = endJointStepNode.Step;
                        }

                        RevertableChangesHandler.Do(new TrainingCommand(() =>
                        {
                            closuredTransition.Data.TargetStep = targetStep;
                            SelectStepNode(stepNodes[closuredStep]);
                            MarkToRefresh();
                        },
                                                                        () =>
                        {
                            closuredTransition.Data.TargetStep = oldStep;
                            SelectStepNode(stepNodes[closuredStep]);
                            MarkToRefresh();
                        }
                                                                        ));

                        joint.DragDelta = Vector2.zero;
                    };

                    joint.GraphicalEventHandler.ContextClick += (sender, args) =>
                    {
                        TestableEditorElements.DisplayContextMenu(new List <TestableEditorElements.MenuOption>
                        {
                            new TestableEditorElements.MenuItem(new GUIContent("Delete transition"), false, () =>
                            {
                                RevertableChangesHandler.Do(new TrainingCommand(() =>
                                {
                                    closuredStep.Data.Transitions.Data.Transitions.Remove(closuredTransition);
                                    MarkToRefresh();
                                },
                                                                                () =>
                                {
                                    closuredStep.Data.Transitions.Data.Transitions.Insert(transitionIndex, closuredTransition);
                                    MarkToRefresh();
                                }
                                                                                ));
                            })
                        });
                    };
                }
            }
        }
コード例 #16
0
ファイル: MapInformations.cs プロジェクト: tuita520/RaidBot
        private void HandleMapComplementaryInformationsDataMessage(MapComplementaryInformationsDataMessage message, ConnectedHost source)
        {
            Data         = MapDataAdapter.GetMap(message.mapId);
            Actors       = new Dictionary <int, ActorModel>();
            Monsters     = new Dictionary <int, GroupOfMonstersModel>();
            Characters   = new Dictionary <int, CharacterModel>();
            Npcs         = new Dictionary <int, NpcModel>();
            Interactives = new Dictionary <int, ElementModel>();
            Doors        = new Dictionary <int, ElementModel>();
            X            = GameDataAdapter.GetClass <MapPosition>((int)Data.Id).PosX;
            Y            = GameDataAdapter.GetClass <MapPosition>((int)Data.Id).PosY;
            WorldId      = GameDataAdapter.GetClass <MapPosition>((int)Data.Id).WorldMap;
            foreach (var mess in message.actors)
            {
                switch (mess.TypeId)
                {
                case GameRolePlayNpcInformations.Id:
                    Npcs.Add(mess.contextualId, new NpcModel((GameRolePlayNpcInformations)mess));
                    break;

                case GameRolePlayNpcWithQuestInformations.Id:
                    Npcs.Add(mess.contextualId, new NpcModel((GameRolePlayNpcInformations)mess));
                    break;

                case GameRolePlayCharacterInformations.Id:
                    Characters.Add(mess.contextualId, new CharacterModel((GameRolePlayCharacterInformations)mess));
                    break;

                case GameRolePlayGroupMonsterInformations.Id:
                    Monsters.Add(mess.contextualId, new GroupOfMonstersModel((GameRolePlayGroupMonsterInformations)mess));
                    break;
                }
                Actors.Add(mess.contextualId, new ActorModel((GameRolePlayActorInformations)mess));
            }
            foreach (var element in message.interactiveElements)
            {
                Interactives.Add(element.elementId, new ElementModel(element));
                InteractiveElement interactiveElement = element;
                List <int>         listDoorSkillId    = new List <int>(new[] { 184, 183, 187, 198, 114 });
                List <int>         listDoorTypeId     = new List <int>(new[] { -1, 128, 168, 16 });
                if (listDoorTypeId.Contains(interactiveElement.elementTypeId) && (interactiveElement.enabledSkills.Length > 0) && (listDoorSkillId.Contains((int)interactiveElement.enabledSkills[0].skillId)))
                {
                    foreach (var layer in Data.Layers)
                    {
                        foreach (var cell in layer.cells)
                        {
                            foreach (var layerElement in cell.elements)
                            {
                                if (layerElement is GraphicalElement)
                                {
                                    GraphicalElement graphicalElement = (GraphicalElement)layerElement;
                                    if ((graphicalElement.identifier == interactiveElement.elementId) && !Doors.ContainsKey(cell.cellId))
                                    {
                                        Doors.Add(element.elementId, new ElementModel(element));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            foreach (StatedElement element in message.statedElements)
            {
                ElementModel value;
                if (Interactives.TryGetValue(element.elementId, out value))
                {
                    value.Update(element);
                }
            }
            source.Bot.Game.Player.mPathFinder.SetMap(this, false);
            OnUpdated();
        }