/// <summary> /// Вызов события разрушения стены /// </summary> /// <param name="Cell">Клетка, в которой расположена стена</param> /// <param name="Wall">Стена</param> protected void OnWallDestroyed(MapCellState Cell, MapWallState Wall) { if (WallDestroyed != null) { WallDestroyed(this, Cell, new MapWallEventArgs(Wall)); } }
/// <summary> /// Проверка возможности размещения в данной клетке объекта /// </summary> /// <param name="ActiveObject">Объект</param> /// <param name="Position">Координаты</param> /// <param name="IgnoreNorth">Игнорируется ли северная стена</param> /// <param name="IgnoreSouth">Мгнорируется ли южная стена</param> /// <param name="IgnoreWest">Игнорируется ли западная стена</param> /// <param name="IgnoreEast">Игнорируется ли восточная стена</param> /// <returns>Возможно ли разместить объект в данной клетке</returns> private bool CheckCell(MapActiveObject ActiveObject, MapPoint Position, bool IgnoreNorth, bool IgnoreSouth, bool IgnoreWest, bool IgnoreEast) { MapCellState cell = Levels[Position.Level].Cells[Position]; if ((cell.Place != null) && (cell.Place.Passability < ActiveObject.Passability)) { return(false); } if (!IgnoreNorth && (cell.GetPassbilityByDirection(MapDirection.North) < ActiveObject.Passability)) { return(false); } if (!IgnoreSouth && (cell.GetPassbilityByDirection(MapDirection.South) < ActiveObject.Passability)) { return(false); } if (!IgnoreWest && (cell.GetPassbilityByDirection(MapDirection.West) < ActiveObject.Passability)) { return(false); } if (!IgnoreEast && (cell.GetPassbilityByDirection(MapDirection.East) < ActiveObject.Passability)) { return(false); } return(true); }
/// <summary> /// Состояние уровня карты /// </summary> /// <param name="Level">Уровень</param> /// <param name="Index">Координата уровня</param> public MapLevelState(MapLevel Level, UInt16 Index) { if (Level == null) { throw new ArgumentNullException("Level", "Level of MapLevelState cannot be null"); } this.Index = Index; this.Level = Level; Cells = new MapMatrix <MapCellState>(Level.Size); for (UInt16 x = 0; x < Size.Width; x++) { for (UInt16 y = 0; y < Size.Height; y++) { if (Level.Cells[x, y] == null) { Cells[x, y] = null; } else { Cells[x, y] = new MapCellState(Level.Cells[x, y], new MapPoint(Index, x, y)); Cells[x, y].WallDestroying += (sender, cell, args) => { OnWallDestroying(cell, args.Wall); }; Cells[x, y].WallDestroyed += (sender, cell, args) => { OnWallDestroyed(cell, args.Wall); }; } } } }
public MapCellState SetPlace(MapPlace place, MapPoint point) { MapCellState cell = this[point]; if (cell == null) { return(cell = CreateCell(place, null, point)); } else { return(cell = CreateCell(place, cell.Cell.Walls, point)); } }
public MapCellState CreateCell(MapPlace place, Dictionary <MapDirection, MapWall> walls, MapPoint point) { MapCellState currentCell = this[point]; if (currentCell != null) { if (currentCell.ActiveObjects != null) { foreach (var activeObject in currentCell.ActiveObjects) { this.RemoveActiveObject(GetIdOfActiveObject(activeObject)); } } } MapCell cell = Map[point] = new MapCell(place, walls); return(this[point] = new MapCellState(cell, point)); }
/// <summary> /// Состояние уровня карты /// </summary> /// <param name="Level">Уровень</param> /// <param name="Index">Координата уровня</param> public MapLevelState(MapLevel Level, UInt16 Index) { if (Level == null) throw new ArgumentNullException("Level", "Level of MapLevelState cannot be null"); this.Index = Index; this.Level = Level; Cells = new MapMatrix<MapCellState>(Level.Size); for (UInt16 x = 0; x < Size.Width; x++) for (UInt16 y = 0; y < Size.Height; y++) { if (Level.Cells[x, y] == null) Cells[x, y] = null; else { Cells[x, y] = new MapCellState(Level.Cells[x, y], new MapPoint(Index, x, y)); Cells[x, y].WallDestroying += (sender, cell, args) => { OnWallDestroying(cell, args.Wall); }; Cells[x, y].WallDestroyed += (sender, cell, args) => { OnWallDestroyed(cell, args.Wall); }; } } }
/// <summary> /// Вызов события разрушения стены /// </summary> /// <param name="Cell">Клетка, в которой расположена стена</param> /// <param name="Wall">Стена</param> protected void OnWallDestroying(MapCellState Cell, MapWallState Wall) { if (WallDestroying != null) WallDestroying(this, Cell, new MapWallEventArgs(Wall)); }
public MapCellState CreateCell(MapPlace place, Dictionary<MapDirection, MapWall> walls, MapPoint point) { MapCellState currentCell = this[point]; if (currentCell != null) { if (currentCell.ActiveObjects != null) { foreach (var activeObject in currentCell.ActiveObjects) this.RemoveActiveObject(GetIdOfActiveObject(activeObject)); } } MapCell cell = Map[point] = new MapCell(place, walls); return (this[point] = new MapCellState(cell, point)); }
/// <summary> /// Определить принадлежит ли району клетка карты /// </summary> /// <param name="Cell">Клетка карты</param> /// <returns>Принадлежит ли району</returns> public bool CheckCellInArea(MapCellState Cell) { return CheckCellInArea(Cell.Point); }
private List<FrameworkElement> RenderCell(MapCellState cell, Rect cellArea) { List<FrameworkElement> result = new List<FrameworkElement>(); if (cell == null) return result; result.Add(RenderPlace(cell.Place, cellArea)); result.Add(RenderWall(cell.GetWall(MapDirection.South), cellArea)); result.Add(RenderWall(cell.GetWall(MapDirection.West), cellArea)); result.Add(RenderWall(cell.GetWall(MapDirection.North), cellArea)); result.Add(RenderWall(cell.GetWall(MapDirection.East), cellArea)); result.Add(RenderWallCorner(cell.GetWall(MapDirection.North), cell.GetWall(MapDirection.West), cellArea)); result.Add(RenderWallCorner(cell.GetWall(MapDirection.North), cell.GetWall(MapDirection.East), cellArea)); result.Add(RenderWallCorner(cell.GetWall(MapDirection.South), cell.GetWall(MapDirection.West), cellArea)); result.Add(RenderWallCorner(cell.GetWall(MapDirection.South), cell.GetWall(MapDirection.East), cellArea)); while (result.Remove(null)); return result; }
/// <summary> /// Определить принадлежит ли району клетка карты /// </summary> /// <param name="Cell">Клетка карты</param> /// <returns>Принадлежит ли району</returns> public bool CheckCellInArea(MapCellState Cell) { return(CheckCellInArea(Cell.Point)); }