Example #1
0
        public XmlContent(XElement elem)
        {
            Uid  = Interlocked.Increment(ref Manager.LastUid);
            Type = (ContentType)int.Parse(elem.Attribute("type").Value);
            Id   = int.Parse(elem.Attribute("id").Value);
            Name = elem.Attribute("name").Value;

            if ((_e = elem.Element("Layer")) != null)
            {
                LayerData = new LayerData()
                {
                    Type  = (MapLayer)int.Parse(_e.Attribute("type").Value),
                    Group = _e.Attribute("group").Value
                }
            }
            ;

            if ((_e = elem.Element("Texture")) != null)
            {
                TextureData = new TextureData()
                {
                    File     = _e.Element("FileName").Value,
                    X        = int.Parse(_e.Attribute("x").Value),
                    Y        = int.Parse(_e.Attribute("y").Value),
                    Animated = _e.Element("Animated") != null
                }
            }
            ;
        }
    }
}
Example #2
0
    public void Init(LayerData data, int ID)
    {
        this.ID          = ID;
        chunkSize        = data.chunkSize;
        voxelResolution  = data.voxelResolution;
        chunkResolutionX = data.chunkResolutionX;
        chunkResolutionY = data.chunkResolutionY;

        callbacksCount = 0;
        halfSize       = chunkSize * 0.5f;

        voxelSize = chunkSize / voxelResolution;
        int chunksCount = chunkResolutionX * chunkResolutionY;

        chunks = new VoxelGrid[chunksCount];

        activeVoxelsCount = totalVoxelsCount = chunksCount * voxelResolution * voxelResolution;


        for (int i = 0, y = 0; y < chunkResolutionY; y++)
        {
            for (int x = 0; x < chunkResolutionX; x++, i++)
            {
                CreateChunk(i, x, y, data.zOffset, data.matID, data.isLast);
            }
        }

        if (data.isLast)
        {
            BoxCollider box = gameObject.AddComponent <BoxCollider>();
            box.size   = new Vector3(chunkResolutionX * chunkSize, chunkResolutionY * chunkSize);
            box.center = new Vector3((chunkResolutionX * chunkSize) / 2 - 1, (chunkResolutionY * chunkSize) / 2 - 1, data.zOffset);
        }
        InitCallback();
    }
Example #3
0
    public void startup(World world)
    {
        this.world = world;

        int size = this.world.mapSize;

        this.cellRenderer.initializedRenderer(
            size,
            (x, y) => {
            return(this.world.mapGenerator.getLayerFromDepth(this.targetLayer.depth).getGroundTint(world, x, y));
        },
            (x, y) => {
            LayerData layerData = this.world.mapGenerator.getLayerFromDepth(this.targetLayer.depth);
            int hardness        = this.targetLayer.getHardness(x, y);
            hardness            = Mathf.Clamp(hardness, 0, this._hardnessColors.Length - 1);
            return(this._hardnessColors[hardness] * layerData.getGroundTint(world, x, y));
        },
            (x, y) => {
            return(this.targetLayer.getCellState(x, y));
        },
            (x, y) => {
            return(this.world.mapGenerator.getLayerFromDepth(this.targetLayer.depth).getGroundTile(world, x, y));
        }
            );

        this.fogRenderer.mapSize = size;
    }
        private LayerData CustomListItem(Rect position, LayerData itemValue)
        {
            var getPriorityByIndex = _layers.FindIndex(test => test == itemValue);

            if (itemValue is null)
            {
                itemValue       = new LayerData();
                itemValue.Name  = "Default_" + getPriorityByIndex;
                itemValue.Color = _state.layerDefaultColor;
            }

            position.x     = 30;
            position.width = 25;
            EditorGUI.LabelField(position, getPriorityByIndex.ToString());
            itemValue.Priority = getPriorityByIndex;

            /*position.x = 50;
             * position.width = 50;
             * EditorGUI.LabelField(position, "Name");*/

            position.width -= 50;
            position.x      = 50;
            position.xMax   = 200;
            itemValue.Name  = EditorGUI.TextField(position, itemValue.Name);

            position.x               = 210;
            position.width           = 75;
            itemValue.Color          = EditorGUI.ColorField(position, itemValue.Color);
            _state.layerDefaultColor = itemValue.Color;

            return(itemValue);
        }
Example #5
0
    public override void generate(System.Random rnd, LayerData layerData, MapAccessor accessor)
    {
        if (layerData.generateCaves)
        {
            int[,] map = this.makeCaves(rnd, layerData.lakeType, accessor.size);

            // Set tiles.
            for (int x = 0; x < accessor.size; x++)
            {
                for (int y = 0; y < accessor.size; y++)
                {
                    int      id   = map[x, y];
                    CellData cell = null;

                    if (id == 0)
                    {
                        cell = Main.instance.tileRegistry.getAir();
                    }
                    else if (id == 2)
                    {
                        cell = layerData.lakeType == EnumLakeType.WATER ? this.waterTile : this.lavaTile;
                    }

                    if (cell != null)
                    {
                        accessor.setCell(x, y, cell);
                    }
                }
            }
        }
    }
Example #6
0
    private int FindNearestYear(LayerData layerData, Transform dotContainer = null)
    {
        int dotIndex = layerData.years.IndexOf(selectedYear);

        if (dotIndex >= 0)
        {
            return(dotIndex);
        }

        // If not, then find the nearest/newest year
        int yearCount = layerData.years.Count;

        for (int i = 0; i < yearCount; i++)
        {
            int layerYear = layerData.years[i];
            if (layerYear > selectedYear)
            {
                if (dotContainer == null)
                {
                    return(i);
                }

                if (i > 0 && dotContainer.GetChild(i - 1).GetComponent <Toggle>().isOn)
                {
                    return(i - 1);
                }

                return(i);
            }
        }

        return(layerData.years.Count - 1);
    }
Example #7
0
        static MapHelper()
        {
            LayerData landmarks = new LayerData
            {
                LabelColumn = "LANAME",
                Style       = new VectorStyle {
                    EnableOutline = true, Fill = new SolidBrush(Color.FromArgb(192, Color.LightBlue))
                }
            };
            LayerData roads = new LayerData
            {
                LabelColumn = "NAME",
                Style       = new VectorStyle {
                    Line = new Pen(Color.FromArgb(200, Color.DarkBlue), 0.5f)
                }
            };
            LayerData pois = new LayerData
            {
                LabelColumn = "NAME",
                Style       = new VectorStyle {
                    PointColor = new SolidBrush(Color.FromArgb(200, Color.DarkGreen)), PointSize = 10
                }
            };

            layers = new Dictionary <string, LayerData>
            {
                { "poly_landmarks", landmarks },
                { "tiger_roads", roads },
                { "poi", pois }
            };
        }
Example #8
0
        public static Map Default()
        {
            HttpContext context = HttpContext.Current;
            Map         map     = new Map(new Size(1, 1));

            IDictionary <string, LayerData> dict = Nyc;

            foreach (string layer in dict.Keys)
            {
                string format = String.Format("~/App_Data/{0}", layer);
                string path   = context.Server.MapPath(format);
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("file not found", path);
                }

                string      name   = Path.GetFileNameWithoutExtension(layer);
                LayerData   data   = dict[layer];
                ShapeFile   source = new ShapeFile(path, true);
                VectorLayer item   = new VectorLayer(name, source)
                {
                    SRID          = 4326,
                    Style         = (VectorStyle)data.Style,
                    SmoothingMode = SmoothingMode.AntiAlias
                };
                map.Layers.Add(item);
            }
            return(map);
        }
Example #9
0
    void Awake()
    {
        layers = new List <VoxelLayer>();
        System.Random randomSequence = new System.Random();

        LayerData data = new LayerData(randomSequence);

        ResetActiveLayers();
        clickState = ClickState.NONE;
        // cameraControler.Initialze(new Vector2(data.chunkResolutionX * data.chunkSize / 2, data.chunkResolutionY));
        halfSize  = data.chunkSize * 0.5f;
        voxelSize = data.chunkSize / data.voxelResolution;

        for (int i = 0; i < layersCount; i++)
        {
            data = new LayerData(randomSequence)
            {
                zOffset = zSize * i, isLast = i == layersCount - 1
            };

            layers.Add(Instantiate(voxelLayerPrefab) as VoxelLayer);

            layers[i].Init(data, i);
        }

        FrustumTest();
    }
        public LayerSolver(LayerData prevLayer, NumericalParameters numericalParameters)
        {
            width     = prevLayer.Width;
            height    = prevLayer.Height;
            thickness = prevLayer.Thickness;

            this.prevLayer          = prevLayer;
            this.oldLayer           = prevLayer;
            this.nextLayer          = new LayerData(width, height, thickness);
            this.intermediateLayer1 = new LayerData(width, height, thickness);
            this.intermediateLayer2 = new LayerData(width, height, thickness);

            this.numPar = numericalParameters;
            this.cp     = (numericalParameters.Gamma - 1) / (numericalParameters.Gamma * numericalParameters.Re);

            //Параметры колонны
            Ax = Az = 0;
            Dx = width;
            Dz = thickness;
            //if (Nz = 50, Ny = Nx = 40) =>
            Bx = (int)(numericalParameters.Nx / 2.0 - numericalParameters.Nx / 4.0);    //10
            Cx = (int)(numericalParameters.Nx / 2.0 + numericalParameters.Nx / 4.0);    //30
            Bz = (int)(numericalParameters.Nz / 2.0 - numericalParameters.Nz / 5.0);    //15
            Cz = (int)(numericalParameters.Nz / 2.0 + numericalParameters.Nz / 5.0);    //35
        }
Example #11
0
        private void lstLayers_SelectedIndexChanged(object sender, EventArgs e)
        {
            LayerData layer = (LayerData)lstLayers.SelectedItem;

            int vShowing = picLayer.Height / 32;
            int hShowing = picLayer.Width / 32;

            if (vShowing < Maps[layer.Map].Height)
            {
                vscrMap.Visible = true;
                vscrMap.Maximum = Maps[layer.Map].Height - vShowing;
            }
            else
            {
                vscrMap.Visible = false;
            }
            if (hShowing < Maps[layer.Map].Width)
            {
                hscrMap.Visible = true;
                hscrMap.Maximum = Maps[layer.Map].Width - hShowing;
            }
            else
            {
                hscrMap.Visible = false;
            }

            if (chkDrawAll.Checked)
            {
                DrawMap();
            }
            else
            {
                DrawMap(layer);
            }
        }
Example #12
0
    public static List <TiledMapLayer> BuildLayers(MapData2D map, TilesetData tileset, ref int nextLayerId)
    {
        var underlayId = nextLayerId++;
        var overlayId  = nextLayerId++;

        return(new()
        {
            new()
            {
                Id = underlayId,
                Name = LayerName.Underlay,
                Width = map.Width,
                Height = map.Height,
                Data = new LayerData {
                    Encoding = "csv", Content = BuildCsvData(map, tileset, false)
                }
            },
            new()
            {
                Id = overlayId,
                Name = LayerName.Overlay,
                Width = map.Width,
                Height = map.Height,
                Data = new LayerData {
                    Encoding = "csv", Content = BuildCsvData(map, tileset, true)
                }
            }
        });
    }
Example #13
0
 public void AddItemToRoom(ItemData item)
 {
     if (item.SpriteSheet == null)
     {
         return;
     }
     //RoomData rd = currentScene.Rooms[0];
     if (currentRoom == null)
     {
         // alert user to select room
         return;
     }
     if (currentLayer.Equals(Constants.LAYER_TYPES.NONE))
     {
         // alert user to select layer.
         return;
     }
     if (item.PositionX >= currentRoom.PositionX && item.PositionX < currentRoom.PositionX + currentRoom.Width)
     {
         if (item.PositionY >= currentRoom.PositionY && item.PositionY < currentRoom.PositionY + currentRoom.Height)
         {
             LayerData ld = currentRoom.getLayerByType(currentLayer);
             if (ld != null)
             {
                 ld.addItem(item);
             }
             return;
         }
     }
 }
Example #14
0
 public void RemoveItemFromRoom(float x, float y)
 {
     //RoomData rd = currentScene.Rooms[0];
     if (currentRoom == null)
     {
         // alert user to select room
         return;
     }
     if (currentLayer.Equals(Constants.LAYER_TYPES.NONE))
     {
         // alert user to select layer.
         return;
     }
     if (x >= currentRoom.PositionX && x <= currentRoom.PositionX + currentRoom.Width)
     {
         if (y >= currentRoom.PositionY && y <= currentRoom.PositionY + currentRoom.Height)
         {
             LayerData ld = currentRoom.getLayerByType(currentLayer);
             if (ld != null)
             {
                 //ld.addItem(item);
                 ld.removeItem(x, y);
             }
             return;
         }
     }
 }
Example #15
0
        private void PaintTile()
        {
            LayerData curLayer = (LayerData)lstLayers.SelectedItem;
            bool      Painted  = false;

            foreach (TileData tile in curLayer.Tiles)
            {
                if (tile.X == HoverTile.X && tile.Y == HoverTile.Y)
                {
                    if (tile.Sheet != SelectedSheet ||
                        tile.SheetX != SelectedTile.X ||
                        tile.SheetY != SelectedTile.Y)
                    {
                        tile.Sheet  = SelectedSheet;
                        tile.SheetX = SelectedTile.X;
                        tile.SheetY = SelectedTile.Y;
                        Painted     = true;
                    }
                    break;
                }
            }
            if (Painted)
            {
                //if (chkDrawAll.Checked)
                DrawMap(HoverTile);
                //else
                //    DrawMap(curLayer, HoverTile);
            }
        }
Example #16
0
        public static Map Spherical()
        {
            ICoordinateTransformation transformation = ProjHelper.LatLonToGoogle();
            HttpContext context = HttpContext.Current;
            Map         map     = new Map(new Size(1, 1));

            IDictionary <string, LayerData> dict = Nyc;

            foreach (string layer in dict.Keys)
            {
                string format = String.Format("~/App_Data/{0}", layer);
                string path   = context.Server.MapPath(format);
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("file not found", path);
                }

                string      name   = Path.GetFileNameWithoutExtension(layer);
                LayerData   data   = dict[layer];
                ShapeFile   source = new ShapeFile(path, true, new WebCacheUtility());
                VectorLayer item   = new VectorLayer(name, source)
                {
                    SRID       = 4326,
                    TargetSRID = 900913,
                    CoordinateTransformation = transformation,
                    Style         = (VectorStyle)data.Style,
                    SmoothingMode = SmoothingMode.AntiAlias
                };
                map.Layers.Add(item);
            }
            return(map);
        }
Example #17
0
        public XmlContent(XElement elem)
        {
            Type = (ContentType)int.Parse(elem.Attribute("type").Value);
            Id   = int.Parse(elem.Attribute("id").Value);
            Name = elem.Attribute("name").Value;

            if ((_e = elem.Element("Layer")) != null)
            {
                LayerData = new LayerData()
                {
                    Type  = (MapLayer)int.Parse(_e.Attribute("type").Value),
                    Group = _e.Attribute("group").Value
                }
            }
            ;

            if ((_e = elem.Element("Texture")) != null)
            {
                TextureData = new TextureData()
                {
                    File = _e.Element("FileName").Value,
                    X    = int.Parse(_e.Attribute("x").Value),
                    Y    = int.Parse(_e.Attribute("y").Value)
                }
            }
            ;
        }
    }
}
Example #18
0
        public static void UT2()
        {
            DicStorage <int, LayerData> storage = new DicStorage <int, LayerData>(
                (a) => { return(a.Key1); },
                () =>
            {
                return(new DicObjectStorage <int, LayerData>((a) => { return a.Key2; }));
            });

            LayerData ldA = new LayerData()
            {
                Key1 = 1, Key2 = 2
            };

            storage.Insert(ldA);
            System.Diagnostics.Debug.Assert(storage.Count == 1);

            LayerData ldB = new LayerData()
            {
                Key1 = 2, Key2 = 3
            };

            storage.Insert(ldB);
            System.Diagnostics.Debug.Assert(storage.Count == 2);

            LayerData ldC = new LayerData()
            {
                Key1 = 2, Key2 = 3, Data = 100
            };

            storage.Update(ldC);
        }
Example #19
0
        public static Map OpenLayers()
        {
            ICoordinateTransformation transformation = LatLonToGoogle();
            HttpContext context = HttpContext.Current;
            Map         map     = new Map(new Size(1, 1));

            IDictionary <string, LayerData> dict = Nyc;

            foreach (string layer in dict.Keys)
            {
                string format = String.Format("~/App_Data/nyc/{0}.shp", layer);
                string path   = context.Server.MapPath(format);
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("file not found", path);
                }

                LayerData data       = dict[layer];
                ShapeFile dataSource = new ShapeFile(path, true)
                {
                    SRID = 900913
                };
                VectorLayer item = new VectorLayer(layer, dataSource)
                {
                    Style                    = (VectorStyle)data.Style,
                    SmoothingMode            = SmoothingMode.AntiAlias,
                    CoordinateTransformation = transformation
                };
                map.Layers.Add(item);
            }
            return(map);
        }
Example #20
0
        public static Map InitializeMap()
        {
            HttpContext context = HttpContext.Current;
            Map         map     = new Map(new Size(1, 1));

            foreach (string layer in layers.Keys)
            {
                string format = String.Format("~/App_Data/nyc/{0}.shp", layer);
                string path   = context.Server.MapPath(format);
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("file not found", path);
                }

                LayerData data       = layers[layer];
                ShapeFile dataSource = new ShapeFile(path, true)
                {
                    SRID = 900913
                };
                VectorLayer item = new VectorLayer(layer, dataSource)
                {
                    CoordinateTransformation = data.Transformation,
                    Style         = (VectorStyle)data.Style,
                    SmoothingMode = SmoothingMode.AntiAlias
                };
                map.Layers.Add(item);

                // LabelLayer labels = CreateLabelLayer(item, data.LabelColumn);
                // map.Layers.Add(labels);
            }
            return(map);
        }
Example #21
0
        private TreeNode MakeLayerNode(LayerData layer)
        {
            TreeNode nodeLayer = new TreeNode(), nodeLayerPrf = new TreeNode(), nodeObj;

            nodeLayer.Text               = layer.Name;
            nodeLayer.Tag                = layer;
            nodeLayer.ImageIndex         = 7;
            nodeLayer.SelectedImageIndex = 7;
            layer.TreeNode               = nodeLayer;

            nodeLayerPrf.Text               = layer.Name + " " + Language.ProjectExplorer.NodeText_LayerProfile;
            nodeLayerPrf.Tag                = layer.Profile;
            nodeLayerPrf.ImageIndex         = 8;
            nodeLayerPrf.SelectedImageIndex = 8;
            layer.Profile.TreeNode          = nodeLayerPrf;
            nodeLayer.Nodes.Add(nodeLayerPrf);

            foreach (GeometricObjectDataBase obj in layer.GeometricObjects)
            {
                nodeObj                    = new TreeNode();
                nodeObj.Text               = obj.Name;
                nodeObj.Tag                = obj;
                nodeObj.ImageIndex         = 9;
                nodeObj.SelectedImageIndex = 9;
                obj.TreeNode               = nodeObj;
                nodeLayer.Nodes.Add(nodeObj);
            }
            return(nodeLayer);
        }
Example #22
0
        public void BuildLayerAndObjectNodes(List <BaseTreeNode> treeNodeList, IEnumerable <IILayer> layers, Hashtable folderNodeIdMap)
        {
            foreach (IILayer layer in layers)
            {
                UIntPtr   handle        = MaxAnimatable.GetHandleByAnim(layer);
                LayerData layerNodeData = MaxIO.LoadLayerData(layer);

                // If layer has node data, create treeNode based on that.
                // If not, create a new treeNode and append to root.
                LayerTreeNode layerTreeNode;
                if (layerNodeData == null)
                {
                    layerTreeNode = new LayerTreeNode(handle, HandleMap);
                    BuildChildObjects(layerTreeNode, layer);
                    treeNodeList.Add(layerTreeNode);
                }
                else
                {
                    List <Guid> layerTreeNodeParentIDs = layerNodeData.ParentIDs;
                    foreach (Guid layerTreeNodeParentID in layerTreeNodeParentIDs)
                    {
                        // If the handle already exists it is an instance.
                        // Populate the instance properties on all layers with that handle.
                        if (HandleMap.ContainsHandle(handle))
                        {
                            layerTreeNode = new LayerTreeNode(layerNodeData, handle, HandleMap);
                        }
                        else
                        {
                            layerTreeNode = new LayerTreeNode(layerNodeData, handle, HandleMap);
                        }

                        // If folderNodeData does not have a parent ID,
                        // it should be appended as a root node.
                        if (layerTreeNodeParentID == Guid.Empty)
                        {
                            treeNodeList.Add(layerTreeNode);
                        }
                        // If not, it should be parented to an existing treeNode,
                        // as long as it exists.
                        else
                        {
                            FolderTreeNode parent = folderNodeIdMap[layerTreeNodeParentID] as FolderTreeNode;
                            if (parent == null)
                            {
                                treeNodeList.Add(layerTreeNode);
                            }
                            else
                            {
                                layerTreeNode.Parent = parent;
                                parent.Children.Add(layerTreeNode);
                            }
                        }

                        // Add objects to layer.
                        BuildChildObjects(layerTreeNode, layer);
                    }
                }
            }
        }
Example #23
0
    short RangeArray(int mapX, int mapY, short layer, LayerData layerData)
    {
        if (mapX < 0 || mapY < 0)
        {
            return(0);
        }

        if (mapX > mapSizeX || mapY > mapSizeY)
        {
            //нет спрайта
            return(0);
        }
        if (layerData == LayerData.WaterLayer)
        {
            return(Map[mapX, mapY].liquidType);
        }

        if (layerData == LayerData.TerrainBgLayer)
        {
            return(Map[mapX, mapY].typeBG);
        }

        if (Map[mapX, mapY].layer == layer)
        {
            return(Map[mapX, mapY].type);
        }

        if (layer == -1)
        {
            return(Map[mapX, mapY].type);
        }

        return(0);
    }
Example #24
0
    public void LevelSpawn(int layers = 10)
    {
        this.layers = layers;
        for (int i = 0; i < spawnBase.childCount; i++)
        {
            spawnBase.GetChild(i).gameObject.SetActive(false);
        }

        score    = 0;
        scoreMax = layerAmount * layers;
        float angle = 360f / layerAmount;

        layerList = new LayerData[layers];
        for (int i = 0; i < layers; i++)
        {
            layerList[i] = new LayerData(i, pinPrefab.Height * 2f * i + pinPrefab.Height);
            spawnBase.AddPoolList(pinPrefab, layerAmount, ref pinPool, (p, j) =>
            {
                p.transform.localRotation = Quaternion.identity;
                p.transform.localPosition =
                    Quaternion.Euler(0, angle * j + (i % 2 == 0 ? 0 : angle / 2f), 0) * (Vector3.forward * layerRadius) +
                    (Vector3.up * layerList[i].posHeight);
                p.Init(this, layerList[i]);
                layerList[i].pins.Add(p);
            });
        }
        layerTop = layers - 1;
    }
Example #25
0
        private void _Paste()
        {
            if (!(Selection is LayerData || Selection is GeometricObjectDataBase))
            {
                return;
            }
            if (Clipboard == null)
            {
                return;
            }

            EnableUndoRedoStoring = false;

            GeometricObjectDataBase obj = Clipboard.DeepClone() as GeometricObjectDataBase;
            LayerData target            = SelectedLayer;

            target.GeometricObjects.Add(obj);
            Action       undo   = () => { target.GeometricObjects.Remove(obj); };
            Action       redo   = () => { target.GeometricObjects.Add(obj); };
            UndoRedoPair urPair = new UndoRedoPair(new UndoRedoPairString(CurrentLanguage.StandardFunction.Paste + " : " + obj.Name, ""), undo, redo);

            EnableUndoRedoStoring = true;
            AddUndoRedoPair(urPair);

            ValidateProject(DoesUpdateShapeAuto);
        }
Example #26
0
        public static Map PolyMaps()
        {
            HttpContext context = HttpContext.Current;
            Map         map     = new Map(new Size(1, 1));

            foreach (string layer in layers.Keys)
            {
                string format = String.Format("~/App_Data/nyc/{0}.shp", layer);
                string path   = context.Server.MapPath(format);
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("file not found", path);
                }

                LayerData data       = layers[layer];
                ShapeFile dataSource = new ShapeFile(path, true)
                {
                    SRID = 4326
                };
                VectorLayer item = new VectorLayer(layer, dataSource)
                {
                    Style         = (VectorStyle)data.Style,
                    SmoothingMode = SmoothingMode.AntiAlias
                };
                map.Layers.Add(item);
            }
            return(map);
        }
Example #27
0
 /// <summary>レイヤを追加する。</summary>
 /// <param name="layer"></param>
 public LayerData AddLayer(LayerData layer)
 {
     LogMethodStart();
     _AddLayer(layer);
     LogMethodEnd();
     return(layer);
 }
Example #28
0
    /// <summary>
    /// 得到层数据
    /// </summary>
    /// <param name="layer"></param>
    /// <returns></returns>
    public static LayerData GetLayer(Layer layer)
    {
        LayerData d = null;

        s_dict.TryGetValue(layer, out d);
        return(d);
    }
Example #29
0
        public LayerData GetLayerData(BaseDocument doc)
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.BaseList2D_GetLayerData__SWIG_1(swigCPtr, BaseDocument.getCPtr(doc));
            LayerData             ret  = (cPtr == global::System.IntPtr.Zero) ? null : new LayerData(cPtr, false);

            return(ret);
        }
Example #30
0
    public override void generate(World world, int depth)
    {
        LayerData layerData = world.mapGenerator.getLayerFromDepth(depth);

        // Generate the inside/outside map
        for (int x = 0; x < world.mapSize; x++)
        {
            for (int y = 0; y < world.mapSize; y++)
            {
                Random.State state = Random.state;
                Random.InitState(world.seed);

                float noise = Mathf.PerlinNoise(x * 0.1f, Random.value * 1000);
                float endY  = (noise * 7) + this._surfaceSize;

                Random.state = state;

                world.storage.setOutside(x, y, y < endY);
            }
        }

        for (int x = 0; x < world.mapSize; x++)
        {
            for (int y = 0; y < world.mapSize; y++)
            {
                Position pos = new Position(x, y, depth);

                if (world.isOutside(pos))
                {
                    // Outside Tile.

                    CellData cell     = null;
                    Rotation rotation = Rotation.UP;
                    if (world.isOutside(new Position(x, y + 1, depth)))
                    {
                        foreach (PrimitiveRndObject pro in this.rndObjects)
                        {
                            pro.getRnd(ref cell, ref rotation);
                        }
                    }

                    world.setCell(pos, cell, rotation);

                    // Remove fog from outside
                    world.liftFog(pos, false);
                }
                else
                {
                    // Inside Tile

                    // Remove ores exposed to the surface, but not the bedrock
                    if (x != 0 && x != world.mapSize - 1 && world.isOutside(new Position(x, y - 1, depth)))
                    {
                        world.setCell(pos, layerData.getFillCell(world, x, y));
                    }
                }
            }
        }
    }
Example #31
0
	private static LayerData AddLayer(JSONObject layerJSON)
	{
		LayerData ly = new LayerData();

		ly.layerType = layerJSON["name"].str.ToLower();
		ly.objects = new ObjectData[layerJSON["objects"].list.Count];

		for (int i = 0; i < layerJSON["objects"].list.Count; i++)
		{
			ly.objects[i] = AddObject(layerJSON["objects"][i]);
		}

		return ly;
	}
		internal LayerSettingDialog(LayerData layer)
			{
			InitializeComponent();
			DialogResult = DialogResult.Cancel;

			Layer = layer;
			LayerProfile = Layer.Profile;
			textBoxLayerName.Text = Layer.Name;
			Border = new PenEx( LayerProfile.RenderSetting.Border );
			Fill = new HatchBrushEx( LayerProfile.RenderSetting.Fill );

			Text = Language.LayerSettingDialog.Text;
			labelName.Text = Language.LayerSettingDialog.LabelLayerName;
			groupBoxMaterial.Text = Language.LayerSettingDialog.GroupBoxMaterial;
			buttonMaterial.Text = Language.LayerSettingDialog.ButtonMaterial;
			groupBoxRenderingStyle.Text = Language.LayerSettingDialog.GroupBoxRenderingStyle;
			buttonBorderColor.Text = Language.LayerSettingDialog.ButtonBorderColor;
			buttonFillColor.Text = Language.LayerSettingDialog.ButtonFillColor;
			buttonFillStyle.Text = Language.LayerSettingDialog.ButtonFillStyle;
			buttonOK.Text = Language.DialogGeneral.ButtonOK;
			buttonCancel.Text = Language.DialogGeneral.ButtonCancel;
			}
        /// <summary>
        /// Deserialize the message
        /// </summary>
        /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
        public override void Deserialize(OSDMap map)
        {
            OSDMap agentMap = (OSDMap)map["AgentData"];
            Flags = agentMap["Flags"].AsInteger();

            OSDArray layerArray = (OSDArray)map["LayerData"];

            LayerDataBlocks = new LayerData[layerArray.Count];

            for (int i = 0; i < LayerDataBlocks.Length; i++)
            {
                OSDMap layerMap = (OSDMap)layerArray[i];

                LayerData layer = new LayerData();
                layer.ImageID = layerMap["ImageID"].AsUUID();
                layer.Top = layerMap["Top"].AsInteger();
                layer.Right = layerMap["Right"].AsInteger();
                layer.Left = layerMap["Left"].AsInteger();
                layer.Bottom = layerMap["Bottom"].AsInteger();

                LayerDataBlocks[i] = layer;
            }
        }
Example #34
0
        private string ConvertLayerDataToString(LayerData layer, bool compressed)
        {
            //
            MemoryStream ms=new MemoryStream();
            BinaryWriter bw=new BinaryWriter(ms);

            for(int y=0;y<layer.height;y++)
            {
                for(int x=0;x<layer.width;x++)
                {
                    bw.Write(layer.data[x, y]);
                }
            }

            //Gzip Decodierung
            byte[] layerdataCompressed;

            if(compressed)
            {
                layerdataCompressed=gzip.Compress(ms.ToArray());
            }
            else
            {
                layerdataCompressed=ms.ToArray();
            }

            //Base64 Encodierung
            string layerdataEncoded=CSCL.Crypto.Encoding.Base64.Encode(layerdataCompressed);
            return layerdataEncoded;
        }
		private TreeNode MakeLayerNode(LayerData layer)
			{
			TreeNode nodeLayer = new TreeNode(), nodeLayerPrf = new TreeNode(), nodeObj;
			nodeLayer.Text = layer.Name;
			nodeLayer.Tag = layer;
			nodeLayer.ImageIndex = 7;
			nodeLayer.SelectedImageIndex = 7;
			layer.TreeNode = nodeLayer;

			nodeLayerPrf.Text = layer.Name + " " + Language.ProjectExplorer.NodeText_LayerProfile;
			nodeLayerPrf.Tag = layer.Profile;
			nodeLayerPrf.ImageIndex = 8;
			nodeLayerPrf.SelectedImageIndex = 8;
			layer.Profile.TreeNode = nodeLayerPrf;
			nodeLayer.Nodes.Add( nodeLayerPrf );

			foreach( GeometricObjectDataBase obj in layer.GeometricObjects )
				{
				nodeObj = new TreeNode();
				nodeObj.Text = obj.Name;
				nodeObj.Tag = obj;
				nodeObj.ImageIndex = 9;
				nodeObj.SelectedImageIndex = 9;
				obj.TreeNode = nodeObj;
				nodeLayer.Nodes.Add( nodeObj );
				}
			return nodeLayer;
			}
Example #36
0
        private void crateLayerButtonItem(LayerData layer, int i)
        {
            GameObject layerLine = GameObject.Instantiate(LayerLinePrefab);
            LayerLineGUI layerLineGui = layerLine.GetComponent<LayerLineGUI>();
            layerLineGui.Init(layer, ItemPanel, () => switchLayer(layer));

            layerButtons.Add(layerLineGui);
        }
Example #37
0
 void switchLayer(LayerData layer)
 {
     switchLayerSelection(Layers.IndexOf(layer));
 }
Example #38
0
 void showHide(LayerData layer)
 {
 }
		/// <summary></summary>
		public MeepGeometricObjectMaker(LayerData layer)
			{
			Layer = layer;
			}
Example #40
0
        void Open(string filename, bool loadTilesets)
        {
            //Datei öffnen
            Tilesets=new List<TilesetData>();
            Layers=new List<LayerData>();
            ObjectLayers=new List<Objectgroup>();
            Properties=new List<Property>();

            //XMLdata öffnen
            FileData=new XmlData(filename);

            #region MapsInfo ermitteln
            XmlNodeList xnl=FileData.Document.SelectNodes("/map");

            MapVersion=xnl[0].Attributes["version"].Value;
            Orientation=xnl[0].Attributes["orientation"].Value;

            Width=Convert.ToInt32(xnl[0].Attributes["width"].Value);
            Height=Convert.ToInt32(xnl[0].Attributes["height"].Value);

            TileWidth=Convert.ToInt32(xnl[0].Attributes["tilewidth"].Value);
            TileHeight=Convert.ToInt32(xnl[0].Attributes["tileheight"].Value);
            #endregion

            #region Properties auslesen
            xnl=FileData.Document.SelectNodes("/map/properties");

            foreach(XmlNode j in xnl)
            {
                XmlNodeList subnodes=j.SelectNodes("child::property");

                foreach(XmlNode pNode in subnodes)
                {
                    string name=pNode.Attributes[0].Name;
                    string value=pNode.Attributes[0].Value;

                    Properties.Add(new Property(pNode));
                }
            }
            #endregion

            #region Tilesets ermitteln
            xnl=FileData.Document.SelectNodes("/map/tileset");

            foreach(XmlNode j in xnl)
            {
                //Tilesets
                TilesetData ts=new TilesetData();

                ts.imgsource=j.SelectNodes("child::image")[0].Attributes[0].Value; //Image Source für den Layer
                string imgsourceComplete=FileSystem.GetPath(filename)+ts.imgsource;

                //Tiles laden, wenn vorhanden
                XmlNodeList nodelist=j.SelectNodes("child::tile");

                foreach(XmlNode tileXml in nodelist)
                {
                    Tile tile=new Tile();
                    tile.ID=tileXml.Attributes["id"].Value.ToString();

                    xnl=tileXml.SelectNodes("child::properties");

                    foreach(XmlNode jProp in xnl)
                    {
                        XmlNodeList subnodes=jProp.SelectNodes("child::property");

                        foreach(XmlNode pNode in subnodes)
                        {
                            tile.Properties.Add(new Property(pNode));
                        }
                    }

                    ts.Tiles.Add(tile);
                }

                //Tilebildl laden
                if(loadTilesets)
                {
                    try
                    {
                        ts.img=pooledLoader.FromFile(imgsourceComplete);
                    }
                    catch(FileNotFoundException ex)
                    {
                        throw new TilesetNotExistsException(ex.Message);
                    }
                }

                //Attrribute
                ts.name=j.Attributes["name"].Value; 
                ts.firstgid=Convert.ToInt32(j.Attributes["firstgid"].Value);
                ts.tilewidth=Convert.ToInt32(j.Attributes["tilewidth"].Value);
                ts.tileheight=Convert.ToInt32(j.Attributes["tileheight"].Value);

                Tilesets.Add(ts);
            }
            #endregion

            #region Layers ermitteln
            xnl=FileData.Document.SelectNodes("/map/layer");

            foreach(XmlNode j in xnl) //pro layer
            {
                //Layer
                LayerData lr=new LayerData();

                //Attribute
                lr.name=j.Attributes["name"].Value;
                lr.width=Convert.ToInt32(j.Attributes["width"].Value);
                lr.height=Convert.ToInt32(j.Attributes["height"].Value);

                //Layerdaten
                // Attribute werden als "<data encoding="base64" compression="gzip">" angenommen
                string encoding=j["data"].Attributes["encoding"].Value;

                string compression="uncompressed";

                if(j["data"].Attributes["compression"]!=null)
                {
                    compression=j["data"].Attributes["compression"].Value;
                }

                if(encoding!="base64")
                {
                    throw (new NotImplementedException("Weitere Codierungsarten sind noch nicht implementiert!"));
                }


                if(compression!="uncompressed"&&compression!="gzip")
                {
                    throw (new NotSupportedCompressionException("Weitere Kompressionsverfahren sind noch nicht implementiert!"));
                }

                //Base64 Encodierung
                string layerdataBase64Compressed=j.SelectNodes("child::data")[0].InnerText;
                layerdataBase64Compressed=layerdataBase64Compressed.TrimStart('\n');
                layerdataBase64Compressed=layerdataBase64Compressed.Trim();
                byte[] layerdataCompressed=CSCL.Crypto.Encoding.Base64.Decode(layerdataBase64Compressed); 

                //Gzip Decodierung (wenn nötig)
                byte[] layerdataDecompressed;
                if(compression=="uncompressed")
                {
                    layerdataDecompressed=layerdataCompressed;
                }
                else
                {
                    layerdataDecompressed=gzip.Decompress(layerdataCompressed);
                }

                //Interpretieren der Codierten Daten
                lr.data=new int[lr.width, lr.height];
                //int[,] zelle=new int[4, 3];
                BinaryReader br=new BinaryReader(new MemoryStream(layerdataDecompressed));

                for(int y=0;y<lr.height;y++)
                {
                    for(int x=0;x<lr.width;x++)
                    {
                        lr.data[x, y]=br.ReadInt32();
                    }
                }
				
                Layers.Add(lr);
            }
            #endregion

            #region Objektlayer ermitteln
            xnl=FileData.Document.SelectNodes("/map/objectgroup");

            foreach(XmlNode j in xnl) //pro layer
            {
                ObjectLayers.Add(new Objectgroup(j));
            }
            #endregion
        }
		private void DeleteLayer(LayerData layer)
			{
			string notice = CurrentLanguage.StandardFunction.Delete_UserNotice;
			if( MessageBox.Show( notice, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) return;

			WaveguideDesignerProjectData parent = layer.Parent as WaveguideDesignerProjectData;
			int index = parent.Layers.IndexOf( layer );
			Action undo = () => { parent.Layers.Insert( index, layer ); };
			Action redo = () => { parent.Layers.Remove( layer ); };
			parent.Layers.Remove( layer );
			Selection = parent;

			UndoRedoPair urPair = new UndoRedoPair( new UndoRedoPairString( CurrentLanguage.StandardFunction.Delete + " : Layer[" + layer.Name + "]", "" ), undo, redo );
			AddUndoRedoPair( urPair );
			}
		/// <summary>レイヤを追加する。</summary>
		/// <param name="layer"></param>
		public LayerData AddLayer(LayerData layer)
			{
			LogMethodStart();
			_AddLayer( layer );
			LogMethodEnd();
			return layer;
			}
		private void _AddLayer(LayerData layer)
			{
			if( OpenedProject == null ) return;

			int oldLayerNo = layer.LayerNumber, newLayerNo = ( OpenedProject.Layers.Count > 0 ) ? ( OpenedProject.Layers[OpenedProject.Layers.Count - 1].LayerNumber + 1 ) : 1;
			Action undo = () => { OpenedProject.Layers.Remove( layer ); layer.LayerNumber = oldLayerNo; };
			Action redo = () => { OpenedProject.Layers.Add( layer ); layer.LayerNumber = newLayerNo; };
			OpenedProject.Layers.Add( layer );
			layer.LayerNumber = newLayerNo;
			AddUndoRedoPair( new UndoRedoPair( CurrentLanguage.ProjectList_ValueChangedDefault, undo, redo ) );
			ValidateProject( false );
			}