Beispiel #1
0
        public bool EraseTile(int x, int y, LAYERS layer)
        {
            switch (layer)
            {
            case LAYERS.Graphic:
                (GetTile(x, y, LAYERS.Graphic) as GraphicTile).Graphic = 0;
                break;

            case LAYERS.Special:
                (GetTile(x, y, LAYERS.Special) as SpecialTile).Type    = SpecialTileSpec.NONE;
                (GetTile(x, y, LAYERS.Special) as SpecialTile).Graphic = 0;
                break;

            case LAYERS.Item:
                layers[(int)LAYERS.Item].Remove(x.ToString() + ":" + y.ToString());
                break;

            case LAYERS.NPC:
                throw new NotImplementedException();

            case LAYERS.Interactive:
                throw new NotImplementedException();
            }

            isSaved = false;

            return(true);
        }
Beispiel #2
0
        public bool LayerIsNotLock(LAYERS layer)
        {
            if (_parenttabgraphicpagecontrol.TabPageType == TABPAGETYPE.DISPLAY)
            {
                switch (layer)
                {
                case LAYERS.Layer1:
                    return(!((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer1Lock);

                case LAYERS.Layer2:
                    return(!((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer2Lock);

                case LAYERS.Layer3:
                    return(!((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer3Lock);

                case LAYERS.Layer4:
                    return(!((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer4Lock);

                case LAYERS.Layer5:
                    return(!((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer5Lock);

                case LAYERS.Layer6:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer6Lock);

                case LAYERS.Layer7:
                    return(!((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer7Lock);

                case LAYERS.Layer8:
                    return(!((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer8Lock);
                }
            }
            return(true);
        }
Beispiel #3
0
        public bool LayerIsEnable(LAYERS layer)
        {
            if (_parenttabgraphicpagecontrol.TabPageType == TABPAGETYPE.DISPLAY)
            {
                switch (layer)
                {
                case LAYERS.Layer1:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer1Enable);

                case LAYERS.Layer2:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer2Enable);

                case LAYERS.Layer3:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer3Enable);

                case LAYERS.Layer4:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer4Enable);

                case LAYERS.Layer5:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer5Enable);

                case LAYERS.Layer6:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer6Enable);

                case LAYERS.Layer7:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer7Enable);

                case LAYERS.Layer8:
                    return(((TabDisplayPageControl)_parenttabgraphicpagecontrol).tbldisplay.Layer8Enable);
                }
            }
            return(true);
        }
Beispiel #4
0
        protected DrawObject(SerializationInfo info, StreamingContext context)
        {
            try
            {
                if (info == null)
                {
                    throw new ArgumentNullException("info");
                }

                GUID   = Guid.NewGuid();
                ID     = GetHashCode();
                oIndex = Parentpagelist.GetNewobjectoIndex();
                //Movable = true;
                rectangle        = (Rectangle)info.GetValue("Rectangle", rectangle.GetType());
                this.tipText     = info.GetString("tipText");
                this.movable     = info.GetBoolean("Movable");
                this._resizeable = info.GetBoolean("Resizeable");
                this.layer       = (LAYERS)info.GetInt32("LAYERS");
                this._type       = (STATIC_OBJ_TYPE)info.GetInt32("STATIC_OBJ_TYPE");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        private void mnuClearLayer_Click(object sender, EventArgs e)
        {
            LAYERS layer = (LAYERS)tabs.SelectedIndex;

            if (layer != LAYERS.Graphic && layer != LAYERS.Special)
            {
                return;
            }

            if (m_openMap.Layers[(int)layer].Count == 0)
            {
                return;
            }

            DialogResult res = MessageBox.Show("This will clear all tile data on the selected layer. Continue?", "Continue", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                m_openMap.ClearLayer(layer);

                m_buffer.AddState(m_openMap);
                UpdateUndoRedo();

                mapViewer1.Refresh();
            }
        }
Beispiel #6
0
        public void ClearLayer(LAYERS layer)
        {
            int i = 0;

            do
            {
                Tile tile = layers[(int)layer].Values[i++];
                EraseTile(tile.X, tile.Y, layer);
            } while (i < layers[(int)layer].Values.Count);

            isSaved = false;
        }
Beispiel #7
0
        public void AddTile(Microsoft.Xna.Framework.Vector2 location, LAYERS layer, Tile t)
        {
            isSaved = false;

            if (layers[(int)layer].ContainsKey((int)location.X + ":" + (int)location.Y))
            {
                layers[(int)layer][(int)location.X + ":" + (int)location.Y] = t;
            }
            else
            {
                layers[(int)layer].Add((int)location.X + ":" + (int)location.Y, t);
            }
        }
Beispiel #8
0
        public void AddTile(int x, int y, LAYERS layer, Tile t)
        {
            isSaved = false;

            if (layers[(int)layer].ContainsKey(x + ":" + y))
            {
                layers[(int)layer][x + ":" + y] = t;
            }
            else
            {
                layers[(int)layer].Add(x + ":" + y, t);
            }
        }
Beispiel #9
0
        public Tile GetTile(int x, int y, LAYERS layer)
        {
            Tile ret = null;

            try
            {
                ret = layers[(int)layer][x + ":" + y];
            }
            catch
            {
            }

            return(ret);
        }
Beispiel #10
0
        public Tile GetTile(int x, int y, LAYERS layer)
        {
            Tile ret = null;

            if (!layers[(int)layer].ContainsKey(x + ":" + y))
            {
                return(ret);
            }

            try
            {
                ret = layers[(int)layer][x + ":" + y];
            }
            catch
            {
            }

            return(ret);
        }
Beispiel #11
0
        public bool LoadFromStream(Stream s)
        {
            isLoaded = false;

            byte[] all;
            using (var memoryStream = new MemoryStream())
            {
                s.CopyTo(memoryStream);
                all = memoryStream.ToArray();
            }

            CRC32 crc    = new CRC32();
            uint  crcVal = crc.Check(all, 0, (uint)all.Length - 4); //crc everything except the value of the crc

            s.Seek(-sizeof(int), SeekOrigin.End);                   //last four bytes (int) is CRC value
            uint fileVal = (uint)s.ReadInt();

            if (crcVal != fileVal)
            {
                return(isLoaded);
            }

            s.Seek(0, SeekOrigin.Begin);

            if (s.ReadInt() != Const.MAGIC_NUMBER)
            {
                return(isLoaded);
            }

            spawns = new List <Spawn>();

            int loadedLayers = 0;

            while (s.Position < s.Length - 4)
            {
                switch ((MapField)s.ReadByte())
                {
                case MapField.MapInfo:
                    w           = s.ReadInt();
                    h           = s.ReadInt();
                    Type        = (MapType)s.ReadInt();
                    mapname     = s.ReadString();
                    Warp        = s.ReadInt();
                    PlayerSpawn = new Microsoft.Xna.Framework.Point(s.ReadInt(), s.ReadInt());
                    int numLayers = s.ReadInt();

                    if (numLayers != this.layers.Length)
                    {
                        throw new Exception("Invalid number of layers!");
                    }
                    break;

                case MapField.MapLayer:
                    int numTiles = s.ReadInt();
                    var newLayer = layers[loadedLayers] = new SortedList <string, Tile>(numTiles);

                    for (int i = 0; i < numTiles; i++)
                    {
                        Tile   toAdd = null;
                        LAYERS layer = LAYERS.Graphic;

                        switch ((TileType)s.ReadInt())
                        {
                        case TileType.Animated:
                            toAdd = new AnimatedTile(s.ReadInt(), s.ReadInt(), s.ReadInt());
                            layer = LAYERS.Graphic;
                            break;

                        case TileType.Graphic:
                            toAdd = new GraphicTile(s.ReadInt(), s.ReadInt(), s.ReadInt());
                            break;

                        case TileType.Special:
                            layer = LAYERS.Special;
                            SpecialTile st = new SpecialTile(s.ReadInt(), s.ReadInt());

                            SpecialTileSpec tt = (SpecialTileSpec)s.ReadInt();
                            st.Graphic = s.ReadInt();

                            if (tt == SpecialTileSpec.WALL)
                            {
                                st.Density = (float)s.ReadDouble();
                            }

                            object[] param = null;
                            switch (tt)
                            {
                            case SpecialTileSpec.WARP:
                                param = new object[] { s.ReadInt(), s.ReadInt(), s.ReadInt(), (WarpAnim)s.ReadInt() };
                                break;
                            }

                            st.SetType(tt, param);
                            toAdd = st;
                            break;
                        }

                        if (toAdd != null)
                        {
                            AddTile(toAdd.X, toAdd.Y, layer, toAdd);
                        }
                    }

                    layers[loadedLayers++] = newLayer;
                    break;

                case MapField.SpawnInfo:
                    Spawn sp = new Spawn(s.ReadInt(), s.ReadString());

                    int numPairs = s.ReadInt();
                    for (int i = 0; i < numPairs; i++)
                    {
                        sp.AddSpawnPair(s.ReadInt(), s.ReadInt());
                    }
                    break;
                }
            }

            // Make sure we don't have any null layers (they cause problems later)
            for (int i = 0; i < layers.Length; i++)
            {
                if (layers[i] == null)
                {
                    layers[i] = new SortedList <string, Tile>();
                }
            }

            fileName = "";
            isLoaded = true;
            isSaved  = true;

            return(isLoaded);
        }