public void OnRemoveTile(TilePlaceModel model) { foreach (var mapPlaceReceiver in _mapPlaceReceivers) { mapPlaceReceiver?.OnRemoveTile(model); } }
public void Remove(TilePlaceModel model, Dictionary <Vector3Int, bool> passable) { if (model.PlaceMode != PlaceTileMode.PlaceTileDraw) { return; } }
public static void SetTileModel(this Tilemap self, TilePlaceModel model) { switch (model.PlaceMode) { //1個置き case PlaceTileMode.PlaceTileSingle: case PlaceTileMode.PlaceTileDraw: //ブラシサイズ対応 if (model.Model.Brush.sqrMagnitude > 1) { self.SetBrushTiles(model, model.Model); } else { var pos = self.WorldToCell(model.StartWorldPos); pos.z = model.Model.MinLayer; self.SetTile(pos, model.Model); } break; case PlaceTileMode.PlaceTileRect: self.SetRectTiles(model, model.Model); break; default: throw new ArgumentOutOfRangeException(); } }
private static Vector3Int[] SetRectTiles(this Tilemap self, TilePlaceModel model, TileBase tile) { Debug.Log("矩形モード"); Debug.Log(model.Model); var start = self.WorldToCell(model.StartWorldPos); var end = self.WorldToCell(model.EndWorldPos); var sx = Mathf.Min(start.x, end.x); var ex = Mathf.Max(start.x, end.x); var sy = Mathf.Min(start.y, end.y); var ey = Mathf.Max(start.y, end.y); var lx = ex - sx; var ly = ey - sy; var positions = new Vector3Int[lx * ly]; var tiles = new TileBase[lx * ly]; for (var i = 0; i < lx; i++) { for (var j = 0; j < ly; j++) { positions[i * ly + j] = new Vector3Int(sx + i, sy + j, model.Model.MinLayer); tiles[i * ly + j] = tile; } } self.SetTiles(positions, tiles); return(positions); }
void AddPassableMap(TilePlaceModel model, Dictionary <Vector3Int, bool> passable) { foreach (var createPassableData in _createPassableDatas) { createPassableData.Add(model, passable); } }
public void Add(TilePlaceModel model, Dictionary <Vector3Int, bool> passable) { if (model.PlaceMode != PlaceTileMode.PlaceTileRect) { return; } var start = _tilemapUseCase.WorldToCell(model.StartWorldPos); var end = _tilemapUseCase.WorldToCell(model.EndWorldPos); var sx = Mathf.Min(start.x, end.x); var ex = Mathf.Max(start.x, end.x); var sy = Mathf.Min(start.y, end.y); var ey = Mathf.Max(start.y, end.y); for (var i = sx; i < ex; i++) { for (var j = sy; j < ey; j++) { var pos = new Vector3Int(i, j, 0); if (!passable.ContainsKey(pos)) { passable.Add(pos, false); } } } }
/// <summary> /// todo Usecaseに一部委譲したい /// </summary> /// <param name="model"></param> public void SetTile(TilePlaceModel model) { _tilemap.SetTileModel(model); _tilemapManager.OnUpdateTile(new TilemapModel() { Tilemap = _tilemap, //TilemapCollider2D = _tilemapCollider }); }
private static Vector3Int[] SetBrushTiles(this Tilemap self, TilePlaceModel model, TileBase tile) { Debug.Log("ブラシモード"); Debug.Log(model.Model); var positions = new Vector3Int[model.Model.Brush.x * model.Model.Brush.y]; var tiles = new TileBase[model.Model.Brush.x * model.Model.Brush.y]; var origin = self.WorldToCell(model.StartWorldPos); int xhalf = (model.Model.Brush.x + 1 - (model.Model.Brush.x % 2)) / 2; int yhalf = (model.Model.Brush.y + 1 - (model.Model.Brush.y % 2)) / 2; for (var i = 0; i < model.Model.Brush.x; i++) { for (var j = 0; j < model.Model.Brush.y; j++) { positions[i * model.Model.Brush.y + j] = new Vector3Int(origin.x - xhalf + i, origin.y - yhalf + j, model.Model.MinLayer); tiles[i * model.Model.Brush.y + j] = tile; } } self.SetTiles(positions, tiles); return(positions); }
public void Add(TilePlaceModel model, Dictionary <Vector3Int, bool> passable) { if (model.PlaceMode != PlaceTileMode.PlaceTileDraw) { return; } if (model.Model.Brush.sqrMagnitude > 1) { Debug.Log(model.Model); var positions = new Vector3Int[model.Model.Brush.x * model.Model.Brush.y]; var tiles = new TileBase[model.Model.Brush.x * model.Model.Brush.y]; var origin = _tilemapUseCase.WorldToCell(model.StartWorldPos); int xhalf = (model.Model.Brush.x + 1 - (model.Model.Brush.x % 2)) / 2; int yhalf = (model.Model.Brush.y + 1 - (model.Model.Brush.y % 2)) / 2; for (var i = 0; i < model.Model.Brush.x; i++) { for (var j = 0; j < model.Model.Brush.y; j++) { var pos = new Vector3Int(origin.x - xhalf + i, origin.y - yhalf + j, model.Model.MinLayer); pos.z = 0; if (!passable.ContainsKey(pos)) { passable.Add(pos, false); } } } } else { var pos = _tilemapUseCase.WorldToCell(model.StartWorldPos); pos.z = 0; if (!passable.ContainsKey(pos)) { passable.Add(pos, false); } } }
/// <summary> /// タイル設置 /// </summary> void PlaceTile(TilePlaceModel model) { _placeTileManager?.OnPlaceTile(model); }
public void OnRemoveTile(TilePlaceModel model) { throw new NotImplementedException(); }
public void OnPlaceTile(TilePlaceModel model) { SetTile(model); }
//タイルマップ設置と同時 public void OnPlaceTile(TilePlaceModel model) { AddPassableMap(model, _passableMap); }
public void OnRemoveTile(TilePlaceModel model) { throw new global::System.NotImplementedException(); }
public void SetTile(TilePlaceModel model) { }