示例#1
0
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            var mapScene = new MapScene(element.Attributes["id"].Value);
            var chapter  = parameters[0] as Chapter;

            mapScene.CameraType         = ExParsers.ParseEnum <CameraType>(ExString.Default(element.GetAttribute("cameraType"), CameraType.Aerial2D.ToString()));
            mapScene.RenderStyle        = ExParsers.ParseEnum <RenderStyle>(ExString.Default(element.GetAttribute("renderStyle"), RenderStyle.Tile.ToString()));
            mapScene.TileMetaIdentifier = ExString.Default(element.GetAttribute("tileMetaIdentifier"), "OSMTile");
            mapScene.UsesGameplayArea   = ExString.EqualsDefault(element.GetAttribute("usesGameplayArea"), "yes", false);
            mapScene.GameplayArea       = ExParsers.ParseDefault(element.GetAttribute("gameplayArea"), new RectD(Vector2d.zero, Vector2d.zero));
            mapScene.LatLon             = ExParsers.ParseDefault(element.GetAttribute("center"), Vector2d.zero);
            mapScene.Zoom = ExParsers.ParseDefault(element.GetAttribute("zoom"), 19);

            bool initialScene = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false);

            if (initialScene)
            {
                chapter.setTargetId(mapScene.getId());
            }

            int layer = 0;

            foreach (var e in element.SelectNodes("map-element"))
            {
                var        mapElementNode = e as XmlElement;
                MapElement mapElement     = null;
                XmlElement extElemNode;
                var        targetId = mapElementNode.GetAttribute("targetId");
                if ((extElemNode = (XmlElement)mapElementNode.SelectSingleNode("ext-elem-ref")) != null)
                {
                    var extElem = new ExtElemReference(targetId);
                    mapElement = extElem;
                    extElem.TransformManagerDescriptor = GetDescriptor(ExString.Default(extElemNode.GetAttribute("transformManager"),
                                                                                        typeof(GeopositionedDescriptor).FullName));

                    foreach (var param in extElem.TransformManagerDescriptor.ParameterDescription)
                    {
                        var paramNode = extElemNode.SelectSingleNode("param[@name=\"" + param.Key + "\"]");
                        if (paramNode != null)
                        {
                            extElem.TransformManagerParameters.Add(param.Key, parseParam(param.Value.Type, paramNode.InnerText));
                        }
                    }
                }
                else
                {
                    mapElement = new GeoReference(targetId);
                }

                mapElement.Conditions  = DOMParserUtility.DOMParse <Conditions>(mapElementNode.SelectSingleNode("condition") as XmlElement, parameters);
                mapElement.Layer       = ExParsers.ParseDefault(mapElementNode.GetAttribute("layer"), layer);
                mapElement.Scale       = ExParsers.ParseDefault(mapElementNode.GetAttribute("scale"), 1f);
                mapElement.Orientation = (Orientation)ExParsers.ParseDefault(mapElementNode.GetAttribute("orientation"), 2);
                layer = Mathf.Max(mapElement.Layer, layer) + 1;
                mapScene.Elements.Add(mapElement);
            }

            return(mapScene);
        }
        protected override void OnReorder(ReorderableList r)
        {
            string   idToMove = r.list [r.index] as string;
            var      temp     = Controller.getInstance().getSelectedChapterDataControl().getObjects <MapScene> ();
            MapScene toMove   = temp.Find(map => map.getId() == idToMove);

            temp.Remove(toMove);
            temp.Insert(r.index, toMove);
        }
 public GameplayAreaDataControl(MapSceneDataControl mapSceneDataControl)
 {
     this.mapSceneDataControl = mapSceneDataControl;
     this.mapScene            = mapSceneDataControl.getContent() as MapScene;
     this.gameplayArea        = new GameplayArea
     {
         UsesGameplayArea   = mapScene.UsesGameplayArea,
         BoundingBox        = mapScene.GameplayArea,
         TileMetaIdentifier = mapScene.TileMetaIdentifier
     };
 }
示例#4
0
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            var mapScene = new MapScene(element.Attributes["id"].Value);
            var chapter  = parameters[0] as Chapter;

            mapScene.CameraType = element.Attributes["cameraType"].Value.ToEnum <CameraType>();

            var tmpArgVal = element.GetAttribute("start");

            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                if (tmpArgVal.Equals("yes"))
                {
                    chapter.setTargetId(mapScene.getId());
                }
            }

            tmpArgVal = element.GetAttribute("center");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                mapScene.LatLon = (Vector2d)parseParam(typeof(Vector2d), tmpArgVal);
            }

            foreach (var e in element.SelectNodes("map-element"))
            {
                var        mapElementNode = e as XmlElement;
                MapElement mapElement     = null;
                XmlElement extElemNode;
                if ((extElemNode = (XmlElement)mapElementNode.SelectSingleNode("ext-elem-ref")) != null)
                {
                    var extElem = new ExtElemReference(mapElementNode.Attributes["targetId"].Value);
                    mapElement = extElem;
                    extElem.TransformManagerDescriptor = GetDescriptor(extElemNode.Attributes["transformManager"].Value);
                    foreach (var param in extElem.TransformManagerDescriptor.ParameterDescription)
                    {
                        var paramNode = extElemNode.SelectSingleNode("param[@name=\"" + param.Key + "\"]");
                        if (paramNode != null)
                        {
                            extElem.TransformManagerParameters.Add(param.Key, parseParam(param.Value.Type, paramNode.InnerText));
                        }
                    }
                }
                else
                {
                    mapElement = new GeoReference(mapElementNode.Attributes["targetId"].Value);
                }

                mapElement.Conditions = (Conditions)DOMParserUtility.DOMParse(mapElementNode.SelectSingleNode("condition") as XmlElement, parameters);
                mapElement.Layer      = int.Parse(mapElementNode.Attributes["layer"].Value);
                mapScene.Elements.Add(mapElement);
            }

            return(mapScene);
        }
        protected override void OnSelect(ReorderableList r)
        {
            selectedElement = r.index;

            if (selectedElement != -1)
            {
                mapScene = Controller.getInstance().getSelectedChapterDataControl().getObjects <MapScene>()[selectedElement];
                // Set geometries list reference
                mapElementReorderableList.list = mapScene.Elements;
                // Update map resources
                UpdateMapResources();
            }
        }
 public AreaMeta(MapScene mapScene)
     : this(mapScene.GameplayArea, mapScene.TileMetaIdentifier)
 {
 }
        public MapSceneDataControl(MapScene mapScene)
        {
            this.mapScene = mapScene;
            this.gameplaAreaDataControl = new GameplayAreaDataControl(this);
            var mapParametersGatherer = new Action <Action <object> >[]
            {
                callback => callback(LatLon),
                callback => callback(Zoom)
            };

            this.mapElementListDataControl = new ListDataControl <MapSceneDataControl, MapElementDataControl>(this, mapScene.Elements, new ListDataControl <MapSceneDataControl, MapElementDataControl> .ElementFactoryView()
            {
                Titles         = { { GEO_REFERENCE, "Operation.AddGeoReferenceTitle" } },
                Messages       = { { GEO_REFERENCE, "Operation.AddGeoReferenceMessage" } },
                Errors         = { { GEO_REFERENCE, "Operation.AddGeoReferenceErrorNoItems" } },
                ElementFactory = new DefaultElementFactory <MapElementDataControl>(new DefaultElementFactory <MapElementDataControl> .ElementCreator()
                {
                    CreateDataControl = o => new GeoElementRefDataControl(o as GeoReference),
                    CreateElement     = (type, targetId, _) => new GeoElementRefDataControl(new GeoReference(targetId)),
                    TypeDescriptors   = new DefaultElementFactory <MapElementDataControl> .ElementCreator.TypeDescriptor[]
                    {
                        new DefaultElementFactory <MapElementDataControl> .ElementCreator.TypeDescriptor()
                        {
                            Type                = GEO_REFERENCE,
                            ContentType         = typeof(GeoReference),
                            ValidReferenceTypes = new[] { typeof(GeoElement) },
                            ReferencesId        = true
                        }
                    }
                })
            }, new ListDataControl <MapSceneDataControl, MapElementDataControl> .ElementFactoryView()
            {
                Titles =
                {
                    { Controller.ITEM_REFERENCE,    "Operation.AddItemReferenceTitle"    },
                    { Controller.ATREZZO_REFERENCE, "Operation.AddAtrezzoReferenceTitle" },
                    { Controller.NPC_REFERENCE,     "Operation.AddNPCReferenceTitle"     }
                },
                Messages =
                {
                    { Controller.ITEM_REFERENCE,    "Operation.AddItemReferenceMessage"    },
                    { Controller.ATREZZO_REFERENCE, "Operation.AddAtrezzoReferenceMessage" },
                    { Controller.NPC_REFERENCE,     "Operation.AddNPCReferenceMessage"     }
                },
                Errors =
                {
                    { Controller.ITEM_REFERENCE,    "Operation.AddItemReferenceErrorNoItems" },
                    { Controller.ATREZZO_REFERENCE, "Operation.AddReferenceErrorNoAtrezzo"   },
                    { Controller.NPC_REFERENCE,     "Operation.AddReferenceErrorNoNPC"       }
                },
                ElementFactory = new DefaultElementFactory <MapElementDataControl>(new DefaultElementFactory <MapElementDataControl> .ElementCreator()
                {
                    CreateDataControl = o => new ExtElementRefDataControl(o as ExtElemReference),
                    CreateElement     = (type, targetId, extra) =>
                    {
                        var extElementRef = new ExtElemReference(targetId);
                        extElementRef.TransformManagerParameters["Position"] = (Vector2d)extra[0];
                        var zoom            = (int)extra[1];
                        var pixelScale      = GM.MetersToPixels(GM.PixelsToMeters(new Vector2d(1, 1), zoom), 19);
                        extElementRef.Scale = (float)pixelScale.x;
                        return(new ExtElementRefDataControl(extElementRef));
                    },
                    TypeDescriptors = new DefaultElementFactory <MapElementDataControl> .ElementCreator.TypeDescriptor[]
                    {
                        new DefaultElementFactory <MapElementDataControl> .ElementCreator.TypeDescriptor()
                        {
                            Type                = Controller.ITEM_REFERENCE,
                            ContentType         = typeof(ExtElemReference),
                            ValidReferenceTypes = new[] { typeof(Item) },
                            ExtraParameters     = mapParametersGatherer,
                            ReferencesId        = true
                        },
                        new DefaultElementFactory <MapElementDataControl> .ElementCreator.TypeDescriptor()
                        {
                            Type                = Controller.ATREZZO_REFERENCE,
                            ContentType         = typeof(ExtElemReference),
                            ValidReferenceTypes = new[] { typeof(Atrezzo) },
                            ExtraParameters     = mapParametersGatherer,
                            ReferencesId        = true
                        },
                        new DefaultElementFactory <MapElementDataControl> .ElementCreator.TypeDescriptor()
                        {
                            Type                = Controller.NPC_REFERENCE,
                            ContentType         = typeof(ExtElemReference),
                            ValidReferenceTypes = new[] { typeof(NPC) },
                            ExtraParameters     = mapParametersGatherer,
                            ReferencesId        = true
                        }
                    }
                })
            });

            xApiOptions = new Dictionary <string, List <string> >();

            var accessibleOptions = Enum.GetValues(typeof(AccessibleTracker.Accessible))
                                    .Cast <AccessibleTracker.Accessible>()
                                    .Select(v => v.ToString().ToLower())
                                    .ToList();

            xApiOptions.Add("accesible", accessibleOptions);

            var alternativeOptions = Enum.GetValues(typeof(AlternativeTracker.Alternative))
                                     .Cast <AlternativeTracker.Alternative>()
                                     .Select(v => v.ToString().ToLower())
                                     .ToList();

            xApiOptions.Add("alternative", alternativeOptions);
        }