Пример #1
0
        private PolygonColliderTrigger[] LoadColliders(IsometricMap map, string groupName)
        {
            var collidersGroup = map.ObjectGroups[groupName];
            var colliders      = new PolygonColliderTrigger[collidersGroup.Count];

            for (var i = 0; i < collidersGroup.Count; i++)
            {
                var obj = collidersGroup[i];

                var points = new Vector2[4];
                points[0] = new Vector2(obj.Position.X, obj.Position.Y);                          //Topleft
                points[1] = new Vector2(obj.Position.X + obj.Width, obj.Position.Y);              //Topright
                points[2] = new Vector2(obj.Position.X + obj.Width, obj.Position.Y + obj.Height); //BotRight
                points[3] = new Vector2(obj.Position.X, obj.Position.Y + obj.Height);             //BotLeft

                for (var o = 0; o < 4; o++)
                {
                    points[o] = Isometric.WorldToIsometricWorld(points[o], map);
                }

                colliders[i] = new PolygonColliderTrigger(points);
                colliders[i].SetShouldColliderScaleAndRotateWithTransform(false);


                //Finally check to see if it has a depth property before adding
                if (obj.Properties.TryGetValue("depth", out var depth))
                {
                    float.TryParse(depth, out var floatValue);
                    colliders[i].Depth = floatValue;
                }

                colliderEntity.AddComponent(colliders[i]);
            }
            return(colliders);
        }
Пример #2
0
 private static void ReadObjectGroupNode(XmlReader rdr, IsometricMap map)
 {
     foreach (var r in IterateNodeEnumerable(rdr))
     {
         ObjectGroupParseMap.TryGetValue(r.Name, out var value);
         value?.Invoke(r, map);
     }
 }
Пример #3
0
 //Reads <map ...>
 private static void ReadMapNode(XmlReader rdr, IsometricMap map)
 {
     //Only iterate attributes, </map> end element is at the end of the file.
     while (rdr.MoveToNextAttribute())
     {
         MapParseMap.TryGetValue(rdr.Name, out var value);
         value?.Invoke(rdr, map);
     }
 }
Пример #4
0
        public IsometricLayer(int sizex, int sizey, bool isObjectPositioningLayer = false)
        {
            Indices = new DenseArray <int>(sizey, sizex);
            map     = IsometricMap.Instance;

            if (isObjectPositioningLayer)
            {
                SetAsObjectPositioningLayer();
            }
        }
Пример #5
0
        //Reads <layer .../>
        private static void ReadLayerNode(XmlReader rdr, IsometricMap map)
        {
            map.Layers.Add(new IsometricLayer(map.Width, map.Height));

            foreach (var r in IterateNodeEnumerable(rdr))
            {
                LayerParseMap.TryGetValue(r.Name, out var value);
                value?.Invoke(r, map);
            }
        }
Пример #6
0
        //Reads <tileset .../>
        private static void ReadTilesetNode(XmlReader rdr, IsometricMap map)
        {
            var tileset = new Tileset();

            foreach (var r in IterateNodeEnumerable(rdr))
            {
                TilesetParseMap.TryGetValue(r.Name, out var value);
                value?.Invoke(r, tileset);
            }

            map.Tilesets.Add(tileset);
        }
Пример #7
0
 public OverlapZones(IsometricMap map, Entity ent)
 {
     colliderEntity = ent;
     frontColliders = LoadColliders(map, "FrontOverlapZones");
     //backColliders = LoadColliders(map, "BackOverlapZones");
 }
 public IsometricMapComponent(IsometricMap map)
 {
     this.map = map;
 }
Пример #9
0
 public Vector2 ConvertCoordinatesToIsometricSpace(IsometricMap map)
 {
     WorldPosition = Isometric.WorldToIsometricWorld(Position, map);
     return(WorldPosition);
 }