Exemple #1
0
        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();
        }