private void Construct(IMapSettings mapSettings, SpriteRenderer spriteRenderer) { _mapSettings = mapSettings; _spriteRenderer = spriteRenderer; _mapSettings.Updated += Reinit; Reinit(null, null); }
public RegisterPlayerCommand(IIdGenerator idGenerator, INameGenerator nameGenerator, IMapSettings mapSettings, IRandom random, IPlayerRepository playerRepository) { this.idGenerator = idGenerator; this.nameGenerator = nameGenerator; this.mapSettings = mapSettings; this.random = random; this.playerRepository = playerRepository; }
public MapImageBuilder(IPlayerRepository playerRepository, IMapSettings mapSettings) { this.playerRepository = playerRepository; mapWidth = mapSettings.MapWidth; mapHeight = mapSettings.MapHeight; cellWidth = ImageWidth / mapWidth; cellHeight = ImageHeight / mapHeight; }
protected override void OnSetMapSettings(DrawElementMaps control, IMapSettings oldValue, IMapSettings newValue) { if (newValue == null) { return; } Stroke = Convert(newValue.CourseLineColor); StrokeThickness = newValue.CourseLineThickness; }
private void CreateMapLayer <T>(IMapSettings settings, string name, int layer) where T : Tile, new() { for (int y = 0; y < settings.Height; y++) { for (int x = 0; x < settings.Width; x++) { GameObject _mapBackground = Functions.CreateObject(name + " " + x.ToString() + ":" + y.ToString(), mapFolder); SpriteRenderer _spriteRenderer = _mapBackground.AddComponent <SpriteRenderer>(); _spriteRenderer.sprite = Functions.CreateSprite(1, 1, Color.white); _spriteRenderer.color = Color.red; _spriteRenderer.sortingOrder = layer; T _tile = _mapBackground.AddComponent <T>(); _tile.SetPosition(new Vector2Int(x, y)); _mapBackground.transform.localPosition = (Vector3Int)_tile.Position; map [x, y, layer] = _tile; } } }
protected override void OnSetMapSettings(DrawElementMaps control, IMapSettings oldValue, IMapSettings newValue) { if (newValue == null) { return; } var binding = new Binding { Source = newValue, Path = new PropertyPath(NameHelper <IMapSettings> .Name(v => v.PointLineColor)), Converter = new DrawingColorToMediaColorConverter(), Mode = BindingMode.OneWay }; SetBinding(StrokeProperty, binding); //Stroke = Convert(newValue.PointLineColor); StrokeThickness = newValue.PointLineThickness; Radius = newValue.PointCircleRadius; }
public List <ICell> FindPathOnMap(ICell fromCell, ICell toCell, IMap map) { if (_hexMapSettings == null) { _hexMapSettings = GameInstances.Instance.MapSettings; } List <ICell> path = new List <ICell>(); _searchFrontier.Clear(); for (int i = 0; i < map.Cells.Count; i++) { map.Cells[i].Distance = int.MaxValue; map.Cells[i].DisableHighlight(); map.Cells[i].UpdateLabel(string.Empty); } fromCell.EnableHighlight(_hexMapSettings.ColorSelectionFrom); toCell.EnableHighlight(_hexMapSettings.ColorSelectionTo); fromCell.Distance = 0; _searchFrontier.Enqueue(fromCell); while (_searchFrontier.Count > 0) { ICell current = _searchFrontier.Dequeue(); if (current == toCell) { current = current.PathFrom; path.Add(toCell); path.Add(toCell.PathFrom); while (current != fromCell) { current.EnableHighlight(_hexMapSettings.ColorPath); current = current.PathFrom; path.Add(current); } ; int i = 0; path.Reverse(); foreach (var item in path) { item.UpdateLabel(i++ + ""); } break; } for (HexDirection direction = HexDirection.NE; direction <= HexDirection.NW; direction++) { ICell neighbor = current.GetNeighbor(direction); if (neighbor == null) { continue; } if (!neighbor.IsWalkable) { continue; } int distance = current.Distance; if (current.HasRoadThroughEdge(direction)) { distance += 1; } else { distance += 10; } if (neighbor.Distance == int.MaxValue) { neighbor.Distance = distance; neighbor.PathFrom = current; neighbor.SearchHeuristic = neighbor.Coordinates.DistanceTo(toCell.Coordinates); _searchFrontier.Enqueue(neighbor); } else if (distance < neighbor.Distance) { int oldPriority = neighbor.SearchPriority; neighbor.Distance = distance; neighbor.PathFrom = current; _searchFrontier.Change(neighbor, oldPriority); } } } return(map.Cells); }
public MovePlayerCommand(IPlayerRepository playerRepository, IMapSettings mapSettings) { this.playerRepository = playerRepository; this.mapSettings = mapSettings; }
private void Construct(IMapSettings mapSettings, SpriteRenderer spriteRenderer) { spriteRenderer.color = mapSettings.CrawlerBeltColor; Destroy(this); }
private void Start() { _mapSettings = GameInstances.Instance.MapSettings; _pathFinder = GameInstances.Instance.PathFinder; _map = GameInstances.Instance.Map; }
public Map(IMapSettings settings, IMapGenerator generator) { this.Settings = settings; this.Generator = generator; }
public void Generate(IMapSettings settings) { mapFolder = Functions.CreateObject("MAP"); //map = new ATile[settings.Width, settings.Height, allLayers]; //CreateMapLayer<TileBackground>(settings, "Background", 0); }
protected virtual void OnSetMapSettings(DrawElementMaps control, IMapSettings oldValue, IMapSettings newValue) { }