Exemple #1
0
 private List <GameObject> GetGeneratedGameObjects(MapCellType mapCellType)
 {
     if (!generated.ContainsKey(mapCellType))
     {
         generated[mapCellType] = new List <GameObject>();
     }
     return(generated[mapCellType]);
 }
Exemple #2
0
 public MapCell(MapCellType type, Sprite wallSprite, Sprite floorSprite, Sprite ceilingSprite)
 {
     Type          = type;
     WallSprite    = wallSprite;
     CeilingSprite = ceilingSprite;
     FloorSprite   = floorSprite;
     isAnimation   = false;
 }
Exemple #3
0
 public MapCell(MapCellType type, Animation animation, Sprite floorSprite, Sprite ceilingSprite)
 {
     this.animation = animation;
     isAnimation    = true;
     Type           = type;
     WallSprite     = animation.CurrentFrame;
     CeilingSprite  = ceilingSprite;
     FloorSprite    = floorSprite;
 }
Exemple #4
0
 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;
 }
Exemple #5
0
    CellResource ResourceOfCell(int cellId)
    {
        MapCellType cellType = (MapCellType)cellId;

        foreach (CellResource res in cellResources)
        {
            if (res.cellType == cellType)
            {
                return(res);
            }
        }
        return(cellResources[0]);
    }
Exemple #6
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]);
    }
Exemple #7
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);
    }
Exemple #8
0
        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");
            }
        }
Exemple #9
0
    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;
        }
    }
Exemple #10
0
        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);
            }
        }
Exemple #11
0
 internal MapCell(MapCellType cellType, int x, int y)
 {
     this.cellType = cellType;
     positionOnY   = y;
     positionOnX   = x;
 }
Exemple #12
0
        public static float GetChanceFor(MapCellType possibleRessource, int deepness)
        {
            var formula = formulaPerRessource[possibleRessource];

            return(formula(deepness) / 100);
        }
Exemple #13
0
 protected MapCell(MapCellType type)
 {
     Type = type;
 }
Exemple #14
0
    void RefreshMapCell(Coordinate pos)
    {
        MapCellType mapCellTyp = _map.GetMapCellType(pos);

        _mapCellGo[pos.x, pos.y].SetMapCellType(mapCellTyp);
    }
Exemple #15
0
 public MapCell(MapCellType type)
 {
     this.type = type;
 }
Exemple #16
0
 internal MapCell(int x, int y)
 {
     positionOnX   = x;
     positionOnY   = y;
     this.cellType = MapCellType.Normal;
 }
Exemple #17
0
 public MapCell()
 {
     type = MapCellType.none;
 }
Exemple #18
0
 public void SetMapCell(Coordinate coordinate, MapCellType cellType)
 {
     _mapModel[coordinate.x, coordinate.y] = (int)cellType;
 }
Exemple #19
0
 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);
     }
 }
Exemple #20
0
 public MapCell(MapCellType cellType)
 {
     this.cellType = cellType;
 }