public static void CreateMix(ContentManager _content) { TileSet tmp = new TileSet(_content, 64, 64); tmp.Add("Aniarrow", 1, new Rectangle(0, 0, 64, 64), 16, 1, false); tmp.Add("Aniarrow", 2, new Rectangle(0, 64, 64, 64), 16, 1, false); tmp.Add("Aniarrow", 3, new Rectangle(0, 128, 64, 64), 16, 1, false); tmp.Add("Aniarrow", 4, new Rectangle(0, 192, 64, 64), 16, 1, false); tmp.Add("Aniarrow", 5, new Rectangle(0, 256, 64, 64), 16, 1, false); tmp.Add("Aniarrow", 6, new Rectangle(0, 320, 64, 64), 16, 1, false); tmp.Add("Aniarrow", 7, new Rectangle(0, 384, 64, 64), 16, 1, false); tmp.Add("Aniarrow", 8, new Rectangle(0, 448, 64, 64), 16, 1, false); tmp.Add("spikefield", 9, new Rectangle(64, 128, 64, 64)); tmp.Add("spikefield", 10, new Rectangle(64, 192, 64, 64)); tmp.Add("stairs1", 11, new Rectangle(0, 717, 160, 208)); tmp.Add("stairs1", 12, new Rectangle(160, 717, 160, 208)); tmp.Add("stairs1", 13, new Rectangle(398, 702, 112, 208)); tmp.Add("stairs2", 14, new Rectangle(0, 320, 192, 160)); tmp.Add("stairs2", 15, new Rectangle(0, 480, 192, 160)); tmp.Add("stairs2", 16, new Rectangle(192, 320, 192, 160)); tmp.Add("stairs2", 17, new Rectangle(192, 480, 192, 160)); tmp.Add("stairs2", 18, new Rectangle(400, 160, 112, 160)); tmp.Add("stairs2", 19, new Rectangle(400, 480, 112, 160)); tmp.Add("chest", 20, new Rectangle(0, 0, 64, 80), 9, 1, false); tmp.Add("chest", 21, new Rectangle(0, 80, 64, 80), 9, 1, false); tmp.Add("chest", 22, new Rectangle(0, 160, 64, 80), 9, 1, false); tmp.Add("fields", 23, new Rectangle(0, 0, 64, 48)); tmp.Add("checkpoint", 24, new Rectangle(0, 0, 128, 96)); tmp.Save("Content\\Misc.xml"); tmp = new TileSet(_content, 64, 64); tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.UpRight, 2), new Rectangle(0, 0, 32, 64)); // ok tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.Right, 2), new Rectangle(32, 0, 32, 64)); tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.DownRight, 2), new Rectangle(64, 0, 32, 64)); // ok tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.Down, 2), new Rectangle(96, 0, 32, 64)); tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.DownLeft, 2), new Rectangle(0, 64, 32, 64)); // ok tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.Left, 2), new Rectangle(32, 64, 32, 64)); tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.UpLeft, 2), new Rectangle(64, 64, 32, 64)); // ok tmp.Add("Arrow", (int)Math.Log((double)Backend.Direction.Up, 2), new Rectangle(96, 64, 32, 64)); tmp.Save("Content\\Arrow.xml"); tmp = new TileSet(_content, 64, 64); tmp.Add("sparks", 0, new Rectangle(0, 192, 64, 64), 1, 4); tmp.Add("blood", 1, new Rectangle(0, 0, 96, 96), 6, 1); tmp.Add("magic", 2, new Rectangle(0, 0, 64, 96), 17, 2, true); tmp.Save("Content\\explosion.xml"); tmp = new TileSet(_content, 64, 64); tmp.Add("Shop", 0, new Rectangle(448, 192, 64, 64), 1, 1, false); tmp.Add("Shop", 1, new Rectangle(354, 509, 64, 96), 1, 1, false); tmp.Add("Shop", 2, new Rectangle(195, 256, 64, 64), 1, 1, false); tmp.Add("Shop", 3, new Rectangle(0, 512, 96, 128), 1, 1, false); tmp.Save("Content\\shop.xml"); }
/// <summary> /// Display all walls on the current map /// </summary> private void _drawWalls(GameTime gametime) { Backend.Coords currentPos = _map.actors[_playerID].tile.coords; // System.Diagnostics.Debug.WriteLine((Math.Max(currentPos.y - _renderScope, 0)) + " " + (Math.Min(currentPos.y + _renderScope, _map.height))); // System.Diagnostics.Debug.WriteLine((Math.Max(currentPos.x - _renderScope, 0)) + " " + (Math.Min(currentPos.x + _renderScope, _map.height))); for (int y = (Math.Max(currentPos.y - Math.Max(_map.actors[_playerID].viewRange, _map.light), 0)); y < (Math.Min(currentPos.y + Math.Max(_map.actors[_playerID].viewRange, _map.light) + 1, _map.height)); ++y) { for (int x = (Math.Min(currentPos.x + Math.Max(_map.actors[_playerID].viewRange, _map.light) + 1, _map.width)); x >= (Math.Max(currentPos.x - Math.Max(_map.actors[_playerID].viewRange, _map.light), 0)); --x) { _drawWall(GetWallStyle(x, y), _tileRect(new Vector2(x + 1, y - 1), true), false, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)), _map[x, y].wallType); if (((x != 0) && (y != 0) && (x != _map.width - 1) && (y != _map.height - 1)) && (_map[x, y].hasTeleport)) if (_map[x, y].teleport.down) { _spriteBatch.Draw(_environment[0][12].animationTexture, new Rectangle(_map2screen(x, y).x, _map2screen(x, y).y - 92, _environment[0][12].animationRect.Width, _environment[0][12].animationRect.Height), _environment[0][12].animationRect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White); }; if ((x != _map.width - 2) && (y != _map.height - 2) && (_map[x + 1, y + 1].hasTeleport)) if (!_map[x + 1, y + 1].teleport.down) { _spriteBatch.Draw(_environment[0][14].animationTexture, new Rectangle(_map2screen(x + 1, y + 1).x - 16, _map2screen(x + 1, y + 1).y - 32, _environment[0][14].animationRect.Width, _environment[0][14].animationRect.Height), _environment[0][14].animationRect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White); } // show special objects Backend.ReservedTile temp = _map[x, y].reserved; if (temp != null) { if (temp.envIndex == -1) { for (int i = 0; i < _environment.Count; ++i) { if (_environment[i].filename == temp.filename) { temp.envIndex = i; break; } } if (temp.envIndex == -1) { TileSet tmp = new TileSet(_content, 96, 96); tmp.Load(temp.filename); _environment.Add(tmp); temp.envIndex = _environment.Count - 1; } } _spriteBatch.Draw(_environment[temp.envIndex][temp.index].animationTexture, new Rectangle(_map2screen(x, y).x - 16, _map2screen(x, y).y - 32, _environment[temp.envIndex][temp.index].animationRect.Width, _environment[temp.envIndex][temp.index].animationRect.Height), _environment[temp.envIndex][temp.index].animationRect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White); _environment[temp.envIndex][temp.index].NextAnimation(); } foreach (ActorView actor in _actors) { if (!actor.invisible) { if ((_map.actors[actor.id].actorType != Backend.ActorType.Player) || (_map.actors[actor.id].online)) { Backend.Coords apos = _screen2map((int)actor.position.x, (int)actor.position.y); if (((int)apos.x == x) && ((int)apos.y == y)) { Color tempColor = new Color(((_map.actors[actor.id].tile.coords.y == (int)_highlightedTile.y) && (_map.actors[actor.id].tile.coords.x == (int)_highlightedTile.x) && !(_map.actors[actor.id] is Backend.Player)) ? Color.Red : Color.White, 1.0f); if ((_map.actors[actor.id].actorType == Backend.ActorType.Player) && (_map.actors[actor.id].id != _playerID)) { tempColor.A = 80; tempColor.B = 250; tempColor.R = 90; tempColor.G = 90; } if (actor.animationTexture != null) _spriteBatch.Draw(actor.animationTexture, new Vector2((actor.position.x + actor.offsetX), (actor.position.y + actor.offsetY - 32)), actor.animationRect, tempColor); if (actor.effect != null) { actor.effect.position = new Backend.Coords((actor.position.x + actor.offsetX), (actor.position.y + actor.offsetY - 32)); actor.effect.Draw(_spriteBatch, gametime); } if (!_map.actors[actor.id].isDead) { _spriteBatch.DrawString(_font, _map.actors[actor.id].name, new Vector2((actor.position.x + actor.offsetX + 25), (actor.position.y + actor.offsetY - 25)), Color.Black, 0f, new Vector2(0, 0), 0.5f, SpriteEffects.None, 0f); _spriteBatch.DrawString(_font, _map.actors[actor.id].name, new Vector2((actor.position.x + actor.offsetX + 24), (actor.position.y + actor.offsetY - 26)), ((_map.actors[actor.id].actorType == Backend.ActorType.Enemy) ? Color.Red : Color.LightGreen), 0f, new Vector2(0, 0), 0.5f, SpriteEffects.None, 0f); _spriteBatch.Draw(_background, new Rectangle((actor.position.x + actor.offsetX + 25), (actor.position.y + actor.offsetY - 10), actor.animationRect.Width, 5), new Rectangle(39, 6, 1, 1), Color.Black); _spriteBatch.Draw(_background, new Rectangle((actor.position.x + actor.offsetX + 26), (actor.position.y + actor.offsetY - 9), (_map.actors[actor.id].health * (actor.animationRect.Width - 2)) / _map.actors[actor.id].maxHealth, 3), new Rectangle(39, 6, 1, 1), ((_map.actors[actor.id].actorType == Backend.ActorType.Enemy) ? Color.Red : Color.LightGreen)); } } } } } if (_map[x, y].hasTreasure) { foreach (Backend.Item item in (_map[x, y].items)) { if (item.itemType == Backend.ItemType.Potion) { System.Diagnostics.Debug.WriteLine(item.icon.rect.Width); } _spriteBatch.Draw(TextureFromData.Convert(item.icon, _content), new Rectangle(_map2screen(x, y).x + item.icon.offset.x + 32, _map2screen(x, y).y + 16 + item.icon.offset.y, item.icon.rect.Width - item.icon.crop.x, item.icon.rect.Height - item.icon.crop.y), item.icon.rect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White); } } } } }