private List <GameObject> GetGeneratedGameObjects(MapCellType mapCellType) { if (!generated.ContainsKey(mapCellType)) { generated[mapCellType] = new List <GameObject>(); } return(generated[mapCellType]); }
public MapCell(MapCellType type, Sprite wallSprite, Sprite floorSprite, Sprite ceilingSprite) { Type = type; WallSprite = wallSprite; CeilingSprite = ceilingSprite; FloorSprite = floorSprite; isAnimation = false; }
public MapCell(MapCellType type, Animation animation, Sprite floorSprite, Sprite ceilingSprite) { this.animation = animation; isAnimation = true; Type = type; WallSprite = animation.CurrentFrame; CeilingSprite = ceilingSprite; FloorSprite = floorSprite; }
private void PlaceCellType(int x, int y, MapCellType mapCellType) { if (x < 0 || y < 0) { return; } if (x >= config.width || y >= Height) { return; } mapRows[y][x] = mapCellType; }
CellResource ResourceOfCell(int cellId) { MapCellType cellType = (MapCellType)cellId; foreach (CellResource res in cellResources) { if (res.cellType == cellType) { return(res); } } return(cellResources[0]); }
CellModel CellModelOf(int cell_id) { MapCellType celltype = (MapCellType)cell_id; foreach (CellModel model in cellModels) { if (model.cell_id == celltype) { return(model); } } return(cellModels[0]); }
//Create a cell with given type and coordinates private MapCell createCell(MapCellType cellType, IntVector2 coordinates) { //Pick an appropriate prefab, for now only ground and obstacle cells are used MapCell prefab; bool isPassable; float elevation = 0f;; switch (cellType) { case MapCellType.groundCell: prefab = groundCellPrefabs [Random.Range(0, groundCellPrefabs.Length)]; isPassable = true; break; case MapCellType.miscObstacleCell: prefab = miscObstacleCellPrefabs[Random.Range(0, miscObstacleCellPrefabs.Length)]; isPassable = false; break; case MapCellType.waterCell: prefab = waterPrefab; isPassable = false; break; default: prefab = null; isPassable = false; break; } if (!isPassable) { //Control passability with elevation elevation = 0.5f; } MapCell cell = Instantiate(prefab) as MapCell; //Put the cell at the proper location cell.transform.position = coordinatesFrom2D(coordinates, elevation); //Assign the cell properties to the cell cell.coordinates = coordinates; cell.cellType = cellType; cell.isPassable = isPassable; //Put the cell into the array if (withinMap(coordinates)) { cells [coordinates.x, coordinates.z] = cell; } return(cell); }
public GameObject GetOne(MapCellType mapCellType) { switch (mapCellType) { case MapCellType.Iron: case MapCellType.Copper: case MapCellType.Gold: case MapCellType.Platinum: case MapCellType.Diamond: return(GetGameObjectOf(mapCellType)); default: throw new NotImplementedException("Ressource prefab unknowned"); } }
public void SetMapCellType(MapCellType mapCellType) { switch (mapCellType) { case MapCellType.Ground: _material.SetColor("_EmisColor", Color.white); break; case MapCellType.Tree: _material.SetColor("_EmisColor", Color.green); break; case MapCellType.Wall: _material.SetColor("_EmisColor", Color.gray); break; } }
private GameObject GetGameObjectOf(MapCellType ressourceType) { var generatedCandidates = GetGeneratedGameObjects(ressourceType); var inactiveGameObject = generatedCandidates.FirstOrDefault(g => !g.activeInHierarchy); if (inactiveGameObject != null) { inactiveGameObject.SetActive(true); return(inactiveGameObject); } else { var prefab = prefabPerRessourceType[ressourceType]; var newInstance = Instantiate(prefab, transform); generatedCandidates.Add(newInstance); return(newInstance); } }
internal MapCell(MapCellType cellType, int x, int y) { this.cellType = cellType; positionOnY = y; positionOnX = x; }
public static float GetChanceFor(MapCellType possibleRessource, int deepness) { var formula = formulaPerRessource[possibleRessource]; return(formula(deepness) / 100); }
protected MapCell(MapCellType type) { Type = type; }
void RefreshMapCell(Coordinate pos) { MapCellType mapCellTyp = _map.GetMapCellType(pos); _mapCellGo[pos.x, pos.y].SetMapCellType(mapCellTyp); }
public MapCell(MapCellType type) { this.type = type; }
internal MapCell(int x, int y) { positionOnX = x; positionOnY = y; this.cellType = MapCellType.Normal; }
public MapCell() { type = MapCellType.none; }
public void SetMapCell(Coordinate coordinate, MapCellType cellType) { _mapModel[coordinate.x, coordinate.y] = (int)cellType; }
public void setType(char c) { switch (c) { case '?': type = MapCellType.none; break; case '#': type = MapCellType.wall; break; case '.': type = MapCellType.floor; break; case 'X': break; default: throw new ArgumentException("Unexpected map cell: " + c); } }
public MapCell(MapCellType cellType) { this.cellType = cellType; }