Ejemplo n.º 1
0
        public void CreateNew(int width, int height, int texSize)
        {
            TexSize = texSize;

            Layers.Clear();
            MapLayer layer = new MapLayer("New Layer");

            layer.CreateNew(width, height);
            Layers.Add(layer);

            Decorations.Clear();
            Decorations.Add(new AnimLayer("New Deco"));

            Entities.Clear();
            Entities.Add(new EntityLayer("New EntLayer"));

            int divSize = GraphicsManager.TEX_SIZE;

            obstacles = new GroundWall[width * TexSize][];
            for (int ii = 0; ii < obstacles.Length; ii++)
            {
                obstacles[ii] = new GroundWall[height * TexSize];
                for (int jj = 0; jj < obstacles[ii].Length; jj++)
                {
                    obstacles[ii][jj] = new GroundWall(ii * divSize, jj * divSize, divSize, divSize);
                }
            }

            this.grid = new AABB.Grid(width, height, GraphicsManager.TileSize);

            AddMapScriptEvent(LuaEngine.EMapCallbacks.Init);
            AddMapScriptEvent(LuaEngine.EMapCallbacks.Enter);
        }
Ejemplo n.º 2
0
        internal void OnDeserializedMethod(StreamingContext context)
        {
            //DiagManager.Instance.LogInfo(String.Format("GroundMap.OnDeserializedMethod(): Map {0} deserialized!", AssetName));

            //recompute the grid
            grid = new AABB.Grid(Width, Height, GraphicsManager.TileSize);

            //TODO: v0.5: remove this
            if (Background == null)
            {
                Background = new MapBG();
            }
            if (BlankBG == null)
            {
                BlankBG = new AutoTile();
            }


            if (ActiveChar != null)
            {
                ActiveChar.OnDeserializeMap(this);
                signCharToMap(ActiveChar);
            }

            ReloadEntLayer(0);
        }
Ejemplo n.º 3
0
        internal void OnDeserializedMethod(StreamingContext context)
        {
            //DiagManager.Instance.LogInfo(String.Format("GroundMap.OnDeserializedMethod(): Map {0} deserialized!", AssetName));

            //recompute the grid
            grid = new AABB.Grid(Width, Height, GraphicsManager.TileSize);

            //Because we clear those on save, we'll need to assign a new array here

            if (Spawners == null)
            {
                Spawners = new List <GroundSpawner>();
            }

            //Make sure the temp char array is instantiated
            TemporaryChars = new List <GroundChar>();

            //reconnect characters and objects references
            foreach (GroundChar player in IterateCharacters())
            {
                if (player != null)
                {
                    player.OnDeserializeMap(this);
                    signCharToMap(player);
                }
            }
            foreach (GroundObject groundObj in GroundObjects)
            {
                groundObj.OnDeserializeMap(this);
                grid.Add(groundObj);
            }
        }
Ejemplo n.º 4
0
        public void ResizeJustified(int width, int height, Dir8 anchorDir)
        {
            foreach (MapLayer layer in Layers)
            {
                layer.ResizeJustified(width, height, anchorDir);
            }

            int divSize = GraphicsManager.TEX_SIZE;

            RogueElements.Grid.LocAction blockChangeOp = (Loc effectLoc) => { obstacles[effectLoc.X][effectLoc.Y].Bounds = new Rect(effectLoc.X * divSize, effectLoc.Y * divSize, divSize, divSize); };
            RogueElements.Grid.LocAction blocknewOp    = (Loc effectLoc) => { obstacles[effectLoc.X][effectLoc.Y] = new GroundWall(effectLoc.X * divSize, effectLoc.Y * divSize, divSize, divSize); };

            Loc texDiff = RogueElements.Grid.ResizeJustified(ref obstacles,
                                                             width * TexSize, height * TexSize, anchorDir.Reverse(), blockChangeOp, blocknewOp);

            foreach (GroundChar character in ZoneManager.Instance.CurrentGround.IterateCharacters())
            {
                Loc newLoc = character.MapLoc + texDiff * divSize;
                if (newLoc.X < 0)
                {
                    newLoc.X = 0;
                }
                else if (newLoc.X >= width)
                {
                    newLoc.X = width - 1;
                }
                if (newLoc.Y < 0)
                {
                    newLoc.Y = 0;
                }
                else if (newLoc.Y >= height)
                {
                    newLoc.Y = height - 1;
                }

                character.SetMapLoc(newLoc);
                character.UpdateFrame();
            }

            this.grid = new AABB.Grid(width, height, GraphicsManager.TileSize);
        }
Ejemplo n.º 5
0
        public void Retile(int texSize)
        {
            int newWidth  = (Width * TexSize - 1) / texSize + 1;
            int newHeight = (Height * TexSize - 1) / texSize + 1;

            TexSize = texSize;

            foreach (MapLayer layer in Layers)
            {
                layer.CreateNew(newWidth, newHeight);
            }

            int divSize = GraphicsManager.TEX_SIZE;

            RogueElements.Grid.LocAction blockChangeOp = (Loc effectLoc) => { obstacles[effectLoc.X][effectLoc.Y].Bounds = new Rect(effectLoc.X * divSize, effectLoc.Y * divSize, divSize, divSize); };
            RogueElements.Grid.LocAction blocknewOp    = (Loc effectLoc) => { obstacles[effectLoc.X][effectLoc.Y] = new GroundWall(effectLoc.X * divSize, effectLoc.Y * divSize, divSize, divSize); };

            RogueElements.Grid.ResizeJustified(ref obstacles,
                                               newWidth * TexSize, newHeight * TexSize, Dir8.DownRight, blockChangeOp, blocknewOp);

            this.grid = new AABB.Grid(newWidth, newHeight, GraphicsManager.TileSize);
        }
Ejemplo n.º 6
0
        public void ResizeJustified(int width, int height, Dir8 anchorDir)
        {
            foreach (MapLayer layer in Layers)
            {
                layer.ResizeJustified(width, height, anchorDir);
            }

            int divSize = GraphicsManager.TEX_SIZE;

            RogueElements.Grid.LocAction blockChangeOp = (Loc effectLoc) => { obstacles[effectLoc.X][effectLoc.Y].Bounds = new Rect(effectLoc.X * divSize, effectLoc.Y * divSize, divSize, divSize); };
            RogueElements.Grid.LocAction blocknewOp    = (Loc effectLoc) => { obstacles[effectLoc.X][effectLoc.Y] = new GroundWall(effectLoc.X * divSize, effectLoc.Y * divSize, divSize, divSize); };

            Loc texDiff = RogueElements.Grid.ResizeJustified(ref obstacles,
                                                             width * TexSize, height * TexSize, anchorDir.Reverse(), blockChangeOp, blocknewOp);

            foreach (GroundChar character in IterateCharacters())
            {
                character.SetMapLoc(RogueElements.Collision.ClampToBounds(width * TileSize - character.Width, height * TileSize - character.Height, character.MapLoc + texDiff * divSize));
                character.UpdateFrame();
            }

            this.grid = new AABB.Grid(width, height, GraphicsManager.TileSize);
        }
Ejemplo n.º 7
0
        public void CreateNew(int width, int height, int texSize)
        {
            TexSize = texSize;

            Layers.Clear();
            MapLayer layer = new MapLayer("New Layer");

            layer.CreateNew(width, height);
            Layers.Add(layer);

            int divSize = GraphicsManager.TEX_SIZE;

            obstacles = new GroundWall[width * TexSize][];
            for (int ii = 0; ii < obstacles.Length; ii++)
            {
                obstacles[ii] = new GroundWall[height * TexSize];
                for (int jj = 0; jj < obstacles[ii].Length; jj++)
                {
                    obstacles[ii][jj] = new GroundWall(ii * divSize, jj * divSize, divSize, divSize);
                }
            }

            this.grid = new AABB.Grid(width, height, GraphicsManager.TileSize);
        }