Example #1
0
        public void SetOpenTilesOnMap(XleMap map)
        {
            var firstTile  = map[X, Y];
            var chestGroup = map.TileSet.TileGroups.FirstOrDefault(
                x => x.GroupType == Maps.GroupType.Chest && x.Tiles.Contains(firstTile));
            var openChestGroup = (from grp in map.TileSet.TileGroups
                                  where grp.GroupType == Maps.GroupType.OpenChest &&
                                  grp.Tiles.All(x => x > firstTile)
                                  orderby grp.Tiles.Min()
                                  select grp).FirstOrDefault();

            Closed = false;

            if (chestGroup == null || openChestGroup == null)
            {
                return;
            }

            for (int j = this.Rectangle.Top; j < this.Rectangle.Bottom; j++)
            {
                for (int i = this.Rectangle.Left; i < this.Rectangle.Right; i++)
                {
                    int index = chestGroup.Tiles.IndexOf(map[i, j]);

                    if (index == -1 || index >= openChestGroup.Tiles.Count)
                    {
                        continue;
                    }

                    map[i, j] = openChestGroup.Tiles[index];
                }
            }
        }
Example #2
0
        public IMapExtender CreateMapExtender(XleMap map)
        {
            var result = serviceLocator.ResolveNamed <IMapExtender>(map.ExtenderName);

            result.TheMap = map;

            return(result);
        }
Example #3
0
 public void EraseMantrek(XleMap map)
 {
     for (int j = 4; j <= 12; j++)
     {
         for (int i = 28; i <= 36; i++)
         {
             if (i < 36)
             {
                 map[i, j] = 37;
             }
             else
             {
                 map[i, j] = 263;
             }
         }
     }
 }
Example #4
0
        public IMapExtender LoadMap(string filename, int id)
        {
            XleMap data = LoadMapData(filename, id);

            var extender = (MapExtender)extenderFactory.CreateMapExtender(data);

            extender.TheMap = data;

            var renderer = extender.CreateMapRenderer(rendererFactory);

            renderer.Extender       = extender;
            renderer.TheMap         = data;
            extender.TheMapRenderer = renderer;

            data.MapID = id;

            extender.CreateEventExtenders(eventFactory);

            return(extender);
        }
Example #5
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (GameState == null)
            {
                return;
            }

            DrawTextAreaBackColor(spriteBatch, GameState.Map.ColorScheme);

            Player player = GameState.Player;
            XleMap map    = GameState.Map;

            int   i          = 0;
            Color boxColor   = map.ColorScheme.FrameColor;
            Color innerColor = map.ColorScheme.FrameHighlightColor;
            int   horizLine  = 18 * 16;
            int   vertLine   = (38 - map.ColorScheme.MapAreaWidth) * 16;

            Screen.FontColor = map.ColorScheme.TextColor;
            Color menuColor = map.ColorScheme.TextColor;

            if (commands.IsLeftMenuActive)
            {
                menuColor = XleColor.Yellow;
            }

            DrawFrame(spriteBatch, boxColor);

            DrawFrameLine(spriteBatch, vertLine, 0, 0, horizLine + 12, boxColor);
            DrawFrameLine(spriteBatch, 0, horizLine, 1, GameAreaSize.Width, boxColor);

            DrawFrameHighlight(spriteBatch, innerColor);

            DrawInnerFrameHighlight(spriteBatch, vertLine, 0, 0, horizLine + 12, innerColor);
            DrawInnerFrameHighlight(spriteBatch, 0, horizLine, 1, GameAreaSize.Width, innerColor);

            Rectangle mapRect = RectangleX.FromLTRB
                                    (vertLine + 16, 16, GameAreaSize.Width - 16, horizLine);

            MapRenderer.Draw(spriteBatch, player.Location, player.FaceDirection, mapRect);

            i = 0;
            int cursorPos = 0;

            foreach (var cmd in commands.Items.ToList())
            {
                WriteText(spriteBatch, 48, 16 * (i + 1), cmd.Name, menuColor);

                if (cmd == commands.CurrentCommand)
                {
                    cursorPos = i;
                }

                i++;
            }

            WriteText(spriteBatch, 32, 16 * (cursorPos + 1), "`", menuColor);

            Color hpColor = statsDisplay.HPColor;

            WriteText(spriteBatch, 48, 16 * 15, "H.P. " + statsDisplay.HP, hpColor);
            WriteText(spriteBatch, 48, 16 * 16, "Food " + statsDisplay.Food, hpColor);
            WriteText(spriteBatch, 48, 16 * 17, "Gold " + statsDisplay.Gold, hpColor);

            TextAreaRenderer.Draw(spriteBatch, TextArea);

            if (map.AutoDrawPlayer)
            {
                DrawRafts(spriteBatch, mapRect);

                if (player.IsOnRaft == false)
                {
                    DrawCharacter(spriteBatch, playerAnimator.Animating, playerAnimator.AnimFrame, vertLine);
                }
            }

            if (Screen.PromptToContinue)
            {
                FillRect(spriteBatch, 192, 384, 17 * 16, 16, XleColor.Black);
                WriteText(spriteBatch, 208, 384, "(Press to Cont)", XleColor.Yellow);
            }
        }